mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 19:24:33 +02:00
Merge branch 'fix/kconcheck_checks_v4.4' into 'release/v4.4'
fix(kconfcheck): Fixed false-positive indent errors and extended limits (backport v4.4) See merge request espressif/esp-idf!28475
This commit is contained in:
@@ -43,7 +43,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
|
||||||
|
|
||||||
@@ -117,7 +117,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]:
|
||||||
@@ -309,6 +309,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:
|
||||||
@@ -338,8 +341,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))
|
||||||
@@ -353,6 +354,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('\\'):
|
||||||
@@ -384,7 +389,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)
|
||||||
|
@@ -183,7 +183,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"')
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user