Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -324,7 +324,7 @@ def check_script_section(self, lines):
invalid_ext_keys = [
key
for key in re.findall(r"\bext\.\w+", script)
if key not in permitted_ext_keys and not re.match(r"^ext\.args([2-9]|\d{2,})$", key)
if key not in permitted_ext_keys and not re.match(r"^ext\.(args|prefix)([2-9]|\d{2,})$", key)
]
if not invalid_ext_keys:
self.passed.append(("main_nf", "main_nf_ext_key", "All 'ext' keys are valid", self.main_nf))
Expand Down
14 changes: 14 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,20 @@ def args99 = task.ext.args99 ?: ''
)
assert len(mock_lint.failed) == 0

# ext.prefixN where N >= 2 should be valid

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought only prefix2 would be allowed, not prefix3

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.

At the moment I just copied the args code and added prefix as well

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.

Swapped to just adding prefix2 directly to the allowed keys.

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.

def prefix10 = task.ext.prefix10 ?: ''
def prefix99 = task.ext.prefix99 ?: ''
"""
],
)
assert len(mock_lint.failed) == 0

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