Skip to content

Commit

Permalink
fix linter: duplicated label check
Browse files Browse the repository at this point in the history
duplicated labels may be OK if there are filters
  • Loading branch information
bernt-matthias committed Apr 13, 2023
1 parent b050d3d commit a81f095
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
9 changes: 8 additions & 1 deletion lib/galaxy/tool_util/linters/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ def lint_output(tool_xml, lint_ctx):

label = output.attrib.get("label", "${tool.name} on ${on_string}")
if label in labels:
lint_ctx.error(f"Tool output [{name}] uses duplicated label '{label}'", node=output)
filter_node = output.find(".//filter")
if filter_node is not None:
lint_ctx.info(
f"Tool output [{name}] uses duplicated label '{label}', double check if filters imply disjoint cases",
node=output
)
else:
lint_ctx.error(f"Tool output [{name}] uses duplicated label '{label}'", node=output)
labels.add(label)

format_set = False
Expand Down
14 changes: 12 additions & 2 deletions test/unit/tool_util/test_tool_linters.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,12 @@
<outputs>
<data name="valid_name" format="fasta"/>
<data name="valid_name" format="fasta"/>
<data name="another_valid_name" format="fasta" label="same label may be OK if there is a filter">
<filter>a condition</filter>
</data>
<data name="yet_another_valid_name" format="fasta" label="same label may be OK if there is a filter">
<filter>another condition</filter>
</data>
</outputs>
</tool>
"""
Expand Down Expand Up @@ -1410,8 +1416,12 @@ def test_outputs_discover_tool_provided_metadata(lint_ctx):
def test_outputs_duplicated_name_label(lint_ctx):
tool_source = get_xml_tool_source(OUTPUTS_DUPLICATED_NAME_LABEL)
run_lint(lint_ctx, outputs.lint_output, tool_source)
assert "2 outputs found." in lint_ctx.info_messages
assert len(lint_ctx.info_messages) == 1
assert "4 outputs found." in lint_ctx.info_messages
assert (
"Tool output [yet_another_valid_name] uses duplicated label 'same label may be OK if there is a filter', double check if filters imply disjoint cases"
in lint_ctx.info_messages
)
assert len(lint_ctx.info_messages) == 2
assert not lint_ctx.valid_messages
assert not lint_ctx.warn_messages
assert "Tool output [valid_name] has duplicated name" in lint_ctx.error_messages
Expand Down

0 comments on commit a81f095

Please sign in to comment.