npm-groovy-lint 8.2.0 → 9.3.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.
- package/CHANGELOG.md +24 -1
- package/README.md +8 -5
- package/lib/.groovylintrc-all.json +6 -0
- package/lib/codenarc-caller.js +16 -8
- package/lib/config.js +2 -2
- package/lib/example/RuleSet-All.groovy +417 -409
- package/lib/example/SampleFile.groovy +0 -8
- package/lib/example/SampleFileSmall.groovy +0 -6
- package/lib/example/SampleFileSmallFixed.txt +0 -5
- package/lib/example/SampleFileSmallFormatted.txt +0 -6
- package/lib/groovy-lint-fix.js +0 -2
- package/lib/groovy-lint.js +0 -2
- package/lib/java/CodeNarc-2.2.0.jar +0 -0
- package/lib/java/CodeNarcServer.jar +0 -0
- package/lib/java/groovy/lib/{ant-1.10.8.jar → ant-1.10.11.jar} +0 -0
- package/lib/java/groovy/lib/ant-launcher-1.10.11.jar +0 -0
- package/lib/java/groovy/lib/{groovy-3.0.5.jar → groovy-3.0.9.jar} +0 -0
- package/lib/java/groovy/lib/{groovy-ant-3.0.5.jar → groovy-ant-3.0.9.jar} +0 -0
- package/lib/java/groovy/lib/{groovy-json-3.0.5.jar → groovy-json-3.0.9.jar} +0 -0
- package/lib/java/groovy/lib/{groovy-templates-3.0.5.jar → groovy-templates-3.0.9.jar} +0 -0
- package/lib/java/groovy/lib/{groovy-xml-3.0.5.jar → groovy-xml-3.0.9.jar} +0 -0
- package/lib/java/log4j-api-2.17.1.jar +0 -0
- package/lib/java/log4j-core-2.17.1.jar +0 -0
- package/lib/java/log4j-slf4j-impl-2.17.1.jar +0 -0
- package/package.json +16 -14
- package/lib/java/CodeNarc-2.0.0.jar +0 -0
- package/lib/java/groovy/lib/ant-launcher-1.10.8.jar +0 -0
- package/lib/java/log4j-api-2.13.0.jar +0 -0
- package/lib/java/log4j-core-2.13.0.jar +0 -0
- package/lib/java/log4j-slf4j-impl-2.13.0.jar +0 -0
- package/lib/test/errors.test.js +0 -92
- package/lib/test/helpers/common.js +0 -84
- package/lib/test/helpers/init.js +0 -29
- package/lib/test/lint-api.test.js +0 -221
- package/lib/test/lint-build-fix.test.js +0 -43
- package/lib/test/lint-build-format.test.js +0 -43
- package/lib/test/lint-build.test.js +0 -168
- package/lib/test/lint-comments.test.js +0 -197
- package/lib/test/lint-fix.rules.test.js +0 -71
- package/lib/test/lint-fix.test.js +0 -224
- package/lib/test/lint-format.test.js +0 -293
- package/lib/test/miscellaneous.test.js +0 -326
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## UNRELEASED
|
|
4
|
+
|
|
5
|
+
## [9.3.0] 2021-12-29
|
|
6
|
+
|
|
7
|
+
- Upgrade log4j dependencies because of [security issue](https://nvd.nist.gov/vuln/detail/CVE-2021-44832).
|
|
8
|
+
|
|
9
|
+
## [9.2.0] 2021-12-23
|
|
10
|
+
|
|
11
|
+
- Upgrade log4j dependencies because of (another) [security issue](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-45105) (#196)
|
|
12
|
+
|
|
13
|
+
## [9.1.0] 2021-12-14
|
|
14
|
+
|
|
15
|
+
- Upgrade log4j dependencies because of [security issue](https://unit42.paloaltonetworks.com/apache-log4j-vulnerability-cve-2021-44228/) (#194)
|
|
16
|
+
|
|
17
|
+
## [9.0.0] 2021-09-30
|
|
18
|
+
|
|
19
|
+
- Upgrade to [CodeNarc v2.2.0](https://github.com/CodeNarc/CodeNarc/releases/tag/v2.2.0)
|
|
20
|
+
- Upgrade to [Groovy v3.0.9](https://groovy-lang.org/)
|
|
21
|
+
- Reorganize sources test folder
|
|
22
|
+
- Use java from 8 to 14 (install it if a later version is found)
|
|
23
|
+
- Add timeouts in CI jobs
|
|
24
|
+
- Add colors in error logs
|
|
25
|
+
|
|
26
|
+
## [8.2.0] 2021-06-11
|
|
4
27
|
|
|
5
28
|
- Upgrade dependencies advised by dependabot
|
|
6
29
|
- Fix Mega-Linter errors found
|
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
|
|
@@ -73,8 +75,9 @@ Any **question**, **problem** or **enhancement request** ? Ask [**here**](https:
|
|
|
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 = {
|
|
@@ -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": {},
|
package/lib/codenarc-caller.js
CHANGED
|
@@ -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.
|
|
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.17.1.jar:java/log4j-api-2.17.1.jar:java/log4j-core-2.17.1.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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
|
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
|
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: "
|
|
15
|
-
GroovyVersion: "3.0.
|
|
14
|
+
CodeNarcVersion: "2.2.0",
|
|
15
|
+
GroovyVersion: "3.0.9"
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
const configLintFilenames = [
|