False Positive and Incorrect Error Message for Style/AccessModifierDeclarations #7740
RuboCop 0.80.0 is reporting offences for marking existing methods as private, even when the method is not defined within the scope it is marked private in.
I expect to be able to mark methods introduced by reflection or otherwise defined outside of the current scope as protected or private.
Consider a hypothetical example using a Rails model:
ApplicationRecord.connection.create_table(:articles) do |t| t.string :name t.string :slug end class Article < ApplicationRecord def name=(value) super self.slug = name&.parameterize end private :slug= end
The rubocop offence is reported on the
The reported offence is incorrect since:
Steps to reproduce the problem
Minimum case to reproduce:
module Bar def bar nil end end class Foo include Bar private :bar end
The error message is produced:
The line neither defines a method, nor does class
The text was updated successfully, but these errors were encountered: