Skip to content

Nextflow linter gives an error when using Groovy code from lib/ #6910

@scwatts

Description

@scwatts

Bug report

The Nextflow linter does not appear to allow use of Groovy code in the lib/ directory.

Expected behavior and actual behavior

Nextflow strict syntax removes the ability to call the import <classpath> statement, and the Nextflow linter shows any such use as an error. However, when Groovy code in the lib/ directory is used without an import statement the Nextflow linter also shows this as an undefined error.

This then means that used of Groovy code from the lib/ directory is not allowed by the linter since:

  • importing gives "Groovy import declarations are not supported", and
  • not importing gives: "MyClass is not defined"

I had expected the Nextflow linter to only return an error when Groovy code from the lib/ directory is explicitly imported.

Steps to reproduce the problem

Please see scwatts/nextflow-lib-import-lint-error for reproducible example

Program output

Taken from the above linked example:

$ NXF_VER=26.02.0-edge nextflow lint ./main.1.noimport.nf
Error main.1.noimport.nf:16:15: `Helper` is not defined
│  16 |   data_list = Helper.getDataList()
╰     |               ^^^^^^

Nextflow linting complete!
 ❌ 1 file had 1 error


$ NXF_VER=26.02.0-edge nextflow lint ./main.2.withimport.nf
Error main.2.withimport.nf:2:1: Groovy `import` declarations are not supported -- use fully-qualified name inline instead
│   2 | import Helper
╰     | ^^^^^^^^^^^^^

Error main.2.withimport.nf:17:15: `Helper` is not defined
│  17 |   data_list = Helper.getDataList()
╰     |               ^^^^^^

Nextflow linting complete!
 ❌ 1 file had 2 errors

Environment

  • Nextflow version: 26.02.0-edge, 25.10.4
  • Java version: openjdk version "17.0.17" 2025-10-21 LTS
  • Operating system: macOS
  • Bash version: GNU bash, version 5.3.3(1)-release

Additional context

There may be some import trick or way to refer to the lib/ classes in a fully-qualified but I haven't been able to find any at this point

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