Creating a Custom CodeNarc Rule for Nextflow Config Validation #40
-
From README:
How does one go about creating a custom CodeNarc rule for Nextflow? For example, if I wanted to enforce a rule where params can only specify file locations starting with |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Linters can only do static analysis and so won't be able to alert you if a runtime parameter has been set to an invalid value. However, if the file location is hard coded in the nextflow file then you can detect this. You could also scan a config file to detect one there. To make a new rule you generally make a class that overrides the |
Beta Was this translation helpful? Give feedback.
-
Examples of custom rules can be found under https://github.com/awslabs/linter-rules-for-nextflow/tree/main/linter-rules/src/main/groovy/software/amazon/nextflow/rules |
Beta Was this translation helpful? Give feedback.
-
Thanks @markjschreiber! This is super helpful. |
Beta Was this translation helpful? Give feedback.
Linters can only do static analysis and so won't be able to alert you if a runtime parameter has been set to an invalid value. However, if the file location is hard coded in the nextflow file then you can detect this. You could also scan a config file to detect one there.
To make a new rule you generally make a class that overrides the
org.codenarc.rule.AbstractAstVisitor
class and visits the appropriate AST nodes in the parse tree. To find out what type of language constructs you want to visit and inspect you can run the ASTEcho application to dump out the AST for the nf or config file.