-
Notifications
You must be signed in to change notification settings - Fork 0
Add json output format to check #24
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
365120a
Implement json output format option
martinemde 9d02f70
Add line and column to json output for violations
martinemde 85bd32b
Control exit status for `check` command
martinemde b04193f
Update src/packs/json.rs
martinemde 70345c9
cargo fmt
martinemde 181e16f
Don't be too preshus about exit 2 approach
martinemde 1ae3dff
Fix clippy again, for everything
martinemde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "title": "pks check JSON output", | ||
| "type": "object", | ||
| "required": ["violations", "stale_todos", "summary"], | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "violations": { | ||
| "type": "array", | ||
| "items": { "$ref": "#/$defs/Violation" } | ||
| }, | ||
| "stale_todos": { | ||
| "type": "array", | ||
| "items": { "$ref": "#/$defs/StaleTodo" } | ||
| }, | ||
| "summary": { | ||
| "type": "object", | ||
| "required": [ | ||
| "violation_count", | ||
| "stale_todo_count", | ||
| "strict_violation_count", | ||
| "success" | ||
| ], | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "violation_count": { "type": "integer", "minimum": 0 }, | ||
| "stale_todo_count": { "type": "integer", "minimum": 0 }, | ||
| "strict_violation_count": { | ||
| "type": "integer", | ||
| "minimum": 0, | ||
| "description": "Count of violations where strict=true (subset of violation_count)" | ||
| }, | ||
| "success": { "type": "boolean" } | ||
| } | ||
| } | ||
| }, | ||
| "$defs": { | ||
| "ViolationType": { | ||
| "type": "string", | ||
| "enum": ["dependency", "privacy", "visibility", "layer", "folder_privacy"] | ||
| }, | ||
| "Violation": { | ||
| "type": "object", | ||
| "required": [ | ||
| "violation_type", | ||
| "file", | ||
| "line", | ||
| "column", | ||
| "constant_name", | ||
| "referencing_pack_name", | ||
| "defining_pack_name", | ||
| "strict", | ||
| "message" | ||
| ], | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "violation_type": { "$ref": "#/$defs/ViolationType" }, | ||
| "file": { "type": "string" }, | ||
| "line": { "type": "integer", "minimum": 1 }, | ||
| "column": { "type": "integer", "minimum": 0 }, | ||
| "constant_name": { "type": "string" }, | ||
| "referencing_pack_name": { "type": "string" }, | ||
| "defining_pack_name": { "type": "string" }, | ||
| "strict": { "type": "boolean" }, | ||
| "message": { "type": "string" } | ||
| } | ||
| }, | ||
| "StaleTodo": { | ||
| "type": "object", | ||
| "required": [ | ||
| "violation_type", | ||
| "file", | ||
| "constant_name", | ||
| "referencing_pack_name", | ||
| "defining_pack_name" | ||
| ], | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "violation_type": { "$ref": "#/$defs/ViolationType" }, | ||
| "file": { "type": "string" }, | ||
| "constant_name": { "type": "string" }, | ||
| "referencing_pack_name": { "type": "string" }, | ||
| "defining_pack_name": { "type": "string" } | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,18 @@ | ||
| use packs::packs::cli; | ||
| use std::process::ExitCode; | ||
|
|
||
| pub fn main() -> anyhow::Result<()> { | ||
| cli::run() | ||
| pub fn main() -> ExitCode { | ||
| match cli::run() { | ||
| Ok(()) => ExitCode::SUCCESS, | ||
| Err(e) => { | ||
| if e.downcast_ref::<cli::ViolationsFound>().is_some() { | ||
| // ViolationsFound already printed its output; exit 1 for violations | ||
| ExitCode::from(1) | ||
| } else { | ||
| // Other errors (IO, config, etc.) exit 2; usage errors handled by clap | ||
| eprintln!("Error: {e:#}"); | ||
| ExitCode::from(2) | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.