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 Shows bash Color Escape Sequences in Output Files #2262

Closed
roberts1000 opened this issue Sep 21, 2015 · 1 comment
Closed

Rubocop Shows bash Color Escape Sequences in Output Files #2262

roberts1000 opened this issue Sep 21, 2015 · 1 comment
Labels

Comments

@roberts1000
Copy link
Contributor

I just tried running the following command with rubcop 0.34.1

rubocop --format simple --out issues.txt

and got the following output in the text file

C: 39: 32: Use ESC[33m&&ESC[0m instead of ESC[33mandESC[0m.
@jonas054 jonas054 added the bug label Sep 21, 2015
@minustehbare
Copy link
Contributor

I believe I found where this bug is occurring and can submit the fix I mention below if appropriate. Running rspec shows a few failures/pending tests, none related to this change, and a quick test on a real file produced the correct results.

From lib/rubocop/formatter/simple_text_formatter:

class SimpleTextFormatter < BaseFormatter
  include Colorizable, PathUtil, TextUtil

...

def annotate_message
  msg.gsub(/`(.*?)`/, Rainbow('\1').yellow)
end

In the same file, the file name/path is output in yellow using a separate syntax mixed in through Colorizable:

def report_file(file, offenses)
  output.puts yellow("== #{smart_path(file)} ==")
  ...
end

Proposed fix:

# this
def annotate_message
  msg.gsub(/`(.*?)`/, Rainbow('\1').yellow)
end

# to this
def annotate_message
  msg.gsub(/`(.*?)`/, yellow('\1'))
end

bbatsov added a commit that referenced this issue Oct 29, 2015
[Fix #2262] Replace Rainbow reference with Colorizable#yellow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants