diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f46a265cc..6dd09482b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### Linting +- Fix linting fail on nfcore_external_java_deps if nf_schema is used ([#2976](https://github.com/nf-core/tools/pull/2976)) + ### Download ### Components diff --git a/nf_core/lint/files_exist.py b/nf_core/lint/files_exist.py index d801caf704..0c87100622 100644 --- a/nf_core/lint/files_exist.py +++ b/nf_core/lint/files_exist.py @@ -200,8 +200,8 @@ def files_exist(self) -> Dict[str, Union[List[str], bool]]: Path("Singularity"), ] files_warn_ifexists = [Path(".travis.yml")] - files_fail_ifinconfig: List[Tuple[Path, Dict[str, str]]] = [ - (Path("lib", "nfcore_external_java_deps.jar"), {"plugins": "nf-validation"}), + files_fail_ifinconfig: List[Tuple[Path, List[Dict[str, str]]]] = [ + (Path("lib", "nfcore_external_java_deps.jar"), [{"plugins": "nf-validation"}, {"plugins": "nf-schema"}]), ] # Remove files that should be ignored according to the linting config @@ -246,10 +246,11 @@ def pf(file_path: Union[str, Path]) -> Path: if str(file_cond[0]) in ignore_files: continue in_config = False - config_key, config_value = list(file_cond[1].items())[0] - if config_key in self.nf_config and config_value in self.nf_config[config_key]: - log.debug(f"Found {config_key} in nextflow.config with value {config_value}") - in_config = True + for condition in file_cond[1]: + config_key, config_value = list(condition.items())[0] + if config_key in self.nf_config and config_value in self.nf_config[config_key]: + log.debug(f"Found {config_key} in nextflow.config with value {config_value}") + in_config = True if pf(file_cond[0]).is_file() and in_config: failed.append(f"File must be removed: {self._wrap_quotes(file_cond[0])}") elif pf(file_cond[0]).is_file() and not in_config: diff --git a/tests/lint/files_exist.py b/tests/lint/files_exist.py index 5081522899..08da7f14db 100644 --- a/tests/lint/files_exist.py +++ b/tests/lint/files_exist.py @@ -79,3 +79,20 @@ def test_files_exist_fail_conditional(self): results = lint_obj.files_exist() assert results["failed"] == ["File must be removed: `lib/nfcore_external_java_deps.jar`"] assert results["ignored"] == [] + + +def test_files_exist_pass_conditional_nfschema(self): + new_pipeline = self._make_pipeline_copy() + # replace nf-validation with nf-schema in nextflow.config + with open(Path(new_pipeline, "nextflow.config")) as f: + config = f.read() + config = config.replace("nf-validation", "nf-schema") + with open(Path(new_pipeline, "nextflow.config"), "w") as f: + f.write(config) + + lint_obj = nf_core.lint.PipelineLint(new_pipeline) + lint_obj._load() + lint_obj.nf_config["manifest.schema"] = "nf-core" + results = lint_obj.files_exist() + assert results["failed"] == [] + assert results["ignored"] == [] diff --git a/tests/test_lint.py b/tests/test_lint.py index b72a6bfdfa..15c1550e72 100644 --- a/tests/test_lint.py +++ b/tests/test_lint.py @@ -212,6 +212,7 @@ def test_sphinx_md_files(self): test_files_exist_missing_main, test_files_exist_pass, test_files_exist_pass_conditional, + test_files_exist_pass_conditional_nfschema, ) from .lint.files_unchanged import ( # type: ignore[misc] test_files_unchanged_fail,