Lint (code quality), Format and Auto-fix your groovy files and Jenkinsfile
Visual Studio Code extension embedding npm-groovy-lint, itself embedding CodeNarc
- You can configure the rules by defining a
.groovylintrc.json
file - If you use CI, you can integrate Mega-Linter in your workflow, to make sure all your sources (groovy and other) are clean
Command | Description | Access |
---|---|---|
Analyze code | Lint the code of the current file | Ctrl+Shift+F9 Contextual Status bar Commands |
Format | Format the code of the current file | Shift+Alt+F Contextual Commands |
Fix all auto-fixable problems | Fix the code of the current file | Contextual Commands |
Lint folder | Lint all applicable files of a folder | Contextual |
Fix single error | Apply quick fix for a single problem | Quick Fix Diagnostic |
Fix rule in entire file | Apply quick fix for all problems related to the same rule in the current file | Quick Fix Diagnostic |
Disable rule for this line | Disable rule only for current line | Quick Fix Diagnostic |
Disable rule for this entire file | Disable rule in the entire file | Quick Fix Diagnostic |
Disable rule for this entire project | Updates configuration file (usually .groovylintrc.js in root folder) to disable this rule |
Quick Fix Diagnostic |
- Contextual: *right click in source code or on folder_
- Commands: *Ctrl+Shift+P then type command name_
- Status bar: GroovyLint status item at the bottom right
- Quick Fix: Hover an underlined part of the code after a lint, click Quick Fix then select action to perform
- Diagnostic: Right click on a diagnostic in Problems section
Parameter | Description | Default |
---|---|---|
groovyLint.enable |
Controls whether GroovyLint is enabled or not | true |
groovyLint.lint.trigger |
Run the linter on save (onSave), on type (onType) , or on user request | onSave |
groovyLint.format.enable |
Controls whether the groovy formatter is enabled or not | true |
groovyLint.fix.enable |
Run the auto-fixer on save (onSave), on type (onType) , or on user request | true |
groovyLint.fix.trigger |
Run the fixer on save (onSave), or on user request | user |
groovyLint.basic.loglevel |
Linting error level (error, warning,info) | info |
groovyLint.basic.verbose |
Turn on to have verbose logs | false |
groovyLint.basic.config |
NPM groovy lint configuration file | .groovylintrc.json |
groovyLint.debug.enable |
Display more logs in VsCode Output panel (select "GroovyLint") for issue investigation | false |
groovyLint.java.executable |
Override java executable to use Example: C:\Program Files\Java\jdk1.8.0_144\bin\java.exe |
java |
groovyLint.java.options |
Override java options to use | "-Xms256m,-Xmx2048m" |
groovyLint.insight.enable |
Allow to send anonymous usage statistics used only to improve the tool (we will of course never send your code) | false |
groovyLint.showProblemsView |
Show Problems View once after start | false |
-
Node.js version 18 or higher is required to run this extension. If you can't upgrade, you can use nvm to have different node versions on your computer
-
Java version 17 or higher is required to run this extension
-
As CodeNarc is run in background with java/groovy, performances could be improved on large files (do not hesitate to provide advices !) But do not worry, as the groovy linting is provided by a background local server, your VsCode won't be slowed.
Contributions are very welcome on :
- VsCode Groovy Lint
- NPM Groovy Lint (linter called by this extension)
Please follow Contribution instructions
-
stevenh, for his huge refactoring of npm-groovy-lint and vscode-groovy-lint, saving them from deprecation :)
-
yuvmel, for his great support on #18 that allowed VsCode Groovy Lint to work much better on Mac, Linux, and with other diagnostic extensions
- Added new setting
showProblemsView
that controls if Problems View should open after initial lint pass - Fix doc deployment
- Add stale workflow
- Update all packages, to address security issues and bring in the latest version of npm-groovy-lint and related fixes.
- Refactor of tests to more reliable, including being independent of each other so if one test fails others are not effected.
- Fix partial fixes never applying due to npm-groovy-lint v10.0.0 breaking change.
- Fix Analyze Groovy files in folder (#177)
- Debug sessions correctly enable debugging by default including npm-groovy-lint.
- Upgrade MegaLinter and fix related issues
-
Upgrade to npm-groovy-lint v10.0.0
- Upgrade to CodeNarc 3.1.0
- Many fixes and enhancements (see npm-groovy-lint release note)
-
UI
- Better display for issues contextual menu
-
Fixes
- Wrong lines highlighted when spaces are replaced by tabs
- Document should not be reopened if closed without saving
- Some errors were displayed at the beginning of the file instead of the good line
- Wrong diagnostics lines are format or fix
- Fix bug when file diagnostics is stuck with message
GroovyLint is analyzing code...
(#157) - CI: Upgrade to MegaLinter v6
- Upgrade to npm-groovy-lint v9.5.0
- Disable telemetry by default
- Disable telemetry by default (#93)
- Fix crash when npm-groovy-lint does not return results (#141)
- Upgrade to npm-groovy-lint v9.3.2
- Upgrade cli-progress to avoid colors lib boring but harmless hack
- Upgrade to npm-groovy-lint v9.3.1
- Fix issue when used as module and with file containing spaces (#137)
- Upgrade to npm-groovy-lint v9.3.0
- Upgrade again log4j to avoid security flaw
- Upgrade to npm-groovy-lint v9.2.0
- Upgrade again log4j to avoid security flaw
- Upgrade to npm-groovy-lint v9.1.0
- Upgrade log4j to avoid security flaw
- Detect Jenkinsfile
- Fix TS error & package-lock.json version
- Upgrade to npm-groovy-lint v9.0.0
- Upgrade to CodeNarc 2.2
- Adds Groovy 3.0.9 support.
- Fix use of VsCode setting groovyLint.basic.config to use a generic npm-groovy-lint configuration file
- Upgrade to MegaLinter v5 and move config in .mega-linter.yml file
- Upgrade to npm-groovy-lint v8.1.0
- Exclude
UnnecessaryGetter
,FactoryMethodName
,MethodReturnTypeRequired
, andGStringExpressionWithinString
inrecommended-jenkinsfile
(#140) (Felipe Santos)
- Exclude
- Upgrade to npm-groovy-lint v8.0.0
- Upgrade to CodeNarc 2.0.0
- Improve performances
- Fix bugs
- Upgrade to npm-groovy-lint v7.5.4
- Upgrade to npm-groovy-lint v7.5.2
- Fix crash when empty groovy file
- Fix crash when non-sense groovy file
- Fix bug on Windows when username contains space(s)
- Allow user to hide future npm-groovy-lint error messages
- Manage correctly user choice
Never
for tabs auto-replacement by spaces - Upgrade to npm-groovy-lint v7.4.0
- Upgrade to npm-groovy-lint v7.3.0
- Allow to link to CodeNarc RuleSet files from
.groovylintrc.json
, using property"codenarcRulesets"
. Warning: doing so means that all other properties of config file will be ignored.
- Allow to link to CodeNarc RuleSet files from
- Upgrade to npm-groovy-lint v7.2.0
- Upgradejava-caller to v2.0.0 : better performances
- Upgrade to npm-groovy-lint v7.1.0
- Externalize JavaCaller class into a separate package java-caller and use it
See complete CHANGELOG