Skip to content

Linter drops trailing double quote when parsing eval() in topics #3941

@pinin4fjords

Description

@pinin4fjords

Description of the bug

When linting modules that use topic: versions with eval-based version collection, the linter incorrectly drops the trailing double quote from sed/awk commands when comparing to meta.yml. This means meta.yml must have a key missing the closing " to pass lint.

Example

main.nf has:

tuple val("${task.process}"), val('ribodetector'), eval('ribodetector --version | sed "s/ribodetector //"'), emit: versions_ribodetector, topic: versions

The eval string is: ribodetector --version | sed "s/ribodetector //"

To pass lint, meta.yml must use this malformed key (missing closing "):

topics:
  versions:
    - - ${task.process}:
          type: string
          description: Name of the process
      - ribodetector:
          type: string
          description: Name of the tool
      - ribodetector --version | sed "s/ribodetector //:
          type: string
          description: Version of ribodetector used

If you write the correct key WITH the closing ":

      - ribodetector --version | sed "s/ribodetector //":

Linter fails:

correct_meta_topics: Module meta.yml does not match main.nf. Topics should contain: 
{'versions': [['${task.process}', 'ribodetector', 'ribodetector --version | sed "s/ribodetector //']]}

Note: "s/ribodetector //' - the ' is the Python string delimiter, revealing the expected content is ribodetector --version | sed "s/ribodetector // (missing trailing ").

Observed in existing modules

This pattern appears in multiple existing modules including samtools/view, fastqc, etc. - all have meta.yml with truncated eval command keys missing the trailing ".

Related

Possibly related to #3901 (--fix produces mangled output) and #3530 (incorrect parsing with special characters).

System information

  • nf-core/tools: 3.5.1
  • Nextflow: 24.10.0
  • OS: macOS

PR where encountered

nf-core/modules#9474

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions