-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Layout/AccessModifierIndentation requires odd indentations #5956
Comments
//cc @brandonweiss |
@jodosha Hey! You’ve left out some useful information, like what your configuration is for the relevant cops ( Hmm. 🤔 I can imagine what might be going wrong here… Offhand, it seems like we probably want to alter |
@brandonweiss Thanks for getting back. AFAIK these meta-programming examples are the only ones where I get the I don't have any configuration for To use the Anyway, even enabling the |
@jodosha I'm confused as to what you mean… when you say you “don’t have any configuration” for those cops, do you mean like, now you don't, because you disabled them? Or do you mean before you didn't have an explicit configuration set? Because if the cops are enabled then they are “configured” with the defaults. So you were using the defaults? I’m not sure what “the team style is to use private inline, but as a group modifier” means? Can you explain and give an example? |
@brandonweiss Let me explain: by upgrading to Because we use Rubocop in our CI, in order to avoid build failures, I disabled these two cops in our local
The default team style is: class Foo
def call(input)
end
private
def a_private_method
end
end I mentioned this, because it prevents us to use |
I just ran into this as well. For me, this occurs with: Layout/AccessModifierIndentation:
EnforcedStyle: outdent
Style/AccessModifierDeclarations:
Enabled: false The code where issues occur is for meta programmed methods (changing a parent class / module method access or for methods defined via module SomeModule
include AnotherModule
alias_method :another_name, :orig_name
module_function :another_name # violation happens here
protected
def any_protected_method
# ...
end
end This behaved as expected before 0.57.0. |
I ran into this as well now with the inverse of @cupakromer :
This incorrectly outdents:
And this one
|
My case with RSpec: stub_const(
'Foo', Class.new do
private
def foo; end
end
) |
I tried to fix this in #6573. Can you double check if that fixes the issue for you? |
I have 3 disabling of this cop in Formalism and I have |
That means it's working, right? |
Yep! For my case. Thank you. |
… modules (#6573) * [Fix #5956] More robust AccessModifierIndentation Use `end`'s indentation as the base indentation, which is more robust since it also plays nice with dynamic module or class definitions. * Move `effective_column` method to `RangeHelp` It fits better in there an it also make it possible to reuse the method in places where `ConfigurableEnforcedStyle` has been separatedly mixed in. * Extract `column_offset_between` method And move `effective_colum` under the "private note".
To make
Layout/AccessModifierIndentation
to pass, I need to write code with odd indentation levels.Expected behavior
I don't expect any violations for the snippets below.
Actual behavior
There are violations.
Steps to reproduce the problem
Example 1
Existing code
Code that satisfies
Layout/AccessModifierIndentation
Example 2
Actual code
Code that satisfies
Layout/AccessModifierIndentation
, BUT it leads to a violation ofLayout/IndentationConsistency
RuboCop version
The text was updated successfully, but these errors were encountered: