Skip to content

Commit

Permalink
Fix check option fails when no issues and no lock file
Browse files Browse the repository at this point in the history
  • Loading branch information
skryukov committed Jul 21, 2024
1 parent 0a6b028 commit 8538816
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/rubocop/gradual/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ def call
private

def fail_with_outdated_lock?(diff)
Configuration.mode == :check && diff.state != :no_changes
return false if Configuration.mode != :check
return false if diff.state == :complete && old_results.nil?

diff.state != :no_changes
end

def sync_lock_file(diff)
Expand Down
19 changes: 19 additions & 0 deletions spec/rubocop/gradual_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,25 @@
include_examples "error with --check option", with_extended_steps: false
end

context "when no lock file and no issues found" do
let(:options) { %w[--config security_only_rubocop.yml --gradual-file] }
let(:actual_lock_path) { File.expand_path("no.lock") }

it "removes file" do
expect(gradual_cli).to eq(0)
expect($stdout.string).to include("RuboCop Gradual is complete!")
end

context "with --check option" do
let(:options) { super().unshift("--check") }

it "returns success and doesn't update file" do
expect(gradual_cli).to eq(0)
expect($stdout.string).to include("RuboCop Gradual is complete!")
end
end
end

context "with --autocorrect option" do
let(:options) { %w[--autocorrect --gradual-file] }
let(:actual_lock_path) { File.expand_path("full.lock") }
Expand Down

0 comments on commit 8538816

Please sign in to comment.