npm-groovy-lint 15.2.1 → 15.2.2
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/rules/UnnecessaryGString.js +9 -1
- package/lib/utils.js +14 -1
- package/package.json +2 -2
|
@@ -32,7 +32,7 @@ const rule = {
|
|
|
32
32
|
const str = getVariable(variables, "STRING", { mandatory: true });
|
|
33
33
|
// Single line replacement: replace " by '
|
|
34
34
|
if (range.start.line === range.end.line) {
|
|
35
|
-
allLines[lineNumber] = allLines[lineNumber].replace(`"${str}"`, `'${str}'`);
|
|
35
|
+
allLines[lineNumber] = allLines[lineNumber].replace(`"""${str}"""`, `'''${str}'''`).replace(`"${str}"`, `'${str}'`);
|
|
36
36
|
}
|
|
37
37
|
// Multiline replacement: replace """ by '''
|
|
38
38
|
else {
|
|
@@ -95,6 +95,14 @@ I am a string"""
|
|
|
95
95
|
sourceAfter: `
|
|
96
96
|
def b = '''
|
|
97
97
|
I am a string'''
|
|
98
|
+
`,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
sourceBefore: `
|
|
102
|
+
def b = """I am a string"""
|
|
103
|
+
`,
|
|
104
|
+
sourceAfter: `
|
|
105
|
+
def b = '''I am a string'''
|
|
98
106
|
`,
|
|
99
107
|
},
|
|
100
108
|
],
|
package/lib/utils.js
CHANGED
|
@@ -358,8 +358,21 @@ function moveOpeningBracket(allLines, variables) {
|
|
|
358
358
|
if (allLines[realPos - 1].trim().replace(/ /g, "").includes("){")) {
|
|
359
359
|
throw new Error("Fix not applied: probably a CodeNarc false positive");
|
|
360
360
|
}
|
|
361
|
+
|
|
362
|
+
// Check if the line contains a comment and insert bracket before it
|
|
363
|
+
const targetLine = allLines[realPos - 2];
|
|
364
|
+
const commentIndex = targetLine.indexOf("//");
|
|
365
|
+
let addedBracketLine;
|
|
366
|
+
|
|
367
|
+
if (commentIndex !== -1) {
|
|
368
|
+
// Insert bracket before the comment
|
|
369
|
+
const beforeComment = targetLine.substring(0, commentIndex).trimEnd();
|
|
370
|
+
const comment = targetLine.substring(commentIndex);
|
|
371
|
+
addedBracketLine = beforeComment + " { " + comment;
|
|
372
|
+
} else {
|
|
361
373
|
// Add bracket after if
|
|
362
|
-
|
|
374
|
+
addedBracketLine = targetLine.trimEnd() + " {";
|
|
375
|
+
}
|
|
363
376
|
allLines[realPos - 2] = addedBracketLine;
|
|
364
377
|
// Remove bracket which was on the wrong line
|
|
365
378
|
const removedBracketLine = allLines[realPos - 1].substring(allLines[realPos - 1].indexOf("{") + 1).trimEnd();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-groovy-lint",
|
|
3
|
-
"version": "15.2.
|
|
3
|
+
"version": "15.2.2",
|
|
4
4
|
"description": "Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files",
|
|
5
5
|
"exports": "./lib/groovy-lint.js",
|
|
6
6
|
"type": "module",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"node-sarif-builder": "^3.0.0",
|
|
66
66
|
"optionator": "^0.9.0",
|
|
67
67
|
"strip-json-comments": "^5.0.0",
|
|
68
|
-
"uuid": "^
|
|
68
|
+
"uuid": "^13.0.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@babel/core": "^7.23.2",
|