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 explodes :\ #497

Closed
fuadsaud opened this issue Sep 19, 2013 · 10 comments
Closed

Rubocop explodes :\ #497

fuadsaud opened this issue Sep 19, 2013 · 10 comments

Comments

@fuadsaud
Copy link

This is the codebase: https://github.com/fuadsaud/bis

�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
To see the complete backtrace run rubocop -d.
�[31m
20 errors occurred:�[0m
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while UselessComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
�[31mAn error occurred while NilComparison�[0m�[31m cop was inspecting /Users/fuad/Code/bis/lib/bis.rb.�[0m
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
Mention the following information in the issue report:
0.13.0 (using Parser 2.0.0.pre8, running on ruby 2.0.0 x86_64-darwin12.3.0)
RuboCop failed!
@fuadsaud
Copy link
Author

Also there seems to be a bug with ansi escape sequence redirection (I redirected stderr to a file in this case)

@bbatsov
Copy link
Collaborator

bbatsov commented Sep 19, 2013

I'm on it :-)

There's no bug with the redirection - the odd sequences are ANSI colour codes.

@fuadsaud
Copy link
Author

Ah really awesome, thanks!

I'm aware of ANSI escape sequences, but they shouldn't be printed when the output is a file. A check for #tty? on the output stream should do the job.

@fuadsaud
Copy link
Author

Hum, I see the problem. Rainbow only checks for STDOUT.tty? when starting. I'm not really sure how to solve this.

@bbatsov
Copy link
Collaborator

bbatsov commented Sep 19, 2013

Open a ticket there and we'll see.

@yujinakayama
Copy link
Collaborator

Actually I've tried to tackle the problem with escape sequences before. However RuboCop supports multiple formatters (i.e. multiple outputs), and Sickill::Rainbow.enabled = false disables all colors in a Ruby program. So I think we need to migrate from Rainbow to another coloring gem (non monkey patch one).

@fuadsaud
Copy link
Author

So, Cape-Cod doesn't monkey patch string by default.

The issue is that Rainbow disables itself if it sees that stdout is not tty. This approach - used in cape-cod and a lot of other gems as well - is brittle. Maybe we could have a colorizer instance that gets a stream passed and only adds ansi sequences if that's a tty?

@bbatsov
Copy link
Collaborator

bbatsov commented Sep 19, 2013

I'm no expert on the subject, so I'm open to suggestions. I've tried term-ansocolor and colorize before rainbow and they were even worse than rainbow. Maybe we should move this discussion to a new ticket?

@yujinakayama
Copy link
Collaborator

Maybe we should move this discussion to a new ticket?

👍

@ku1ik
Copy link

ku1ik commented Dec 26, 2013

I have just released a new rainbow 1.99 which has this fixed (checks if any of stdout and stderr is not a tty). rainbow will drop monkey patching of String class in 2.0 and this 1.99 release is a preparation for that. You can now upgrade to 1.99 and convert all "foo".color(:red) to Rainbow("foo").color(:red). When 2.0 is out you'll be prepared.

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