-
Notifications
You must be signed in to change notification settings - Fork 137
Restructure environmentVariablesUsed detection to avoid falsely alerting #1196
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,10 +101,20 @@ | |
}, | ||
} | ||
|
||
const environmentVariablesUsed = Object.entries(rawConfig) | ||
.map(([key, value]) => (typeof value !== 'undefined' ? key : null)) | ||
.filter((key): key is string => key !== null) | ||
.filter((key) => key !== 'logLevel') // logLevel is a special case that we ignore | ||
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. Why don't we filter out 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. Personal preference, if I'm honest. I trend towards exhaustivity checks, where possible, but I'm happy to switch it back to the way it was and add a test to the filter. |
||
const getUsedEnvvars = (rawConfigComponent: {[key: string]: any}): string[] => { | ||
Check failure on line 104 in server/src/config.ts GitHub Actions / verify (16.x)
Check failure on line 104 in server/src/config.ts GitHub Actions / verify (18.x)
|
||
return Object.entries(rawConfigComponent) | ||
.map(([key, value]) => (typeof value !== 'undefined' ? key : null)) | ||
.filter((key): key is string => key !== null) | ||
.filter((key) => key !== 'logLevel') // logLevel is a special case that we ignore | ||
}; | ||
Check failure on line 109 in server/src/config.ts GitHub Actions / verify (16.x)
Check failure on line 109 in server/src/config.ts GitHub Actions / verify (18.x)
|
||
|
||
// Since shfmt is structurally _always_ defined, we need to be careful to not | ||
// incorrectly alert the user that they are doing something that needs to be | ||
// changed. | ||
// | ||
// If other objects are added to rawConfig, please treat them similarly below. | ||
const {shfmt, ... rest } = rawConfig; | ||
Check failure on line 116 in server/src/config.ts GitHub Actions / verify (16.x)
Check failure on line 116 in server/src/config.ts GitHub Actions / verify (18.x)
|
||
const environmentVariablesUsed = getUsedEnvvars(rest).concat(getUsedEnvvars(shfmt)); | ||
Check failure on line 117 in server/src/config.ts GitHub Actions / verify (16.x)
Check failure on line 117 in server/src/config.ts GitHub Actions / verify (18.x)
|
||
|
||
const config = ConfigSchema.parse(rawConfig) | ||
|
||
|