Skip to content

Commit

Permalink
Merge pull request #18096 from bernt-matthias/topic/output-filter-fp
Browse files Browse the repository at this point in the history
[24.0] tool linters: output filters should only consider child filter nodes
  • Loading branch information
mvdbeek authored May 6, 2024
2 parents 9c43535 + f57b68c commit 03d1f66
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 03d1f66

Please sign in to comment.