-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Call :expression on node instead of :keyword loc #2629
Conversation
@@ -730,7 +730,7 @@ def full_description_of_cop(cop) | |||
' ^', | |||
'example2.rb:3:1: C: Inconsistent indentation ' \ | |||
'detected.', | |||
'def a', | |||
'def a...', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why we're highlighting more than def a
here. A bug in the cop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess we should check this out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's here that we highlight the whole node, in this case a def
node. I wouldn't call it a bug. It's the easiest solution.
I'm not sure ellipses are the way to go, as they don't see to imply strongly enough the omitted code is on a subsequent line, but I'm not sure what we can use instead. |
I agree that ellipses do not imply that the code is on a different line. I am not sure that it necessarily matters though. Ellipses imply that there is more code included in the offense that is not shown. One alternative that we could do is add a line count to the end of the highlighted offense. # source code
def some_method
does_something
does_something_else
end An offense highlight could be
This may take me a little while to finish up. I have been in the process of moving and have not had too much free time recently. |
7a3f52d
to
cf9423c
Compare
Well, everything beats nothing. There's one problem with |
cf9423c
to
2a044f8
Compare
I could add a space between the end of the line and the ellipses. It could be |
2a044f8
to
d66f58f
Compare
Guess so. Or |
P.S. I like the html formatter idea as well. |
d66f58f
to
bb4bc01
Compare
I have a basic implementation for |
67dd007
to
80d09b6
Compare
OK, let me know when this is ready to be reviewed. |
Will do. Sorry this has taken so long to get running. I should have this done shortly. Everything is functioning as expected. I still have a failing test. Also, as mentioned before, I think I am going to add a |
80d09b6
to
90b8b45
Compare
This is finally functionally complete and ready for review. |
8a4a187
to
8ca7db9
Compare
@@ -730,7 +730,7 @@ def full_description_of_cop(cop) | |||
' ^', | |||
'example2.rb:3:1: C: Inconsistent indentation ' \ | |||
'detected.', | |||
'def a', | |||
"def a \e[33m...\e[0m", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why coloring is enabled in this case can be found in spec_helper.rb
. There we have the setting Rainbow.enabled = false
, but it comes after require 'rubocop'
, which means that ELLIPSES = Rainbow('...').yellow.freeze
has already been executed when we disable coloring.
I made a comment about disabling Rainbow. Fix that if you want. |
8ca7db9
to
43b7ca2
Compare
@jonas054 thanks for the info on why the test was printing in color. In order to fix it, I had to require Rainbow in the |
43b7ca2
to
f1e01e7
Compare
The changes look good. Just add some changelog entry. |
f1e01e7
to
2cf4b1f
Compare
I have added changelog entries. I also changed the name of the method from |
Call :expression on node instead of :keyword loc
@BlakeWilliams, FYI, this has been merged. |
This is a continuation/replacement of #2414.
I have modified the formatters to include ellipses (...) at the end of the highlighted code if the highlighted code spans more than one line. This could open up the html formatter to have an expand button that could show the entire highlighted offense.
I will work on adding
highlighted_area
to the offense.