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(
|
distenv.PhonyTarget(
|
||||||
"lint",
|
"lint",
|
||||||
"${PYTHON3} ${FBT_SCRIPT_DIR}/lint.py check ${LINT_SOURCES}",
|
"${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(
|
distenv.PhonyTarget(
|
||||||
"format",
|
"format",
|
||||||
"${PYTHON3} ${FBT_SCRIPT_DIR}/lint.py format ${LINT_SOURCES}",
|
"${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
|
# PY_LINT_SOURCES contains recursively-built modules' SConscript files + application manifests
|
||||||
|
@ -22,7 +22,7 @@ env = ENV.Clone(
|
|||||||
FW_FLAVOR=fw_build_meta["flavor"],
|
FW_FLAVOR=fw_build_meta["flavor"],
|
||||||
LIB_DIST_DIR=fw_build_meta["build_dir"].Dir("lib"),
|
LIB_DIST_DIR=fw_build_meta["build_dir"].Dir("lib"),
|
||||||
LINT_SOURCES=[
|
LINT_SOURCES=[
|
||||||
"applications",
|
Dir("applications"),
|
||||||
],
|
],
|
||||||
LIBPATH=[
|
LIBPATH=[
|
||||||
"${LIB_DIST_DIR}",
|
"${LIB_DIST_DIR}",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
Import("env")
|
Import("env")
|
||||||
|
|
||||||
env.Append(
|
env.Append(
|
||||||
LINT_SOURCES=["firmware"],
|
LINT_SOURCES=[Dir(".")],
|
||||||
SDK_HEADERS=[
|
SDK_HEADERS=[
|
||||||
*env.GlobRecursive("*.h", "targets/furi_hal_include", "*_i.h"),
|
*env.GlobRecursive("*.h", "targets/furi_hal_include", "*_i.h"),
|
||||||
*env.GlobRecursive("*.h", "targets/f${TARGET_HW}/furi_hal", "*_i.h"),
|
*env.GlobRecursive("*.h", "targets/f${TARGET_HW}/furi_hal", "*_i.h"),
|
||||||
|
@ -2,8 +2,7 @@ Import("env")
|
|||||||
|
|
||||||
env.Append(
|
env.Append(
|
||||||
LINT_SOURCES=[
|
LINT_SOURCES=[
|
||||||
"furi",
|
Dir("."),
|
||||||
"furi/core",
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2,19 +2,19 @@ Import("env")
|
|||||||
|
|
||||||
env.Append(
|
env.Append(
|
||||||
LINT_SOURCES=[
|
LINT_SOURCES=[
|
||||||
"lib/app-scened-template",
|
Dir("app-scened-template"),
|
||||||
"lib/digital_signal",
|
Dir("digital_signal"),
|
||||||
"lib/drivers",
|
Dir("drivers"),
|
||||||
"lib/flipper_format",
|
Dir("flipper_format"),
|
||||||
"lib/infrared",
|
Dir("infrared"),
|
||||||
"lib/nfc",
|
Dir("nfc"),
|
||||||
"lib/one_wire",
|
Dir("one_wire"),
|
||||||
"lib/ST25RFAL002",
|
Dir("ST25RFAL002"),
|
||||||
"lib/subghz",
|
Dir("subghz"),
|
||||||
"lib/toolbox",
|
Dir("toolbox"),
|
||||||
"lib/u8g2",
|
Dir("u8g2"),
|
||||||
"lib/update_util",
|
Dir("update_util"),
|
||||||
"lib/print",
|
Dir("print"),
|
||||||
],
|
],
|
||||||
SDK_HEADERS=[
|
SDK_HEADERS=[
|
||||||
File("one_wire/one_wire_host_timing.h"),
|
File("one_wire/one_wire_host_timing.h"),
|
||||||
|
@ -2,7 +2,7 @@ Import("env")
|
|||||||
|
|
||||||
env.Append(
|
env.Append(
|
||||||
LINT_SOURCES=[
|
LINT_SOURCES=[
|
||||||
"lib/lfrfid",
|
Dir("."),
|
||||||
],
|
],
|
||||||
CPPPATH=[
|
CPPPATH=[
|
||||||
"#/lib/lfrfid",
|
"#/lib/lfrfid",
|
||||||
|
@ -5,7 +5,7 @@ env.Append(
|
|||||||
"#/lib/nfc",
|
"#/lib/nfc",
|
||||||
],
|
],
|
||||||
SDK_HEADERS=[
|
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)
|
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):
|
def _check_folders(self, folders: list):
|
||||||
show_message = False
|
show_message = False
|
||||||
pattern = re.compile(SOURCE_CODE_DIR_PATTERN)
|
pattern = re.compile(SOURCE_CODE_DIR_PATTERN)
|
||||||
for folder in folders:
|
for folder in folders:
|
||||||
for dirpath, dirnames, filenames in os.walk(folder):
|
for dirpath, dirnames, filenames in os.walk(folder):
|
||||||
|
self._filter_lint_directories(dirnames)
|
||||||
|
|
||||||
for dirname in dirnames:
|
for dirname in dirnames:
|
||||||
if not pattern.match(dirname):
|
if not pattern.match(dirname):
|
||||||
to_fix = os.path.join(dirpath, dirname)
|
to_fix = os.path.join(dirpath, dirname)
|
||||||
@ -54,9 +66,7 @@ class Main(App):
|
|||||||
output = []
|
output = []
|
||||||
for folder in folders:
|
for folder in folders:
|
||||||
for dirpath, dirnames, filenames in os.walk(folder):
|
for dirpath, dirnames, filenames in os.walk(folder):
|
||||||
# Skipping 3rd-party code - usually resides in subfolder "lib"
|
self._filter_lint_directories(dirnames)
|
||||||
if "lib" in dirnames:
|
|
||||||
dirnames.remove("lib")
|
|
||||||
|
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
ext = os.path.splitext(filename.lower())[1]
|
ext = os.path.splitext(filename.lower())[1]
|
||||||
|
Loading…
Reference in New Issue
Block a user