Skip to content

Commit

Permalink
Rename "supressed" to "ignored"
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
roehling committed Sep 2, 2019
1 parent 28cbc56 commit 530a3d1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 30 deletions.
2 changes: 1 addition & 1 deletion bash/catkin_lint
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
30 changes: 15 additions & 15 deletions src/catkin_lint/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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,
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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
22 changes: 11 additions & 11 deletions src/catkin_lint/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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


Expand Down
5 changes: 2 additions & 3 deletions test/test_all_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 530a3d1

Please sign in to comment.