Any question, problem or enhancement request ? Ask here :)
Usage
npm-groovy-lint OPTIONS
Parameter
Type
Description
-p --path
String
Directory containing the files to lint Example: ./path/to/my/groovy/files
-f --files
String
Comma-separated list of Ant-style file patterns specifying files that must be included. Default: "**/*.groovy,**/Jenkinsfile,**/*.gradle" Examples: - "**/Jenkinsfile" - "**/*.groovy" - "**/*.gradle" - "**/mySingleFile.groovy"
-o --output
String
Output format (txt,json,sarif,html,xml), or path to a file with one of these extensions Default: txt Examples: - "txt" - "json" - "./logs/myLintResults.txt" - "./logs/myLintResults.sarif" - "./logs/myLintResults.html" - "./logs/myLintResults.xml"
-l --loglevel
String
Log level (error,warning or info) Default: info
--failon
String
Defines the error level where CLI will fail (return code = 1). error,warning,info or none. Each failure level includes the more critical ones.
Option for --fix argument: List of rule identifiers to fix (if not specified, all available fixes will be applied). See Autofixable rules Examples: - "SpaceBeforeClosingBrace,SpaceAfterClosingBrace,UnusedImport" - "Indentation"
--nolintafter
Boolean
When format or fix is called, a new lint is performed after the fixes to update the returned error list. If you just want the updated source code and do not care about the error logs, use this parameter to improve performances
-r --rulesets
String
RuleSet file(s) to use for linting, if you do not want to use recommended rules or .groovylintrc.js defined rules. If list of comma separated strings corresponding to CodeNarc rules, a RuleSet file will be dynamically generated Examples: - "./config/codenarc/RuleSet-Custom.groovy" - "./path/to/my/ruleset/files" - Indentation{"spacesPerIndentLevel":2,"severity":"warning"},UnnecessarySemicolon,UnnecessaryGString
--rulesetsoverridetype
String
If list of rules sent in rulesets option, defines if they replace rules defined in .groovylintrc.json, or if they are appended Values: replaceConfig (default), appendConfig
-s --source
String
If path and files are not set, you can directly send the source code string to analyze
--verbose
Boolean
More outputs in console, including performed fixes
-i --ignorepattern
String
Comma-separated list of Ant-style file patterns specifying files that must be ignored Default: none Example: "**/test/*""
--noserver
Boolean
npm-groovy-lint launches a microservice to avoid performance issues caused by loading java/groovy each time,that auto kills itself after 1h idle. Use this argument if you do not want to use this feature
--returnrules
Boolean
Return rules descriptions and URL if set
--javaexecutable
String
Override java executable to use Default: java Example: C:\Program Files\Java\jdk1.8.0_144\bin\java.exe
--javaoptions
String
Override java options to use Default: "-Xms256m,-Xmx2048m"
--insight
Boolean
npm-groovy-lint collects anonymous usage statistics using amplitude, in order to make new improvements based on how users use this package. Summary charts are available at https://tinyurl.com/groovy-stats. Analytics obviously does not receive sensitive information like your code, as you can see in analytics.js. If you want to enable anonymous usage statistics, use --insight option.
--codenarcargs
String
Use core CodeNarc arguments (all npm-groovy-lint arguments will be ignored) Doc: http://codenarc.github.io/CodeNarc/codenarc-command-line.html Example: npm-groovy-lint --codenarcargs -basedir="lib/example" -rulesetfiles="file:lib/example/RuleSet-Groovy.groovy" -maxPriority1Violations=0 -report="xml:ReportTestCodenarc.xml
-h --help
Boolean
Show help (npm-groovy-lint -h OPTIONNAME to see option detail with examples)
-v --version
Boolean
Show npm-groovy-lint version (with CodeNarc version)
Installation
npm install -g npm-groovy-lint
If you have issues with v9, install previous version with npm install -g [email protected]
If you do not have java (from 8 to 14) installed on your computer npm-groovy-lint will install them for you, so the first run may be long.
Configuration
Default rules definition (recommended, based on all tracks a lot of errors, do not hesitate to ignore some of them (like NoDef ou RequiredVariableType) if they are too mean for your project.
Create a file named .groovylintrc.json in the current or any parent directory of where your files to analyze are located
your-repo-root-folder
src
groovy
mygroovyfile.groovy
Jenkinsfile
.groovylintrc.json(do not forget the dot at the beginning of the file name)
If you are using VsCode Groovy Lint extension, just use QuickFixIgnore in all filesand it will generate groovylintrc.json file
codenarcRulesets: Comma-separated string containing the list of .xml or .groovy CodeNarc RuleSet files (in case you already are a CodeNarc user and do not wish to switch to npm-groovy-lint config format)
Latest npm-groovy-lint version is natively integrated in Mega-Linter, that you can use as GitHub action or in other CI tools
This tool can also automatically apply fixes on Pull Request branches
请发表评论