forked from espressif/esp-idf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tool): use ast-grep to lint code base
- Loading branch information
1 parent
96c81c8
commit c4c8965
Showing
9 changed files
with
76 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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 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 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,2 @@ | ||
ruleDirs: | ||
- ./tools/ci/sg_rules |
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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 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 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,32 @@ | ||
# Refer to https://ast-grep.github.io/guide/rule-config.html for Rule Essentials | ||
id: no-private-rom-api-in-c-examples | ||
message: Don't use private ROM APIs in the examples | ||
severity: error # error, warning, info, hint | ||
note: Only APIs prefixed with "esp_rom_" are treated as public. | ||
language: C | ||
files: | ||
- "./examples/**/*" | ||
rule: | ||
kind: preproc_include | ||
has: | ||
field: path | ||
regex: "rom/.*h" | ||
pattern: $N | ||
fix: '' | ||
|
||
--- | ||
|
||
id: no-private-rom-api-in-cpp-examples | ||
message: Don't use private ROM APIs in the examples | ||
severity: error # error, warning, info, hint | ||
note: Only APIs prefixed with "esp_rom_" are treated as public. | ||
language: Cpp | ||
files: | ||
- "./examples/**/*" | ||
rule: | ||
kind: preproc_include | ||
has: | ||
field: path | ||
regex: "rom/.*h" | ||
pattern: $N | ||
fix: '' |
This file contains 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,35 @@ | ||
# Refer to https://ast-grep.github.io/guide/rule-config.html for Rule Essentials | ||
id: no-std-assert-call-in-hal-component | ||
message: Don't use standard assert function in the hal component | ||
severity: error # error, warning, info, hint | ||
note: The standard assert function depends on newlib(G1) component, but hal is a G0 component | ||
language: C | ||
files: | ||
- "./components/hal/**/*" | ||
ignores: | ||
- "./components/hal/test_apps/**/*" | ||
rule: | ||
kind: expression_statement | ||
pattern: assert($$$ARGS); | ||
fix: HAL_ASSERT($$$ARGS); | ||
|
||
--- | ||
|
||
id: no-std-assert-include-in-hal-component | ||
message: Don't include assert.h in the hal component | ||
severity: error # error, warning, info, hint | ||
note: Please use hal/assert.h to replace assert.h | ||
language: C | ||
files: | ||
- "./components/hal/**/*" | ||
ignores: | ||
- "./components/hal/test_apps/**/*" | ||
rule: | ||
kind: preproc_include | ||
has: | ||
field: path | ||
pattern: $N | ||
constraints: | ||
N: | ||
regex: '^["<]assert' # match "assert.h" or <assert.h> | ||
fix: '' |