23
npm-groovy-lint
source link: https://oxsecurity.github.io/megalinter/latest/descriptors/groovy_npm_groovy_lint/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
npm-groovy-lint
npm-groovy-lint documentation
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 |
file |
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 name Use 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 !
MegaLinter Flavours
This linter is available in the following flavours
Flavor | Description | Embedded linters | Info | |
---|---|---|---|---|
all | Default MegaLinter Flavor | 101 | ||
ci_light | Optimized for CI items (Dockerfile, Jenkinsfile, JSON/YAML schemas,XML | 18 | ||
documentation | MegaLinter for documentation projects | 42 | ||
dotnet | Optimized for C, C++, C# or VB based projects | 50 | ||
go | Optimized for GO based projects | 44 | ||
java | Optimized for JAVA based projects | 44 | ||
javascript | Optimized for JAVASCRIPT or TYPESCRIPT based projects | 51 | ||
php | Optimized for PHP based projects | 46 | ||
python | Optimized for PYTHON based projects | 50 | ||
ruby | Optimized for RUBY based projects | 43 | ||
rust | Optimized for RUST based projects | 43 | ||
salesforce | Optimized for Salesforce based projects | 45 | ||
swift | Optimized for SWIFT based projects | 43 | ||
terraform | Optimized for TERRAFORM based projects | 48 |
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,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: 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 want to enable them, use --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
- APK packages (Linux):
- NPM packages (node.js):
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK