Skip to content

Subworkflow lint bugfixes#3968

Merged
mashehu merged 14 commits intonf-core:devfrom
andresferben:dev
Jan 30, 2026
Merged

Subworkflow lint bugfixes#3968
mashehu merged 14 commits intonf-core:devfrom
andresferben:dev

Conversation

@andresferben
Copy link
Copy Markdown
Contributor

@andresferben andresferben commented Dec 10, 2025

PR checklist

  • This comment contains a description of changes (with reason)
  • CHANGELOG.md is updated
  • If you've fixed a bug or added code that should be tested, add tests!
  • Documentation in docs is updated

Fixed

  • If a line contains a comment with a keyword ('emit', 'take', 'main', etc.), the subworkflow linter would take it as the beginning of a new section (example).
  • If a file contains more than one workflow definition (example), the subworkflow linter would take everything after the first workflow as the "emit" section from the first workflow.

Both these bugs produce false positive warnings like "Included component not used in main.nf" because the linter is not able to properly capture the whole main section.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.52%. Comparing base (fef1c72) to head (22b6fcb).
⚠️ Report is 2 commits behind head on dev.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@andresferben andresferben marked this pull request as ready for review December 10, 2025 21:28
@andresferben andresferben requested a review from jfy133 December 13, 2025 03:33
@sateeshperi sateeshperi requested a review from mashehu December 16, 2025 09:28
@atrigila
Copy link
Copy Markdown

I can help add some context of why this PR is useful. In nf-core/smrnaseq we had many issues with warnings when linting, as showed here: https://github.com/nf-core/smrnaseq/actions/runs/20112360084/job/57712837018. This fixes two edge-cases in the subworkflow linter that can generate misleading “Included component not used in main.nf” warnings.

Basically the message would say that almost all components of a subworkflow, e.g. INDEX_RRNA were not included in the main file, while they were there.

image

The linting would break after finding the word 'emit' (which was written as a comment in that subworkflow). This PR fixes that issue :)

Copy link
Copy Markdown
Contributor

@mashehu mashehu left a comment

Choose a reason for hiding this comment

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

Nice, thanks for the contribution.

Do you have time to also add test case to tests/modules/lint/test_main_nf.py where the old linting failed and your solution works? I can have a look otherwise

Comment thread nf_core/subworkflows/lint/main_nf.py Outdated
@andresferben
Copy link
Copy Markdown
Contributor Author

Nice, thanks for the contribution.

Do you have time to also add test case to tests/modules/lint/test_main_nf.py where the old linting failed and your solution works? I can have a look otherwise

Thanks @mashehu!
I added two test cases to tests/subworkflows/test_lint.py. I haven't used Pytest before, so it's probably far from perfect. Can you please review it? Feel free to make any changes.

@andresferben andresferben requested a review from mashehu January 13, 2026 03:39
assert len(subworkflow_lint.warned) >= 0

def test_skip_keyword_in_comment(self):
"""Test linting a subworkflow where a comment contains a keyword (workflow, subworkflow, take, main, emit)"""
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 think we recently decided against allowing multiple workflows in one subworkflow https://nfcore.slack.com/archives/C043UU89KKQ/p1742461607278339

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.

The utils_nfcore-pipeline_pipeline subworkflow, which is currently part of the template, contains multiple workflow definitions:
https://github.com/nf-core/tools/blob/dev/nf_core/pipeline-template/subworkflows/local/utils_nfcore_pipeline_pipeline/main.nf

This makes the linter raise false-positive "unused import" warnings

@andresferben andresferben requested a review from mashehu January 20, 2026 15:13
@mashehu mashehu added this to the 3.5.2 milestone Jan 29, 2026
Copy link
Copy Markdown
Member

@mirpedrol mirpedrol left a comment

Choose a reason for hiding this comment

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

Hi!
As @mashehu mentioned, we agreed that one subworkflow would have only one workflow. I think this should be the standard, and we should update the utils subworkflow in the template instead.
However, taking care of comments containing the word "emit" is a good fix, I would instead skip all comments from the parsing, so lines that start with //.

@andresferben
Copy link
Copy Markdown
Contributor Author

Hi! As @mashehu mentioned, we agreed that one subworkflow would have only one workflow. I think this should be the standard, and we should update the utils subworkflow in the template instead. However, taking care of comments containing the word "emit" is a good fix, I would instead skip all comments from the parsing, so lines that start with //.

Hi @mirpedrol, thanks for the review!
I have removed the "test_file_with_multiple_workflows" test, since it won't be required after the template changes.

As per skipping all comments from the parsing, that's kind of how it works. The problem was that previously, the checking of whether the line is a comment or not, happened after searching for the keywords (emit, take, etc.) and switching the section. After this fix, the check will happen before, so it will not switch sections based on commented lines.

@mashehu mashehu dismissed mirpedrol’s stale review January 30, 2026 13:36

everything was adressed

@mashehu mashehu merged commit eeeb73f into nf-core:dev Jan 30, 2026
113 checks passed
mashehu added a commit to mashehu/tools that referenced this pull request Mar 25, 2026
Co-authored-by: nf-core-bot <[email protected]>
Co-authored-by: Matthias Hörtenhuber <[email protected]>
mashehu added a commit to mashehu/tools that referenced this pull request Mar 25, 2026
Co-authored-by: nf-core-bot <[email protected]>
Co-authored-by: Matthias Hörtenhuber <[email protected]>
mashehu added a commit to JulianFlesch/nf-core-tools that referenced this pull request Mar 25, 2026
Co-authored-by: nf-core-bot <[email protected]>
Co-authored-by: Matthias Hörtenhuber <[email protected]>
mashehu added a commit to JulianFlesch/nf-core-tools that referenced this pull request Mar 30, 2026
Co-authored-by: nf-core-bot <[email protected]>
Co-authored-by: Matthias Hörtenhuber <[email protected]>
mashehu added a commit to JulianFlesch/nf-core-tools that referenced this pull request Mar 31, 2026
Co-authored-by: nf-core-bot <[email protected]>
Co-authored-by: Matthias Hörtenhuber <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants