Skip to content

Conversation

@martinemde
Copy link
Contributor

No description provided.

Create a T::Struct that represents violations from pks JSON output with
fields for violation_type, file, line, column, constant_name, and pack
names. Includes methods for JSON deserialization and compatibility with
the BasicReferenceOffense interface used by existing formatters.
Shells out to `pks check --output-format json <files>`, parses the
response, and converts violations to PksOffense objects. Handles pks
binary not found gracefully by raising PksBinaryNotFoundError.
Create JSON fixture files representing pks check output for various
violation scenarios (privacy, dependency, multiple, strict mode).
Extend pks_offense_spec with fixture-based tests to verify parsing.
Add pks_wrapper_spec with test patterns ready for PksWrapper impl.

All 90 existing tests continue to pass.
Replace PackwerkWrapper with PksWrapper to shell out to the pks binary
for packwerk violation detection. This enables JSON-based violation
parsing and prepares for removing the packwerk gem dependency.

Changes:
- Add PksWrapper to shell out to `pks check --output-format json`
- Add Packwerk::ReferenceOffense adapter methods to PksOffense
- Update DangerPackwerk#check to use PksWrapper.get_offenses_for_files
- Update test mocks to stub PksWrapper instead of PackwerkWrapper
Replace all sorbet_double(Packwerk::ReferenceOffense, ...) mocks with
real PksOffense objects in the test suite. This aligns the tests with
the actual behavior of the PksWrapper, which returns PksOffense objects.

Key changes:
- Add build_pks_offense helper to spec_helper.rb
- Replace Packwerk mocks in 'using inputted formatter' tests
- Replace Packwerk mocks in 'using default formatter' tests
- Update expectations where constant.location now points to the
  violation file instead of the constant definition file

This is a known behavioral change: pks output doesn't include the
constant definition location, so URLs and file paths in formatted
messages now reference the violation file.
@github-project-automation github-project-automation bot moved this to Triage in Modularity Jan 7, 2026
@martinemde martinemde closed this Jan 9, 2026
@github-project-automation github-project-automation bot moved this from Triage to Done in Modularity Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants