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

[Fix #7740] Make Style/AccessModifierDeclarations not flag symbol method-name #7762

Merged
merged 1 commit into from Mar 22, 2020

Conversation

tejasbubane
Copy link
Contributor

Closes #7740


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@bbatsov
Copy link
Collaborator

bbatsov commented Feb 29, 2020

The cop documentation should definitely be updated to reflect this.

I think we also need some flag to enable/disable this, as if you're using modifiers in this manner, you're potentially violating grouping/non-grouping. That's why I'd prefer having more control over the behaviour.

@tejasbubane
Copy link
Contributor Author

tejasbubane commented Feb 29, 2020

@bbatsov Fixed to use node-matcher instead of explicit checks.

Regarding flag to turn this feature off, do you think the following configs make sense?

  1. group (default) - forbids inline method definition but allows inline symbol
  2. strict_group - forbids inline method definition & symbols
  3. inline - all modifiers should be inline

Let me know if you have something else in mind.

@mintyfresh
Copy link

mintyfresh commented Mar 2, 2020

@tejasbubane
The act of allowing inline-symbol seems tangential to the modes of group and inline, since those refer to definition style, whereas referencing a Symbol is used for existing declarations.

Maybe it might make more sense to have it be a flag?
Allowing or forbidding the inline-Symbol behaviour could be applicable regardless of whether the preferred definition style is inline or group.

An argument could even be made to put it under a separate rule (ie. Style/AccessModifierChange or similar) but that might be overkill.

@bbatsov
Copy link
Collaborator

bbatsov commented Mar 3, 2020

Maybe it might make more sense to have it be a flag?

Exactly. This shouldn't be a style, it should a flag that affects both styles - something like AllowModifiersOnSymbols or whatever. A better name would be welcome. :-)

@tejasbubane
Copy link
Contributor Author

@bbatsov I added config option to AllowModifiersOnSymbols.

@tejasbubane tejasbubane force-pushed the fix-7740 branch 3 times, most recently from f7207e2 to 3bb61a3 Compare March 20, 2020 09:26
@bbatsov
Copy link
Collaborator

bbatsov commented Mar 21, 2020

I'd also extend the cop documentation to mention that it covers only definitions and applications of visibility methods to symbols are controlled by the new config.

@tejasbubane
Copy link
Contributor Author

I'd also extend the cop documentation to mention that it covers only definitions and applications of visibility methods to symbols are controlled by the new config.

Added.

@tejasbubane tejasbubane force-pushed the fix-7740 branch 2 times, most recently from 736bae4 to e2253b7 Compare March 22, 2020 09:05
@bbatsov
Copy link
Collaborator

bbatsov commented Mar 22, 2020

Thanks!

@tejasbubane tejasbubane deleted the fix-7740 branch March 22, 2020 10:39
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.

False Positive and Incorrect Error Message for Style/AccessModifierDeclarations
3 participants