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
Add EnforcedStyle
for Style/DoubleNegation
cop
#7985
Add EnforcedStyle
for Style/DoubleNegation
cop
#7985
Conversation
03a16c3
to
496620b
Compare
config/default.yml
Outdated
@@ -2699,6 +2699,11 @@ Style/DoubleNegation: | |||
StyleGuide: '#no-bang-bang' | |||
Enabled: true | |||
VersionAdded: '0.19' | |||
VersionChanged: '1.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this 0.84, please. I'll cut one more release before 1.0 to make sure the rubocop-ast
separation didn't cause problems.
config/default.yml
Outdated
VersionChanged: '1.0' | ||
EnforcedStyle: context | ||
SupportedStyles: | ||
- context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think better names would be forbidden
and allowed_in_returns
or something along those lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or allowed_in_boolean_context
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for suggesting a good name! I think allowed_in_returns
is clear and straightforward!
The cop description should also be updated, as it currently pertains only to the |
ee97052
to
3d8d795
Compare
Follow up to rubocop#7985 (comment). RuboCop 0.84 will be cut before RuboCop 1.0.
This PR adds `EnforcedStyle` option for `Style/DoubleNegation` cop, and `EnforcedStyle: allowed_in_boolean_context` by default based on rubocop#7833 survey. ```ruby # @example EnforcedStyle: allowed_in_boolean_context (default) # # good # def foo? # !!return_value # end # # @example EnforcedStyle: always # # bad # def foo? # !!return_value # end ``` Ruby will return the last evaluated value. This PR only supports simple contexts, such as the end of line value of method, and when using `return`. A complex contexts should also be supported, such as when branching with `if` and others in the future.
3d8d795
to
9d19019
Compare
Follow up to #7985 (comment). RuboCop 0.84 will be cut before RuboCop 1.0.
This PR adds
EnforcedStyle
option forStyle/DoubleNegation
cop, andEnforcedStyle: context
by default based on #7833 survey.Ruby will return the last evaluated value.
This PR only supports simple contexts, such as the end of line value of method, and when using
return
.A complex contexts should also be supported, such as when branching with
if
and others in the future.Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.