From 481a18769de1274bc7f42eee0b3b196bfe40a3f9 Mon Sep 17 00:00:00 2001 From: Thomas Denewiler Date: Tue, 12 Jan 2021 12:55:04 -0800 Subject: [PATCH] Check for a valid plugin context before accessing plugin context variables related to showing tool output. (#325) --- statick_tool/plugins/tool/cccc_tool_plugin.py | 2 +- statick_tool/plugins/tool/clang_tidy_tool_plugin.py | 2 +- statick_tool/plugins/tool/cppcheck_tool_plugin.py | 2 +- statick_tool/plugins/tool/spotbugs_tool_plugin.py | 2 +- statick_tool/plugins/tool/uncrustify_tool_plugin.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/statick_tool/plugins/tool/cccc_tool_plugin.py b/statick_tool/plugins/tool/cccc_tool_plugin.py index f5ad034a..5ca7f970 100644 --- a/statick_tool/plugins/tool/cccc_tool_plugin.py +++ b/statick_tool/plugins/tool/cccc_tool_plugin.py @@ -77,7 +77,7 @@ def scan( # pylint: disable=too-many-branches print("Couldn't find cccc executable! ({})".format(ex)) return None - if self.plugin_context.args.show_tool_output: + if self.plugin_context and self.plugin_context.args.show_tool_output: print("{}".format(log_output)) # type: ignore if self.plugin_context and self.plugin_context.args.output_directory: diff --git a/statick_tool/plugins/tool/clang_tidy_tool_plugin.py b/statick_tool/plugins/tool/clang_tidy_tool_plugin.py index f4446a21..c478a5a1 100644 --- a/statick_tool/plugins/tool/clang_tidy_tool_plugin.py +++ b/statick_tool/plugins/tool/clang_tidy_tool_plugin.py @@ -89,7 +89,7 @@ def scan(self, package: Package, level: str) -> Optional[List[Issue]]: print("Couldn't find {}! ({})".format(clang_tidy_bin, ex)) return None - if self.plugin_context.args.show_tool_output: + if self.plugin_context and self.plugin_context.args.show_tool_output: print("{}".format(output)) if self.plugin_context and self.plugin_context.args.output_directory: diff --git a/statick_tool/plugins/tool/cppcheck_tool_plugin.py b/statick_tool/plugins/tool/cppcheck_tool_plugin.py index 969335e8..f9047a2b 100644 --- a/statick_tool/plugins/tool/cppcheck_tool_plugin.py +++ b/statick_tool/plugins/tool/cppcheck_tool_plugin.py @@ -117,7 +117,7 @@ def scan(self, package: Package, level: str) -> Optional[List[Issue]]: print("{}".format(ex.output)) return None - if self.plugin_context.args.show_tool_output: + if self.plugin_context and self.plugin_context.args.show_tool_output: print("{}".format(output)) if self.plugin_context and self.plugin_context.args.output_directory: diff --git a/statick_tool/plugins/tool/spotbugs_tool_plugin.py b/statick_tool/plugins/tool/spotbugs_tool_plugin.py index 7ddfddfe..8fa21e61 100644 --- a/statick_tool/plugins/tool/spotbugs_tool_plugin.py +++ b/statick_tool/plugins/tool/spotbugs_tool_plugin.py @@ -80,7 +80,7 @@ def scan(self, package: Package, level: str) -> Optional[List[Issue]]: print("Couldn't find maven! ({})".format(ex)) return None - if self.plugin_context.args.show_tool_output: + if self.plugin_context and self.plugin_context.args.show_tool_output: print("{}".format(output)) total_output += output diff --git a/statick_tool/plugins/tool/uncrustify_tool_plugin.py b/statick_tool/plugins/tool/uncrustify_tool_plugin.py index 14490d1f..17096461 100644 --- a/statick_tool/plugins/tool/uncrustify_tool_plugin.py +++ b/statick_tool/plugins/tool/uncrustify_tool_plugin.py @@ -96,7 +96,7 @@ def scan( # pylint: disable=too-many-locals, too-many-branches print("Couldn't find uncrustify executable! ({})".format(ex)) return None - if self.plugin_context.args.show_tool_output: + if self.plugin_context and self.plugin_context.args.show_tool_output: for output in total_output: print("{}".format(output))