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 #6888] Fix an error for Rails/ActiveRecordOverride #6889

Merged

Commits on Apr 12, 2019

  1. [Fix rubocop#6888] Fix an error for Rails/ActiveRecordOverride

    Fixes rubocop#6888.
    
    This PR fixes the following error for `Rails/ActiveRecordOverride`
    when there is no `parent_class` to match against.
    
    ```ruby
    % cat app/models/user.rb
    class User
      def initialize; end
    
      def create; end
    end
    ```
    
    ```console
    % rubocop app/models/user.rb --only Rails/ActiveRecordOverride -d
    For /Users/dannyiachini/github/jpw/rubocop_ex: configuration from /Users/dannyiachini/github/jpw/rubocop_ex/.rubocop.yml
    Default configuration from /Users/dannyiachini/.gem/ruby/2.5.3/gems/rubocop-0.67.2/config/default.yml
    Inspecting 1 file
    Scanning /Users/dannyiachini/github/jpw/rubocop_ex/app/models/user.rb
    An error occurred while Rails/ActiveRecordOverride cop was inspecting /Users/dannyiachini/github/jpw/rubocop_ex/app/models/user.rb:6:2.
    undefined method `const_name' for nil:NilClass
    /Users/dannyiachini/.gem/ruby/2.5.3/gems/rubocop-0.67.2/lib/rubocop/cop/rails/active_record_override.rb:42:in `on_def'
    
    (snip)
    
    1 file inspected, no offenses detected
    
    1 error occurred:
    An error occurred while Rails/ActiveRecordOverride cop was inspecting /Users/dannyiachini/github/jpw/rubocop_ex/app/models/user.rb:6:2.
    Errors are usually caused by RuboCop bugs.
    Please, report your problems to RuboCop's issue tracker.
    https://github.com/rubocop-hq/rubocop/issues
    
    Mention the following information in the issue report:
    0.67.2 (using Parser 2.6.2.0, running on ruby 2.5.3 x86_64-darwin17)
    ```
    diachini committed Apr 12, 2019
    Configuration menu
    Copy the full SHA
    9e1c4ed View commit details
    Browse the repository at this point in the history

Commits on Apr 18, 2019

  1. Configuration menu
    Copy the full SHA
    0438caf View commit details
    Browse the repository at this point in the history