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-git exits with status 1 with disabled cops #39

Open
tcollier opened this issue Feb 9, 2018 · 2 comments · May be fixed by #47
Open

rubocop-git exits with status 1 with disabled cops #39

tcollier opened this issue Feb 9, 2018 · 2 comments · May be fixed by #47

Comments

@tcollier
Copy link

tcollier commented Feb 9, 2018

I have rubocop-git in my CI build process and it's breaking despite the lack of offenses. The output and return value for rubocop-git looks like

rubocop-git --display-cop-names master
#
# 14 files inspected, no offenses detected
echo $?
# 1

To debug this code, I printed out the violations variable after https://github.com/m4i/rubocop-git/blob/master/lib/rubocop/git/runner.rb#L13

[#<struct RuboCop::Git::FileViolation
  filename="spec/models/web_monitor/processes_count_spec.rb",
  offenses=
   [#<RuboCop::Cop::Offense:0x00007fa29e055648
     @cop_name="RSpec/InstanceVariable",
     @location=#<Parser::Source::Range spec/models/web_monitor/processes_count_spec.rb 676...692>,
     @message="RSpec/InstanceVariable: Use `let` instead of an instance variable.",
     @severity=#<RuboCop::Cop::Severity:0x00007fa29e055620 @name=:convention>,
     @status=:disabled>]>]

This points to a violation for a disabled cop causing the failure. The code at the location specified in the violation is spec/models/web_monitor/processes_count_spec.rb:28:48, which is shown below.

  end

  after do
    # rubocop:disable InstanceVariable
    Rails.application.config.heroku_app_name = @heroku_app_name
    # rubocop:enable InstanceVariable
  end

  describe '#successful?' do
    context 'when quantity is above threshold' do
      it { is_expected.to be_successful }
    end

    context 'when quantity is equal to threshold' do
      let(:quantity) { 3 }

      it { is_expected.to be_successful }
    end

    context 'when quantity is below threshold' do
      let(:quantity) { 2 }

      it { is_expected.to_not be_successful }
    end
vassalloandrea added a commit to vassalloandrea/rubocop-git that referenced this issue Oct 26, 2022
We should exit 1, that means error, only
when the violations are valid.
For valid we mean all the validations that have
at least one offence that is not disabled.
This will fix this issue: m4i#39
@vassalloandrea vassalloandrea linked a pull request Oct 26, 2022 that will close this issue
@vassalloandrea
Copy link

This PR will fix the issue: #47

You can install the gem pointing to the fixed branch in the meantime that it is not merged with master:
gem 'rubocop-git', github: 'vassalloandrea/rubocop-git', branch: 'av/39/fix-exits-with-status-1-with-disabled-cops'

Remember to add the github source on the top of the gem file:

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
  "https://github.com/#{repo_name}.git"
end

@jaynetics
Copy link

jaynetics commented Mar 24, 2023

if anyone is still using this, i've release a forked gem, rubocop-git2, with this and other fixes included

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 a pull request may close this issue.

3 participants