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

Rubocop does not properly indent method body #4219

Closed
IanTrudel opened this issue Mar 31, 2017 · 4 comments
Closed

Rubocop does not properly indent method body #4219

IanTrudel opened this issue Mar 31, 2017 · 4 comments

Comments

@IanTrudel
Copy link

sample.rb:

class RubocopSampleTest
def m(args)
puts "properly indented"
puts "Why am I not indented?"
puts "how about me?"
end
end

Expected behavior

class RubocopSampleTest
  def m(_args)
    puts 'properly indented'
    puts 'Why am I not indented?'
    puts 'how about me?'
  end
end

Actual behavior

class RubocopSampleTest
  def m(_args)
    puts 'properly indented'
  puts 'Why am I not indented?'
  puts 'how about me?'
  end
end

Steps to reproduce the problem

Ran with default options (no .rubocop.yml) and using command line rubocop --only-guide-cops -a -D sample.rb.

$ rubocop -V
0.48.0 (using Parser 2.4.0.0, running on ruby 2.2.6 i386-mingw32) **Windows/MSYS2**
0.47.1 (using Parser 2.4.0.0, running on ruby 2.1.5 i386-mingw32) **Windows/cmd**
@pocke
Copy link
Collaborator

pocke commented Mar 31, 2017

The indentation can be corrected by Style/IndentationConsistency cop. However, the cop doesn't have a link to the style guide. So, with --only-guide-cops option, the indentation is not corrected.

I think we can fix the problem by adding a link to the style guide for the cop. https://github.com/bbatsov/ruby-style-guide#spaces-indentation

@bbatsov
Copy link
Collaborator

bbatsov commented Mar 31, 2017

Definitely.

@Drenmi
Copy link
Collaborator

Drenmi commented Mar 31, 2017

I'm not a huge fan on relying on people having a certain other cop enabled to clean up a messy auto-correct. I've been making the opposite assumption for the cops I've been working on. 🤔

@IanTrudel
Copy link
Author

Thanks. You guys are fast. The fix does work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants