Skip to content

Commit

Permalink
Make some rawstring in codecheck rules (CB #4828 / GH #6466)
Browse files Browse the repository at this point in the history
  • Loading branch information
The Widelands Bunny Bot committed Jun 10, 2024
1 parent f85a62c commit 9768a6b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions cmake/codecheck/rules/format_TODO_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,38 @@ def evaluate_matches(lines, fn):
errors.append(
(fn, lineno+1, "Use \"TODO(username): <msg>\". Do not use\"FIXME\"."))

elif re.compile('/\s*BUG').search(line):
elif re.compile(r'/\s*BUG').search(line):
errorfound = True
errors.append(
(fn, lineno+1, "Use \"TODO(username): <msg>\". Do not use\"BUG\"."))

elif re.compile('[*]\s*BUG').search(line):
elif re.compile(r'[*]\s*BUG').search(line):
errorfound = True
errors.append(
(fn, lineno+1, "Use \"TODO(username): <msg>\". Do not use\"BUG\" or put TODOs in Doxygen comments."))

# No dogygen
elif line.count('\TODO'):
elif line.count(r'\TODO'):
errorfound = True
errors.append(
(fn, lineno+1, "Use \"TODO(username): <msg>\". Do not put TODOs in Doxygen comments."))

elif line.count('\todo'):
elif line.count(r'\todo'):
errorfound = True
errors.append(
(fn, lineno+1, "Use \"TODO(username): <msg>\". Do not put TODOs in Doxygen comments."))

elif re.compile('[*]\s*TODO').search(line):
elif re.compile(r'[*]\s*TODO').search(line):
errorfound = True
errors.append(
(fn, lineno+1, "Use \"TODO(username): <msg>\". Do not put TODOs in Doxygen comments."))

elif re.compile('///\s*TODO').search(line):
elif re.compile(r'///\s*TODO').search(line):
errorfound = True
errors.append(
(fn, lineno+1, "Use \"TODO(username): <msg>\". Do not put TODOs in Doxygen comments."))

elif re.compile('//!\s*TODO').search(line):
elif re.compile(r'//!\s*TODO').search(line):
errorfound = True
errors.append(
(fn, lineno+1, "Use \"TODO(username): <msg>\". Do not put TODOs in Doxygen comments."))
Expand Down Expand Up @@ -85,8 +85,8 @@ def evaluate_matches(lines, fn):
'* TODO: This is a todo comment',
'/// TODO: This is a todo comment',
'//! TODO: This is a todo comment',
'\TODO: This is a todo comment',
'\\\todo: This is a todo comment'
r'\TODO: This is a todo comment',
r'\\\todo: This is a todo comment'
]

allowed = [
Expand Down
2 changes: 1 addition & 1 deletion cmake/codecheck/rules/function_returning_constant_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

error_msg = "Do not return values as 'const'. This does not make sense."

regexp = """^\s*virtual +(?:const +(?:[_a-zA-Z][_a-zA-Z0-9]*::)*[_a-zA-Z][_a-zA-Z0-9]*|(?:[_a-zA-Z][_a-zA-Z0-9]*::)*[_a-zA-Z][_a-zA-Z0-9]* +const) *[_a-zA-Z][_a-zA-Z0-9]* *\("""
regexp = r"""^\s*virtual +(?:const +(?:[_a-zA-Z][_a-zA-Z0-9]*::)*[_a-zA-Z][_a-zA-Z0-9]*|(?:[_a-zA-Z][_a-zA-Z0-9]*::)*[_a-zA-Z][_a-zA-Z0-9]* +const) *[_a-zA-Z][_a-zA-Z0-9]* *\("""

forbidden = [
'virtual const My::integer f();',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def evaluate_matches(lines, fn):
last_translators_comment = ''
last_translators_comment_line = 0

translator_tag = re.compile('.*[*/]\s+[TRANSLATOR]{10}.*')
translator_tag = re.compile(r'.*[*/]\s+[TRANSLATOR]{10}.*')

for lineno, line in enumerate(lines, 1):
# Find start of translators' comment
Expand Down
2 changes: 1 addition & 1 deletion cmake/codecheck/rules/void_parameter_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""This catches some functions that are declared to have no parameters with the
syntax "some_function(void)"."""

regexp = """\( *(const)* *void *\)"""
regexp = r"""\( *(const)* *void *\)"""
error_msg = 'void f(void) is invalid. Use void f() instead!'

forbidden = [
Expand Down

0 comments on commit 9768a6b

Please sign in to comment.