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(ci): add ast-grep rules to lint kconfig in the hal
- Loading branch information
1 parent
1c13798
commit 09ca9df
Showing
4 changed files
with
121 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
ruleDirs: | ||
- ./tools/ci/sg_rules | ||
- 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# Refer to https://ast-grep.github.io/guide/rule-config.html for Rule Essentials | ||
id: no-kconfig-in-hal-component | ||
message: Don't use Kconfig macros in the hal component | ||
severity: error # error, warning, info, hint | ||
note: hal component should be able to deliver without 3rd party config system | ||
language: C | ||
files: | ||
- "components/hal/**/*" | ||
ignores: | ||
# porting layer and test apps are allowed to use Kconfig macros | ||
- "components/hal/platform_port/**/*" | ||
- "components/hal/test_apps/**/*" | ||
# the following files should be refactored to remove Kconfig macros | ||
- "components/hal/adc_hal.c" | ||
- "components/hal/adc_oneshot_hal.c" | ||
- "components/hal/apm_hal.c" | ||
- "components/hal/ecdsa_hal.c" | ||
- "components/hal/emac_hal.c" | ||
- "components/hal/mmu_hal.c" | ||
- "components/hal/sha_hal.c" | ||
- "components/hal/spi_flash_encrypt_hal_iram.c" | ||
- "components/hal/spi_flash_hal_iram.c" | ||
- "components/hal/spi_flash_hal.c" | ||
- "components/hal/spi_hal_iram.c" | ||
- "components/hal/spi_hal.c" | ||
- "components/hal/spi_slave_hal_iram.c" | ||
- "components/hal/twai_hal_iram.c" | ||
- "components/hal/twai_hal.c" | ||
- "components/hal/usb_dwc_hal.c" | ||
- "components/hal/wdt_hal_iram.c" | ||
- "components/hal/esp32/efuse_hal.c" | ||
- "components/hal/esp32/gpio_hal_workaround.c" | ||
- "components/hal/esp32/include/hal/twai_ll.h" | ||
- "components/hal/esp32/include/hal/uart_ll.h" | ||
- "components/hal/esp32c2/clk_tree_hal.c" | ||
- "components/hal/*/efuse_hal.c" | ||
- "components/hal/include/hal/adc_types.h" | ||
- "components/hal/include/hal/adc_hal.h" | ||
- "components/hal/include/hal/apm_hal.h" | ||
- "components/hal/include/hal/ecdsa_hal.h" | ||
- "components/hal/include/hal/emac_hal.h" | ||
- "components/hal/include/hal/gpio_hal.h" | ||
- "components/hal/include/hal/mmu_hal.h" | ||
- "components/hal/include/hal/pmu_types.h" | ||
- "components/hal/include/hal/sha_types.h" | ||
- "components/hal/include/hal/spi_slave_hal.h" | ||
- "components/hal/include/hal/spi_types.h" | ||
- "components/hal/include/hal/touch_sensor_legacy_types.h" | ||
- "components/hal/include/hal/twai_types.h" | ||
rule: | ||
any: | ||
- kind: argument_list | ||
has: | ||
kind: identifier | ||
pattern: $N | ||
- kind: preproc_if | ||
has: | ||
field: condition | ||
pattern: $M | ||
constraints: | ||
N: | ||
regex: "^CONFIG" | ||
M: | ||
regex: "^CONFIG" | ||
|
||
--- | ||
|
||
id: no-sdkconfig-include-in-hal-component | ||
message: Don't include sdkconfig.h in the hal component | ||
severity: error # error, warning, info, hint | ||
note: hal component should be able to deliver without 3rd party config system | ||
language: C | ||
files: | ||
- "components/hal/**/*" | ||
ignores: | ||
# porting layer and test apps are allowed to include sdkconfig.h | ||
- "components/hal/platform_port/**/*" | ||
- "components/hal/test_apps/**/*" | ||
# the following files should be refactored to remove sdkconfig.h | ||
- "components/hal/adc_hal.c" | ||
- "components/hal/adc_oneshot_hal.c" | ||
- "components/hal/cache_hal.c" | ||
- "components/hal/emac_hal.c" | ||
- "components/hal/mmu_hal.c" | ||
- "components/hal/mpi_hal.c" | ||
- "components/hal/spi_flash_hal_iram.c" | ||
- "components/hal/twai_hal_iram.c" | ||
- "components/hal/twai_hal.c" | ||
- "components/hal/usb_dwc_hal.c" | ||
- "components/hal/efuse_hal.c" | ||
- "components/hal/esp32/include/hal/twai_ll.h" | ||
- "components/hal/esp32c2/clk_tree_hal.c" | ||
- "components/hal/*/efuse_hal.c" | ||
- "components/hal/include/hal/adc_types.h" | ||
- "components/hal/include/hal/ecdsa_hal.h" | ||
- "components/hal/include/hal/modem_clock_hal.h" | ||
- "components/hal/include/hal/mpi_hal.h" | ||
- "components/hal/include/hal/pmu_types.h" | ||
- "components/hal/include/hal/rtc_hal.h" | ||
- "components/hal/include/hal/sha_types.h" | ||
- "components/hal/include/hal/spi_slave_hal.h" | ||
- "components/hal/include/hal/spi_types.h" | ||
- "components/hal/include/hal/touch_sensor_legacy_types.h" | ||
- "components/hal/include/hal/twai_hal.h" | ||
- "components/hal/include/hal/twai_types.h" | ||
rule: | ||
kind: preproc_include | ||
has: | ||
field: path | ||
pattern: $N | ||
constraints: | ||
N: | ||
regex: '^["<]sdkconfig' # match "sdkconfig.h" or <sdkconfig.h> | ||
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
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