Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint check for params.enable_conda #2213

Merged
merged 11 commits into from
Mar 29, 2023
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

### Linting

- Update modules lint test to fail if enable_conda is found ([#2213](https://github.com/nf-core/tools/pull/2213))

### Modules

- Add an `--empty-template` option to create a module without TODO statements or examples ([#2175](https://github.com/nf-core/tools/pull/2175) & [#2177](https://github.com/nf-core/tools/pull/2177))
Expand Down
25 changes: 21 additions & 4 deletions nf_core/modules/lint/main_nf.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,26 @@ def check_process_section(self, lines, fix_version, progress_bar):
self.warned.append(("process_standard_label", "Process label unspecified", self.main_nf))
for i, l in enumerate(lines):
url = None
if _container_type(l) == "bioconda":
mirpedrol marked this conversation as resolved.
Show resolved Hide resolved
bioconda_packages = [b for b in l.split() if "bioconda::" in b]
l = l.strip(" '\"")
if _container_type(l) == "conda":
bioconda_packages = [b for b in l.split() if "bioconda::" in b]
match = re.search(r"params\.enable_conda", l)
if match is None:
self.passed.append(
(
"deprecated_enable_conda",
f"Deprecated parameter 'params.enable_conda' correctly not found in the conda definition",
self.main_nf,
)
)
else:
self.failed.append(
(
"deprecated_enable_conda",
f"Found deprecated parameter 'params.enable_conda' in the conda definition",
self.main_nf,
)
)
if _container_type(l) == "singularity":
# e.g. "https://containers.biocontainers.pro/s3/SingImgsRepo/biocontainers/v1.2.0_cv1/biocontainers_v1.2.0_cv1.img' :" -> v1.2.0_cv1
# e.g. "https://depot.galaxyproject.org/singularity/fastqc:0.11.9--0' :" -> 0.11.9--0
Expand Down Expand Up @@ -516,8 +533,8 @@ def _get_build(response):

def _container_type(line):
"""Returns the container type of a build."""
if re.search("bioconda::", line):
return "bioconda"
if line.startswith("conda"):
mirpedrol marked this conversation as resolved.
Show resolved Hide resolved
return "conda"
if line.startswith("https://containers") or line.startswith("https://depot"):
# Look for a http download URL.
# Thanks Stack Overflow for the regex: https://stackoverflow.com/a/3809435/713980
Expand Down
6 changes: 3 additions & 3 deletions tests/modules/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_modules_lint_gitlab_modules(self):
self.mods_install_gitlab.install("multiqc")
module_lint = nf_core.modules.ModuleLint(dir=self.pipeline_dir, remote_url=GITLAB_URL)
module_lint.lint(print_results=False, all_modules=True)
assert len(module_lint.failed) == 0
assert len(module_lint.failed) == 2
assert len(module_lint.passed) > 0
assert len(module_lint.warned) >= 0

Expand All @@ -77,7 +77,7 @@ def test_modules_lint_multiple_remotes(self):
self.mods_install_gitlab.install("multiqc")
module_lint = nf_core.modules.ModuleLint(dir=self.pipeline_dir, remote_url=GITLAB_URL)
module_lint.lint(print_results=False, all_modules=True)
assert len(module_lint.failed) == 0
assert len(module_lint.failed) == 1
assert len(module_lint.passed) > 0
assert len(module_lint.warned) >= 0

Expand All @@ -103,6 +103,6 @@ def test_modules_lint_patched_modules(self):
all_modules=True,
)

assert len(module_lint.failed) == 0
assert len(module_lint.failed) == 1
assert len(module_lint.passed) > 0
assert len(module_lint.warned) >= 0