-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Add explicit return type for most functions #138
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,7 @@ export async function addCloudWatchForwarderSubscriptions( | |
stackName: string | undefined, | ||
forwarderArn: string, | ||
cloudWatchLogs: CloudWatchLogs, | ||
) { | ||
): Promise<void> { | ||
let logGroupsOnStack: CloudWatchLogs.LogGroups | undefined; | ||
let logGroupsInTemplate: LogGroupDefinition[] | undefined; | ||
let subscriptionsInTemplate: SubscriptionDefinition[] | undefined; | ||
|
@@ -203,7 +203,10 @@ export async function addCloudWatchForwarderSubscriptions( | |
} | ||
} | ||
|
||
export async function findExistingLogGroupWithFunctionName(cloudWatchLogs: CloudWatchLogs, functionName: string) { | ||
export async function findExistingLogGroupWithFunctionName( | ||
cloudWatchLogs: CloudWatchLogs, | ||
functionName: string, | ||
): Promise<any> { | ||
const logGroupName = `${LAMBDA_LOG_GROUP_PREFIX}${functionName}`; | ||
const args = { | ||
logGroupNamePrefix: logGroupName, | ||
|
@@ -216,7 +219,10 @@ export async function findExistingLogGroupWithFunctionName(cloudWatchLogs: Cloud | |
return logGroups.find((lg) => lg.logGroupName === logGroupName); | ||
} | ||
|
||
export async function getExistingLambdaLogGroupsOnStack(cloudWatchLogs: CloudWatchLogs, stackName: string) { | ||
export async function getExistingLambdaLogGroupsOnStack( | ||
cloudWatchLogs: CloudWatchLogs, | ||
stackName: string, | ||
): Promise<any> { | ||
const logGroupNamePrefix = `${LAMBDA_LOG_GROUP_PREFIX}${stackName}-`; | ||
const args = { logGroupNamePrefix }; | ||
const response = await cloudWatchLogs.describeLogGroups(args).promise(); | ||
|
@@ -225,7 +231,7 @@ export async function getExistingLambdaLogGroupsOnStack(cloudWatchLogs: CloudWat | |
return logGroups ?? []; | ||
} | ||
|
||
export async function shouldSubscribeLogGroup(cloudWatchLogs: CloudWatchLogs, logGroupName: string) { | ||
export async function shouldSubscribeLogGroup(cloudWatchLogs: CloudWatchLogs, logGroupName: string): Promise<boolean> { | ||
const subscriptionFilters = await describeSubscriptionFilters(cloudWatchLogs, logGroupName); | ||
const numberOfActiveSubscriptionFilters = subscriptionFilters.length; | ||
if (numberOfActiveSubscriptionFilters >= MAX_ALLOWABLE_LOG_GROUP_SUBSCRIPTIONS) { | ||
|
@@ -243,7 +249,7 @@ export async function shouldSubscribeLogGroup(cloudWatchLogs: CloudWatchLogs, lo | |
return true; | ||
} | ||
|
||
async function describeSubscriptionFilters(cloudWatchLogs: CloudWatchLogs, logGroupName: string) { | ||
async function describeSubscriptionFilters(cloudWatchLogs: CloudWatchLogs, logGroupName: string): Promise<any> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
const request = { logGroupName }; | ||
const response = await cloudWatchLogs.describeSubscriptionFilters(request).promise(); | ||
return response.subscriptionFilters ?? []; | ||
|
@@ -257,7 +263,11 @@ function findLogGroupsInTemplate(resources: Resources) { | |
}); | ||
} | ||
|
||
export function findDeclaredLogGroup(logGroups: LogGroupDefinition[], functionKey: string, functionName?: string) { | ||
export function findDeclaredLogGroup( | ||
logGroups: LogGroupDefinition[], | ||
functionKey: string, | ||
functionName?: string, | ||
): LogGroupDefinition | undefined { | ||
for (const resource of Object.values(logGroups)) { | ||
const logGroupName = resource.logGroupResource.Properties.LogGroupName; | ||
|
||
|
@@ -298,7 +308,7 @@ function findDeclaredSub( | |
subscriptions: SubscriptionDefinition[], | ||
logGroupName: string | { [fn: string]: any }, | ||
logGroupKey: string, | ||
) { | ||
): SubscriptionDefinition | undefined { | ||
for (const subscription of subscriptions) { | ||
const subscribedLogGroupName = subscription.subscriptionResource.Properties.LogGroupName; | ||
if (typeof subscribedLogGroupName === "string" && subscribedLogGroupName.includes(logGroupKey)) { | ||
|
@@ -310,7 +320,11 @@ function findDeclaredSub( | |
} | ||
} | ||
|
||
async function putSubscriptionFilter(cloudWatchLogs: CloudWatchLogs, forwarderArn: string, logGroupName: string) { | ||
async function putSubscriptionFilter( | ||
cloudWatchLogs: CloudWatchLogs, | ||
forwarderArn: string, | ||
logGroupName: string, | ||
): Promise<void> { | ||
const args = { | ||
destinationArn: forwarderArn, | ||
filterName: SUBSCRIPTION_FILTER_NAME, | ||
|
@@ -320,7 +334,7 @@ async function putSubscriptionFilter(cloudWatchLogs: CloudWatchLogs, forwarderAr | |
await cloudWatchLogs.putSubscriptionFilter(args).promise(); | ||
} | ||
|
||
async function createLogGroup(cloudWatchLogs: CloudWatchLogs, logGroupName: string) { | ||
async function createLogGroup(cloudWatchLogs: CloudWatchLogs, logGroupName: string): Promise<void> { | ||
const args = { logGroupName }; | ||
await cloudWatchLogs.createLogGroup(args).promise(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚪ Code Quality Violation
Unexpected any. Specify a different type. (...read more)
Do not use the
any
type, as it is too broad and can lead to unexpected behavior.