summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2024-09-26 15:01:40 -0400
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-09-28 01:39:36 +0000
commit10783187ddb71808a4ea361e887800d3b899b85f (patch)
tree59aceb3bc719b273faeb3d8ed112a43670cf4902
parent48b5815d7771b92f343bfa2b32b70be36c98e6f3 (diff)
downloadedk2-10783187ddb71808a4ea361e887800d3b899b85f.tar.gz
.pytool/UncrustifyCheck: Show errors in output
Shows code formatting errors directly in build output. Previously only the filenames were in build output and the user had to look at the test result file either locally or in CI to find details. It is still recommended that users configure their local environment to run Uncrustify so it can automatically fix problems as opposed to manually correcting code based on the output shown in the terminal. In any case, it is easier to see what is expected now. Uncrustify reference material: https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Code-Formatting https://github.com/tianocore/edk2/tree/master/.pytool/Plugin/UncrustifyCheck#readme Some logging levels are also updated to refocus log output by current message importance and relevance. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
-rw-r--r--.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py
index 2bdc3e2925..0f593982d7 100644
--- a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py
+++ b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py
@@ -373,9 +373,9 @@ class UncrustifyCheck(ICiBuildPlugin):
file_template_path = pathlib.Path(os.path.join(self._plugin_path, file_template_name))
self._file_template_contents = file_template_path.read_text()
except KeyError:
- logging.warning("A file header template is not specified in the config file.")
+ logging.info("A file header template is not specified in the config file.")
except FileNotFoundError:
- logging.warning("The specified file header template file was not found.")
+ logging.info("The specified file header template file was not found.")
try:
func_template_name = parser["dummy_section"]["cmt_insert_func_header"]
@@ -385,9 +385,9 @@ class UncrustifyCheck(ICiBuildPlugin):
func_template_path = pathlib.Path(os.path.join(self._plugin_path, func_template_name))
self._func_template_contents = func_template_path.read_text()
except KeyError:
- logging.warning("A function header template is not specified in the config file.")
+ logging.info("A function header template is not specified in the config file.")
except FileNotFoundError:
- logging.warning("The specified function header template file was not found.")
+ logging.info("The specified function header template file was not found.")
def _initialize_app_info(self) -> None:
"""
@@ -563,13 +563,12 @@ class UncrustifyCheck(ICiBuildPlugin):
self._formatted_file_error_count = len(formatted_files)
if self._formatted_file_error_count > 0:
- logging.warning(f'Uncrustify found {self._formatted_file_error_count} files with formatting errors')
+ logging.error(f'Uncrustify found {self._formatted_file_error_count} files with formatting errors\n')
self._tc.LogStdError(f"Uncrustify found {self._formatted_file_error_count} files with formatting errors:\n")
- logging.critical(
+ logging.warning(
"Visit the following instructions to learn "
- "how to find the detailed formatting errors in Azure "
- "DevOps CI: "
- "https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Code-Formatting#how-to-find-uncrustify-formatting-errors-in-continuous-integration-ci")
+ "more about uncrustify setup instructions and CI:"
+ "https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Code-Formatting\n")
if self._output_file_diffs:
logging.info("Calculating file diffs. This might take a while...")
@@ -577,8 +576,8 @@ class UncrustifyCheck(ICiBuildPlugin):
for formatted_file in formatted_files:
pre_formatted_file = formatted_file[:-len(UncrustifyCheck.FORMATTED_FILE_EXTENSION)]
+ logging.error(f"Formatting errors in {os.path.relpath(pre_formatted_file, self._abs_package_path)}")
self._tc.LogStdError(f"Formatting errors in {os.path.relpath(pre_formatted_file, self._abs_package_path)}\n")
- logging.info(f"Formatting errors in {os.path.relpath(pre_formatted_file, self._abs_package_path)}")
if (self._output_file_diffs or
self._file_template_contents is not None or
@@ -589,10 +588,12 @@ class UncrustifyCheck(ICiBuildPlugin):
if (self._file_template_contents is not None and
self._file_template_contents in formatted_file_text):
+ logging.info(f"File header is missing in {os.path.relpath(pre_formatted_file, self._abs_package_path)}")
self._tc.LogStdError(f"File header is missing in {os.path.relpath(pre_formatted_file, self._abs_package_path)}\n")
if (self._func_template_contents is not None and
self._func_template_contents in formatted_file_text):
+ logging.info(f"A function header is missing in {os.path.relpath(pre_formatted_file, self._abs_package_path)}")
self._tc.LogStdError(f"A function header is missing in {os.path.relpath(pre_formatted_file, self._abs_package_path)}\n")
if self._output_file_diffs:
@@ -600,8 +601,10 @@ class UncrustifyCheck(ICiBuildPlugin):
pre_formatted_file_text = pf.read()
for line in difflib.unified_diff(pre_formatted_file_text.split('\n'), formatted_file_text.split('\n'), fromfile=pre_formatted_file, tofile=formatted_file, n=3):
+ logging.error(line)
self._tc.LogStdError(line)
+ logging.error('\n')
self._tc.LogStdError('\n')
def _remove_tree(self, dir_path: str, ignore_errors: bool = False) -> None: