npm-groovy-lint
Advanced tools
Comparing version
# Changelog | ||
## [4.4.0] 2020-04-16 | ||
- Cancel a CodeNarc Lint when a similar CodeNarcServer request is received (allowing onType mode for language servers) | ||
## [4.3.0] 2020-04-14 | ||
@@ -4,0 +8,0 @@ |
@@ -38,3 +38,3 @@ // Call CodeNarc by server or java | ||
// If use of --codenarcargs, get default values for CodeNarcServer host & port | ||
const serverUri = this.getCodeNarcServerUri(); | ||
const requestUri = this.getCodeNarcServerUri() + "/request"; | ||
// Remove "" around values because they won't get thru system command line parser | ||
@@ -52,7 +52,8 @@ const codeNarcArgsForServer = this.codenarcArgs.map(codeNarcArg => { | ||
method: "POST", | ||
uri: serverUri, | ||
uri: requestUri, | ||
body: { | ||
codeNarcArgs: codeNarcArgsString, | ||
parse: this.options.parse ? true : false, | ||
file: this.execOpts.groovyFileName ? this.execOpts.groovyFileName : null | ||
file: this.execOpts.groovyFileName ? this.execOpts.groovyFileName : null, | ||
requestKey: this.execOpts.requestKey || null | ||
}, | ||
@@ -80,2 +81,8 @@ json: true | ||
} | ||
} | ||
// Cancelled codeNarcAction (duplicate) | ||
else if (e.cause && e.cause.code == "ECONNRESET") { | ||
return { | ||
status: 9 | ||
}; | ||
} else { | ||
@@ -97,2 +104,10 @@ console.error("CodeNarcServer http call unexpected error:\n" + JSON.stringify(e, null, 2)); | ||
} | ||
// Cancelled codeNarcAction (duplicate) (TODO: Update CodeNarcServer.groovy to cleanly stop task and not kill the thread !) | ||
else if (parsedBody.status === "cancelledByDuplicateRequest") { | ||
return { | ||
codeNarcStdOut: parsedBody.stdout, | ||
codeNarcStdErr: parsedBody.stderr, | ||
status: 9 | ||
}; | ||
} | ||
// Codenarc error | ||
@@ -99,0 +114,0 @@ else { |
@@ -42,3 +42,3 @@ // Filter errors | ||
const linePos = errItem.line - 1; | ||
const line = allLines[linePos] || ''; | ||
const line = allLines[linePos] || ""; | ||
const ruleName = errItem.rule; | ||
@@ -59,3 +59,3 @@ | ||
// groovylint-disable-next-line in previous line | ||
const lineConfigNextLine = parseGroovyLintComment("groovylint-disable-next-line", allLines[linePos - 1] || ''); | ||
const lineConfigNextLine = parseGroovyLintComment("groovylint-disable-next-line", allLines[linePos - 1] || ""); | ||
if (checkMatch(lineConfigNextLine, ruleName)) { | ||
@@ -62,0 +62,0 @@ return true; |
@@ -22,2 +22,3 @@ #! /usr/bin/env node | ||
origin = "initialCall"; | ||
requestKey; | ||
jdeployFile; | ||
@@ -58,2 +59,3 @@ jdeployFilePlanB; | ||
this.origin = internalOpts.origin || this.origin; | ||
this.requestKey = internalOpts.requestKey; | ||
} | ||
@@ -140,2 +142,17 @@ | ||
// Kill running CodeNarcServer | ||
if (this.options.killserver) { | ||
const startPerf = performance.now(); | ||
const codeNarcCaller = new CodeNarcCaller(this.codenarcArgs, this.serverStatus, this.args, this.options, { | ||
jdeployFile: this.jdeployFile, | ||
jdeployFilePlanB: this.jdeployFilePlanB, | ||
jdeployRootPath: this.jdeployRootPath, | ||
groovyFileName: this.tmpGroovyFileName | ||
}); | ||
this.outputString = await codeNarcCaller.killCodeNarcServer(); | ||
console.info(this.outputString); | ||
this.manageStats(startPerf); | ||
return false; | ||
} | ||
// Show version | ||
@@ -176,17 +193,2 @@ if (this.options.version) { | ||
// Kill running CodeNarcServer | ||
if (this.options.killserver) { | ||
const startPerf = performance.now(); | ||
const codeNarcCaller = new CodeNarcCaller(this.codenarcArgs, this.serverStatus, this.args, this.options, { | ||
jdeployFile: this.jdeployFile, | ||
jdeployFilePlanB: this.jdeployFilePlanB, | ||
jdeployRootPath: this.jdeployRootPath, | ||
groovyFileName: this.tmpGroovyFileName | ||
}); | ||
this.outputString = await codeNarcCaller.killCodeNarcServer(); | ||
console.info(this.outputString); | ||
this.manageStats(startPerf); | ||
return false; | ||
} | ||
// Prepare CodeNarc call then set result on NpmGroovyLint instance | ||
@@ -212,3 +214,4 @@ const codeNarcFactoryResult = await prepareCodeNarcCall(this.options, this.jdeployRootPath); | ||
jdeployRootPath: this.jdeployRootPath, | ||
groovyFileName: this.tmpGroovyFileName ? this.tmpGroovyFileName : null | ||
groovyFileName: this.tmpGroovyFileName ? this.tmpGroovyFileName : null, | ||
requestKey: this.requestKey || null | ||
}); | ||
@@ -227,4 +230,8 @@ if (!this.options.noserver) { | ||
async postProcess() { | ||
// Cancelled request | ||
if (this.status === 9) { | ||
console.info(`GroovyLint: Request cancelled by duplicate call on requestKey ${this.requestKey}`); | ||
} | ||
// CodeNarc error | ||
if ((this.codeNarcStdErr && [null, "", undefined].includes(this.codeNarcStdOut)) || this.status > 0) { | ||
else if ((this.codeNarcStdErr && [null, "", undefined].includes(this.codeNarcStdOut)) || this.status > 0) { | ||
this.status = 2; | ||
@@ -231,0 +238,0 @@ console.error("GroovyLint: Error running CodeNarc: \n" + this.codeNarcStdErr); |
{ | ||
"name": "npm-groovy-lint", | ||
"version": "4.3.1", | ||
"version": "4.4.0", | ||
"description": "NPM CodeNarc wrapper to easily lint Groovy files", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
16379886
0.07%98
1.03%4846
0.46%