npm-groovy-lint 8.1.0 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +38 -35
  3. package/lib/.groovylintrc-all.json +6 -0
  4. package/lib/.groovylintrc-format.json +43 -43
  5. package/lib/.groovylintrc-recommended-jenkinsfile.json +17 -17
  6. package/lib/.groovylintrc-recommended.json +42 -42
  7. package/lib/analytics.js +2 -2
  8. package/lib/codenarc-caller.js +16 -8
  9. package/lib/codenarc-factory.js +1 -1
  10. package/lib/config.js +7 -7
  11. package/lib/example/Jenkinsfile +1 -1
  12. package/lib/example/RuleSet-All.groovy +417 -409
  13. package/lib/example/SampleFile.groovy +0 -8
  14. package/lib/example/SampleFileSmall.groovy +0 -6
  15. package/lib/example/SampleFileSmallFixed.txt +0 -5
  16. package/lib/example/SampleFileSmallFormatted.txt +0 -6
  17. package/lib/groovy-lint-fix.js +0 -2
  18. package/lib/groovy-lint.js +1 -3
  19. package/lib/java/CodeNarc-2.2.0.jar +0 -0
  20. package/lib/java/CodeNarcServer.jar +0 -0
  21. package/lib/java/groovy/lib/{ant-1.10.8.jar → ant-1.10.11.jar} +0 -0
  22. package/lib/java/groovy/lib/ant-launcher-1.10.11.jar +0 -0
  23. package/lib/java/groovy/lib/{groovy-3.0.5.jar → groovy-3.0.9.jar} +0 -0
  24. package/lib/java/groovy/lib/{groovy-ant-3.0.5.jar → groovy-ant-3.0.9.jar} +0 -0
  25. package/lib/java/groovy/lib/{groovy-json-3.0.5.jar → groovy-json-3.0.9.jar} +0 -0
  26. package/lib/java/groovy/lib/{groovy-templates-3.0.5.jar → groovy-templates-3.0.9.jar} +0 -0
  27. package/lib/java/groovy/lib/{groovy-xml-3.0.5.jar → groovy-xml-3.0.9.jar} +0 -0
  28. package/lib/java/log4j-api-2.16.0.jar +0 -0
  29. package/lib/java/log4j-core-2.16.0.jar +0 -0
  30. package/lib/java/log4j-slf4j-impl-2.16.0.jar +0 -0
  31. package/lib/rules/JavaIoPackageAccess.js +1 -1
  32. package/package.json +17 -15
  33. package/lib/java/CodeNarc-2.0.0.jar +0 -0
  34. package/lib/java/groovy/lib/ant-launcher-1.10.8.jar +0 -0
  35. package/lib/java/log4j-api-2.13.0.jar +0 -0
  36. package/lib/java/log4j-core-2.13.0.jar +0 -0
  37. package/lib/java/log4j-slf4j-impl-2.13.0.jar +0 -0
  38. package/lib/test/errors.test.js +0 -92
  39. package/lib/test/helpers/common.js +0 -84
  40. package/lib/test/helpers/init.js +0 -29
  41. package/lib/test/lint-api.test.js +0 -221
  42. package/lib/test/lint-build-fix.test.js +0 -43
  43. package/lib/test/lint-build-format.test.js +0 -43
  44. package/lib/test/lint-build.test.js +0 -168
  45. package/lib/test/lint-comments.test.js +0 -197
  46. package/lib/test/lint-fix.rules.test.js +0 -71
  47. package/lib/test/lint-fix.test.js +0 -224
  48. package/lib/test/lint-format.test.js +0 -293
  49. package/lib/test/miscellaneous.test.js +0 -326
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## UNRELEASED
4
+
5
+ ## [9.1.0] 2021-12-14
6
+
7
+ - Upgrade log4j dependencies because of [security issue](https://unit42.paloaltonetworks.com/apache-log4j-vulnerability-cve-2021-44228/) (#194)
8
+
9
+ ## [9.0.0] 2021-09-30
10
+
11
+ - Upgrade to [CodeNarc v2.2.0](https://github.com/CodeNarc/CodeNarc/releases/tag/v2.2.0)
12
+ - Upgrade to [Groovy v3.0.9](https://groovy-lang.org/)
13
+ - Reorganize sources test folder
14
+ - Use java from 8 to 14 (install it if a later version is found)
15
+ - Add timeouts in CI jobs
16
+ - Add colors in error logs
17
+
18
+ ## [8.2.0] 2021-06-11
19
+
20
+ - Upgrade dependencies advised by dependabot
21
+ - Fix Mega-Linter errors found
22
+
3
23
  ## [8.1.0] 2020-12-14
4
24
 
5
25
  - Exclude `UnnecessaryGetter`, `FactoryMethodName`, `MethodReturnTypeRequired`, and `GStringExpressionWithinString` in `recommended-jenkinsfile` ([#140](https://github.com/nvuillam/npm-groovy-lint/pull/140)) ([Felipe Santos](https://github.com/felipecrs))
package/README.md CHANGED
@@ -16,6 +16,8 @@
16
16
 
17
17
  ## Groovy & Jenkinsfile Linter, Formatter and Auto-fixer
18
18
 
19
+ _**New: The [article about the story of npm-groovy-lint](https://nicolas.vuillamy.fr/a-groovy-journey-to-open-source-during-covid-19-npm-groovy-lint-8d88c7eecebc), and why you should dive in open-source community !**_
20
+
19
21
  Based on [CodeNarc](http://codenarc.github.io/CodeNarc/) , this out of the box package allows to **track groovy errors** and **correct a part of them**
20
22
 
21
23
  - Use option **--format** to format & prettify source code
@@ -27,7 +29,7 @@ You can also use this package in :
27
29
 
28
30
  - [Visual Studio Code Groovy Lint extension](https://marketplace.visualstudio.com/items?itemName=NicolasVuillamy.vscode-groovy-lint)
29
31
  - [Mega-Linter](https://nvuillam.github.io/mega-linter/) (can be used as GitHub Action, and lints all other languages and formats)
30
- - [Docker Image](#call-via-docker)
32
+ - [Docker Image](#other)
31
33
 
32
34
  ![image](https://github.com/nvuillam/npm-groovy-lint/raw/master/docs/assets/images/npm-groovy-lint-results.png)
33
35
 
@@ -41,40 +43,41 @@ Any **question**, **problem** or **enhancement request** ? Ask [**here**](https:
41
43
  npm-groovy-lint OPTIONS
42
44
  ```
43
45
 
44
- | Parameter | Type | Description |
45
- |--------------------------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
46
- | -p<br/> --path | String | Directory containing the files to lint<br/> Example: `./path/to/my/groovy/files` |
47
- | -f<br/> --files | String | Comma-separated list of Ant-style file patterns specifying files that must be included.<br/> Default: `"**/*.groovy,**/Jenkinsfile,**/*.gradle"`<br/>Examples:<br/> - `"**/Jenkinsfile"`<br/> - `"**/*.groovy"`<br/> - `"**/*.gradle"`<br/> - `"**/mySingleFile.groovy"` |
48
- | -o<br/> --output | String | Output format (txt,json,html,xml), or path to a file with one of these extensions<br/> Default: `txt`<br/> Examples:<br/> - `"txt"`<br/> - `"json"`<br/> - `"./logs/myLintResults.txt"`<br/> - `"./logs/myLintResults.json"`<br/> - `"./logs/myLintResults.html"`<br/> - `"./logs/myLintResults.xml"` |
49
- | -l<br/> --loglevel | String | Log level (error,warning or info)<br/>Default: info |
50
- | --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. |
51
- | -c<br/> --config | String | Custom path to [GroovyLint config file](#Configuration), or preset config `recommended|recommended-jenkinsfile|all`<br/> Default: Browse current directory to find `.groovylintrc.json|js|yml|package.json` config file, or default npm-groovy-lint config if not defined.<br/>Note: command-line arguments have priority on config file properties |
52
- | --parse | Boolean | Try to compile the source code and return parse errors (since v5.7.0, default to true, use --no-parse to deactivate) |
53
- | --format | Boolean | Format source code |
54
- | --fix | Boolean | Automatically fix problems when possible<br/> See [Autofixable rules](#Autofixable-rules) |
55
- | -x<br/> --fixrules | String | Option for --fix argument: List of rule identifiers to fix (if not specified, all available fixes will be applied). See [Autofixable rules](#Autofixable-rules) <br/> Examples:<br/> - `"SpaceBeforeClosingBrace,SpaceAfterClosingBrace,UnusedImport"`<br/> - `"Indentation"`<br/> |
56
- | --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 |
57
- | -r<br/> --rulesets | String | [RuleSet file(s)](http://codenarc.github.io/CodeNarc/codenarc-creating-ruleset.html) to use for linting, if you do not want to use recommended rules or .groovylintrc.js defined rules.<br/>If list of comma separated strings corresponding to CodeNarc rules, a RuleSet file will be dynamically generated </br> Examples:<br/> - `"./config/codenarc/RuleSet-Custom.groovy"`<br/> - `"./path/to/my/ruleset/files"`<br/>- `Indentation{"spacesPerIndentLevel":2,"severity":"warning"},UnnecessarySemicolon,UnnecessaryGString` |
58
- | --rulesetsoverridetype | String | If list of rules sent in rulesets option, defines if they replace rules defined in .groovylintrc.json, or if they are appended<br/> Values: `replaceConfig` (default), `appendConfig` |
59
- | -s<br/> --source | String | If path and files are not set, you can directly send the source code string to analyze |
60
- | --verbose | Boolean | More outputs in console, including performed fixes |
61
- | -i<br/> --ignorepattern | String | Comma-separated list of Ant-style file patterns specifying files that must be ignored<br/> Default: none<br/> Example: `"**/test/*""` |
62
- | --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 |
63
- | --returnrules | Boolean | Return rules descriptions and URL if set |
64
- | --javaexecutable | String | Override java executable to use <br/>Default: java<br/>Example: C:\\Program Files\\Java\\jdk1.8.0_144\\bin\\java.exe |
65
- | --javaoptions | String | Override java options to use <br/>Default: "-Xms256m,-Xmx2048m" |
66
- | --no-insight | Boolean | npm-groovy-lint collects anonymous usage statistics using [amplitude](https://www.npmjs.com/package/amplitude), in order to make new improvements based on how users use this package. <br/> Summary charts are available at [https://tinyurl.com/groovy-stats](https://tinyurl.com/groovy-stats).<br/> Analytics obviously does not receive sensitive information like your code, as you can see in [analytics.js](https://github.com/nvuillam/npm-groovy-lint/blob/master/lib/analytics.js).<br/> If you want to disable anonymous usage statistics, use `--no-insight` option. |
67
- | --codenarcargs | String | Use core CodeNarc arguments (all npm-groovy-lint arguments will be ignored)<br/> Doc: <http://codenarc.github.io/CodeNarc/codenarc-command-line.html><br/> Example: `npm-groovy-lint --codenarcargs -basedir="lib/example" -rulesetfiles="file:lib/example/RuleSet-Groovy.groovy" -maxPriority1Violations=0 -report="xml:ReportTestCodenarc.xml` |
68
- | -h<br/> --help | Boolean | Show help (npm-groovy-lint -h OPTIONNAME to see option detail with examples) |
69
- | -v<br/> --version | Boolean | Show npm-groovy-lint version (with CodeNarc version) |
46
+ | Parameter | Type | Description |
47
+ |-------------------------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
48
+ | -p<br/> --path | String | Directory containing the files to lint<br/> Example: `./path/to/my/groovy/files` |
49
+ | -f<br/> --files | String | Comma-separated list of Ant-style file patterns specifying files that must be included.<br/> Default: `"**/*.groovy,**/Jenkinsfile,**/*.gradle"`<br/>Examples:<br/> - `"**/Jenkinsfile"`<br/> - `"**/*.groovy"`<br/> - `"**/*.gradle"`<br/> - `"**/mySingleFile.groovy"` |
50
+ | -o<br/> --output | String | Output format (txt,json,html,xml), or path to a file with one of these extensions<br/> Default: `txt`<br/> Examples:<br/> - `"txt"`<br/> - `"json"`<br/> - `"./logs/myLintResults.txt"`<br/> - `"./logs/myLintResults.json"`<br/> - `"./logs/myLintResults.html"`<br/> - `"./logs/myLintResults.xml"` |
51
+ | -l<br/> --loglevel | String | Log level (error,warning or info)<br/>Default: info |
52
+ | --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. |
53
+ | -c<br/> --config | String | Custom path to [GroovyLint config file](#Configuration), or preset config `recommended|recommended-jenkinsfile|all`<br/> Default: Browse current directory to find `.groovylintrc.json|js|yml|package.json` config file, or default npm-groovy-lint config if not defined.<br/>Note: command-line arguments have priority on config file properties |
54
+ | --parse | Boolean | Try to compile the source code and return parse errors (since v5.7.0, default to true, use --no-parse to deactivate) |
55
+ | --format | Boolean | Format source code |
56
+ | --fix | Boolean | Automatically fix problems when possible<br/> See [Autofixable rules](#Autofixable-rules) |
57
+ | -x<br/> --fixrules | String | Option for --fix argument: List of rule identifiers to fix (if not specified, all available fixes will be applied). See [Autofixable rules](#Autofixable-rules) <br/> Examples:<br/> - `"SpaceBeforeClosingBrace,SpaceAfterClosingBrace,UnusedImport"`<br/> - `"Indentation"`<br/> |
58
+ | --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 |
59
+ | -r<br/> --rulesets | String | [RuleSet file(s)](http://codenarc.github.io/CodeNarc/codenarc-creating-ruleset.html) to use for linting, if you do not want to use recommended rules or .groovylintrc.js defined rules.<br/>If list of comma separated strings corresponding to CodeNarc rules, a RuleSet file will be dynamically generated </br> Examples:<br/> - `"./config/codenarc/RuleSet-Custom.groovy"`<br/> - `"./path/to/my/ruleset/files"`<br/>- `Indentation{"spacesPerIndentLevel":2,"severity":"warning"},UnnecessarySemicolon,UnnecessaryGString` |
60
+ | --rulesetsoverridetype | String | If list of rules sent in rulesets option, defines if they replace rules defined in .groovylintrc.json, or if they are appended<br/> Values: `replaceConfig` (default), `appendConfig` |
61
+ | -s<br/> --source | String | If path and files are not set, you can directly send the source code string to analyze |
62
+ | --verbose | Boolean | More outputs in console, including performed fixes |
63
+ | -i<br/> --ignorepattern | String | Comma-separated list of Ant-style file patterns specifying files that must be ignored<br/> Default: none<br/> Example: `"**/test/*""` |
64
+ | --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 |
65
+ | --returnrules | Boolean | Return rules descriptions and URL if set |
66
+ | --javaexecutable | String | Override java executable to use <br/>Default: java<br/>Example: C:\\Program Files\\Java\\jdk1.8.0_144\\bin\\java.exe |
67
+ | --javaoptions | String | Override java options to use <br/>Default: "-Xms256m,-Xmx2048m" |
68
+ | --no-insight | Boolean | npm-groovy-lint collects anonymous usage statistics using [amplitude](https://www.npmjs.com/package/amplitude), in order to make new improvements based on how users use this package. <br/> Summary charts are available at [https://tinyurl.com/groovy-stats](https://tinyurl.com/groovy-stats).<br/> Analytics obviously does not receive sensitive information like your code, as you can see in [analytics.js](https://github.com/nvuillam/npm-groovy-lint/blob/master/lib/analytics.js).<br/> If you want to disable anonymous usage statistics, use `--no-insight` option. |
69
+ | --codenarcargs | String | Use core CodeNarc arguments (all npm-groovy-lint arguments will be ignored)<br/> Doc: <http://codenarc.github.io/CodeNarc/codenarc-command-line.html><br/> Example: `npm-groovy-lint --codenarcargs -basedir="lib/example" -rulesetfiles="file:lib/example/RuleSet-Groovy.groovy" -maxPriority1Violations=0 -report="xml:ReportTestCodenarc.xml` |
70
+ | -h<br/> --help | Boolean | Show help (npm-groovy-lint -h OPTIONNAME to see option detail with examples) |
71
+ | -v<br/> --version | Boolean | Show npm-groovy-lint version (with CodeNarc version) |
70
72
 
71
73
  ## Installation
72
74
 
73
75
  ```shell
74
76
  npm install -g npm-groovy-lint
75
77
  ```
76
-
77
- Node.js >= 12 is required to run this package. If you can't upgrade, you can use [nvm](https://github.com/nvm-sh/nvm) to have [different node versions on your computer](https://www.sitepoint.com/quick-tip-multiple-versions-node-nvm/)
78
+ - If you have issues with v9, install previous version with `npm install -g npm-groovy-lint@8.2.0`
79
+ - Node.js >= 12 is required to run this package. If you can't upgrade, you can use [nvm](https://github.com/nvm-sh/nvm) to have [different node versions on your computer](https://www.sitepoint.com/quick-tip-multiple-versions-node-nvm/)
80
+ - 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.
78
81
 
79
82
  ## Configuration
80
83
 
@@ -343,13 +346,13 @@ node {
343
346
  Run with default settings
344
347
 
345
348
  ```shell
346
- docker run -u "$(id -u):$(id -g)" -w=/tmp -v "$PWD":/tmp nvuillam/npm-groovy-lint
349
+ docker run --rm -u "$(id -u):$(id -g)" -w=/tmp -v "$PWD":/tmp nvuillam/npm-groovy-lint
347
350
  ```
348
351
 
349
352
  Run with additional flags by simply appending them at after docker image name:
350
353
 
351
354
  ```shell
352
- docker run -u "$(id -u):$(id -g)" -w=/tmp -v "$PWD":/tmp nvuillam/npm-groovy-lint --failon warning --verbose
355
+ docker run --rm -u "$(id -u):$(id -g)" -w=/tmp -v "$PWD":/tmp nvuillam/npm-groovy-lint --failon warning --verbose
353
356
  ```
354
357
 
355
358
  ### Other
@@ -367,7 +370,7 @@ Example
367
370
  ```
368
371
 
369
372
  ```javascript
370
- const NpmGroovyLint = require("npm-groovy-lint/groovy-lint.js");
373
+ const NpmGroovyLint = require("npm-groovy-lint/lib/groovy-lint.js");
371
374
  const fse = require("fs-extra");
372
375
 
373
376
  const npmGroovyLintConfig = {
@@ -400,9 +403,9 @@ Please follow [Contribution instructions](https://github.com/nvuillam/npm-groovy
400
403
 
401
404
  ### Contributors
402
405
 
403
- [<img alt="nvuillam" src="https://avatars1.githubusercontent.com/u/17500430?v=4&s=50 width=50">](https://github.com/nvuillam) |[<img alt="Dave Gallant" src="https://avatars2.githubusercontent.com/u/4519234?v=4&s=50 width=50">](https://github.com/davegallant) |[<img alt="warhod" src="https://avatars1.githubusercontent.com/u/1305176?v=4&s=50 width=50">](https://github.com/warhod) |[<img alt="pawelkopka" src="https://avatars1.githubusercontent.com/u/17784034?v=4&s=50 width=50">](https://github.com/pawelkopka) |[<img alt="docwhat" src="https://avatars1.githubusercontent.com/u/40799?v=4&s=50 width=50">](https://github.com/docwhat) |[<img alt="CatSue" src="https://avatars3.githubusercontent.com/u/26134618?v=4&s=50 width=50">](https://github.com/CatSue) |
404
- :---:|:---:|:---:|:---:|:---:|:---:|
405
- [Nicolas Vuillamy](https://github.com/nvuillam)|[Dave Gallant](https://github.com/davegallant)|[Howard Lo](https://github.com/warhod)|[Pawel Kopka](https://github.com/pawelkopka)|[docwhat](https://github.com/docwhat)|[CatSue](https://github.com/CatSue)|
406
+ [<img alt="nvuillam" src="https://avatars1.githubusercontent.com/u/17500430?v=4&s=50 width=50">](https://github.com/nvuillam) | [<img alt="Dave Gallant" src="https://avatars2.githubusercontent.com/u/4519234?v=4&s=50 width=50">](https://github.com/davegallant) | [<img alt="warhod" src="https://avatars1.githubusercontent.com/u/1305176?v=4&s=50 width=50">](https://github.com/warhod) | [<img alt="pawelkopka" src="https://avatars1.githubusercontent.com/u/17784034?v=4&s=50 width=50">](https://github.com/pawelkopka) | [<img alt="docwhat" src="https://avatars1.githubusercontent.com/u/40799?v=4&s=50 width=50">](https://github.com/docwhat) | [<img alt="CatSue" src="https://avatars3.githubusercontent.com/u/26134618?v=4&s=50 width=50">](https://github.com/CatSue)
407
+ :----------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------:
408
+ [Nicolas Vuillamy](https://github.com/nvuillam) | [Dave Gallant](https://github.com/davegallant) | [Howard Lo](https://github.com/warhod) | [Pawel Kopka](https://github.com/pawelkopka) | [docwhat](https://github.com/docwhat) | [CatSue](https://github.com/CatSue)
406
409
 
407
410
  ## Release notes
408
411
 
@@ -39,6 +39,7 @@
39
39
  "basic.HardCodedWindowsRootDirectory": {},
40
40
  "basic.IntegerGetInteger": {},
41
41
  "basic.MultipleUnaryOperators": {},
42
+ "basic.ParameterAssignmentInFilterClosure": {},
42
43
  "basic.RandomDoubleCoercedToZero": {},
43
44
  "basic.RemoveAllOnSelf": {},
44
45
  "basic.ReturnFromFinallyBlock": {},
@@ -185,11 +186,15 @@
185
186
  "formatting.LineLength": {},
186
187
  "formatting.MissingBlankLineAfterImports": {},
187
188
  "formatting.MissingBlankLineAfterPackage": {},
189
+ "formatting.MissingBlankLineBeforeAnnotatedField": {},
188
190
  "formatting.SpaceAfterCatch": {},
189
191
  "formatting.SpaceAfterClosingBrace": {},
190
192
  "formatting.SpaceAfterComma": {},
191
193
  "formatting.SpaceAfterFor": {},
192
194
  "formatting.SpaceAfterIf": {},
195
+ "formatting.SpaceAfterMethodCallName": {},
196
+ "formatting.SpaceAfterMethodDeclarationName": {},
197
+ "formatting.SpaceAfterNotOperator": {},
193
198
  "formatting.SpaceAfterOpeningBrace": {},
194
199
  "formatting.SpaceAfterSemicolon": {},
195
200
  "formatting.SpaceAfterSwitch": {},
@@ -199,6 +204,7 @@
199
204
  "formatting.SpaceAroundOperator": {},
200
205
  "formatting.SpaceBeforeClosingBrace": {},
201
206
  "formatting.SpaceBeforeOpeningBrace": {},
207
+ "formatting.SpaceInsideParentheses": {},
202
208
  "formatting.TrailingWhitespace": {},
203
209
  "generic.IllegalClassMember": {},
204
210
  "generic.IllegalClassReference": {},
@@ -1,45 +1,45 @@
1
1
  {
2
- "rules": {
3
- "braces.ElseBlockBraces": {},
4
- "braces.ForStatementBraces": {},
5
- "braces.IfStatementBraces": {},
6
- "braces.WhileStatementBraces": {},
7
- "convention.NoTabCharacter": {},
8
- "formatting.BlankLineBeforePackage": {},
9
- "formatting.BlockEndsWithBlankLine": {},
10
- "formatting.BlockStartsWithBlankLine": {},
11
- "formatting.BracesForClass": {},
12
- "formatting.BracesForForLoop": {},
13
- "formatting.BracesForIfElse": {},
14
- "formatting.BracesForMethod": {},
15
- "formatting.BracesForTryCatchFinally": {},
16
- "formatting.ClassEndsWithBlankLine": {},
17
- "formatting.ClassStartsWithBlankLine": {},
18
- "formatting.ClosureStatementOnOpeningLineOfMultipleLineClosure": {},
19
- "formatting.ConsecutiveBlankLines": {},
20
- "formatting.FileEndsWithoutNewline": {},
21
- "formatting.Indentation": {
22
- "spacesPerIndentLevel": 4,
23
- "severity": "info"
24
- },
25
- "formatting.MissingBlankLineAfterImports": {},
26
- "formatting.MissingBlankLineAfterPackage": {},
27
- "formatting.SpaceAfterCatch": {},
28
- "formatting.SpaceAfterClosingBrace": {},
29
- "formatting.SpaceAfterComma": {},
30
- "formatting.SpaceAfterFor": {},
31
- "formatting.SpaceAfterIf": {},
32
- "formatting.SpaceAfterOpeningBrace": {},
33
- "formatting.SpaceAfterSemicolon": {},
34
- "formatting.SpaceAfterSwitch": {},
35
- "formatting.SpaceAfterWhile": {},
36
- "formatting.SpaceAroundClosureArrow": {},
37
- "formatting.SpaceAroundMapEntryColon": {},
38
- "formatting.SpaceAroundOperator": {},
39
- "formatting.SpaceBeforeClosingBrace": {},
40
- "formatting.SpaceBeforeOpeningBrace": {},
41
- "formatting.TrailingWhitespace": {},
42
- "unnecessary.UnnecessaryGString": {},
43
- "unnecessary.UnnecessarySemicolon": {}
44
- }
2
+ "rules": {
3
+ "braces.ElseBlockBraces": {},
4
+ "braces.ForStatementBraces": {},
5
+ "braces.IfStatementBraces": {},
6
+ "braces.WhileStatementBraces": {},
7
+ "convention.NoTabCharacter": {},
8
+ "formatting.BlankLineBeforePackage": {},
9
+ "formatting.BlockEndsWithBlankLine": {},
10
+ "formatting.BlockStartsWithBlankLine": {},
11
+ "formatting.BracesForClass": {},
12
+ "formatting.BracesForForLoop": {},
13
+ "formatting.BracesForIfElse": {},
14
+ "formatting.BracesForMethod": {},
15
+ "formatting.BracesForTryCatchFinally": {},
16
+ "formatting.ClassEndsWithBlankLine": {},
17
+ "formatting.ClassStartsWithBlankLine": {},
18
+ "formatting.ClosureStatementOnOpeningLineOfMultipleLineClosure": {},
19
+ "formatting.ConsecutiveBlankLines": {},
20
+ "formatting.FileEndsWithoutNewline": {},
21
+ "formatting.Indentation": {
22
+ "spacesPerIndentLevel": 4,
23
+ "severity": "info"
24
+ },
25
+ "formatting.MissingBlankLineAfterImports": {},
26
+ "formatting.MissingBlankLineAfterPackage": {},
27
+ "formatting.SpaceAfterCatch": {},
28
+ "formatting.SpaceAfterClosingBrace": {},
29
+ "formatting.SpaceAfterComma": {},
30
+ "formatting.SpaceAfterFor": {},
31
+ "formatting.SpaceAfterIf": {},
32
+ "formatting.SpaceAfterOpeningBrace": {},
33
+ "formatting.SpaceAfterSemicolon": {},
34
+ "formatting.SpaceAfterSwitch": {},
35
+ "formatting.SpaceAfterWhile": {},
36
+ "formatting.SpaceAroundClosureArrow": {},
37
+ "formatting.SpaceAroundMapEntryColon": {},
38
+ "formatting.SpaceAroundOperator": {},
39
+ "formatting.SpaceBeforeClosingBrace": {},
40
+ "formatting.SpaceBeforeOpeningBrace": {},
41
+ "formatting.TrailingWhitespace": {},
42
+ "unnecessary.UnnecessaryGString": {},
43
+ "unnecessary.UnnecessarySemicolon": {}
44
+ }
45
45
  }
@@ -1,20 +1,20 @@
1
1
  {
2
- "extends": "recommended",
3
- "rules": {
4
- "convention.CompileStatic": "off",
5
- "convention.NoDef": "off",
6
- "convention.VariableTypeRequired": "off",
7
- "convention.MethodReturnTypeRequired": "off",
8
- "groovyism.ExplicitCallToEqualsMethod": "off",
9
- "groovyism.GStringExpressionWithinString": "off",
10
- "naming.VariableName": "off",
11
- "naming.FactoryMethodName": "off",
12
- "unnecessary.UnnecessaryGetter": "off",
13
- "size.NestedBlockDepth": {
14
- "maxNestedBlockDepth": 10
15
- },
16
- "unused.UnusedVariable": {
17
- "ignoreVariableNames": "_"
18
- }
2
+ "extends": "recommended",
3
+ "rules": {
4
+ "convention.CompileStatic": "off",
5
+ "convention.NoDef": "off",
6
+ "convention.VariableTypeRequired": "off",
7
+ "convention.MethodReturnTypeRequired": "off",
8
+ "groovyism.ExplicitCallToEqualsMethod": "off",
9
+ "groovyism.GStringExpressionWithinString": "off",
10
+ "naming.VariableName": "off",
11
+ "naming.FactoryMethodName": "off",
12
+ "unnecessary.UnnecessaryGetter": "off",
13
+ "size.NestedBlockDepth": {
14
+ "maxNestedBlockDepth": 10
15
+ },
16
+ "unused.UnusedVariable": {
17
+ "ignoreVariableNames": "_"
19
18
  }
19
+ }
20
20
  }
@@ -1,44 +1,44 @@
1
1
  {
2
- "extends": "all",
3
- "rules": {
4
- "basic.DeadCode": "error",
5
- "convention.CompileStatic": {
6
- "severity": "info"
7
- },
8
- "convention.FieldTypeRequired": "info",
9
- "convention.IfStatementCouldBeTernary": "info",
10
- "convention.NoDef": "info",
11
- "convention.TrailingComma": "off",
12
- "convention.VariableTypeRequired": "info",
13
- "dry.DuplicateListLiteral": "info",
14
- "dry.DuplicateMapLiteral": "warning",
15
- "dry.DuplicateNumberLiteral": {
16
- "ignoreNumbers": [0, 1, 2, 3, -1],
17
- "severity": "info"
18
- },
19
- "dry.DuplicateStringLiteral": "info",
20
- "exceptions.ThrowException": "info",
21
- "exceptions.ThrowNullPointerException": "info",
22
- "exceptions.ThrowRuntimeException": "info",
23
- "exceptions.ThrowThrowable": "info",
24
- "formatting.BracesForClass": "info",
25
- "formatting.BracesForForLoop": "info",
26
- "formatting.BracesForIfElse": "info",
27
- "formatting.BracesForMethod": "info",
28
- "formatting.BracesForTryCatchFinally": "info",
29
- "formatting.Indentation": {
30
- "spacesPerIndentLevel": 4,
31
- "severity": "info"
32
- },
33
- "formatting.SpaceAroundMapEntryColon": "off",
34
- "groovyism.ExplicitCallToEqualsMethod": "info",
35
- "logging.Println": "off",
36
- "unused.UnusedArray": "error",
37
- "unused.UnusedObject": "error",
38
- "unused.UnusedPrivateField": "error",
39
- "unused.UnusedPrivateMethod": "error",
40
- "unused.UnusedPrivateMethodParameter": "error",
41
- "unused.UnusedVariable": "error",
42
- "unnecessary.UnnecessaryReturnKeyword": "off"
43
- }
2
+ "extends": "all",
3
+ "rules": {
4
+ "basic.DeadCode": "error",
5
+ "convention.CompileStatic": {
6
+ "severity": "info"
7
+ },
8
+ "convention.FieldTypeRequired": "info",
9
+ "convention.IfStatementCouldBeTernary": "info",
10
+ "convention.NoDef": "info",
11
+ "convention.TrailingComma": "off",
12
+ "convention.VariableTypeRequired": "info",
13
+ "dry.DuplicateListLiteral": "info",
14
+ "dry.DuplicateMapLiteral": "warning",
15
+ "dry.DuplicateNumberLiteral": {
16
+ "ignoreNumbers": [0, 1, 2, 3, -1],
17
+ "severity": "info"
18
+ },
19
+ "dry.DuplicateStringLiteral": "info",
20
+ "exceptions.ThrowException": "info",
21
+ "exceptions.ThrowNullPointerException": "info",
22
+ "exceptions.ThrowRuntimeException": "info",
23
+ "exceptions.ThrowThrowable": "info",
24
+ "formatting.BracesForClass": "info",
25
+ "formatting.BracesForForLoop": "info",
26
+ "formatting.BracesForIfElse": "info",
27
+ "formatting.BracesForMethod": "info",
28
+ "formatting.BracesForTryCatchFinally": "info",
29
+ "formatting.Indentation": {
30
+ "spacesPerIndentLevel": 4,
31
+ "severity": "info"
32
+ },
33
+ "formatting.SpaceAroundMapEntryColon": "off",
34
+ "groovyism.ExplicitCallToEqualsMethod": "info",
35
+ "logging.Println": "off",
36
+ "unused.UnusedArray": "error",
37
+ "unused.UnusedObject": "error",
38
+ "unused.UnusedPrivateField": "error",
39
+ "unused.UnusedPrivateMethod": "error",
40
+ "unused.UnusedPrivateMethodParameter": "error",
41
+ "unused.UnusedVariable": "error",
42
+ "unnecessary.UnnecessaryReturnKeyword": "off"
43
+ }
44
44
  }
package/lib/analytics.js CHANGED
@@ -61,8 +61,8 @@ function buildLinterEvent(eventType, data) {
61
61
  if (data.options.rulesets) {
62
62
  payloadFiltered.rulesets = data.options.rulesets;
63
63
  }
64
- if (data.options.overridenRules) {
65
- payloadFiltered.overridenRules = data.options.overridenRules;
64
+ if (data.options.overriddenRules) {
65
+ payloadFiltered.overriddenRules = data.options.overriddenRules;
66
66
  }
67
67
  if (data.options.path) {
68
68
  payloadFiltered.optionPath = data.options.path;
@@ -6,6 +6,7 @@ const { JavaCaller } = require("java-caller");
6
6
  const optionsDefinition = require("./options");
7
7
  const { performance } = require("perf_hooks");
8
8
  const { getSourceLines } = require("./utils");
9
+ const c = require("chalk");
9
10
 
10
11
  class CodeNarcCaller {
11
12
  "use strict";
@@ -27,16 +28,18 @@ class CodeNarcCaller {
27
28
  javaCallerOptions = {
28
29
  codeNarcServer: {
29
30
  minimumJavaVersion: 8,
31
+ maximumJavaVersion: 14,
30
32
  rootPath: __dirname,
31
33
  mainClass: "com.nvuillam.CodeNarcServer",
32
34
  classPath: "java/CodeNarcServer.jar:java/*"
33
35
  },
34
36
  codeNarcJava: {
35
37
  minimumJavaVersion: 8,
38
+ maximumJavaVersion: 14,
36
39
  rootPath: __dirname,
37
40
  mainClass: "org.codenarc.CodeNarc",
38
41
  classPath:
39
- "java/CodeNarc-2.0.0.jar:java/groovy/lib/groovy-3.0.5.jar:java/groovy/lib/groovy-templates-3.0.5.jar:java/groovy/lib/groovy-xml-3.0.5.jar:java/groovy/lib/groovy-json-3.0.5.jar:java/groovy/lib/groovy-ant-3.0.5.jar:java/groovy/lib/ant-1.10.8.jar:java/groovy/lib/ant-launcher-1.10.8.jar:java/slf4j-api-1.7.9.jar:java/log4j-slf4j-impl-2.13.0.jar:java/log4j-api-2.13.0.jar:java/log4j-core-2.13.0.jar:java/gmetrics-1.1.jar:java/*"
42
+ "java/CodeNarc-2.2.0.jar:java/groovy/lib/groovy-3.0.9.jar:java/groovy/lib/groovy-templates-3.0.9.jar:java/groovy/lib/groovy-xml-3.0.9.jar:java/groovy/lib/groovy-json-3.0.9.jar:java/groovy/lib/groovy-ant-3.0.9.jar:java/groovy/lib/ant-1.10.11.jar:java/groovy/lib/ant-launcher-1.10.11.jar:java/slf4j-api-1.7.9.jar:java/log4j-slf4j-impl-2.16.0.jar:java/log4j-api-2.16.0.jar:java/log4j-core-2.16.0.jar:java/gmetrics-1.1.jar:java/*"
40
43
  }
41
44
  };
42
45
 
@@ -103,10 +106,14 @@ class CodeNarcCaller {
103
106
  };
104
107
  } else {
105
108
  console.error(
106
- "CodeNarcServer unexpected error:\n" +
107
- JSON.stringify(e, null, 2) +
108
- "\n" +
109
- (e.response && e.response.data && e.response.data.errorDtl ? JSON.stringify(e.response.data.errorDtl, null, 2) : undefined)
109
+ c.red(
110
+ "CodeNarcServer unexpected error:\n" +
111
+ JSON.stringify(e, null, 2) +
112
+ "\n" +
113
+ (e.response && e.response.data && e.response.data.errorDtl
114
+ ? JSON.stringify(e.response.data.errorDtl, null, 2)
115
+ : undefined)
116
+ )
110
117
  );
111
118
  }
112
119
  this.serverStatus = "error";
@@ -255,7 +262,8 @@ class CodeNarcCaller {
255
262
  const javaCallRes = await javaCaller.run(scriptArgs, { detached: true, waitForErrorMs: 500 });
256
263
 
257
264
  if ([666, 1].includes(javaCallRes.status)) {
258
- console.error(`Unable to run java command: ${JSON.stringify(javaCallRes)}`);
265
+ console.error(c.red(`Unable to start CodeNarc server: ${JSON.stringify(javaCallRes)}`));
266
+ console.error(c.grey(JSON.stringify(scriptArgs)));
259
267
  this.serverStatus = "error";
260
268
  return false;
261
269
  }
@@ -296,7 +304,7 @@ class CodeNarcCaller {
296
304
  });
297
305
 
298
306
  if (this.serverStatus === "running") {
299
- console.log(`GroovyLint: Started CodeNarc Server`);
307
+ console.log(c.green(`GroovyLint: Started CodeNarc Server`));
300
308
  return true;
301
309
  } else {
302
310
  return false;
@@ -312,7 +320,7 @@ class CodeNarcCaller {
312
320
  const errMsg = "GroovyLint: Unable to start CodeNarc Server. Use --noserver if you do not even want to try";
313
321
  debug(errMsg);
314
322
  debug(e.message);
315
- console.error(errMsg);
323
+ console.error(c.grey(errMsg));
316
324
  }
317
325
 
318
326
  // Kill CodeNarc server by telling it to do so
@@ -347,7 +347,7 @@ async function buildRuleSets(options) {
347
347
  if ((ruleSetsDef.length === 0 || options.rulesetsoverridetype === "appendConfig") && options.rules) {
348
348
  for (const ruleName of Object.keys(options.rules)) {
349
349
  let ruleDef = options.rules[ruleName];
350
- // If rule has been overriden in argument, set it on top of config file properties
350
+ // If rule has been overridden in argument, set it on top of config file properties
351
351
  const ruleFromRuleSetsArgPos = ruleSetsDef.findIndex(ruleDef => ruleDef.ruleName === ruleName);
352
352
  if (ruleFromRuleSetsArgPos > -1) {
353
353
  const ruleFromRuleSetsArg = ruleSetsDef[ruleFromRuleSetsArgPos];
package/lib/config.js CHANGED
@@ -11,8 +11,8 @@ const defaultConfigLintFileName = ".groovylintrc-recommended.json";
11
11
  const allConfigLintFileName = ".groovylintrc-all.json";
12
12
 
13
13
  const NPM_GROOVY_LINT_CONSTANTS = {
14
- CodeNarcVersion: "1.6.1",
15
- GroovyVersion: "3.0.5"
14
+ CodeNarcVersion: "2.2.0",
15
+ GroovyVersion: "3.0.9"
16
16
  };
17
17
 
18
18
  const configLintFilenames = [
@@ -31,7 +31,7 @@ const defaultConfigFormatFileName = ".groovylintrc-format.json";
31
31
 
32
32
  const configFormatFilenames = [".groovylintrc-format.json", ".groovylintrc-format.js"];
33
33
 
34
- let overridenRules;
34
+ let overriddenRules;
35
35
 
36
36
  // Load configuration from identified file, or find config file from a start path
37
37
  async function loadConfig(startPathOrFile, mode = "lint", sourcefilepath, fileNamesIn = []) {
@@ -83,8 +83,8 @@ async function loadConfig(startPathOrFile, mode = "lint", sourcefilepath, fileNa
83
83
  }
84
84
  }
85
85
  }
86
- if (overridenRules != null) {
87
- configUser.overridenRules = overridenRules;
86
+ if (overriddenRules != null) {
87
+ configUser.overriddenRules = overriddenRules;
88
88
  }
89
89
  return configUser;
90
90
  }
@@ -198,7 +198,7 @@ async function loadConfigFromFile(filePath) {
198
198
  configLoaded = null;
199
199
  }
200
200
  if (configLoaded != null && !filePath.includes(defaultConfigLintFileName) && !filePath.includes(allConfigLintFileName)) {
201
- overridenRules = configLoaded.rules;
201
+ overriddenRules = configLoaded.rules;
202
202
  }
203
203
  return configLoaded;
204
204
  }
@@ -278,4 +278,4 @@ async function shortenRuleNames(rules) {
278
278
  return shortenedRules;
279
279
  }
280
280
 
281
- module.exports = { NPM_GROOVY_LINT_CONSTANTS, loadConfig, getConfigFileName, overridenRules };
281
+ module.exports = { NPM_GROOVY_LINT_CONSTANTS, loadConfig, getConfigFileName, overriddenRules };