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 new Style/OptionalBooleanParameter
cop
#8412
Add new Style/OptionalBooleanParameter
cop
#8412
Conversation
config/default.yml
Outdated
Style/BooleanKeywordArgument: | ||
Description: 'Use keyword arguments when defining method with boolean argument.' | ||
StyleGuide: '#boolean-keyword-arguments' | ||
Enabled: pending |
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 that this cop is unsafe, just like Style/OptionalArguments
cop.
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'm curious why Style/OptionalArguments
is "unsafe", or this one?
For this one, my only concern is if there is a call to super
, or super(that_argument)
, then maybe there should be no offense since this method is just copying the interface it inherits. Maybe there should not be an offense then; the base method will be flagged probably. What other cases are unsafe?
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 it means a breaking change to users if the API signature is a published interface.
https://martinfowler.com/bliki/PublishedInterface.html
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.
Made it unsafe.
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 love it when a new cop improves our codebase!
Here, I think all of these true
/false
were clear examples of arguments that can not be understood when called.
12b12f2
to
786d100
Compare
Seems we've made a mistake with the heading in the style guide - I think the cop should be named |
786d100
to
cd8d521
Compare
Style/BooleanKeywordArgument
copStyle/OptionalBooleanParameter
cop
cd8d521
to
45250d2
Compare
Updated with new name. |
Great cop! |
https://rubystyle.guide/#boolean-keyword-arguments