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

Make RuboCop aware of Rails concerning and delegate methods #21

Merged
merged 2 commits into from
Dec 18, 2023

Conversation

mattbrictson
Copy link
Owner

In its default configuration, RuboCop's Lint/UselessAccessModifier rule can get confused by the concerning and delegate constructs in Rails.

Take this code for example,

class User < ApplicationRecord
  concerning :Authentication do
    has_secure_password
    before_save :some_callback_method

    private

    def some_callback_method
      # ...
    end
  end

  private

  def another_private_method
    # ...
  end
end

RuboCop sees two private modifiers and considers this a violation, even though they take place in two different scopes.

This PR fixes this by configuring Lint/UselessAccessModifier to understand Rails-specific syntax, as recommended in the RuboCop docs: https://docs.rubocop.org/rubocop/cops_lint.html#lintuselessaccessmodifier

@mattbrictson mattbrictson added ✨ Feature Adds a new feature automerge Automatically merge PR once all required checks pass labels Dec 18, 2023
@kodiakhq kodiakhq bot merged commit 2949153 into main Dec 18, 2023
7 checks passed
@kodiakhq kodiakhq bot deleted the rails-access-modifier branch December 18, 2023 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Automatically merge PR once all required checks pass ✨ Feature Adds a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant