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

Reimplement max-warnings as a proper option #857

Merged
merged 1 commit into from
Sep 2, 2016

Conversation

nottrobin
Copy link
Contributor

@nottrobin nottrobin commented Aug 31, 2016

What do the changes you have made achieve?

This adds max-warnings as a proper option, including tests and documentation. This option can be set in the config file, passed straight through to failOnError, or set via the command-line.

See #856 for more detail.

Are there any new warning messages?

No.

There's a new error message:

MaxWarningsExceededError: Number of warnings (257) exceeds the allowed maximum of 20.

Have you written tests?

Yes.

  failures
    ✓ should raise SassLintFailureError if indentation is set to error (595ms)
    ✓ should not raise SassLintFailureError if indentation is only set to warn
    ✓ should raise MaxWarningsExceededError if warnings exceed `max-warnings` setting (133ms)
    ✓ should not raise MaxWarningsExceededError if warnings do not exceed `max-warnings` setting

Have you included relevant documentation

Yes, in docs/options/max-warnings.md.

Which issues does this resolve?

Closes #856.

<DCO 1.1 Signed-off-by: Robin Winslow robin@robinwinslow.co.uk>

@coveralls
Copy link

coveralls commented Sep 1, 2016

Coverage Status

Coverage increased (+0.3%) to 97.527% when pulling d7eae87 on nottrobin:max-warnings-option into 01eb696 on sasstools:develop.

@nottrobin nottrobin force-pushed the max-warnings-option branch 2 times, most recently from 24d793c to 71a2917 Compare September 1, 2016 01:48
@coveralls
Copy link

coveralls commented Sep 1, 2016

Coverage Status

Coverage increased (+0.3%) to 97.527% when pulling 71a2917 on nottrobin:max-warnings-option into 01eb696 on sasstools:develop.

@coveralls
Copy link

coveralls commented Sep 1, 2016

Coverage Status

Coverage increased (+0.3%) to 97.527% when pulling d57be3b on nottrobin:max-warnings-option into 01eb696 on sasstools:develop.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 97.527% when pulling d57be3b on nottrobin:max-warnings-option into 01eb696 on sasstools:develop.

@@ -9,6 +9,8 @@ options:
formatter: html
# Output file instead of logging results
output-file: 'linters/sass-lint.html'
# Raise an error if more than 10 warnings are generated
max-warnings: 50
Copy link
Member

Choose a reason for hiding this comment

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

Set to 50 but the comment mentions 10

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Fixed.

@coveralls
Copy link

coveralls commented Sep 1, 2016

Coverage Status

Coverage increased (+0.3%) to 97.527% when pulling ac6a8fe on nottrobin:max-warnings-option into 01eb696 on sasstools:develop.

@DanPurdy
Copy link
Member

DanPurdy commented Sep 1, 2016

Looking good @nottrobin, can we add a few test cases for when the user specifically sets max-warnings to 0 in their config file. I can see that it will pass but just belts and braces for the future.

As a side note we will need to remember to replace that util.inherits when we drop support for earlier versions of node as they come off of LTS.

Thanks! 👍

@DanPurdy DanPurdy added this to the 1.10 milestone Sep 1, 2016
@nottrobin
Copy link
Contributor Author

Good idea. I'll get those new tests written in the next couple of hours.

On Thu, 1 Sep 2016, 09:34 Dan Purdy, notifications@github.com wrote:

Looking good @nottrobin https://github.com/nottrobin, can we add a few
test cases for when the user specifically sets max-warnings to 0 in their
config file. I can see that it will pass but just belts and braces for the
future.

As a side note we will need to remember to replace that util.inherits
when we drop support for earlier versions of node as they come off of LTS.

Thanks! 👍


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
#857 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAfu_76dI-5qhOuJiFG_05Ol28Qj4S8hks5qlo4kgaJpZM4Jx4i-
.

@DanPurdy
Copy link
Member

DanPurdy commented Sep 1, 2016

No rush, got a few other things to finish and add in 1.10 anyway.

@coveralls
Copy link

coveralls commented Sep 1, 2016

Coverage Status

Coverage increased (+0.3%) to 97.527% when pulling 4fd8964 on nottrobin:max-warnings-option into 01eb696 on sasstools:develop.

@nottrobin
Copy link
Contributor Author

@DanPurdy I've now added two new tests:

  • should raise MaxWarningsExceededError if warnings exceed max-warnings of zero
  • should not raise error if no warnings even if max-warnings is zero


it('should not raise error if no warnings even if `max-warnings` is zero', function (done) {
var results = lint.lintFiles('sass/success.scss', {}); // no warnings
lint.failOnError(results, {'max-warnings': 0}); // Max 100 warnings, should succceed
Copy link
Member

Choose a reason for hiding this comment

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

The comments are still for max 100 tests here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, again. I'll fix this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@DanPurdy
Copy link
Member

DanPurdy commented Sep 1, 2016

Thanks just the copy n pasted comments to deal with and then this lgtm for me!

👍

- Remove custom, slightly hacky code for `max-warnings` from `bin/sass-lint.js`
- Tidy up `bin/sass-lint.js` more generally
- Add `max-warnings` as an option to be passed to `failOnError`, either through a config file or through passing options directly
- Add documentation for the max-warnings option
- Create new descriptive exceptions for `failOnError` - MaxWarningsExceededError and SassLintFailureError
- Test the functionality of `failOnError`
@coveralls
Copy link

coveralls commented Sep 1, 2016

Coverage Status

Coverage increased (+0.3%) to 97.527% when pulling fbaf738 on nottrobin:max-warnings-option into 01eb696 on sasstools:develop.

@DanPurdy
Copy link
Member

DanPurdy commented Sep 2, 2016

Awesome, thanks @nottrobin looking good. Will come out with 1.10 in the next week or two hopefully

@DanPurdy DanPurdy merged commit b7bcb3a into sasstools:develop Sep 2, 2016
@DanPurdy DanPurdy mentioned this pull request Nov 7, 2016
@nottrobin nottrobin deleted the max-warnings-option branch November 7, 2016 15:10
@DanPurdy
Copy link
Member

DanPurdy commented Nov 7, 2016

Sorry @nottrobin I seemed to miss a unfortunate outcome from this to do with silencing errors and preventing unhandled exceptions with the --no-exit flag on the cli which lead to this change always throwing an unhandled error if a rule of severity 2 detected an issue.

I've had to sort of half patch the old functionality on top of yours so you should still encounter exit code 1 when max-warnings fails but the error itself won't be thrown if you're specifiying --no-exit or -q.

Let me know if there's any issues here and we can work a solution out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make "max-warnings" a proper option
3 participants