Skip to content

Commit

Permalink
Deprecate detect-stale-violations subcommand
Browse files Browse the repository at this point in the history
This command's output is in check and isn't documented.
  • Loading branch information
gmcgibbon committed Nov 8, 2022
1 parent 46cf951 commit ed2e247
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/packwerk/parse_run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ def initialize(

sig { returns(Result) }
def detect_stale_violations
warn(<<~WARNING.squish)
DEPRECATION WARNING: `detect-stale-violation` is deprecated,
the output of `check` includes stale references.
WARNING

run_context = Packwerk::RunContext.from_configuration(@configuration)
offense_collection = find_offenses(run_context)

Expand Down
26 changes: 23 additions & 3 deletions test/unit/parse_run_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ class ParseRunTest < Minitest::Test
teardown_application_fixture
end

test "#detect_stale_violations is deprecated" do
use_template(:minimal)
RunContext.any_instance.stubs(:process_file).returns([])

parse_run = Packwerk::ParseRun.new(
relative_file_set: Set.new(["path/of/exile.rb"]),
configuration: Configuration.from_path
)

_, error_message = capture_io do
parse_run.detect_stale_violations
end

assert_equal(<<~MSG, error_message)
DEPRECATION WARNING: `detect-stale-violation` is deprecated, the output of `check` includes stale references.
MSG
end

test "#detect_stale_violations returns expected Result when stale violations present" do
use_template(:minimal)
OffenseCollection.any_instance.stubs(:stale_violations?).returns(true)
Expand All @@ -26,9 +44,11 @@ class ParseRunTest < Minitest::Test
relative_file_set: Set.new(["path/of/exile.rb"]),
configuration: Configuration.from_path
)
result = parse_run.detect_stale_violations
assert_equal "There were stale violations found, please run `packwerk update-todo`", result.message
refute result.status
capture_io do
result = parse_run.detect_stale_violations
assert_equal "There were stale violations found, please run `packwerk update-todo`", result.message
refute result.status
end
end

test "#update-todo returns success when there are no offenses" do
Expand Down

0 comments on commit ed2e247

Please sign in to comment.