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

feat(stryker): #438 Extensive config validation #549

Merged
merged 5 commits into from
Dec 19, 2017

Conversation

hrb90
Copy link
Contributor

@hrb90 hrb90 commented Dec 13, 2017

No description provided.

@hrb90 hrb90 mentioned this pull request Dec 13, 2017
Copy link
Member

@nicojs nicojs left a comment

Choose a reason for hiding this comment

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

Looks awesome already. Have a small remark. I will merge this later on regardless. Thanks a lot!

const logLevel = this.strykerConfig.logLevel;
const VALID_LOG_LEVEL_VALUES = ['fatal', 'error', 'warn', 'info', 'debug', 'trace', 'all', 'off'];
if (VALID_LOG_LEVEL_VALUES.indexOf(logLevel) < 0) {
this.invalidate('\`logLevel\` is invalid, expected one of \`fatal\`, \`error\`, \`warn\`, \`info\`, \`debug\`, \`trace\`, \`all\` and \`off\`');
Copy link
Member

Choose a reason for hiding this comment

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

You could use VALID_LOG_LEVEL_VALUES .join(',') here to reduce duplication.

Copy link
Member

Choose a reason for hiding this comment

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

This is actually done in validateCoverageAnalysis. I'm a fan on using the join here as well.

this.validateIsString('mutator', this.strykerConfig.mutator);
this.validateIsStringArray('plugins', this.strykerConfig.plugins);
this.validateIsStringArray('reporter', this.strykerConfig.reporter);
this.validateIsStringArray('transpilers', this.strykerConfig.transpilers);
Copy link
Member

Choose a reason for hiding this comment

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

I love this, very much readable!

@simondel simondel self-requested a review December 15, 2017 10:55
Copy link
Member

@simondel simondel left a comment

Choose a reason for hiding this comment

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

Awesome job! I love how you set up the code :)

I have a small remark: I noticed that there is the invalidation messages differ quite a bit. For example. If the coverageanalsysis property is invalid. You log:

`Value "${coverageAnalysis}" is invalid for \`coverageAnalysis\`. Expected one of the folowing: .......

When the general logLevel is invalid, you don't log which value was actually entered. Similar small inconsistencies can also be found in other logging statements. Two examples of this are the use of the join function on the array of loglevels that @nicojs mentioned and in the quotes that you put around property/values (logLevel is logged as `logLevel` and maxConcurrentTestRunners is logged as maxConcurrentTestRunners for example)

I also think that the logging statements could be a bit more readable in TypeScript if you don't use backticks inside of a interpolated string.

@hrb90
Copy link
Contributor Author

hrb90 commented Dec 17, 2017

@simondel I went ahead and changed as many of the error messages as possible to follow the format "Value {value} is invalid for {field}. Expected {expectation}." I left one pair of backticks in the messages (around the field) for back consistency.

@simondel
Copy link
Member

Awesome! Looking good :) @nicojs Shall we merge this?

@nicojs nicojs merged commit dc6fdf2 into stryker-mutator:master Dec 19, 2017
@nicojs
Copy link
Member

nicojs commented Dec 19, 2017

Great job! 🥇

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