npm-groovy-lint 14.0.1 → 14.1.1-beta202401152058.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/lib/codenarc-caller.js
CHANGED
|
@@ -6,7 +6,6 @@ const trace = require("debug")("npm-groovy-lint-trace");
|
|
|
6
6
|
const { JavaCaller } = require("java-caller");
|
|
7
7
|
const optionsDefinition = require("./options");
|
|
8
8
|
const { performance } = require("perf_hooks");
|
|
9
|
-
const { getSourceLines } = require("./utils");
|
|
10
9
|
const c = require("chalk");
|
|
11
10
|
|
|
12
11
|
// Request over IPv4 because Java typically prefers it.
|
|
@@ -68,9 +67,8 @@ class CodeNarcCaller {
|
|
|
68
67
|
codeNarcBaseDir: this.execOpts.codeNarcBaseDir,
|
|
69
68
|
codeNarcIncludes: this.execOpts.codeNarcIncludes,
|
|
70
69
|
codeNarcExcludes: this.execOpts.codeNarcExcludes,
|
|
71
|
-
parse: this.options.parse !== false && this.execOpts.onlyCodeNarc === false
|
|
72
|
-
|
|
73
|
-
fileList: this.execOpts.inputFileList || null,
|
|
70
|
+
parse: this.options.parse !== false && this.execOpts.onlyCodeNarc === false,
|
|
71
|
+
fileList: this.execOpts.groovyFileName ? [this.execOpts.groovyFileName] : this.execOpts.inputFileList,
|
|
74
72
|
requestKey: this.execOpts.requestKey || null
|
|
75
73
|
},
|
|
76
74
|
timeout: 600000
|
|
@@ -93,9 +91,17 @@ class CodeNarcCaller {
|
|
|
93
91
|
if ((await this.startCodeNarcServer()) && this.serverStatus === "running") {
|
|
94
92
|
return await this.callCodeNarcServer(true);
|
|
95
93
|
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
} else if (e.code === "ERR_BAD_REQUEST") {
|
|
95
|
+
// Bad request.
|
|
96
|
+
return {
|
|
97
|
+
status: e.response.data.statusCode,
|
|
98
|
+
error: {
|
|
99
|
+
msg: `exception: ${e.response.data.exceptionType} message: ${e.response.data.errorMessage}`,
|
|
100
|
+
stack: e.stack,
|
|
101
|
+
responseData: e.response.data.errorDtl
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
} else if (e.code === "ECONNRESET") {
|
|
99
105
|
// The server was shutdown just retry.
|
|
100
106
|
if (startServerTried === false && (await this.startCodeNarcServer()) && this.serverStatus === "running") {
|
|
101
107
|
return await this.callCodeNarcServer(true);
|
|
@@ -110,12 +116,7 @@ class CodeNarcCaller {
|
|
|
110
116
|
} else {
|
|
111
117
|
console.error(
|
|
112
118
|
c.red(
|
|
113
|
-
"CodeNarcServer unexpected error:\n" +
|
|
114
|
-
JSON.stringify(e, null, 2) +
|
|
115
|
-
"\n" +
|
|
116
|
-
(e.response && e.response.data && e.response.data.errorDtl
|
|
117
|
-
? JSON.stringify(e.response.data.errorDtl, null, 2)
|
|
118
|
-
: undefined)
|
|
119
|
+
"CodeNarcServer unexpected error:\n" + JSON.stringify(e, null, 2) + "\n" + JSON.stringify(e.response?.data?.errorDtl, null, 2)
|
|
119
120
|
)
|
|
120
121
|
);
|
|
121
122
|
}
|
|
@@ -125,7 +126,7 @@ class CodeNarcCaller {
|
|
|
125
126
|
error: {
|
|
126
127
|
msg: e.message,
|
|
127
128
|
stack: e.stack,
|
|
128
|
-
responseData: e.response
|
|
129
|
+
responseData: e.response?.data?.errorDtl
|
|
129
130
|
}
|
|
130
131
|
};
|
|
131
132
|
}
|
|
@@ -160,7 +161,7 @@ class CodeNarcCaller {
|
|
|
160
161
|
codeNarcStdErr: response.data.errorDtl,
|
|
161
162
|
status: 1,
|
|
162
163
|
error: {
|
|
163
|
-
msg: `
|
|
164
|
+
msg: `exception: ${response.data.exceptionType} message: ${response.data.errorMessage}`,
|
|
164
165
|
msgDtl: {
|
|
165
166
|
parseErrors: response.data.parseErrors,
|
|
166
167
|
stdout: response.data.stdout,
|
|
@@ -173,7 +174,19 @@ class CodeNarcCaller {
|
|
|
173
174
|
// Call CodeNard java class
|
|
174
175
|
async callCodeNarcJava(secondAttempt = false) {
|
|
175
176
|
// Build java codenarc command (request to launch server for next call except if --noserver is sent)
|
|
176
|
-
const scriptArgs = this.codenarcArgs;
|
|
177
|
+
const scriptArgs = [...this.codenarcArgs]; // Take a copy of the args so we can modify it.
|
|
178
|
+
|
|
179
|
+
if (this.options.parse !== false && this.execOpts.onlyCodeNarc === false) {
|
|
180
|
+
scriptArgs.unshift("--parse");
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (this.execOpts.groovyFileName) {
|
|
184
|
+
scriptArgs.unshift("--file", this.execOpts.groovyFileName);
|
|
185
|
+
} else if (this.execOpts.inputFileList) {
|
|
186
|
+
this.execOpts.inputFileList.forEach(file => {
|
|
187
|
+
scriptArgs.unshift("--file", file);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
177
190
|
|
|
178
191
|
// Start progress bar
|
|
179
192
|
trace(`CALL CodeNarcJava with ${scriptArgs.join(" ")}`);
|
|
@@ -239,8 +252,11 @@ class CodeNarcCaller {
|
|
|
239
252
|
}
|
|
240
253
|
}
|
|
241
254
|
|
|
255
|
+
const response = await this.getCodeNarcServerJson(javaResult.stdout);
|
|
242
256
|
return {
|
|
243
|
-
codeNarcJsonResult:
|
|
257
|
+
codeNarcJsonResult: response.jsonResult,
|
|
258
|
+
fileList: response.fileList,
|
|
259
|
+
parseErrors: response.parseErrors,
|
|
244
260
|
codeNarcStdOut: javaResult.stdout,
|
|
245
261
|
codeNarcStdErr: javaResult.stderr,
|
|
246
262
|
status: 0
|
|
@@ -411,19 +427,19 @@ class CodeNarcCaller {
|
|
|
411
427
|
return (this.options.serverhost || serverOptions.serverhost) + ":" + (this.options.serverport || serverOptions.serverport);
|
|
412
428
|
}
|
|
413
429
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
430
|
+
/**
|
|
431
|
+
* Parse JSON result from CodeNarcServer.
|
|
432
|
+
*
|
|
433
|
+
* @param {string} response the response from CodeNarcServer
|
|
434
|
+
* @returns {Promise<*>}
|
|
435
|
+
* @private
|
|
436
|
+
*/
|
|
437
|
+
async getCodeNarcServerJson(response) {
|
|
438
|
+
try {
|
|
439
|
+
return JSON.parse(response);
|
|
440
|
+
} catch (e) {
|
|
441
|
+
return { err: `Unable to parse ${response}` };
|
|
425
442
|
}
|
|
426
|
-
return {};
|
|
427
443
|
}
|
|
428
444
|
}
|
|
429
445
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/java/logback.xml
CHANGED
|
@@ -5,6 +5,25 @@
|
|
|
5
5
|
<import class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"/>
|
|
6
6
|
<import class="ch.qos.logback.core.ConsoleAppender"/>
|
|
7
7
|
|
|
8
|
+
<if condition='isDefined("logging.appender.file.level")'>
|
|
9
|
+
<then>
|
|
10
|
+
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
|
11
|
+
<file>${logging.appender.file.fileName:-npm-groovy-lint.log}</file>
|
|
12
|
+
<append>${logging.appender.file.append:-true}</append>
|
|
13
|
+
<immediateFlush>${logging.appender.file.flush:-true}</immediateFlush>
|
|
14
|
+
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
|
15
|
+
<level>${logging.appender.file.level:-OFF}</level>
|
|
16
|
+
</filter>
|
|
17
|
+
<encoder>
|
|
18
|
+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
|
19
|
+
</encoder>
|
|
20
|
+
</appender>
|
|
21
|
+
<root>
|
|
22
|
+
<appender-ref ref="FILE"/>
|
|
23
|
+
</root>
|
|
24
|
+
</then>
|
|
25
|
+
</if>
|
|
26
|
+
|
|
8
27
|
<appender name="STDERR" class="ConsoleAppender">
|
|
9
28
|
<target>System.err</target>
|
|
10
29
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
|
@@ -15,20 +34,7 @@
|
|
|
15
34
|
</encoder>
|
|
16
35
|
</appender>
|
|
17
36
|
|
|
18
|
-
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
|
19
|
-
<file>${logging.appender.file.fileName:-logback.log}</file>
|
|
20
|
-
<append>true</append>
|
|
21
|
-
<immediateFlush>true</immediateFlush>
|
|
22
|
-
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
|
23
|
-
<level>${logging.appender.file.level:-OFF}</level>
|
|
24
|
-
</filter>
|
|
25
|
-
<encoder>
|
|
26
|
-
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
|
27
|
-
</encoder>
|
|
28
|
-
</appender>
|
|
29
|
-
|
|
30
37
|
<root>
|
|
31
|
-
<appender-ref ref="FILE"/>
|
|
32
38
|
<appender-ref ref="STDERR"/>
|
|
33
39
|
</root>
|
|
34
40
|
</configuration>
|