From c201daa7a8c946809ad9852f37251f12038f406e Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Wed, 29 May 2024 15:29:00 +0200 Subject: [PATCH] remove linter for unstripped text content for tool xml leaves reverts #17656 we have to many xml nodes where this is allowed (e.g. command) and limiting the linter to a statically defined list of node types seemed difficult to maintain replaced this with a change in the xsd that should lead to the automatic removal of surplus white spaces (leading/trailing are removed, multiple whitespaces are replaced by a single space) for some of the node types that were the original motivation for the linter (if this proves useful this could be used for more node types). --- lib/galaxy/tool_util/linters/general.py | 17 ---------------- lib/galaxy/tool_util/xsd/galaxy.xsd | 17 ++++++++++++---- test/unit/tool_util/test_tool_linters.py | 25 +----------------------- 3 files changed, 14 insertions(+), 45 deletions(-) diff --git a/lib/galaxy/tool_util/linters/general.py b/lib/galaxy/tool_util/linters/general.py index 0e671d418126..eb3a98fd3b82 100644 --- a/lib/galaxy/tool_util/linters/general.py +++ b/lib/galaxy/tool_util/linters/general.py @@ -231,23 +231,6 @@ def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"): ) -class TextSpaces(Linter): - @classmethod - def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"): - _, tool_node = _tool_xml_and_root(tool_source) - if not tool_node: - return - for node in tool_node.iter(): - if len(node) > 0: - continue - if node.text and node.text != node.text.strip(): - lint_ctx.warn( - f"XML node '{node.tag}' has text with leading or trailing spaces ('{node.text}'!='{node.text.strip()}').", - linter=cls.name(), - node=node, - ) - - class BioToolsValid(Linter): @classmethod def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"): diff --git a/lib/galaxy/tool_util/xsd/galaxy.xsd b/lib/galaxy/tool_util/xsd/galaxy.xsd index 771e700f88c9..39d07f0cc8b2 100644 --- a/lib/galaxy/tool_util/xsd/galaxy.xsd +++ b/lib/galaxy/tool_util/xsd/galaxy.xsd @@ -7861,7 +7861,7 @@ A tool can have any number of EDAM topic references. - + @@ -7886,7 +7886,7 @@ A tool can have any number of EDAM operation references. - + @@ -7921,7 +7921,7 @@ A tool can refer multiple reference IDs. information according to a catalog. - + Type of reference - currently ``bio.tools``, ``bioconductor``, and ``biii`` are @@ -7944,11 +7944,20 @@ the only supported options. - + + + + A string without newline characters. + + + + + + diff --git a/test/unit/tool_util/test_tool_linters.py b/test/unit/tool_util/test_tool_linters.py index 2db30308b950..7e6d3b62ec93 100644 --- a/test/unit/tool_util/test_tool_linters.py +++ b/test/unit/tool_util/test_tool_linters.py @@ -120,16 +120,6 @@ """ -GENERAL_TEXT_SPACES = """ - - - - bwa - - - -""" - GENERAL_VALID_BIOTOOLS = """ @@ -1108,19 +1098,6 @@ def test_general_valid_new_profile_fmt(lint_ctx): assert not lint_ctx.error_messages -def test_general_text_spaces(lint_ctx): - tool_source = get_xml_tool_source(GENERAL_TEXT_SPACES) - run_lint_module(lint_ctx, general, tool_source) - assert ( - "XML node 'xref' has text with leading or trailing spaces ('\n bwa\n '!='bwa')" - in lint_ctx.warn_messages - ) - assert not lint_ctx.info_messages - assert len(lint_ctx.valid_messages) == 4 - assert len(lint_ctx.warn_messages) == 1 - assert not lint_ctx.error_messages - - @skip_if_site_down("https://bio.tools/") def test_general_valid_biotools(lint_ctx): tool_source = get_xml_tool_source(GENERAL_VALID_BIOTOOLS) @@ -2168,7 +2145,7 @@ def test_skip_by_module(lint_ctx): def test_list_linters(): linter_names = Linter.list_listers() # make sure to add/remove a test for new/removed linters if this number changes - assert len(linter_names) == 133 + assert len(linter_names) == 132 assert "Linter" not in linter_names # make sure that linters from all modules are available for prefix in [