Skip to content

Commit 4823ba3

Browse files
committed
feat: add --fix option
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
1 parent ab32553 commit 4823ba3

6 files changed

Lines changed: 126 additions & 90 deletions

File tree

docs/cli/t4sanity.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ $ t4sanity -h
1414
│ --revision -rv TEXT Specify if you want to check the specific version. [default: None] │
1515
│ --exclude -e TEXT Exclude specific rules or rule groups. [default: None] │
1616
│ --strict -s Indicates whether warnings are treated as failures. │
17+
│ --fix Attempt to fix the issues reported by the sanity check. │
1718
│ --install-completion Install completion for the current shell. │
1819
│ --show-completion Show completion for the current shell, to copy it or customize the installation. │
1920
│ --help -h Show this message and exit. │
@@ -65,6 +66,15 @@ $ t4sanity <DATA_ROOT>
6566
+-----------+---------+--------+--------+---------+----------+
6667
```
6768
69+
### Exclude Checks
70+
71+
With `-e; --exclude` option enables us to exclude specific checks by specifying the **rule IDs or groups**:
72+
73+
```shell
74+
# Exclude STR001 and all FMT-relevant rules
75+
t4sanity <DATA_ROOT> -e STR001 -e FMT
76+
```
77+
6878
### Strict Mode
6979
7080
Basically, rules whose **severity is WARNING** will be treated as success.
@@ -76,25 +86,27 @@ With `-s; --strict` option enables us to treat warnings as failures:
7686
t4sanity <DATA_ROOT> -s
7787
```
7888
79-
### Exclude Checks
89+
### Fix Issues
8090
81-
With `-e; --excludes` option enables us to exclude specific checks by specifying the **rule IDs or groups**:
91+
With `--fix` option enables to fix issues automatically:
8292
8393
```shell
84-
# Exclude STR001 and all FMT-relevant rules
85-
t4sanity <DATA_ROOT> -e STR001 -e FMT
94+
# Fix issues automatically
95+
t4sanity <DATA_ROOT> --fix
8696
```
8797
8898
### Exit Status Logic
8999
90100
`t4sanity` CLI returns the exit code based on the following conditions:
91101
92-
| Condition | `--strict` | Exit Code | Notes |
93-
| ----------------------------------------------------------------------- | ----------------- | --------- | --------------------------------------------------- |
94-
| At least one `Severity.ERROR` rule failed | N/A | 1 | Always fails the run |
95-
| At least one `Severity.WARNING` rule failed, no `Severity.ERROR` failed | `False` (default) | 0 | Run is considered successful, warnings are reported |
96-
| At least one `Severity.WARNING` rule failed, no `Severity.ERROR` failed | `True` | 1 | Treat warnings as failures; exit with failure |
97-
| All rules passed or skipped | N/A | 0 | Run is considered successful |
102+
| Condition | `--strict` | `--fix` | Exit Code | Notes |
103+
| ---------------------------------------------------------------------------------- | ----------------- | ------- | --------- | ------------------------------------------------------------------------- |
104+
| At least one `Severity.ERROR` rule failed | N/A | `False` | 1 | Always fails the run |
105+
| At least one `Severity.ERROR` rule failed, but fixed | N/A | `True` | 0 | Run is considered successful, error reasons are reported and `Fixed=true` |
106+
| At least one `Severity.WARNING` rule failed, no `Severity.ERROR` failed | `False` (default) | N/A | 0 | Run is considered successful, warnings are reported |
107+
| At least one `Severity.WARNING` rule failed, no `Severity.ERROR` failed | `True` | `False` | 1 | Treat warnings as failures; exit with failure |
108+
| At least one `Severity.WARNING` rule failed, no `Severity.ERROR` failed, but fixed | `True` | `True` | 0 | Run is considered successful, warnings are reported and `Fixed=true` |
109+
| All rules passed or skipped | N/A | N/A | 0 | Run is considered successful |
98110
99111
### Dump Results as JSON
100112

0 commit comments

Comments
 (0)