Skip to content

Performance/AncestorsInclude with auto correct raises error #147

@andreyruby

Description

@andreyruby

Performance/AncestorsInclude with auto correct raises error

Steps to reproduce the problem

Add <file> with text ancestors.include?(SomeClass)
Check it with rubocop <file> --auto-correct --debug

Output includes error:

An error occurred while Performance/AncestorsInclude cop was inspecting <file>:1:0.
undefined method `source' for nil:NilClass
~/rubocop-performance-1.7.0/lib/rubocop/cop/performance/ancestors_include.rb:38:in `block (2 levels) in autocorrect'
~/rubocop-0.87.1/lib/rubocop/cop/cop.rb:134:in `block in emulate_v0_callsequence'
~/rubocop-0.87.1/lib/rubocop/cop/cop.rb:154:in `suppress_clobbering'
~/rubocop-0.87.1/lib/rubocop/cop/cop.rb:133:in `emulate_v0_callsequence'
~/rubocop-0.87.1/lib/rubocop/cop/cop.rb:34:in `block in add_offense'
~/rubocop-0.87.1/lib/rubocop/cop/base.rb:302:in `correct'
~/rubocop-0.87.1/lib/rubocop/cop/base.rb:115:in `add_offense'
~/rubocop-0.87.1/lib/rubocop/cop/cop.rb:33:in `add_offense'

RuboCop version

rubocop -V
0.87.1 (using Parser 2.7.1.4, rubocop-ast 0.1.0, running on ruby 2.6.6 x86_64-linux)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions