-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue where importing pmd would cause CI failures, add some sourc…
…emaps Signed-off-by: Taylor Smock <[email protected]>
- Loading branch information
Showing
14 changed files
with
112 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,10 @@ | ||
import { debug, getInput, setFailed } from "@actions/core"; | ||
import { readFileSync } from "fs"; | ||
import { XMLParser } from "fast-xml-parser"; | ||
import { logProblems } from "./logProblems"; | ||
import { Problem } from "./problem"; | ||
|
||
export { Problem, logProblems }; | ||
|
||
type Violation = { | ||
"@_ruleset": string; | ||
"@_rule": string; | ||
"@_begincolumn": string; | ||
"@_endcolumn": string; | ||
"@_beginline": string; | ||
"@_endline": string; | ||
"@_externalInfoUrl": string; | ||
}; | ||
type FileData = { | ||
violation: Violation[]; | ||
"@_name": string; | ||
}; | ||
|
||
function parseFile(sourceDirectory: string, fileData: FileData): Problem[] { | ||
const file = | ||
(sourceDirectory.length > 0 && !sourceDirectory.endsWith("/") | ||
? sourceDirectory + "/" | ||
: sourceDirectory) + fileData["@_name"]; | ||
const violations = fileData["violation"]; | ||
const problems: Problem[] = []; | ||
for (const violation of violations) { | ||
const title = violation["@_ruleset"] + "/" + violation["@_rule"]; | ||
problems.push({ | ||
file: file, | ||
title: title, | ||
startColumn: parseInt(violation["@_begincolumn"]), | ||
endColumn: parseInt(violation["@_endcolumn"]), | ||
startLine: parseInt(violation["@_beginline"]), | ||
endLine: parseInt(violation["@_endline"]), | ||
info: violation["@_externalInfoUrl"], | ||
}); | ||
} | ||
return problems; | ||
} | ||
|
||
export function parseData( | ||
sourceDirectory: string, | ||
data: string | Buffer, | ||
): Problem[] { | ||
const alwaysArray = ["pmd.file", "pmd.file.violation"]; | ||
const parser = new XMLParser({ | ||
ignoreAttributes: false, | ||
isArray: (name, jpath) => { | ||
return alwaysArray.indexOf(jpath) >= 0; | ||
}, | ||
}); | ||
const parsed = parser.parse(data); | ||
const files = parsed["pmd"]["file"]; | ||
let problems: Problem[] = []; | ||
if (files !== undefined && files !== null) { | ||
for (const file of files) { | ||
problems = problems.concat(parseFile(sourceDirectory, file)); | ||
} | ||
} | ||
return problems; | ||
} | ||
import { getInput, setFailed } from "@actions/core"; | ||
import { run as realRun } from "./pmd"; | ||
|
||
async function run(): Promise<void> { | ||
const pmdFile = getInput("file"); | ||
const sourceDir = getInput("src"); | ||
const data = readFileSync(pmdFile); | ||
debug(data.toString()); | ||
logProblems(parseData(sourceDir, data)); | ||
realRun(sourceDir, pmdFile); | ||
} | ||
|
||
run().catch((err) => setFailed(err)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { debug } from "@actions/core"; | ||
import { readFileSync } from "fs"; | ||
import { XMLParser } from "fast-xml-parser"; | ||
import { logProblems } from "./logProblems"; | ||
import { Problem } from "./problem"; | ||
|
||
export { Problem, logProblems }; | ||
|
||
type Violation = { | ||
"@_ruleset": string; | ||
"@_rule": string; | ||
"@_begincolumn": string; | ||
"@_endcolumn": string; | ||
"@_beginline": string; | ||
"@_endline": string; | ||
"@_externalInfoUrl": string; | ||
}; | ||
type FileData = { | ||
violation: Violation[]; | ||
"@_name": string; | ||
}; | ||
|
||
function parseFile(sourceDirectory: string, fileData: FileData): Problem[] { | ||
const file = | ||
(sourceDirectory.length > 0 && !sourceDirectory.endsWith("/") | ||
? sourceDirectory + "/" | ||
: sourceDirectory) + fileData["@_name"]; | ||
const violations = fileData["violation"]; | ||
const problems: Problem[] = []; | ||
for (const violation of violations) { | ||
const title = violation["@_ruleset"] + "/" + violation["@_rule"]; | ||
problems.push({ | ||
file: file, | ||
title: title, | ||
startColumn: parseInt(violation["@_begincolumn"]), | ||
endColumn: parseInt(violation["@_endcolumn"]), | ||
startLine: parseInt(violation["@_beginline"]), | ||
endLine: parseInt(violation["@_endline"]), | ||
info: violation["@_externalInfoUrl"], | ||
}); | ||
} | ||
return problems; | ||
} | ||
|
||
export function parseData( | ||
sourceDirectory: string, | ||
data: string | Buffer, | ||
): Problem[] { | ||
const alwaysArray = ["pmd.file", "pmd.file.violation"]; | ||
const parser = new XMLParser({ | ||
ignoreAttributes: false, | ||
isArray: (name, jpath) => { | ||
return alwaysArray.indexOf(jpath) >= 0; | ||
}, | ||
}); | ||
const parsed = parser.parse(data); | ||
const files = parsed["pmd"]["file"]; | ||
let problems: Problem[] = []; | ||
if (files !== undefined && files !== null) { | ||
for (const file of files) { | ||
problems = problems.concat(parseFile(sourceDirectory, file)); | ||
} | ||
} | ||
return problems; | ||
} | ||
|
||
export function run(sourceDir: string, pmdFile: string) { | ||
const data = readFileSync(pmdFile); | ||
debug(data.toString()); | ||
logProblems(parseData(sourceDir, data)); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.