Skip to content

Conversation

@stephen-carter-at-sf
Copy link
Contributor

No description provided.


protected createDependencies(outputFile?: string): ConfigDependencies {
const uxDisplay: UxDisplay = new UxDisplay(this, this.spinner);
const modelGeneratorFunction = /* istanbul ignore next - Model tested separately */ (relevantEngines: Set<string>, userContext: ConfigContext, defaultContext: ConfigContext) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an unnecessary dependency. No need to inject this dependency unless we have a reason to do so with regards to testing/etc... which we don't.

ResultsWriter = 'results-writer',
RunAction = 'run-action',
RunCommand = 'run-command',
RunSummaryViewer = 'run-summary-viewer',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaned this up. Was unused.

private readonly config: CodeAnalyzerConfig; // TODO: It would be nice if we updated the CodeAnalyzer (in our core module) to just return its CodeAnalyzerConfig with a getter so we didn't need to pass it around
private readonly codeAnalyzer: CodeAnalyzer;
private readonly userRules: RuleSelection;
private readonly allDefaultRules: RuleSelection;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically I could have passed in a function that just gives me back the default rule since that's how we are using this. But it was easy enough to just pass this in.

But now we don't need to pass in all the values and config. So no more need for the ConfigContext stuff.

return this.toYamlUncheckedFieldWithInlineComment(fieldName, null, commentText);
} else if (JSON.stringify(userValue) === JSON.stringify(defaultValue)) {
return this.toYamlUncheckedField(fieldName, userValue);
private toYamlFieldUsingFieldDescription(fieldName: string, resolvedValue: unknown, fieldDescription: ConfigFieldDescription): string {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the name "resolvedValue" instead of "userValue" because it is post-resolution of the config... which mean it could be a calculated value like our python_command value for example.

private getDefaultRuleFor(engineName: string, ruleName: string): Rule|null {
try {
return this.defaultContext.rules.getRule(engineName, ruleName);
return this.allDefaultRules.getRule(engineName, ruleName);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only place allDefaultRules is used. So like I said, I could have just passed in the getDefaultRuleFor method instead... but this was already here - so just keeping things as is.


let yamlCode: string = '\n' +
this.toYamlSectionHeadingComment(engineConfigDescriptor.overview!) + '\n' +
this.toYamlSectionHeadingComment(engineConfigDescriptor.overview) + '\n' +
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice to be able to remove all these ! now that the core side has its own ConfigDescription which makes these values required (because it always fills it in).

}
}

class PlainYamlFormatter extends YamlFormatter {
Copy link
Contributor Author

@stephen-carter-at-sf stephen-carter-at-sf Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There still is a bit of a code smell having to pass all these input arguments all around. Part of me thinks that we could maybe just give the Formatter the Model instead of passing the values through. But i'm on the fence because doing so means adding a bunch of getters to the model... so just leaving things as is.

(This is analogous to how our results object has a format method and the formatters inside of it then just receive the results object)


# Some description for top_field
top_field: # Modified from: null
top_field: # Modified from: {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in a more appropriate default for this field - which is why the goldfile changed.

{prop: 'config_root'},
{prop: 'log_folder'}
])(`When derivable property $prop input is non-null and non-default, it is rendered as-is with no comment`, async ({prop}) => {
])(`When derivable property $prop input is non-null and non-default, it is rendered as-is`, async ({prop}) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test description was incorrect. There is a comment - which is "#modified from: ". So fixed it.

.replace('__DUMMY_LOG_FOLDER__', parentOfCurrentDirectory)
.replace('__DUMMY_DEFAULT_CONFIG_ROOT__', JSON.stringify(defaultConfig.getConfigRoot()))
.replace('__DUMMY_DEFAULT_LOG_FOLDER__', JSON.stringify(defaultConfig.getLogFolder()))
.replace('__DUMMY_DEFAULT_CONFIG_ROOT__', JSON.stringify(null))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only behavior change. If the user sets their own config_root or log_folder... there is no need to show the old calculated value... we just show "null" instead as I believe we should. For example, who cares if they see that by default we would have chosen a random temporary directory. So adding in the "Modified from: " here was better to just add in "null" as the value.

.replace('__DUMMY_LOG_FOLDER__', parentOfCurrentDirectory)
.replace('__DUMMY_DEFAULT_CONFIG_ROOT__', JSON.stringify(defaultConfig.getConfigRoot()))
.replace('__DUMMY_DEFAULT_LOG_FOLDER__', JSON.stringify(defaultConfig.getLogFolder()))
.replace('__DUMMY_DEFAULT_CONFIG_ROOT__', JSON.stringify(null))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON.stringify(null) feels weird to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... I was a little lazy here. I could have just put 'null'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@stephen-carter-at-sf stephen-carter-at-sf merged commit f105bfe into dev-5 Dec 5, 2024
12 checks passed
@stephen-carter-at-sf stephen-carter-at-sf deleted the sc/W-17293079 branch December 5, 2024 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants