From ec60b94e921ac672c152a94ffc275d4ee7f62a11 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Mon, 18 Oct 2021 12:40:52 +0200 Subject: [PATCH 1/6] linter: regex validator does not require expression --- lib/galaxy/tool_util/linters/inputs.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/galaxy/tool_util/linters/inputs.py b/lib/galaxy/tool_util/linters/inputs.py index 437efe5e76f..78de207632b 100644 --- a/lib/galaxy/tool_util/linters/inputs.py +++ b/lib/galaxy/tool_util/linters/inputs.py @@ -163,8 +163,6 @@ def lint_inputs(tool_xml, lint_ctx): lint_ctx.error(f"Parameter [{param_name}]: expression validator without content") if vtype != "expression" and validator.text is not None: lint_ctx.warn(f"Parameter [{param_name}]: '{vtype}' validators are not expected to contain text (found '{validator.text}')") - if vtype == "regex" and "expression" not in validator.attrib: - lint_ctx.error(f"Parameter [{param_name}]: '{vtype}' validators need to define an 'expression' attribute") if vtype in ["in_range", "length", "dataset_metadata_in_range"] and ("min" not in validator.attrib or "max" not in validator.attrib): lint_ctx.error(f"Parameter [{param_name}]: '{vtype}' validators need to define the 'min' or 'max' attribute(s)") if vtype in ["metadata"] and ("check" not in validator.attrib or "skip" not in validator.attrib): From f5ca471c8e8c6f3a843fdbff61e829691641138f Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Mon, 18 Oct 2021 13:23:34 +0200 Subject: [PATCH 2/6] more fixes to validator linters and test of most correct combinations --- lib/galaxy/tool_util/linters/inputs.py | 14 +++--- test/unit/tool_util/test_tool_linters.py | 57 +++++++++++++++++++++++- 2 files changed, 62 insertions(+), 9 deletions(-) diff --git a/lib/galaxy/tool_util/linters/inputs.py b/lib/galaxy/tool_util/linters/inputs.py index 78de207632b..af378c8d780 100644 --- a/lib/galaxy/tool_util/linters/inputs.py +++ b/lib/galaxy/tool_util/linters/inputs.py @@ -19,16 +19,16 @@ FILTER_TYPES = [ ATTRIB_VALIDATOR_COMPATIBILITY = { "check": ["metadata"], - "expression": ["regex", "substitute_value_in_message"], + "expression": ["substitute_value_in_message"], "table_name": ["dataset_metadata_in_data_table", "dataset_metadata_not_in_data_table", "value_in_data_table", "value_not_in_data_table"], "filename": ["dataset_metadata_in_file"], "metadata_name": ["dataset_metadata_in_data_table", "dataset_metadata_not_in_data_table", "dataset_metadata_in_file"], - "metadata_column": ["dataset_metadata_in_data_table", "dataset_metadata_not_in_data_table", "value_in_data_table", "value_not_in_data_table", "dataset_metadata_in_file options"], + "metadata_column": ["dataset_metadata_in_data_table", "dataset_metadata_not_in_data_table", "value_in_data_table", "value_not_in_data_table", "dataset_metadata_in_file"], "line_startswith": ["dataset_metadata_in_file"], - "min": ["in_range", "length"], - "max": ["in_range", "length"], - "exclude_min": ["in_range"], - "exclude_max": ["in_range"], + "min": ["in_range", "length", "dataset_metadata_in_range"], + "max": ["in_range", "length", "dataset_metadata_in_range"], + "exclude_min": ["in_range", "dataset_metadata_in_range"], + "exclude_max": ["in_range", "dataset_metadata_in_range"], "split": ["dataset_metadata_in_file"], "skip": ["metadata"] } @@ -161,7 +161,7 @@ def lint_inputs(tool_xml, lint_ctx): lint_ctx.error(f"Parameter [{param_name}]: attribute '{attrib}' is incompatible with validator of type '{vtype}'") if vtype == "expression" and validator.text is None: lint_ctx.error(f"Parameter [{param_name}]: expression validator without content") - if vtype != "expression" and validator.text is not None: + if vtype not in ["expression", "regex"] and validator.text is not None: lint_ctx.warn(f"Parameter [{param_name}]: '{vtype}' validators are not expected to contain text (found '{validator.text}')") if vtype in ["in_range", "length", "dataset_metadata_in_range"] and ("min" not in validator.attrib or "max" not in validator.attrib): lint_ctx.error(f"Parameter [{param_name}]: '{vtype}' validators need to define the 'min' or 'max' attribute(s)") diff --git a/test/unit/tool_util/test_tool_linters.py b/test/unit/tool_util/test_tool_linters.py index 0dab32dba2e..c91547aa84d 100644 --- a/test/unit/tool_util/test_tool_linters.py +++ b/test/unit/tool_util/test_tool_linters.py @@ -41,6 +41,7 @@ RADIO_SELECT_INCOMPATIBILITIES = """