Skip to content

Commit 439a0f8

Browse files
committed
Update compiled outputs and version number
1 parent 062b56d commit 439a0f8

File tree

7 files changed

+80
-66
lines changed

7 files changed

+80
-66
lines changed

dist/github/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function getMatchLineRegexString(toolName) {
3030
}
3131
const MATCH_LINE_REGEX_GROUPS = (exports.MATCH_LINE_KEYS
3232
.map((key, index) => ([key, index + 1]))
33-
.reduce((obj, keyAndMatchGroup) => (Object.assign(Object.assign({}, obj), { [keyAndMatchGroup[0]]: keyAndMatchGroup[1] })), {}));
33+
.reduce((obj, [key, matchGroup]) => (Object.assign(Object.assign({}, obj), { [key]: matchGroup })), {}));
3434
function getMatcherPatternObj(toolName) {
3535
return Object.assign({ regexp: getMatchLineRegexString(toolName) }, MATCH_LINE_REGEX_GROUPS);
3636
}

dist/hlint/index.js

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,53 +29,60 @@ const HLINT_SEV_TO_GITHUB_SEV = {
2929
Suggestion: 'warning',
3030
Ignore: 'warning',
3131
};
32-
// Use JSON escaping to turn messages with newlines and such into a single line
32+
/**
33+
* Use JSON escaping to turn messages with newlines and such into a single line.
34+
*/
3335
function escapeString(str, quote) {
3436
const jsonEscaped = JSON.stringify(str).replace(/\n/g, ' ');
3537
// Possibly drop the surrounding quotes
3638
return quote ? jsonEscaped : jsonEscaped.slice(1, jsonEscaped.length - 1);
3739
}
38-
function getNiceMessage(hint) {
40+
/**
41+
* Combine the non-"poblemMatcher" fields of an "idea" into
42+
* a single line as a human-readable message.
43+
*
44+
* Fields are visually separated by a box character (' ▫︎ ').
45+
*/
46+
function getNiceMessage(idea) {
3947
const prefixParts = [];
40-
prefixParts.push(hint.severity);
41-
if (hint.decl && hint.decl.length) {
42-
prefixParts.push(`in ${hint.decl.join(', ')}`);
48+
prefixParts.push(idea.severity);
49+
if (idea.decl && idea.decl.length) {
50+
prefixParts.push(`in ${idea.decl.join(', ')}`);
4351
}
44-
if (hint.module && hint.module.length) {
45-
prefixParts.push(`in module ${hint.module.join('.')}`);
52+
if (idea.module && idea.module.length) {
53+
prefixParts.push(`in module ${idea.module.join('.')}`);
4654
}
4755
const prefix = prefixParts.join(' ');
4856
const messageParts = [];
49-
messageParts.push();
50-
messageParts.push(hint.hint);
51-
if (hint.from) {
52-
messageParts.push(`Found: ${escapeString(hint.from, true)}`);
57+
messageParts.push(idea.hint);
58+
if (idea.from) {
59+
messageParts.push(`Found: ${escapeString(idea.from, true)}`);
5360
}
54-
if (hint.to) {
55-
messageParts.push(`Perhaps: ${escapeString(hint.to, true)}`);
61+
if (idea.to) {
62+
messageParts.push(`Perhaps: ${escapeString(idea.to, true)}`);
5663
}
57-
if (hint.note && hint.note.length) {
58-
messageParts.push(`Note: ${hint.note.map(n => escapeString(n, false)).join(' ')}`);
64+
if (idea.note && idea.note.length) {
65+
messageParts.push(`Note: ${idea.note.map(n => escapeString(n, false)).join(' ')}`);
5966
}
6067
const message = messageParts.join(' ▫︎ ');
6168
return [prefix, message].filter(Boolean).join(': ');
6269
}
63-
function toMatchableProblem(hint) {
64-
const { file, startLine: line, startColumn: column, hint: code, severity: hlintSev } = hint;
70+
function toMatchableProblem(idea) {
71+
const { file, startLine: line, startColumn: column, hint: code, severity: hlintSev } = idea;
6572
return {
6673
file,
6774
line,
6875
column,
6976
severity: HLINT_SEV_TO_GITHUB_SEV[hlintSev],
7077
code,
71-
message: getNiceMessage(hint),
78+
message: getNiceMessage(idea),
7279
};
7380
}
7481
exports.MATCHER = new github_1.SingleLineMatcherFormat('hlint');
7582
// NOTE: Because ncc compiles all the files, take not to use __dirname here.
7683
// This path is relative to the repo root. (Possibly meaning cwd, but not necessarily).
7784
exports.MATCHER_DEF_PATH = path.join('.github', 'hlint.json');
78-
function serializeProblem(hint) {
79-
return exports.MATCHER.serialize(toMatchableProblem(hint));
85+
function serializeProblem(idea) {
86+
return exports.MATCHER.serialize(toMatchableProblem(idea));
8087
}
8188
exports.serializeProblem = serializeProblem;

dist/index.js

Lines changed: 39 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/outputs.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
2020
};
2121
Object.defineProperty(exports, "__esModule", { value: true });
2222
const core = __importStar(require("@actions/core"));
23-
const OUTPUT_KEY_HLINT_HINTS = 'hints';
23+
const OUTPUT_KEY_HLINT_IDEAS = 'ideas';
2424
function setOutputs(result) {
25-
const { ok, hints, statusCode, hintSummary } = result;
26-
core.setOutput(OUTPUT_KEY_HLINT_HINTS, hints);
25+
const { ok, ideas, statusCode, hintSummary } = result;
26+
core.setOutput(OUTPUT_KEY_HLINT_IDEAS, ideas);
2727
if (ok) {
2828
if (hintSummary.length) {
2929
core.info(`HLint finished with hints: ${hintSummary}`);

dist/run.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ function runHLint(cmd, args) {
4343
core.info(`Running ${cmd} ${args.join(' ')}`);
4444
const { stdout: hlintOutputStr, statusCode } = yield bufferedExec_1.default(cmd, args);
4545
core.info(`hlint completed with status code ${statusCode}`);
46-
const hints = JSON.parse(hlintOutputStr);
47-
hints.map(hlint_1.serializeProblem).forEach(line => console.log(line));
48-
return { hints, statusCode };
46+
const ideas = JSON.parse(hlintOutputStr);
47+
ideas.map(hlint_1.serializeProblem).forEach(line => console.log(line));
48+
return { ideas, statusCode };
4949
});
5050
}
51-
function getOverallCheckResult(failOn, { hints, statusCode }) {
52-
const hintsBySev = hlint_1.SEVERITY_LEVELS.map(sev => ([sev, hints.filter(hint => hint.severity === sev).length]));
51+
function getOverallCheckResult(failOn, { ideas, statusCode }) {
52+
const hintsBySev = hlint_1.SEVERITY_LEVELS.map(sev => ([sev, ideas.filter(hint => hint.severity === sev).length]));
5353
const hintSummary = hintsBySev
5454
.filter(([_sevName, numHints]) => numHints > 0)
5555
.map(([sev, num]) => `${sev} (${num})`).join(', ');
@@ -75,9 +75,9 @@ function run({ baseDir, hlintCmd, pathList, failOn }) {
7575
return __awaiter(this, void 0, void 0, function* () {
7676
const hlintArgs = ['-j', '--json', '--', ...pathList];
7777
const matcherDefPath = path.join(baseDir, hlint_1.MATCHER_DEF_PATH);
78-
const { hints, statusCode } = yield withMatcherAtPath_1.default(matcherDefPath, () => runHLint(hlintCmd, hlintArgs));
79-
const { ok, hintSummary } = getOverallCheckResult(failOn, { hints, statusCode });
80-
return { ok, statusCode, hints, hintSummary };
78+
const { ideas, statusCode } = yield withMatcherAtPath_1.default(matcherDefPath, () => runHLint(hlintCmd, hlintArgs));
79+
const { ok, hintSummary } = getOverallCheckResult(failOn, { ideas, statusCode });
80+
return { ok, statusCode, ideas, hintSummary };
8181
});
8282
}
8383
exports.default = run;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rwe/actions-hlint",
3-
"version": "1.0.0",
3+
"version": "2.0.0",
44
"description": "GitHub Action: Run HLint",
55
"main": "dist/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)