-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Cop idea: Style/AllowModifiersOnAttrs
#12242
Comments
ntkme
changed the title
Cop idea: Style/AllowModifiersOnAttrs
Cop idea: Oct 3, 2023
Style/AllowModifiersOnAttrs
krororo
added a commit
to krororo/rubocop
that referenced
this issue
Nov 12, 2023
…/AccessModifierDeclarations`
Merged
8 tasks
krororo
added a commit
to krororo/rubocop
that referenced
this issue
Dec 16, 2023
…/AccessModifierDeclarations`
krororo
added a commit
to krororo/rubocop
that referenced
this issue
Apr 21, 2024
…/AccessModifierDeclarations`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
In Ruby >=3.0, we can write the modifier and
attr_*
helpers inline like:Today, this is an offend on
Style/AccessModifierDeclarations
. However, just forattr*
helpers this style looks much cleaner than the default group style.Describe the solution you'd like
After all the default
group
style ofStyle/AccessModifierDeclarations
works well for normaldef
methods, that I don't want to change that toinline
style. Therefore I think the best approach is to add a new option calledStyle/AllowModifiersOnAttrs
similar toStyle/AllowModifiersOnSymbols
to allow inlined modifier onattr*
methods.Describe alternatives you've considered
Use the group style everywhere - the problem is that I think most of the developers would prefer to put the attr declarations together, and then normal methods together, in that case we need to toggle public and private back and forth like below:
Use the inline style everywhere, the problem would be simply we don't want to add the modifier to each normal method.
With a
Style/AllowModifiersOnAttrs
rule similar toStyle/AllowModifiersOnSymbols
, we would be able to write:Additional context
The text was updated successfully, but these errors were encountered: