Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
- fix linting with missing input ([#4202](https://github.com/nf-core/tools/pull/4202))
- fix(lint): use correct config key zenodo_doi ([#4201](https://github.com/nf-core/tools/pull/4201))
- add missing lint test documentation and add pre-commit check for them ([#4052](https://github.com/nf-core/tools/pull/4052))
- Allow `prefix2` for the ext keys linting ([#4234](https://github.com/nf-core/tools/pull/4234))

### Modules

Expand Down
2 changes: 1 addition & 1 deletion nf_core/modules/lint/main_nf.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def check_script_section(self, lines):
)

# Validate ext keys
permitted_ext_keys = {"ext.args", "ext.prefix", "ext.use_gpu"}
permitted_ext_keys = {"ext.args", "ext.prefix", "ext.prefix2", "ext.use_gpu"}
invalid_ext_keys = [
key
for key in re.findall(r"\bext\.\w+", script)
Expand Down
29 changes: 29 additions & 0 deletions tests/modules/lint/test_main_nf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,35 @@ def args99 = task.ext.args99 ?: ''
)
assert len(mock_lint.failed) == 0

# ext.prefix2 should be valid, but not other numbers
mock_lint.passed, mock_lint.failed = [], []
check_script_section(
mock_lint,
[
"""
def prefix2 = task.ext.prefix2 ?: ''

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for prefix1 and other not permitted combos too please.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a test for prefix1.

"""
],
)
assert len(mock_lint.failed) == 0

# ext.prefix1 or ext.prefix3+ should be invalid
mock_lint.passed, mock_lint.failed = [], []
check_script_section(
mock_lint,
[
"""
def prefix1 = task.ext.prefix1 ?: ''
def prefix3 = task.ext.prefix3 ?: ''
def prefix22 = task.ext.prefix22 ?: ''
"""
],
)
assert len(mock_lint.failed) == 1
assert "ext.prefix1" in mock_lint.failed[0][2]
assert "ext.prefix3" in mock_lint.failed[0][2]
assert "ext.prefix22" in mock_lint.failed[0][2]

# Check false positive matches, e.g. text.tokenize()
mock_lint.passed, mock_lint.failed = [], []
check_script_section(
Expand Down
Loading