Gathering detailed insights and metrics for npm-groovy-lint
Gathering detailed insights and metrics for npm-groovy-lint
Gathering detailed insights and metrics for npm-groovy-lint
Gathering detailed insights and metrics for npm-groovy-lint
npm install npm-groovy-lint
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
209 Stars
439 Commits
65 Forks
6 Watching
12 Branches
25 Contributors
Updated on 26 Nov 2024
JavaScript (72.59%)
Groovy (27.2%)
Dockerfile (0.21%)
Cumulative downloads
Total Downloads
Last day
-4.2%
2,503
Compared to previous day
Last week
9.9%
13,917
Compared to previous week
Last month
9.7%
59,094
Compared to previous month
Last year
67.9%
650,919
Compared to previous year
17
New: The article about the story of npm-groovy-lint, and why you should dive in open-source community !
Based on CodeNarc , this out of the box package allows to track groovy errors and correct a part of them
Easy to integrate in a CI/CD process (Jenkins Pipeline,CircleCI...) to lint your groovy or Jenkinsfile at each build :)
You can also use this package in :
See CHANGELOG
Any question, problem or enhancement request ? Ask here :)
1 npm-groovy-lint [OPTIONS] [FILES|PATH|PATTERN]
Parameter | Type | Description |
---|---|---|
-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" Note: HTML and XML are directly from CodeNarc so using these formats will disable many npm-groovy-lint features |
-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. |
-c --config | String | Custom path to GroovyLint config file, or preset config recommended|recommended-jenkinsfile|all Default: Browse current directory to find .groovylintrc.json|js|yml|package.json config file, or default npm-groovy-lint config if not defined.Note: command-line arguments have priority on config file properties |
--parse | Boolean | Try to compile the source code and return parse errors (since v5.7.0, default to true, use --no-parse to deactivate) |
--format | Boolean | Format source code |
--fix | Boolean | Automatically fix problems when possible See Auto-fixable rules |
-x --fixrules | String | Option for --fix argument: List of rule identifiers to fix (if not specified, all available fixes will be applied). See Auto-fixable 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) |
-p --path | String | (DEPRECATED) Directory containing the files to lint Example: ./path/to/my/groovy/files |
-f --files | String | (DEPRECATED) Comma-separated list of Ant-style file patterns specifying files that must be included. Default: "**/*.groovy,**/Jenkinsfile,**/*.gradle" Examples: - "**/Jenkinsfile" - "**/*.groovy" - "**/*.gradle" - "**/mySingleFile.groovy" |
1 npm-groovy-lint path/to/my/groovy/file.groovy
1 npm-groovy-lint path/to/my/groovy/file.groovy path/to/my/groovy/file2.groovy path/to/my/groovy/file3.groovy
1 npm-groovy-lint path/to/my/groovy
1 npm-groovy-lint path/to/my/groovy/*.groovy
1 npm-groovy-lint --output json
1 npm-groovy-lint --format my/path/to/file.groovy my/path/to/file2.groovy
1 npm-groovy-lint --fix my/path/to/file.groovy my/path/to/file2.groovy
1 cat path/to/my/Jenkinsfile | npm-groovy-lint --format -
1 npm-groovy-lint --path "./path/to/my/groovy/files" --files "**/*.groovy" --config "./config/codenarc/.groovylintrcCustom.js" --loglevel warning --output txt
1 npm-groovy-lint --codenarcargs -basedir="lib/example" -rulesetfiles="file:lib/example/RuleSet-Groovy.groovy" -title="TestTitleCodenarc" -maxPriority1Violations=0' -report="html:ReportTestCodenarc.html"
1 npm install -g npm-groovy-lint
npm install -g npm-groovy-lint@8.2.0
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
If you are using VsCode Groovy Lint extension, just use QuickFix Ignore in all files and it will generate groovylintrc.json file.
recommended
, recommended-jenkinsfile
, all
)"RuleSection.RuleName": ruleParameters
or "RuleName": ruleParameters
"off"
, "error"
, "warning"
, "info"
) , or a property list :
OR
.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)1{ 2 "extends": "recommended", 3 "rules": { 4 "comments.ClassJavadoc": "off", 5 "formatting.Indentation": { 6 "spacesPerIndentLevel": 4, 7 "severity": "info" 8 }, 9 "UnnecessaryReturnKeyword": "error" 10 } 11}
1{ 2 "extends": "recommended-jenkinsfile", 3 "rules": { 4 "CouldBeElvis": "off", 5 "CouldBeSwitchStatement": "off", 6 "VariableName": { 7 "severity": "info" 8 } 9 } 10}
1{ 2 "codenarcRulesets": "RuleSet-1.groovy,RuleSet-2.groovy" 3}
You can disable rules directly by adding comment in file, using eslint style
To temporarily disable rule warnings in your file, use block comments in the following format:
1/* groovylint-disable */ 2 3def variable = 1; 4 5/* groovylint-enable */
You can also disable or enable warnings for specific rules:
1/* groovylint-disable NoDef, UnnecessarySemicolon */ 2 3def variable = 1; 4 5/* groovylint-enable NoDef, UnnecessarySemicolon */
To disable rule warnings in an entire file, put a /* groovylint-disable */
block comment at the top of the file:
1/* groovylint-disable */ 2 3def variable = 1;
You can also disable or enable specific rules for an entire file:
1/* groovylint-disable NoDef */ 2 3def variable = 1;
To disable all rules on a specific line, use a line or block comment in one of the following formats:
1def variable = 1; // groovylint-disable-line 2 3// groovylint-disable-next-line 4def variable = 1; 5 6/* groovylint-disable-next-line */ 7def variable = 1; 8 9def variable = 1; /* groovylint-disable-line */
To disable a specific rule on a specific line:
1def variable = 1; // groovylint-disable-line NoDef 2 3// groovylint-disable-next-line NoDef 4def variable = 1; 5 6def variable = 1; /* groovylint-disable-line NoDef */ 7 8/* groovylint-disable-next-line NoDef */ 9def variable = 1;
To disable multiple rules on a specific line:
1def variable = 1; // groovylint-disable-line NoDef, UnnecessarySemicolon 2 3// groovylint-disable-next-line NoDef, UnnecessarySemicolon 4def variable = 1; 5 6def variable = 1; /* groovylint-disable-line NoDef, UnnecessarySemicolon */ 7 8/* groovylint-disable-next-line NoDef, UnnecessarySemicolon */ 9def variable = 1;
Contribute to add more rules fixes :)
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
1# .circleci/config.yml 2version: 2.1 3jobs: 4 lint: 5 docker: 6 - image: nvuillam/npm-groovy-lint 7 steps: 8 - checkout 9 10 - run: | 11 npm-groovy-lint 12 13workflows: 14 version: 2 15 "lint": 16 jobs: 17 - lint
1node { 2 checkout scm 3 docker.image('nvuillam/npm-groovy-lint').inside { 4 sh 'npm-groovy-lint' 5 } 6}
Run with default settings
1docker run --rm -u "$(id -u):$(id -g)" -w=/tmp -v "$PWD":/tmp nvuillam/npm-groovy-lint
Run with additional flags by simply appending them at after docker image name:
1docker run --rm -u "$(id -u):$(id -g)" -w=/tmp -v "$PWD":/tmp nvuillam/npm-groovy-lint --failon warning --verbose
You can run npm-groovy-lint using its official docker image
You can import npm-groovy-lint into your NPM package and call lint & fix via module, using the same options than from npm-groovy-lint command line
Example
1 npm install npm-groovy-lint --save
1 const NpmGroovyLint = require("npm-groovy-lint/lib/groovy-lint.js"); 2 const fse = require("fs-extra"); 3 4 const npmGroovyLintConfig = { 5 source: fse.readFileSync('./lib/example/SampleFile.groovy').toString(), 6 fix: true, 7 loglevel: 'warning', 8 output: 'none' 9 }; 10 const linter = new NpmGroovyLint(npmGroovyLintConfig, {}); 11 await linter.run(); 12 console.log(JSON.stringify(linter.lintResult));
If you have issues with MegaLinter, you can report it on the repository
To help reproducing, you can access advanced logs using DEBUG env variables
Examples:
DEBUG=npm-groovy-lint npm-groovy-lint ....
DEBUG=npm-groovy-lint,npm-groovy-lint-trace npm-groovy-lint ....
If you want to see what happens in CodeNarc Server, you can clone the repo and run locally npm server:run
before running npm-groovy-lint: you'll see the live logs of the to CodeNarc Server for npm-groovy-lint.
Contributions are very welcome !
Please follow Contribution instructions
Nicolas Vuillamy | Dave Gallant | Howard Lo | Pawel Kopka | docwhat | CatSue |
See complete CHANGELOG
The latest stable version of the package.
Stable Version
1
0/10
Summary
Remote Code Execution in npm-groovy-lint
Affected Versions
< 9.1.0
Patched Versions
9.1.0
Reason
15 commit(s) and 8 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
GitHub workflow tokens follow principle of least privilege
Details
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
1 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
Found 1/12 approved changesets -- score normalized to 0
Reason
binaries present in source code
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More