mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-11-25 14:02:28 +03:00
fbt: lint fixes (#2008)
* lint: exclude "lib" subfolder from naming checks; fbt: moved LINT_SOURCES from literal strings to Dir() nodes * lint: also exclude hidden directories Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
3c7a4eeaed
commit
f9730bcafe
@ -241,13 +241,13 @@ distenv.PhonyTarget(
|
||||
distenv.PhonyTarget(
|
||||
"lint",
|
||||
"${PYTHON3} ${FBT_SCRIPT_DIR}/lint.py check ${LINT_SOURCES}",
|
||||
LINT_SOURCES=firmware_env["LINT_SOURCES"],
|
||||
LINT_SOURCES=[n.srcnode() for n in firmware_env["LINT_SOURCES"]],
|
||||
)
|
||||
|
||||
distenv.PhonyTarget(
|
||||
"format",
|
||||
"${PYTHON3} ${FBT_SCRIPT_DIR}/lint.py format ${LINT_SOURCES}",
|
||||
LINT_SOURCES=firmware_env["LINT_SOURCES"],
|
||||
LINT_SOURCES=[n.srcnode() for n in firmware_env["LINT_SOURCES"]],
|
||||
)
|
||||
|
||||
# PY_LINT_SOURCES contains recursively-built modules' SConscript files + application manifests
|
||||
|
@ -22,7 +22,7 @@ env = ENV.Clone(
|
||||
FW_FLAVOR=fw_build_meta["flavor"],
|
||||
LIB_DIST_DIR=fw_build_meta["build_dir"].Dir("lib"),
|
||||
LINT_SOURCES=[
|
||||
"applications",
|
||||
Dir("applications"),
|
||||
],
|
||||
LIBPATH=[
|
||||
"${LIB_DIST_DIR}",
|
||||
|
@ -1,7 +1,7 @@
|
||||
Import("env")
|
||||
|
||||
env.Append(
|
||||
LINT_SOURCES=["firmware"],
|
||||
LINT_SOURCES=[Dir(".")],
|
||||
SDK_HEADERS=[
|
||||
*env.GlobRecursive("*.h", "targets/furi_hal_include", "*_i.h"),
|
||||
*env.GlobRecursive("*.h", "targets/f${TARGET_HW}/furi_hal", "*_i.h"),
|
||||
|
@ -2,8 +2,7 @@ Import("env")
|
||||
|
||||
env.Append(
|
||||
LINT_SOURCES=[
|
||||
"furi",
|
||||
"furi/core",
|
||||
Dir("."),
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -2,19 +2,19 @@ Import("env")
|
||||
|
||||
env.Append(
|
||||
LINT_SOURCES=[
|
||||
"lib/app-scened-template",
|
||||
"lib/digital_signal",
|
||||
"lib/drivers",
|
||||
"lib/flipper_format",
|
||||
"lib/infrared",
|
||||
"lib/nfc",
|
||||
"lib/one_wire",
|
||||
"lib/ST25RFAL002",
|
||||
"lib/subghz",
|
||||
"lib/toolbox",
|
||||
"lib/u8g2",
|
||||
"lib/update_util",
|
||||
"lib/print",
|
||||
Dir("app-scened-template"),
|
||||
Dir("digital_signal"),
|
||||
Dir("drivers"),
|
||||
Dir("flipper_format"),
|
||||
Dir("infrared"),
|
||||
Dir("nfc"),
|
||||
Dir("one_wire"),
|
||||
Dir("ST25RFAL002"),
|
||||
Dir("subghz"),
|
||||
Dir("toolbox"),
|
||||
Dir("u8g2"),
|
||||
Dir("update_util"),
|
||||
Dir("print"),
|
||||
],
|
||||
SDK_HEADERS=[
|
||||
File("one_wire/one_wire_host_timing.h"),
|
||||
|
@ -2,7 +2,7 @@ Import("env")
|
||||
|
||||
env.Append(
|
||||
LINT_SOURCES=[
|
||||
"lib/lfrfid",
|
||||
Dir("."),
|
||||
],
|
||||
CPPPATH=[
|
||||
"#/lib/lfrfid",
|
||||
|
@ -5,7 +5,7 @@ env.Append(
|
||||
"#/lib/nfc",
|
||||
],
|
||||
SDK_HEADERS=[
|
||||
File("#/lib/nfc/nfc_device.h"),
|
||||
File("nfc_device.h"),
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -35,11 +35,23 @@ class Main(App):
|
||||
)
|
||||
self.parser_format.set_defaults(func=self.format)
|
||||
|
||||
@staticmethod
|
||||
def _filter_lint_directories(dirnames: list[str]):
|
||||
# Skipping 3rd-party code - usually resides in subfolder "lib"
|
||||
if "lib" in dirnames:
|
||||
dirnames.remove("lib")
|
||||
# Skipping hidden folders
|
||||
for dirname in dirnames.copy():
|
||||
if dirname.startswith("."):
|
||||
dirnames.remove(dirname)
|
||||
|
||||
def _check_folders(self, folders: list):
|
||||
show_message = False
|
||||
pattern = re.compile(SOURCE_CODE_DIR_PATTERN)
|
||||
for folder in folders:
|
||||
for dirpath, dirnames, filenames in os.walk(folder):
|
||||
self._filter_lint_directories(dirnames)
|
||||
|
||||
for dirname in dirnames:
|
||||
if not pattern.match(dirname):
|
||||
to_fix = os.path.join(dirpath, dirname)
|
||||
@ -54,9 +66,7 @@ class Main(App):
|
||||
output = []
|
||||
for folder in folders:
|
||||
for dirpath, dirnames, filenames in os.walk(folder):
|
||||
# Skipping 3rd-party code - usually resides in subfolder "lib"
|
||||
if "lib" in dirnames:
|
||||
dirnames.remove("lib")
|
||||
self._filter_lint_directories(dirnames)
|
||||
|
||||
for filename in filenames:
|
||||
ext = os.path.splitext(filename.lower())[1]
|
||||
|
Loading…
Reference in New Issue
Block a user