Skip to content

Commit

Permalink
linters: output filters should only consider child filter nodes
Browse files Browse the repository at this point in the history
otherwise these option filters (which we should document) produce false
positives https://github.com/galaxyproject/tools-iuc/blob/57fa4dcee2aaa115df4a5b7173a3a8fb889bc5a3/tools/bwa/bwa_macros.xml#L83
  • Loading branch information
bernt-matthias committed May 4, 2024
1 parent 9c43535 commit f57b68c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/galaxy/tool_util/linters/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"):
for output in tool_xml.findall("./outputs/data") + tool_xml.findall("./outputs/collection"):
name = output.attrib.get("name", "")
label = output.attrib.get("label", "${tool.name} on ${on_string}")
if label in labels and output.find(".//filter") is not None:
if label in labels and output.find("./filter") is not None:
lint_ctx.warn(
f"Tool output [{name}] uses duplicated label '{label}', double check if filters imply disjoint cases",
linter=cls.name(),
Expand All @@ -105,7 +105,7 @@ def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"):
for output in tool_xml.findall("./outputs/data[@name]") + tool_xml.findall("./outputs/collection[@name]"):
name = output.attrib.get("name", "")
label = output.attrib.get("label", "${tool.name} on ${on_string}")
if label in labels and output.find(".//filter") is None:
if label in labels and output.find("./filter") is None:
lint_ctx.warn(f"Tool output [{name}] uses duplicated label '{label}'", linter=cls.name(), node=output)
labels.add(label)

Expand Down
8 changes: 4 additions & 4 deletions lib/galaxy/tool_util/linters/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"):
for test_idx, test in enumerate(tests, start=1):
# check if expect_num_outputs is set if there are outputs with filters
# (except for tests with expect_failure .. which can't have test outputs)
filter = tool_xml.find("./outputs//filter")
has_no_filter = (
tool_xml.find("./outputs/data/filter") is None and tool_xml.find("./outputs/collection/filter") is None
)
if not (
filter is None
or "expect_num_outputs" in test.attrib
or asbool(test.attrib.get("expect_failure", False))
has_no_filter or "expect_num_outputs" in test.attrib or asbool(test.attrib.get("expect_failure", False))
):
lint_ctx.warn(
f"Test {test_idx}: should specify 'expect_num_outputs' if outputs have filters",
Expand Down

0 comments on commit f57b68c

Please sign in to comment.