Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

npm-groovy-lint

Package Overview
Dependencies
Maintainers
1
Versions
204
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-groovy-lint

NPM CodeNarc wrapper to easily lint Groovy files

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.9K
decreased by-22.02%
Maintainers
1
Weekly downloads
 
Created
Source

NPM GROOVY LINT (and FIX !)

Version Downloads/week CircleCI codecov GitHub contributors GitHub stars License HitCount PRs Welcome Say Thanks!

Groovy / Jenkinsfile linter and autofixer

Based on CodeNarc , this out of the box package allows to track groovy errors and correct a part of them

Use option --fix to activate autofixing (the function is still in experimental phase, you may have to run it several times at first so CodeNarc take in account the updates)

Easy to integrate in a CD/CI process (Jenkins Pipeline,CircleCI...) to lint your groovy or Jenkinsfile at each build :)

INSTALLATION

    $ npm install -g npm-groovy-lint

USAGE

    $ npm-groovy-lint OPTIONS
ParameterTypeDescription
-p
--path
StringDirectory containing the files to lint
Example: ./path/to/my/groovy/files
-f
--files
StringComma-separated list of Ant-style file patterns specifying files that must be included.
Default: "**/*.groovy,**/Jenkinsfile", or "**/*.groovy" if --rulesets Groovy, or **/Jenkinsfile if --rulesets Jenkinsfile
Examples:
- "**/Jenkinsfile"<br/> - "*/*.groovy"
-r
--rulesets
StringRuleSet file(s) to use for linting. If it is a directory, all rulesets will be used.
RuleSet file definition: http://codenarc.sourceforge.net/codenarc-creating-ruleset.html.
If not specified, npm-groovy-script default ones will be used depending on file types found in --path:
- Groovy recommended rules, also usable with --rulesets Groovy
- Jenkinsfile recommended rules, also usable with --rulesets Jenkinsfile
Examples:
- "./config/codenarc/RuleSet-Custom.groovy"
- "./path/to/my/ruleset/files"
- Jenkinsfile
-o
--output
StringOutput format (txt,json,html,xml), or path to a file with one of these extensions
Default: txt
Examples:
- "txt"
- "json"
- "./logs/myLintResults.txt"
- "./logs/myLintResults.json"
- "./logs/myLintResults.html"
- "./logs/myLintResults.xml"
-l
--loglevel
StringLog level (error,warning or info)
Default: info
-v
--verbose
BooleanMore outputs in console, including performed fixes
--fixBoolean(Experimental) Automatically fix problems when possible
See Autofixable rules
-i
--ignore-pattern
StringComma-separated list of Ant-style file patterns specifying files that must be ignored
Default: none
Example: "**/test/*""
--failonerrorBooleanFails if at least one error is found
--failonwarningBooleanFails if at least one warning is found
--failoninfoBooleanFails if at least one error is found
--codenarcargsBooleanUse core CodeNarc arguments (all npm-groovy-lint arguments will be ignored)
Doc: http://codenarc.sourceforge.net/codenarc-command-line.html
Example: npm-groovy-lint --codenarcargs -basedir="jdeploy-bundle/lib/example" -rulesetfiles="file:jdeploy-bundle/lib/example/RuleSet-Groovy.groovy" -maxPriority1Violations=0 -report="xml:ReportTestCodenarc.xml
-h
--help
BooleanShow help (npm-groovy-lint -h OPTIONNAME to see option detail with examples)

EXAMPLES

  • Lint a Jenkinsfile

npm-groovy-lint --rulesets Jenkinsfile

  • Lint groovy files

npm-groovy-lint --rulesets Groovy

  • Lint and fix a Jenkinsfile

npm-groovy-lint --rulesets Jenkinsfile --fix

  • Lint groovy with JSON output

npm-groovy-lint --rulesets Groovy --output json

  • Lint using core CodeNarc parameters and generate HTML report file

npm-groovy-lint --codenarcargs -basedir="jdeploy-bundle/lib/example" -rulesetfiles="file:jdeploy-bundle/lib/example/RuleSet-Groovy.groovy" -title="TestTitleCodenarc" -maxPriority1Violations=0' -report="html:ReportTestCodenarc.html"

Autofixable rules (experimental)

  • ConsecutiveBlankLines
  • Indentation (IfStatementBraces and ElsefStatementBraces must be manually fixed to have correct indentation)
  • NoTabCharacter
  • SpaceAfterCatch
  • SpaceAfterOpeningBrace
  • SpaceAroundOperator
  • SpaceAfterComma
  • SpaceBeforeOpeningBrace
  • UnnecessaryDefInFieldDeclaration
  • UnnecessaryGString
  • UnnecessarySemicolon
  • TrailingWhitespace

Contribute to add more rules fixes :)

TROUBLESHOOTING

  • Embedded Groovy 3.0.1 has issues with JDK12, please use JDK11 or a precedent version if possible

CONTRIBUTE

Contributions are very welcome !

  • Fork the repo and clone it on your computer
  • Run npm run lint then npm run test to check your updates didn't break anything
  • Once your code is ready, documented and testing, please make a pull request :)

THANKS

This package uses :

Keywords

FAQs

Package last updated on 23 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc