feat(sanity): add --fix option#258
Merged
Merged
Conversation
Contributor
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
83593cc to
ca5df65
Compare
2c9efa0 to
3f28a79
Compare
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
3f28a79 to
1d633a7
Compare
mojomex
approved these changes
Jan 30, 2026
Contributor
|
Tested with a few corrupted |
shekharhimanshu
approved these changes
Jan 30, 2026
shekharhimanshu
left a comment
Contributor
There was a problem hiding this comment.
LGTM! 💯
Thank you
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
ktro2828
added a commit
that referenced
this pull request
Jan 30, 2026
* feat: add --fix option Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp> * feat: override fix method for REC007 Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp> * refactor: do refactoring Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp> * docs: update document Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp> * docs: add docstring of the behavior Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp> * refactor: update report color Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp> --------- Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
This pull request introduces a new
--fixoption to thet4sanityCLI tool, enabling automatic fixing of issues detected by sanity checks. It updates the CLI, core checker logic, reporting, and documentation to support and clearly present this new feature. Additionally, it improves the exclusion and reporting of checks.The following diagram shows the logic of checkers:
flowchart LR Start --> A{Can skip?} A --> |Yes| B[Skip check and <br/>returns skipped report] A --> |No| C[Perform check] C --> D{Failed and --fix=True?} D --> |Yes| E[Fix issues] E --> F[Return report] D --> |No| FMajor new feature: Automatic fixing of issues
--fixoption to the CLI, allowing users to attempt to automatically fix issues found during sanity checks. [1] [2] [3]Checkerinterface and all checker calls to support afixparameter, and adds afix()method for implementing fix logic in each checker. [1] [2]Reportdataclass and summary output to include a "Fixed" column. [1] [2] [3] [4] [5]Documentation improvements
--fixoption and provide usage examples.--excludeoption with clearer examples for excluding rules or groups.Tests
I checked this feature with sample data
tests/sample/t4datasetby edittingcategory.json.Before running
t4sanity tests/sample/t4dataset --fix:[ { "token": "1c22a023c1a214447d0bc497088c9a3d", "name": "car", "description": "Vehicle designed primarily for passenger transportation", "index": null }, { "token": "4db2cce0862dbdf1385186fd604d477a", "name": "pedestrian", "description": "Person walking or standing", "index": 1 }, { "token": "0531921ca79d7ca8c3815a77122de529", "name": "bicycle", "description": "Two-wheeled vehicle propelled by pedaling", "index": 2 }, { "token": "bdb3ce20fb731507f2ecf9387071335f", "name": "traffic_cone", "description": "Cone-shaped marker used to redirect traffic", "index": 3 } ]After running:
[ { "token": "1c22a023c1a214447d0bc497088c9a3d", "name": "car", "description": "Vehicle designed primarily for passenger transportation", "index": 0 }, { "token": "4db2cce0862dbdf1385186fd604d477a", "name": "pedestrian", "description": "Person walking or standing", "index": 1 }, { "token": "0531921ca79d7ca8c3815a77122de529", "name": "bicycle", "description": "Two-wheeled vehicle propelled by pedaling", "index": 2 }, { "token": "bdb3ce20fb731507f2ecf9387071335f", "name": "traffic_cone", "description": "Cone-shaped marker used to redirect traffic", "index": 3 } ]The dumped report would be like:
[ { "id": "REC007", "name": "category-indices-consistent", "severity": "ERROR", "description": "All categories must either have a unique 'index' or all have a 'null' index.", "status": "FAILED", "reasons": [ "All categories either must have an 'index' set or all have a 'null' index." ], "fixed": true } ]