Rubocop: Lint/DuplicateMethods for classes inside `class << self` of parent module

Created on 9 Nov 2017  路  4Comments  路  Source: rubocop-hq/rubocop

As in #4758, but with class << self.

Real-life case: https://github.com/panthomakos/timezone/blob/b70e1d8/lib/timezone/lookup.rb


Expected behavior

No warnings.

Actual behavior

Inspecting 1 file
W

Offenses:

.test.rb:10:7: W: Method Foo.config is defined at both .test.rb:4 and .test.rb:10.
      attr_reader :config
      ^^^^^^^^^^^

1 file inspected, 1 offense detected

Steps to reproduce the problem

# Module with class-methods
module Foo
  class << self
    def config
      'Foo.config'
    end

    # Private class for module
    class Bar
      attr_reader :config
    end
  end
end

RuboCop version

$ rubocop -V
0.51.0 (using Parser 2.4.0.0, running on ruby 2.4.2 x86_64-linux)
bug stale

All 4 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

This issues been automatically closed due to lack of activity. Feel free to re-open it if you ever come back to it.

The bug is still here.

Yes. This bug is still here. Rubocop 0.77.0

Was this page helpful?
0 / 5 - 0 ratings