Skip to content

Commit

Permalink
Exclude standard messages (codespell)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Jan 14, 2024
1 parent 6bf0bd9 commit 35f37a3
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion logToCs.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,23 @@ def convert_text_to_checkstyle(text, root_path=None):
),
]

# Exceptionnaly some regexes match messages that are not error.
# This pattern matches those exceptions
EXCLUDE_MSG_PATTERN = re.compile(
r"^("
r"Placeholder pattern" # To remove on first message pattern
r")"
)

# Exceptionnaly some regexes match messages that are not error.
# This pattern matches those exceptions
EXCLUDE_FILE_PATTERN = re.compile(
r"^("
# Codespell: (appears as a file name):
r"Used config files\b"
r")"
)

# Severities available in CodeSniffer report format
SEVERITY_NOTICE = "notice"
SEVERITY_WARNING = "warning"
Expand All @@ -181,7 +198,7 @@ def parse_file(text):
Returns the fields in a dict.
"""
# pylint: disable=too-many-branches
# pylint: disable=too-many-branches,too-many-statements
# regex required to allow same group names
try:
import regex # pylint: disable=import-outside-toplevel
Expand Down Expand Up @@ -212,6 +229,7 @@ def parse_file(text):
confidence = result.pop("confidence", None)
new_file_group = result.pop("file_group", None)
file_endgroup = result.pop("file_endgroup", None)
message = result.get("message", None)

if new_file_group is not None:
# Start of file_group, just store file
Expand All @@ -229,6 +247,16 @@ def parse_file(text):
else:
# No filename, skip
continue
else:
if EXCLUDE_FILE_PATTERN.search(file_name):
# This file_name is excluded
continue

if message is not None:
print(message)
if EXCLUDE_MSG_PATTERN.search(message):
# This message is excluded
continue

if confidence is not None:
# Convert confidence level of cpplint
Expand Down

0 comments on commit 35f37a3

Please sign in to comment.