Skip to content

Commit

Permalink
Add meta-warnings for missing include files
Browse files Browse the repository at this point in the history
Provide suggested solutions for fixing each type of warning.

In future, we may want to add an option to silence these warnings
altogether if the user knows that they are safe to ignore.

Signed-off-by: John Pennycook <[email protected]>
  • Loading branch information
Pennycook committed Oct 10, 2024
1 parent c50c65f commit 78d472a
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions codebasin/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __init__(self, regex: str, msg: str):
self._count = 0

def inspect(self, record):
if self.regex.match(record.msg):
if self.regex.search(record.msg):
self._count += 1

def warn(self):
Expand All @@ -115,7 +115,25 @@ class WarningAggregator(logging.Filter):

def __init__(self):
self.meta_warnings = [
MetaWarning(".*", "{} warnings generated during preprocessing."),
MetaWarning(".", "{} warnings generated during preprocessing."),
MetaWarning(
"user include",
"{} user include files could not be found.\n"
+ " These could contain important macros and includes.\n"
+ " Suggested solutions:\n"
+ " - Check that the file(s) exist in the code base.\n"
+ " - Check the include paths in the compilation database.\n"
+ " - Check if the include(s) should have used '<>'.",
),
MetaWarning(
"system include",
"{} system include files could not be found.\n"
+ " These could define important feature macros.\n"
+ " Suggested solutions:\n"
+ " - Check that the file(s) exist on your system.\n"
+ " - Use .cbi/config to define system include paths.\n"
+ " - Use .cbi/config to define important macros.",
),
]

def filter(self, record):
Expand Down

0 comments on commit 78d472a

Please sign in to comment.