npm-groovy-lint
npm-groovy-lint documentation
- Version in Mega-Linter: 8.2.0
- Visit Official Web Site
- See How to configure npm-groovy-lint rules
- If custom
.groovylintrc.json
config file is not found, .groovylintrc.json will be used
- If custom
- See How to disable npm-groovy-lint rules in files
- See Index of problems detected by npm-groovy-lint
Configuration in Mega-Linter
- Enable npm-groovy-lint by adding
GROOVY_NPM_GROOVY_LINT
in ENABLE_LINTERS variable - Disable npm-groovy-lint by adding
GROOVY_NPM_GROOVY_LINT
in DISABLE_LINTERS variable
- Enable auto-fixes by adding
GROOVY_NPM_GROOVY_LINT
in APPLY_FIXES variable
Variable | Description | Default value |
---|---|---|
GROOVY_NPM_GROOVY_LINT_ARGUMENTS | User custom arguments to add in linter CLI call Ex: -s --foo "bar" |
|
GROOVY_NPM_GROOVY_LINT_FILTER_REGEX_INCLUDE | Custom regex including filter Ex: (src\|lib) |
Include every file |
GROOVY_NPM_GROOVY_LINT_FILTER_REGEX_EXCLUDE | Custom regex excluding filter Ex: (test\|examples) |
Exclude no file |
GROOVY_NPM_GROOVY_LINT_CLI_LINT_MODE | Override default CLI lint mode - file : Calls the linter for each file- list_of_files : Call the linter with the list of files as argument- project : Call the linter from the root of the project |
{linter.cli_lint_mode} |
GROOVY_NPM_GROOVY_LINT_FILE_EXTENSIONS | Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all filesEx: [".py", ""] |
[".groovy", ".gvy", ".gradle", ".nf"] |
GROOVY_NPM_GROOVY_LINT_FILE_NAMES_REGEX | File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files Ex: ["Dockerfile(-.+)?", "Jenkinsfile"] |
["Jenkinsfile"] |
GROOVY_NPM_GROOVY_LINT_PRE_COMMANDS | List of bash commands to run before the linter | None |
GROOVY_NPM_GROOVY_LINT_POST_COMMANDS | List of bash commands to run after the linter | None |
GROOVY_NPM_GROOVY_LINT_CONFIG_FILE | npm-groovy-lint configuration file nameUse LINTER_DEFAULT to let the linter find it |
.groovylintrc.json |
GROOVY_NPM_GROOVY_LINT_RULES_PATH | Path where to find linter configuration file | Workspace folder, then Mega-Linter default rules |
GROOVY_NPM_GROOVY_LINT_DISABLE_ERRORS | Run linter but consider errors as warnings | false |
GROOVY_NPM_GROOVY_LINT_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | 0 |
IDE Integration
Use npm-groovy-lint in your favorite IDE to catch errors before Mega-Linter !
IDE | Extension Name | Install | |
---|---|---|---|
Visual Studio Code | VsCode Groovy Lint |
Mega-Linter Flavours
This linter is available in the following flavours
Flavor | Description | Embedded linters | Info | |
---|---|---|---|---|
all | Default Mega-Linter Flavor | 93 | ||
ci_light | Optimized for CI items (Dockerfile, Jenkinsfile, JSON/YAML schemas,XML | 13 | ||
dart | Optimized for DART based projects | 40 | ||
documentation | Mega-Linter for documentation projects | 39 | ||
dotnet | Optimized for C, C++, C# or VB based projects | 46 | ||
go | Optimized for GO based projects | 41 | ||
java | Optimized for JAVA based projects | 41 | ||
javascript | Optimized for JAVASCRIPT or TYPESCRIPT based projects | 48 | ||
php | Optimized for PHP based projects | 43 | ||
python | Optimized for PYTHON based projects | 48 | ||
ruby | Optimized for RUBY based projects | 40 | ||
rust | Optimized for RUST based projects | 40 | ||
salesforce | Optimized for Salesforce based projects | 42 | ||
scala | Optimized for SCALA based projects | 40 | ||
swift | Optimized for SWIFT based projects | 40 | ||
terraform | Optimized for TERRAFORM based projects | 44 |
Behind the scenes
How are identified applicable files
- File extensions:
.groovy
,.gvy
,.gradle
,.nf
- File names (regex):
Jenkinsfile
How the linting is performed
- npm-groovy-lint is called one time by identified file
Example calls
npm-groovy-lint --path . --files myfile.groovy
npm-groovy-lint --path . --files myfile.groovy -c .groovylintrc.json
npm-groovy-lint --path . --files myfile.groovy -c .groovylintrc.json --fix
Help content
npm-groovy-lint [options]
-p, --path path::String Directory containing the files to lint (default: current directory) - default: .
-f, --files String Comma-separated list of Ant-style file patterns specifying files that must be included
-s, --source String Source text to lint (if no path/files arguments)
--sourcefilepath String Full path of the file whose content is sent in source argument
--parse Try to parse the source code with GroovyShell and return errors (use argument --no-parse if you want to deactivate)
-c, --config String Custom path to directory containing GroovyLint config file.
Default: Found groovylintrc.js/json/yml/package.json config file, or default npm-groovy-lint config if not defined.
Note: command-line arguments have priority on config file properties - default: /
--format Format source code
--fix Automatically fix problems when possible
-x, --fixrules String Option for --fix argument: List of rule identifiers to fix (if not specified, all available fixes will be applied) - default: all
-i, --ignorepattern String Comma-separated list of Ant-style file patterns specifying files that must be ignored. Default: none
-r, --rulesets String RuleSet file(s) to use for linting. If it is a directory, all rulesets will be used. RuleSet file definition: http://codenarc.github.io/CodeNarc/codenarc-creating-ruleset.html. If not specified, npm-groovy-script default one will be used. Can also be a list of rule identifiers with parameters
--rulesetsoverridetype String If list of rules sent in rulesets option, defines if they replace rules defined in .groovylintrc.json, or if they are appended - either: replaceConfig or appendConfig - default: replaceConfig
-o, --output String Output format (txt,json,html,xml), or path to a file with one of these extensions - default: txt
-l, --loglevel String Log level (error,warning,info) - either: error, warning, or info - default: info
--verbose More outputs in console, including performed fixes
--failon String Defines the error level where CLI will fail (return code = 1). error,warning,info or none. Every failure level includes the more critical ones. - either: error, warning, info, or none - default: none
--failonerror (Deprecated) Fails if at least one error is found
--failonwarning (Deprecated) Fails if at least one warning is found
--failoninfo (Deprecated) Fails if at least one error is found
--codenarcargs Use core CodeNarc arguments (all npm-groovy-lint arguments will be ignored). Doc: http://codenarc.github.io/CodeNarc/codenarc-command-line.html
--noserver For better performances, npm-groovy-lint runs a local server to eep CodeNarc alive instead of loading java/groovy at each call. If you don't want that, send this argument
--serverhost String If use of CodeNarc server, host where is the CodeNarc server (default: localhost) - default: http://localhost
--serverport String If use of CodeNarc server, port of the CodeNarc server (default: 7484) - default: 7484
-j, --javaexecutable String If you do not want to use default java executable to run CodeNarcServer, you can override it - default: java
--javaoptions String Override java options - default: -Xms256m,-Xmx2048m
--killserver Terminate the CodeNarcServer if running
--nolintafter Do not lint again after format and fix options (useful for client calling Npm Groovy Lint)
--returnrules Return rule descriptions and url if this argument is set
--insight npm-groovy-lint collects anonymous usage statistics using package https://www.npmjs.com/package/insight. If you do not want to share them, use --no-insight option
-h, --help Show help (npm-groovy-lint -help OPTIONNAME to see option detail)
-v, --version Show version
Installation on mega-linter Docker image
- NPM packages (node.js):
Example success log
Results of npm-groovy-lint linter (version 8.0.2)
See documentation on https://nvuillam.github.io/mega-linter/descriptors/groovy_npm_groovy_lint/
-----------------------------------------------
[SUCCESS] .automation/test/groovy/groovy_good_01.groovy
.automation/test/groovy/groovy_good_01.groovy
npm-groovy-lint results in 1 linted files:
┌─────────┬───────────┬─────────────┐
│ (index) │ Severity │ Total found │
├─────────┼───────────┼─────────────┤
│ 0 │ 'Error' │ 0 │
│ 1 │ 'Warning' │ 0 │
│ 2 │ 'Info' │ 0 │
└─────────┴───────────┴─────────────┘
Example error log
Results of npm-groovy-lint linter (version 8.0.2)
See documentation on https://nvuillam.github.io/mega-linter/descriptors/groovy_npm_groovy_lint/
-----------------------------------------------
[ERROR] .automation/test/groovy/groovy_bad_01.groovy
.automation/test/groovy/groovy_bad_01.groovy
4 error Unexpected input: '$' @ line 4, column 16. NglParseError
2 info Line ends with whitespace characters TrailingWhitespace
npm-groovy-lint results in 1 linted files:
┌─────────┬───────────┬─────────────┐
│ (index) │ Severity │ Total found │
├─────────┼───────────┼─────────────┤
│ 0 │ 'Error' │ 1 │
│ 1 │ 'Warning' │ 0 │
│ 2 │ 'Info' │ 1 │
└─────────┴───────────┴─────────────┘
Failure: 1 error(s) have been found
0 warning(s) have been found
1 info(s) have been found