Skip to content

Commit

Permalink
Merge pull request #1682 from ErikDanielsson/fix-lint-key
Browse files Browse the repository at this point in the history
Fix `--key` flag for `nf-core lint` for module lint tests
  • Loading branch information
ErikDanielsson authored Jul 21, 2022
2 parents cc1ab61 + 27d08b4 commit dc667c9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- Add `CITATION.cff` [#361](https://github.com/nf-core/tools/issues/361)
- Allow customization of the `nf-core` pipeline template when using `nf-core create` ([#1548](https://github.com/nf-core/tools/issues/1548))
- Add Refgenie integration: updating of nextflow config files with a refgenie database ([#1090](https://github.com/nf-core/tools/pull/1090))
- Fix `--key` option in `nf-core lint` when supplying a module lint test name ([#1681](https://github.com/nf-core/tools/issues/1681))

### Modules

Expand Down
34 changes: 21 additions & 13 deletions nf_core/lint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@ def run_linting(
)
log.info("Only running tests: '{}'".format("', '".join(key)))

# Create the lint object
pipeline_keys = list(set(key).intersection(set(PipelineLint._get_all_lint_tests(release_mode)))) if key else []
# Check if we were given any keys, and if they match any pipeline tests
if key:
pipeline_keys = list(set(key).intersection(set(PipelineLint._get_all_lint_tests(release_mode))))
else:
# If no key is supplied, run all tests
pipeline_keys = None

# Create the lint object
lint_obj = PipelineLint(pipeline_dir, release_mode, fix, pipeline_keys, fail_ignored, fail_warned)

# Load the various pipeline configs
Expand Down Expand Up @@ -172,7 +177,7 @@ class PipelineLint(nf_core.utils.Pipeline):
from .template_strings import template_strings
from .version_consistency import version_consistency

def __init__(self, wf_path, release_mode=False, fix=(), key=(), fail_ignored=False, fail_warned=False):
def __init__(self, wf_path, release_mode=False, fix=(), key=None, fail_ignored=False, fail_warned=False):
"""Initialise linting object"""

# Initialise the parent object
Expand Down Expand Up @@ -259,19 +264,22 @@ def _lint_pipeline(self):
)
)

# Check that supplied test keys exist
bad_keys = [k for k in self.key if k not in self.lint_tests]
if len(bad_keys) > 0:
raise AssertionError(
"Test name{} not recognised: '{}'".format(
_s(bad_keys),
"', '".join(bad_keys),
if self.key is not None:
# Check that supplied test keys exist
bad_keys = [k for k in self.key if k not in self.lint_tests]
if len(bad_keys) > 0:
raise AssertionError(
"Test name{} not recognised: '{}'".format(
_s(bad_keys),
"', '".join(bad_keys),
)
)
)

# If -k supplied, only run these tests
if self.key:
# If -k supplied, only run these tests
self.lint_tests = [k for k in self.lint_tests if k in self.key]
if len(self.lint_tests) == 0:
log.debug("No pipeline lint tests to run")
return

# Check that the pipeline_dir is a clean git repo
if len(self.fix):
Expand Down

0 comments on commit dc667c9

Please sign in to comment.