Skip to content

npm-groovy-lint

GitHub stars autofix sarif GitHub release (latest SemVer) GitHub last commit GitHub commit activity GitHub contributors

npm-groovy-lint documentation

npm-groovy-lint - GitHub

Configuration in MegaLinter

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_COMMAND_REMOVE_ARGUMENTS User custom arguments to remove from command line before calling the linter
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 files
Ex: [".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_UNSECURED_ENV_VARIABLES List of env variables explicitly not filtered before calling GROOVY_NPM_GROOVY_LINT and its pre/post commands 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
GROOVY_NPM_GROOVY_LINT_CLI_EXECUTABLE Override CLI executable ['npm-groovy-lint']

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 Install in VSCode

MegaLinter Flavors

This linter is available in the following flavors

Flavor Description Embedded linters Info
all Default MegaLinter Flavor 124 Docker Image Size (tag) Docker Pulls
c_cpp Optimized for pure C/C++ projects 54 Docker Image Size (tag) Docker Pulls
ci_light Optimized for CI items (Dockerfile, Jenkinsfile, JSON/YAML schemas,XML 21 Docker Image Size (tag) Docker Pulls
cupcake MegaLinter for the most commonly used languages 84 Docker Image Size (tag) Docker Pulls
documentation MegaLinter for documentation projects 49 Docker Image Size (tag) Docker Pulls
dotnet Optimized for C, C++, C# or VB based projects 62 Docker Image Size (tag) Docker Pulls
dotnetweb Optimized for C, C++, C# or VB based projects with JS/TS 71 Docker Image Size (tag) Docker Pulls
go Optimized for GO based projects 51 Docker Image Size (tag) Docker Pulls
java Optimized for JAVA based projects 53 Docker Image Size (tag) Docker Pulls
javascript Optimized for JAVASCRIPT or TYPESCRIPT based projects 59 Docker Image Size (tag) Docker Pulls
php Optimized for PHP based projects 54 Docker Image Size (tag) Docker Pulls
python Optimized for PYTHON based projects 62 Docker Image Size (tag) Docker Pulls
ruby Optimized for RUBY based projects 50 Docker Image Size (tag) Docker Pulls
rust Optimized for RUST based projects 50 Docker Image Size (tag) Docker Pulls
salesforce Optimized for Salesforce based projects 54 Docker Image Size (tag) Docker Pulls
swift Optimized for SWIFT based projects 50 Docker Image Size (tag) Docker Pulls
terraform Optimized for TERRAFORM based projects 54 Docker Image Size (tag) Docker Pulls

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

  • Dockerfile commands :
ENV JAVA_HOME_17=/usr/lib/jvm/java-17-openjdk