Skip to content

Commit

Permalink
🐛 Fix output issues (QD-6541, QD-7986)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiulpin committed Jan 17, 2024
1 parent 4017c86 commit 5047802
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Set Node.js 16.x
uses: actions/setup-node@v4.0.1
with:
Expand Down
59 changes: 59 additions & 0 deletions scan/__tests__/data/some.sarif.json
Original file line number Diff line number Diff line change
Expand Up @@ -7977,6 +7977,39 @@
}
]
},
{
"id": "RiderSolutionErrorsInspection",
"shortDescription": {
"text": "Rider toolset and environment errors"
},
"fullDescription": {
"text": "Reports toolset and environment errors detected by Rider.",
"markdown": "Reports toolset and environment errors detected by Rider."
},
"defaultConfiguration": {
"enabled": true,
"level": "error",
"parameters": {
"suppressToolId": "RiderSolutionErrorsInspection",
"ideaSeverity": "ERROR",
"qodanaSeverity": "Critical"
}
},
"relationships": [
{
"target": {
"id": "Rider/General",
"index": 134,
"toolComponent": {
"name": "QDNET"
}
},
"kinds": [
"superset"
]
}
]
},
{
"id": "EqualsOrHashCode",
"shortDescription": {
Expand Down Expand Up @@ -8136,6 +8169,32 @@
]
}
},
{
"ruleId": "RiderSolutionErrorsInspection",
"kind": "fail",
"level": "warning",
"message": {
"text": "[NU1101] Unable to find package PrivatePackage. No packages exist with this id in source(s): github at (0:0) Target: ResolvePackageAssets Task: ResolvePackageAssets",
"markdown": "\\[[NU1101](http://www.google.com/search?q=NU1101)\\] Unable to find package PrivatePackage. No packages exist with this id in source(s): github at (0:0) \n\nTarget: ResolvePackageAssets \nTask: ResolvePackageAssets"
},
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"uri": "LibraryReferencingPackage/LibraryReferencingPackage.csproj",
"uriBaseId": "SRCROOT"
}
}
}
],
"partialFingerprints": {
"equalIndicator/v1": "2eb5998cec5651ad1ad36262cf210caa653ab138d3c22e4338d3eea704104bf6"
},
"properties": {
"ideaSeverity": "WARNING",
"qodanaSeverity": "High"
}
},
{
"ruleId": "MayBeConstant",
"kind": "fail",
Expand Down
14 changes: 13 additions & 1 deletion scan/__tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,17 @@ export function annotationsDefaultFixture(): Annotation[] {
start_column: undefined,
end_column: undefined
},
{
annotation_level: 'warning',
message:
'\\[[NU1101](http://www.google.com/search?q=NU1101)\\] Unable to find package PrivatePackage. No packages exist with this id in source(s): github at (0:0) \n\nTarget: ResolvePackageAssets \nTask: ResolvePackageAssets',
end_line: 1,
start_line: 0,
path: 'LibraryReferencingPackage/LibraryReferencingPackage.csproj',
title: 'Rider toolset and environment errors',
start_column: undefined,
end_column: undefined
},
{
annotation_level: 'notice',
message: "Might be 'const'",
Expand Down Expand Up @@ -239,11 +250,12 @@ export function defaultDockerRunCommandFixture(): string[] {
export function markdownSummaryFixture(): string {
return `# [Qodana](https://example.com/report) for JS
**3 new problems** were found
**4 new problems** were found
| Inspection name | Severity | Problems |
| --- | --- | --- |
| \`Control flow with empty body\` | 🔴 Failure | 1 |
| \`Rider toolset and environment errors\` | 🔶 Warning | 1 |
| \`Condition of 'if' expression is constant\` | 🔶 Warning | 1 |
| \`Might be 'const'\` | ◽️ Notice | 1 |
Expand Down
11 changes: 5 additions & 6 deletions scan/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126751,8 +126751,8 @@ ${body}
__name(getViewReportText, "getViewReportText");
function getRowsByLevel(annotations, level) {
const problems = annotations.reduce((map, e) => {
var _a, _b;
return map.set((_a = e.title) !== null && _a !== void 0 ? _a : UNKNOWN_RULE_ID, map.get((_b = e.title) !== null && _b !== void 0 ? _b : UNKNOWN_RULE_ID) !== void 0 ? map.get(e.title) + 1 : 1);
var _a, _b, _c;
return map.set((_a = e.title) !== null && _a !== void 0 ? _a : UNKNOWN_RULE_ID, map.get((_b = e.title) !== null && _b !== void 0 ? _b : UNKNOWN_RULE_ID) !== void 0 ? map.get((_c = e.title) !== null && _c !== void 0 ? _c : UNKNOWN_RULE_ID) + 1 : 1);
}, /* @__PURE__ */ new Map());
return Array.from(problems.entries()).sort((a, b) => b[1] - a[1]).map(([title, count]) => `| \`${title}\` | ${level} | ${count} |`).join("\n");
}
Expand Down Expand Up @@ -126920,7 +126920,6 @@ var require_annotations = __commonJS({
return;
}
try {
problems.summary = problems.summary.replace(`# Qodana`, "");
if (problems.annotations.length >= MAX_ANNOTATIONS) {
for (let i = 0; i < problems.annotations.length; i += MAX_ANNOTATIONS) {
yield (0, utils_12.publishGitHubCheck)(failedByThreshold, name, {
Expand Down Expand Up @@ -126965,7 +126964,7 @@ var require_annotations = __commonJS({
message: (_a = result.message.markdown) !== null && _a !== void 0 ? _a : result.message.text,
title: (_b = rules.get(result.ruleId)) === null || _b === void 0 ? void 0 : _b.shortDescription,
path: location.artifactLocation.uri,
start_line: (region === null || region === void 0 ? void 0 : region.startLine) || 1,
start_line: (region === null || region === void 0 ? void 0 : region.startLine) || 0,
end_line: (region === null || region === void 0 ? void 0 : region.endLine) || (region === null || region === void 0 ? void 0 : region.startLine) || 1,
start_column: (region === null || region === void 0 ? void 0 : region.startLine) === (region === null || region === void 0 ? void 0 : region.endColumn) ? region === null || region === void 0 ? void 0 : region.startColumn : void 0,
end_column: (region === null || region === void 0 ? void 0 : region.startLine) === (region === null || region === void 0 ? void 0 : region.endColumn) ? region === null || region === void 0 ? void 0 : region.endColumn : void 0,
Expand Down Expand Up @@ -127041,8 +127040,8 @@ var require_annotations = __commonJS({
return {
title: a.title,
file: a.path,
startLine: a.start_line,
endLine: a.end_line,
startLine: a.start_line || 0,
endLine: a.end_line || 1,
startColumn: a.start_column,
endColumn: a.end_column
};
Expand Down
9 changes: 4 additions & 5 deletions scan/src/annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export async function publishAnnotations(
return
}
try {
problems.summary = problems.summary.replace(`# Qodana`, '')
if (problems.annotations.length >= MAX_ANNOTATIONS) {
for (let i = 0; i < problems.annotations.length; i += MAX_ANNOTATIONS) {
await publishGitHubCheck(failedByThreshold, name, {
Expand Down Expand Up @@ -92,7 +91,7 @@ export interface Rule {
}

export interface Annotation {
title: string
title: string | undefined
path: string
start_line: number
end_line: number
Expand Down Expand Up @@ -125,7 +124,7 @@ function parseResult(
message: result.message.markdown ?? result.message.text!!,
title: rules.get(result.ruleId!!)?.shortDescription!!,
path: location.artifactLocation!!.uri!!,
start_line: region?.startLine || 1,
start_line: region?.startLine || 0,
end_line: region?.endLine || region?.startLine || 1,
start_column:
region?.startLine === region?.endColumn ? region?.startColumn : undefined,
Expand Down Expand Up @@ -233,8 +232,8 @@ export function toAnnotationProperties(a: Annotation): AnnotationProperties {
return {
title: a.title,
file: a.path,
startLine: a.start_line,
endLine: a.end_line,
startLine: a.start_line || 0,
endLine: a.end_line || 1,
startColumn: a.start_column,
endColumn: a.end_column
}
Expand Down
2 changes: 1 addition & 1 deletion scan/src/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function getRowsByLevel(annotations: Annotation[], level: string): string {
map.set(
e.title ?? UNKNOWN_RULE_ID,
map.get(e.title ?? UNKNOWN_RULE_ID) !== undefined
? map.get(e.title)!! + 1
? map.get(e.title ?? UNKNOWN_RULE_ID)!! + 1
: 1
),
new Map()
Expand Down

0 comments on commit 5047802

Please sign in to comment.