From 530a3d1b8f08c1571ec0443747c4f8a1a781f6b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20R=C3=B6hling?= Date: Mon, 2 Sep 2019 13:55:32 +0200 Subject: [PATCH] Rename "supressed" to "ignored" Also, reword the message about higher warning levels to avoid confusion between explicitly ignored messages and messages which will not be shown at the current warning level. --- bash/catkin_lint | 2 +- src/catkin_lint/linter.py | 30 +++++++++++++++--------------- src/catkin_lint/main.py | 22 +++++++++++----------- test/test_all_checks.py | 5 ++--- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/bash/catkin_lint b/bash/catkin_lint index eb7ccee..6ba57b7 100644 --- a/bash/catkin_lint +++ b/bash/catkin_lint @@ -22,7 +22,7 @@ _catkin_lint_complete() return 0 fi compopt -o filenames 2>/dev/null - COMPREPLY=( $( compgen -W "-h -q --help --version -W0 -W1 -W2 --strict --text --explain --xml --quiet --offline --clear-cache --pkg --skip-pkg --ignore --package-path --rosdistro --resolve-env --error --warning --notice --show-suppressed" -- "$arg" ) ) + COMPREPLY=( $( compgen -W "-h -q --help --version -W0 -W1 -W2 --strict --text --explain --xml --quiet --offline --clear-cache --pkg --skip-pkg --ignore --package-path --rosdistro --resolve-env --error --warning --notice --show-ignored" -- "$arg" ) ) COMPREPLY+=( $( compgen -d -- "$arg" ) ) return 0 } diff --git a/src/catkin_lint/linter.py b/src/catkin_lint/linter.py index 11b4222..4680090 100644 --- a/src/catkin_lint/linter.py +++ b/src/catkin_lint/linter.py @@ -88,9 +88,9 @@ def __init__(self, env): self.manifest = None self.file = "" self.line = 0 - self.ignore_messages = set() - self.ignore_messages_once = set() - self.suppressed_messages = [] + self.ignore_message_ids = set() + self.ignore_message_ids_once = set() + self.ignored_messages = [] self.command_loc = {} self.commands = set() self.find_packages = set() @@ -111,8 +111,8 @@ def report(self, level, msg_id, **kwargs): file_name, line = loc del kwargs["file_location"] msg_id, text, description = msg(msg_id, **kwargs) - if msg_id in self.ignore_messages or msg_id in self.ignore_messages_once: - self.suppressed_messages.append(Message( + if msg_id in self.ignore_message_ids or msg_id in self.ignore_message_ids_once: + self.ignored_messages.append(Message( package=self.manifest.name, file_name=file_name, line=line, @@ -239,8 +239,8 @@ class CMakeLinter(object): def __init__(self, env): self.env = env self.messages = [] - self.ignore_messages = set() - self.suppressed_messages = [] + self.ignore_message_ids = set() + self.ignored_messages = [] self._cmd_hooks = {} self._running_hooks = set([]) self._init_hooks = [] @@ -425,11 +425,11 @@ def _handle_list(self, info, args): def _handle_pragma(self, info, args): pragma = args.pop(0) if pragma == "ignore": - info.ignore_messages |= set([a.upper() for a in args]) + info.ignore_message_ids |= set([a.upper() for a in args]) if pragma == "report": - info.ignore_messages -= set([a.upper() for a in args]) + info.ignore_message_ids -= set([a.upper() for a in args]) if pragma == "ignore_once": - info.ignore_messages_once |= set([a.upper() for a in args]) + info.ignore_message_ids_once |= set([a.upper() for a in args]) if pragma == "skip": self._ctx.skip_block() @@ -470,7 +470,7 @@ def execute_hook(self, info, other_cmd, args): version = opts["VERSION"] or "" version_parts = version.split(".") while len(version_parts) < 4: - version_parts.append("") + version_parts.append("0") info.var["PROJECT_NAME"] = args[0] info.var["PROJECT_VERSION"] = info.var["%s_VERSION" % args[0]] = version info.var["PROJECT_VERSION_MAJOR"] = info.var["%s_VERSION_MAJOR" % args[0]] = version_parts[0] @@ -600,17 +600,17 @@ def _parse_file(self, info, filename): self.execute_hook(info, cmd, args) info.commands.add(cmd) info.command_loc[cmd] = info.current_location() - info.ignore_messages_once.clear() + info.ignore_message_ids_once.clear() finally: info.file = save_file info.line = save_line - info.ignore_messages_once.clear() + info.ignore_message_ids_once.clear() self._ctx = save_ctx def lint(self, path, manifest, info=None): if info is None: info = LintInfo(self.env) - info.ignore_messages = copy(self.ignore_messages) + info.ignore_message_ids = copy(self.ignore_message_ids) info.path = os.path.abspath(path) info.manifest = manifest info.conditionals = [] @@ -649,4 +649,4 @@ def lint(self, path, manifest, info=None): except IOError as err: info.report(ERROR, "OS_ERROR", msg=str(err)) self.messages += info.messages - self.suppressed_messages += info.suppressed_messages + self.ignored_messages += info.ignored_messages diff --git a/src/catkin_lint/main.py b/src/catkin_lint/main.py index 2af4d90..ab8c84b 100644 --- a/src/catkin_lint/main.py +++ b/src/catkin_lint/main.py @@ -61,7 +61,7 @@ def prepare_arguments(parser): parser.add_argument("--warning", action="append", metavar="ID", default=[], help="treat diagnostic message ID as warning") parser.add_argument("--notice", action="append", metavar="ID", default=[], help="treat diagnostic message ID as notice") parser.add_argument("--strict", action="store_true", help="treat everything reported as error") - parser.add_argument("--show-suppressed", action="store_true", help="show suppressed diagnostics") + parser.add_argument("--show-ignored", action="store_true", help="show messages even if they have been ignored explicitly") parser.add_argument("--pkg", action="append", default=[], help="specify catkin package by name (can be used multiple times)") parser.add_argument("--skip-pkg", metavar="PKG", action="append", default=[], help="skip testing a catkin package (can be used multiple times)") parser.add_argument("--package-path", metavar="PATH", help="additional package path (separate multiple locations with '%s')" % os.pathsep) @@ -148,7 +148,7 @@ def run_linter(args): output = TextOutput(use_color[args.color]) linter = CMakeLinter(env) for a in args.ignore: - linter.ignore_messages |= set(a.upper().split(",")) + linter.ignore_message_ids |= set(a.upper().split(",")) for check in args.check: try: add_linter_check(linter, check) @@ -166,14 +166,14 @@ def run_linter(args): sys.stderr.write("catkin_lint: cannot lint %s: %s\n" % (manifest.name, str(err))) if args.debug: raise - ignored = {ERROR: 0, WARNING: 0, NOTICE: 0} + extras = {ERROR: 0, WARNING: 0, NOTICE: 0} problems = 0 exit_code = 0 diagnostic_label = {ERROR: "error", WARNING: "warning", NOTICE: "notice"} output.prolog(fd=sys.stdout) - if args.show_suppressed: - linter.messages += linter.suppressed_messages - linter.suppressed_messages = [] + if args.show_ignored: + linter.messages += linter.ignored_messages + linter.ignored_messages = [] for msg in sorted(linter.messages): if msg.id in force_notice: msg.level = NOTICE @@ -182,7 +182,7 @@ def run_linter(args): if msg.id in force_error: msg.level = ERROR if args.W < msg.level: - ignored[msg.level] += 1 + extras[msg.level] += 1 continue if args.strict: msg.level = ERROR @@ -194,10 +194,10 @@ def run_linter(args): if not args.quiet: sys.stderr.write("catkin_lint: checked %d packages and found %d problems\n" % (len(pkgs_to_check), problems)) for level in [ERROR, WARNING, NOTICE]: - if ignored[level] > 0: - sys.stderr.write("catkin_lint: %d %ss have been ignored. Use -W%d to see them\n" % (ignored[level], diagnostic_label[level], level)) - if linter.suppressed_messages: - sys.stderr.write("catkin_lint: %d messages have been suppressed. Use --show-suppressed to see them\n" % len(linter.suppressed_messages)) + if extras[level] > 0: + sys.stderr.write("catkin_lint: option -W%d will show %d additional %ss\n" % (level, extras[level], diagnostic_label[level])) + if linter.ignored_messages: + sys.stderr.write("catkin_lint: %d messages have been ignored. Use --show-ignored to see them\n" % len(linter.ignored_messages)) return exit_code diff --git a/test/test_all_checks.py b/test/test_all_checks.py index c4fa973..8247c92 100644 --- a/test/test_all_checks.py +++ b/test/test_all_checks.py @@ -218,7 +218,6 @@ def runTest(self): self.assertEqual(exitcode, 0) self.assertIn("checked 1 packages and found 0 problems", stdout) - os.environ["ROS_PACKAGE_PATH"] = os.pathsep.join([self.ws_srcdir, self.upstream_ws_srcdir]) exitcode, stdout = self.run_catkin_lint("--pkg", "alpha", "--pkg", "beta") self.assertEqual(exitcode, 0) @@ -238,7 +237,7 @@ def runTest(self): exitcode, stdout = self.run_catkin_lint("--pkg", "delta", "-W0") self.assertEqual(exitcode, 0) - self.assertIn("warnings have been ignored", stdout) + self.assertIn("additional warning", stdout) exitcode, stdout = self.run_catkin_lint("--pkg", "delta", "-W2", "--notice", "suggest_catkin_depend") self.assertEqual(exitcode, 0) @@ -268,7 +267,7 @@ def runTest(self): exitcode, stdout = self.run_catkin_lint(os.path.join(self.ws_srcdir, "alpha"), "--ignore", "unknown_package") self.assertEqual(exitcode, 0) - self.assertIn("messages have been suppressed", stdout) + self.assertIn("messages have been ignored", stdout) del os.environ["ROS_DISTRO"] exitcode, stdout = self.run_catkin_lint("--pkg", "invalid_dep")