mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 01:29:21 -04:00
Merge branch 'fix/kconcheck_checks_v5.0' into 'release/v5.0'
fix(kconfcheck): Fixed false-positive indent errors and extended limits (backport v5.0) See merge request espressif/esp-idf!28469
This commit is contained in:
commit
02c6d5033f
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
#
|
#
|
||||||
# SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
|
# SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
@ -32,7 +32,7 @@ IGNORE_DIRS = (
|
|||||||
|
|
||||||
SPACES_PER_INDENT = 4
|
SPACES_PER_INDENT = 4
|
||||||
|
|
||||||
CONFIG_NAME_MAX_LENGTH = 40
|
CONFIG_NAME_MAX_LENGTH = 50
|
||||||
|
|
||||||
CONFIG_NAME_MIN_PREFIX_LENGTH = 3
|
CONFIG_NAME_MIN_PREFIX_LENGTH = 3
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ class LineRuleChecker(BaseChecker):
|
|||||||
if suppress_errors:
|
if suppress_errors:
|
||||||
# just print but no failure
|
# just print but no failure
|
||||||
e = InputError(self.path_in_idf, line_number, rule[1], line)
|
e = InputError(self.path_in_idf, line_number, rule[1], line)
|
||||||
print(e)
|
print(f'NOERROR: {e}')
|
||||||
else:
|
else:
|
||||||
errors.append(rule[1])
|
errors.append(rule[1])
|
||||||
if rule[2]:
|
if rule[2]:
|
||||||
@ -298,6 +298,9 @@ class IndentAndNameChecker(BaseChecker):
|
|||||||
if len(stripped_line) == 0:
|
if len(stripped_line) == 0:
|
||||||
self.force_next_indent = 0
|
self.force_next_indent = 0
|
||||||
return
|
return
|
||||||
|
# Ignore comment lines
|
||||||
|
if stripped_line.startswith('#'):
|
||||||
|
return
|
||||||
current_level = len(self.level_stack)
|
current_level = len(self.level_stack)
|
||||||
m = re.search(r'\S', line) # indent found as the first non-space character
|
m = re.search(r'\S', line) # indent found as the first non-space character
|
||||||
if m:
|
if m:
|
||||||
@ -327,8 +330,6 @@ class IndentAndNameChecker(BaseChecker):
|
|||||||
'Line-wrap with backslash is not supported here',
|
'Line-wrap with backslash is not supported here',
|
||||||
line) # no suggestion for this
|
line) # no suggestion for this
|
||||||
|
|
||||||
self.check_name_and_update_prefix(stripped_line, line_number)
|
|
||||||
|
|
||||||
m = self.re_increase_level.search(line)
|
m = self.re_increase_level.search(line)
|
||||||
if m:
|
if m:
|
||||||
current_level = self.update_level_for_inc_pattern(m.group(1))
|
current_level = self.update_level_for_inc_pattern(m.group(1))
|
||||||
@ -342,6 +343,10 @@ class IndentAndNameChecker(BaseChecker):
|
|||||||
# same prefix level
|
# same prefix level
|
||||||
self.check_common_prefix(line, line_number)
|
self.check_common_prefix(line, line_number)
|
||||||
|
|
||||||
|
# name has to be checked after increase/decrease indentation level
|
||||||
|
# otherwise false-positive indentation error for lines bellow name is raised
|
||||||
|
self.check_name_and_update_prefix(stripped_line, line_number)
|
||||||
|
|
||||||
expected_indent = current_level * SPACES_PER_INDENT
|
expected_indent = current_level * SPACES_PER_INDENT
|
||||||
|
|
||||||
if stripped_line.endswith('\\'):
|
if stripped_line.endswith('\\'):
|
||||||
@ -373,7 +378,12 @@ def validate_kconfig_file(kconfig_full_path, verbose=False): # type: (str, bool
|
|||||||
try:
|
try:
|
||||||
for line_number, line in enumerate(f, start=1):
|
for line_number, line in enumerate(f, start=1):
|
||||||
try:
|
try:
|
||||||
for checker in [line_checker, indent_and_name_checker, source_checker]:
|
for checker in [
|
||||||
|
indent_and_name_checker, # indent checker has to be before line checker, otherwise
|
||||||
|
# false-positive indent error if error in line_checker
|
||||||
|
line_checker,
|
||||||
|
source_checker
|
||||||
|
]:
|
||||||
checker.process_line(line, line_number)
|
checker.process_line(line, line_number)
|
||||||
# The line is correct therefore we echo it to the output file
|
# The line is correct therefore we echo it to the output file
|
||||||
f_o.write(line)
|
f_o.write(line)
|
||||||
|
@ -169,7 +169,6 @@ class TestIndent(TestIndentAndNameChecker):
|
|||||||
self.expt_success(' # comment')
|
self.expt_success(' # comment')
|
||||||
self.expt_success(' help')
|
self.expt_success(' help')
|
||||||
self.expt_success(' text')
|
self.expt_success(' text')
|
||||||
self.expect_error('# comment', expect=' # comment')
|
|
||||||
self.expt_success(' # second not realcomment"')
|
self.expt_success(' # second not realcomment"')
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user