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

Using the --fix option with --stdin appends file content to the json result #199

Closed
jgiovaresco opened this issue Sep 7, 2020 · 4 comments
Labels
rubocop bug 🚨 An apparent bug in RuboCop

Comments

@jgiovaresco
Copy link

When I run the following commands standardrb --format json --force-exclusion --stdin application_controller.rb < app/controllers/application_controller.rb, I can see the result

{"metadata":{"rubocop_version":"0.90.0","ruby_engine":"ruby","ruby_version":"2.7.0","ruby_patchlevel":"0","ruby_platform":"x86_64-darwin19"},"files":[{"path":"Gemfile","offenses":[]}],"summary":{"offense_count":0,"target_file_count":1,"inspected_file_count":1}}% 

However when I run standardrb --format json --force-exclusion --fix --stdin Gemfile < app/controllers/application_controller.rb, I have the result

{"metadata":{"rubocop_version":"0.90.0","ruby_engine":"ruby","ruby_version":"2.7.0","ruby_patchlevel":"0","ruby_platform":"x86_64-darwin19"},"files":[{"path":"Gemfile","offenses":[]}],"summary":{"offense_count":0,"target_file_count":1,"inspected_file_count":1}}====================
class ApplicationController < ActionController::API
end

As you can see, the content of the linted file is appended to the JSON result.

This prevent tools (like RubyMine) to parse the response (https://youtrack.jetbrains.com/issue/RUBY-27006)

@jmkoni
Copy link
Contributor

jmkoni commented Sep 8, 2020

I was able to replicate this issue with a project I have. I also tried running the same command with rubocop and this seems to be an issue with rubocop that is filtering up to standard:

rubocop --format json --force-exclusion --fix --stdin application_controller.rb < app/controllers/application_controller.rb
{"metadata":{"rubocop_version":"0.90.0","ruby_engine":"ruby","ruby_version":"2.7.1","ruby_patchlevel":"83","ruby_platform":"x86_64-darwin19"},"files":[{"path":"application_controller.rb","offenses":[]}],"summary":{"offense_count":0,"target_file_count":1,"inspected_file_count":1}}====================
class ApplicationController < ActionController::Base

@jmkoni
Copy link
Contributor

jmkoni commented Sep 8, 2020

@jgiovaresco Since this is a rubocop bug, I would recommend opening up an issue in rubocop

@jmkoni jmkoni added the rubocop bug 🚨 An apparent bug in RuboCop label Sep 8, 2020
@jmkoni jmkoni closed this as completed Sep 8, 2020
@jgiovaresco
Copy link
Author

Done: rubocop/rubocop#8673

@jmkoni
Copy link
Contributor

jmkoni commented Sep 9, 2020

@jgiovaresco I'm watching that issue now. Thanks for creating it 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rubocop bug 🚨 An apparent bug in RuboCop
Projects
None yet
Development

No branches or pull requests

2 participants