turboladen / tailor

A RubyGem that allows for checking standard styling of Ruby files.
146 stars 18 forks source link

%Q{ #{hashobj['key']} } returns improper indentation message when on multiple lines #123

Closed miketheman closed 8 years ago

miketheman commented 11 years ago

Took me a bit to figure this one out.

A %Q string including a string interpolated with a hash-accessed key returns incorrect indentation message.

Take these three examples:

works %Q{ #{foo} }
works %Q{ #{bar} #{baz['bat']} }

breaks %Q{
  #{bar} #{baz['bat']}
}

Provides:

# Problems:
#  1.
#    * position:  4:2
#    * property:  indentation_spaces
#    * message:   Line is indented to column 2, but should be at 0.

The indentation is indeed correct, something about having the braces/single quotes triggers this.

No idea where to look for something like this.

turboladen commented 11 years ago

Thanks for logging this. Yeah, that's definitely an issue--tailor shouldn't do any indentation checking for code inside a string.

FWIW, for helping narrow down where the problem is coming from, you can turn on tailor logging:

If you use this with anything but a really short file, you'll get tons of output, but sometimes that's what's needed... If I run with this on, I see the following, which doesn't look quite right:

[2013-01-09 09:31:49]  <Lexer> 2[14]: LBRACKET: '['
[2013-01-09 09:31:49]  <IndentationManager> Token '[' not used as a modifier.
[2013-01-09 09:31:49]  <IndentationManager> Added indent reason; it's now:
[2013-01-09 09:31:49]  <IndentationManager> {:event_type=>:on_lbracket, :token=>"[", :lineno=>2, :should_be_at=>0}

It's been a while since I've been in this code, but IIRC the IndentationManager (used by the IndentationSpacesRuler) shouldn't be updating any rules when it's parsing a string.

turboladen commented 11 years ago

Sorry, I incorrectly associated that last commit with this issue.

miketheman commented 11 years ago

Aw, shucks. :)

turboladen commented 11 years ago

Gotta love reminders that the dev still hasn't fixed your bug, right? :)

miketheman commented 11 years ago

Best part of my day.

miketheman commented 8 years ago

Closing this old issue. I can't repro, my code is a little out of whack, and I use another popular library these days.

turboladen commented 8 years ago

Thanks @miketheman.

and I use another popular library these days.

Me too. :)