npm-groovy-lint
npm-groovy-lint documentation
- Version in MegaLinter: 11.1.1
- 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 MegaLinter
- 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 |
list_of_files |
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 MegaLinter 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 MegaLinter !
IDE | Extension Name | Install | |
---|---|---|---|
Visual Studio Code | VSCode Groovy Lint |
MegaLinter Flavours
This linter is available in the following flavours
Flavor | Description | Embedded linters | Info | |
---|---|---|---|---|
all | Default MegaLinter Flavor | 114 | ||
ci_light | Optimized for CI items (Dockerfile, Jenkinsfile, JSON/YAML schemas,XML | 20 | ||
cupcake | MegaLinter for the most commonly used languages | 82 | ||
documentation | MegaLinter for documentation projects | 48 | ||
dotnet | Optimized for C, C++, C# or VB based projects | 60 | ||
go | Optimized for GO based projects | 50 | ||
java | Optimized for JAVA based projects | 51 | ||
javascript | Optimized for JAVASCRIPT or TYPESCRIPT based projects | 57 | ||
php | Optimized for PHP based projects | 51 | ||
python | Optimized for PYTHON based projects | 59 | ||
ruby | Optimized for RUBY based projects | 48 | ||
rust | Optimized for RUST based projects | 48 | ||
salesforce | Optimized for Salesforce based projects | 51 | ||
swift | Optimized for SWIFT based projects | 48 | ||
terraform | Optimized for TERRAFORM based projects | 53 |
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 once with the list of files as arguments (
list_of_files
CLI lint mode)
Example calls
npm-groovy-lint myfile.groovy
npm-groovy-lint -c .groovylintrc.json
npm-groovy-lint -c .groovylintrc.json --fix myfile.groovy myfile2.groovy
Help content
npm-groovy-lint [options]
--ext [String] Specify Groovy file extensions
-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,sarif,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: info
--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 want to enable them, use --insight option
-h, --help Show help (npm-groovy-lint -help OPTIONNAME to see option detail)
-v, --version Show version
-p, --path path::String (DEPRECATED) Directory containing the files to lint (default: current directory) - default: .
-f, --files String (DEPRECATED) Comma-separated list of Ant-style file patterns specifying files that must be included
Installation on mega-linter Docker image
- APK packages (Linux):
- NPM packages (node.js):