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

Layout/EndAlignment should autocorrect #8321

Closed
marcandre opened this issue Jul 13, 2020 · 5 comments
Closed

Layout/EndAlignment should autocorrect #8321

marcandre opened this issue Jul 13, 2020 · 5 comments
Labels
enhancement good first issue Easy task, suitable for newcomers to the project help wanted

Comments

@marcandre
Copy link
Contributor

         def rspec_pattern
           @rspec_pattern ||= if rspec_pattern_config?
                               Regexp.union(rspec_pattern_config.map(&Regexp.public_method(:new)))
                             else
                               DEFAULT_PATTERN_RE
           end
         end

I get "Layout/EndAlignment: end at 52, 10 is not aligned with if at 48, 29."

The cop should autocorrect it.

@marcandre marcandre added enhancement good first issue Easy task, suitable for newcomers to the project help wanted labels Jul 13, 2020
@sebastian-palma
Copy link

If I try to autocorrect with the given example it does it but AutoCorrect in the .rubocop.yml must be set to true. What's not autocorrected is the content inside the if;

--- a/file.rb
+++ b/file.rb
@@ -49,5 +49,5 @@
                               Regexp.union(rspec_pattern_config.map(&Regexp.public_method(:new)))
                             else
                               DEFAULT_PATTERN_RE
-          end
+                             end
         end

@marcandre
Copy link
Contributor Author

Right, the inside is another cop's responsibility.

The full story is that I added @rspec_pattern ||= below:

         def rspec_pattern
           @rspec_pattern ||= if rspec_pattern_config?
             Regexp.union(rspec_pattern_config.map(&Regexp.public_method(:new)))
           else
             DEFAULT_PATTERN_RE
           end
         end

RuboCop corrected the alignment of everything except the end. It's not the first time I notice this, but now I took the time to open this issue.

@sebastian-palma
Copy link

What's the previous and the autocorrected code @marcandre? I ran rubocop to autocorrect your example and got this:

--- a/file.rb
+++ b/file.rb
@@ -49,5 +49,5 @@
             Regexp.union(rspec_pattern_config.map(&Regexp.public_method(:new)))
           else
             DEFAULT_PATTERN_RE
-          end
+                             end
         end

In this case only the end is aligned with the if. I don't know if I'm missing something.

@shekhar-patil
Copy link
Contributor

@marcandre Yes, there is an issue in the alignment of the 'END'. I would like to pick this issue.

marcandre added a commit to marcandre/rubocop that referenced this issue Aug 26, 2020
@mergify mergify bot closed this as completed in 414b6e5 Aug 26, 2020
@marcandre
Copy link
Contributor Author

but AutoCorrect in the .rubocop.yml must be set to true

I'm sorry I skipped over this @sebastian-palma, that was the only issue. Now fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement good first issue Easy task, suitable for newcomers to the project help wanted
Projects
None yet
Development

No branches or pull requests

3 participants