Skip to content
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

build(lint): throw error when number of extra args doesn't match the number of format specifiers in logger. #5895

Merged
merged 28 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
bb862e4
implement custom lint rule
Hweinstock Oct 28, 2024
6788929
add more test cases
Hweinstock Oct 28, 2024
6b52189
add typing, refactor
Hweinstock Oct 28, 2024
5c7724a
adjust comments
Hweinstock Oct 28, 2024
6ff529b
change existing uses
Hweinstock Oct 29, 2024
05d0cdf
merge in upstream changes
Hweinstock Oct 29, 2024
1430a97
migrate case in new file
Hweinstock Oct 29, 2024
8afa3d8
start of work
Hweinstock Oct 29, 2024
0736cf4
add note about depth limit
Hweinstock Oct 29, 2024
aaad8ad
implement rule
Hweinstock Oct 29, 2024
13b1a09
activate rule
Hweinstock Oct 29, 2024
a391f69
start migration
Hweinstock Oct 29, 2024
07f3682
refactor and enforce one of the log functions
Hweinstock Oct 29, 2024
eb08f70
Merge branch 'lint/noJsonStringify' into lint/noStringSubDrop
Hweinstock Oct 29, 2024
2204b77
finish migration
Hweinstock Oct 29, 2024
f09bcee
Merge branch 'master' into lint/noJsonStringify
Hweinstock Oct 29, 2024
26e1c19
Merge branch 'lint/noJsonStringify' into lint/noStringSubDrop
Hweinstock Oct 29, 2024
1fd9d1e
resolve conflicts
Hweinstock Nov 5, 2024
e1c75eb
Merge branch 'master' into lint/noStringSubDrop
Hweinstock Nov 5, 2024
2b60e98
fix new cases of mismatch sub
Hweinstock Nov 6, 2024
f0cb44b
Merge branch 'master' into lint/noStringSubDrop
Hweinstock Nov 6, 2024
d5151c5
fix test cases that inspect the logs
Hweinstock Nov 6, 2024
1d3e68f
remove unrelated change
Hweinstock Nov 7, 2024
708249d
Update packages/core/src/shared/sam/cli/samCliLocalInvoke.ts
Hweinstock Nov 7, 2024
88d3fa0
change rule name
Hweinstock Nov 7, 2024
bbf54c5
change test file name
Hweinstock Nov 7, 2024
96f09b2
Merge branch 'lint/noStringSubDrop' of github.com:Hweinstock/aws-tool…
Hweinstock Nov 7, 2024
cc972d6
Merge branch 'master' into lint/noStringSubDrop
Hweinstock Nov 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ module.exports = {
'aws-toolkits/no-string-exec-for-child-process': 'error',
'aws-toolkits/no-console-log': 'error',
'aws-toolkits/no-json-stringify-in-log': 'error',
'aws-toolkits/no-string-sub-mismatch': 'error',
'no-restricted-imports': [
'error',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function emitTelemetryMessageHandler(message: EmitTelemetryMessage) {
return
}
} catch (e) {
getLogger().error('Could not log telemetry for App Composer', e)
getLogger().error('Could not log telemetry for App Composer %O', e)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export async function generateDeployedNode(
.Configuration as Lambda.FunctionConfiguration
newDeployedResource = new LambdaFunctionNode(lambdaNode, regionCode, configuration)
} catch (error: any) {
getLogger().error('Error getting Lambda configuration')
getLogger().error('Error getting Lambda configuration %O', error)
throw ToolkitError.chain(error, 'Error getting Lambda configuration', {
code: 'lambdaClientError',
})
Expand Down Expand Up @@ -153,7 +153,7 @@ export async function generateDeployedNode(
}
default:
newDeployedResource = new DeployedResourceNode(deployedResource)
getLogger().info('Details are missing or are incomplete for:', deployedResource)
getLogger().info('Details are missing or are incomplete for: %O', deployedResource)
return [
createPlaceholderItem(
localize('AWS.appBuilder.explorerNode.noApps', '[This resource is not yet supported.]')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function getStackName(projectRoot: vscode.Uri): Promise<any> {
} catch (error: any) {
switch (error.code) {
case SamConfigErrorCode.samNoConfigFound:
getLogger().info('No stack name or region information available in samconfig.toml', error)
getLogger().info('No stack name or region information available in samconfig.toml: %O', error)
break
case SamConfigErrorCode.samConfigParseError:
getLogger().error(`Error getting stack name or region information: ${error.message}`, error)
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/awsService/iot/commands/createCert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ async function saveCredentials(
const publicKeyExists = await fileExists(publicKeyPath)

if (certExists) {
getLogger().error('Certificate path {0} already exists', certPath)
getLogger().error('Certificate path %s already exists', certPath)
void vscode.window.showErrorMessage(
localize('AWS.iot.createCert.error', 'Failed to create certificate. Path {0} already exists.', certPath)
)
return false
}
if (privateKeyExists) {
getLogger().error('Key path {0} already exists', privateKeyPath)
getLogger().error('Key path %s already exists', privateKeyPath)
void vscode.window.showErrorMessage(
localize(
'AWS.iot.createCert.error',
Expand All @@ -133,7 +133,7 @@ async function saveCredentials(
return false
}
if (publicKeyExists) {
getLogger().error('Key path {0} already exists', publicKeyPath)
getLogger().error('Key path %s already exists', publicKeyPath)
void vscode.window.showErrorMessage(
localize(
'AWS.iot.createCert.error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class RedshiftNode extends AWSTreeNodeBase implements LoadMoreNode {
newServerlessToken = response.nextToken ?? ''
}
} catch (error) {
getLogger().error("Serverless workgroup operation isn't supported or failed:", error)
getLogger().error("Serverless workgroup operation isn't supported or failed: %O", error)
// Continue without interrupting the provisioned cluster loading
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/awsService/s3/commands/uploadFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export async function promptUserForBucket(
try {
allBuckets = await s3client.listAllBuckets()
} catch (e) {
getLogger().error('Failed to list buckets from client', e)
getLogger().error('Failed to list buckets from client %O', e)
void vscode.window.showErrorMessage(
localize('AWS.message.error.promptUserForBucket.listBuckets', 'Failed to list buckets from client')
)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/codewhisperer/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,6 @@ export async function enableDefaultConfigCloud9() {
await editorSettings.update('acceptSuggestionOnEnter', 'on', vscode.ConfigurationTarget.Global)
await editorSettings.update('snippetSuggestions', 'top', vscode.ConfigurationTarget.Global)
} catch (error) {
getLogger().error('amazonq: Failed to update user settings', error)
getLogger().error('amazonq: Failed to update user settings %O', error)
}
}
2 changes: 1 addition & 1 deletion packages/core/src/codewhisperer/client/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ export function initializeNetworkAgent(): void {
}
} catch (error) {
// Log any errors in the patching logic
getLogger().error('Failed to patch http agent', error)
getLogger().error('Failed to patch http agent %O', error)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export async function startSecurityScan(

logger.verbose(`Security scan completed.`)
} catch (error) {
getLogger().error('Security scan failed.', error)
getLogger().error('Security scan failed. %O', error)
if (error instanceof CodeScanStoppedError) {
codeScanTelemetryEntry.result = 'Cancelled'
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export async function validateSQLMetadataFile(fileContents: string, message: any
`CodeTransformation: Parsed .sct file with source DB: ${sourceDB}, target DB: ${targetDB}, source host name: ${sourceServerName}, and schema names: ${Array.from(schemaNames)}`
)
} catch (err: any) {
getLogger().error('CodeTransformation: Error parsing .sct file.', err)
getLogger().error('CodeTransformation: Error parsing .sct file. %O', err)
transformByQState.getChatMessenger()?.sendUnrecoverableErrorResponse('error-parsing-sct-file', message.tabID)
return false
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/codewhisperer/util/zipUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class ZipUtil {
language: this._language,
}
} catch (error) {
getLogger().error('Zip error caused by:', error)
getLogger().error('Zip error caused by: %O', error)
throw error
}
}
Expand Down
Loading
Loading