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

[Fix #8673] Fix the JSON parse error when specifying --format=json and --stdin #8694

Merged

Conversation

koic
Copy link
Member

@koic koic commented Sep 10, 2020

Fixes #8673.

This PR returns only JSON result when specifying --format=json and --stdin to fix the JSON parse error.


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@koic koic force-pushed the suppress_stdin_info_for_specifying_format_option branch from 2533b56 to 9da0610 Compare September 10, 2020 17:59
# Integration tools (like RubyMine) expect to have only the JSON result
# when specifying JSON format.
# See: https://github.com/rubocop-hq/rubocop/issues/8673
return if @options[:format] == 'json'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, shouldn't we do the same for the HTML formatter as well? Might be weird to append plain text to it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I think also JUnit formatter is similar, so I added HTML and JUnit formatters.

…=json` and `--stdin`

Fixes rubocop#8673.

This PR returns only JSON result when specifying `--format=json` and `--stdin`
to fix the JSON parse error. Similar HTML and JUnit formatters are targeted as well.
@koic koic force-pushed the suppress_stdin_info_for_specifying_format_option branch from 9da0610 to 225c01e Compare September 14, 2020 13:48
@bbatsov bbatsov merged commit 3282218 into rubocop:master Sep 14, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Sep 14, 2020

Thanks!

@koic koic deleted the suppress_stdin_info_for_specifying_format_option branch September 14, 2020 16:06
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

Successfully merging this pull request may close these issues.

Using the --fix option with --stdin appends file content to the json result
2 participants