Skip to content

Commit

Permalink
Comment errors (#60)
Browse files Browse the repository at this point in the history
Handle violation type of "Error".
Set default threshold to 0
  • Loading branch information
mitchspano committed May 30, 2023
1 parent 486f289 commit 3df86f5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

14 changes: 2 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function initialSetup() {
const inputs: PluginInputs = {
reportMode: getInput("report-mode") || "check-runs",
customPmdRules: getInput("custom-pmd-rules"),
severityThreshold: parseInt(getInput("severity-threshold")) || 4,
severityThreshold: parseInt(getInput("severity-threshold")) || 0,
strictlyEnforcedRules: getInput("strictly-enforced-rules"),
deleteResolvedComments: getInput("delete-resolved-comments") === "true",
target: context?.payload?.pull_request ? "" : getInput("target"),
Expand Down Expand Up @@ -131,7 +131,6 @@ function filterFindingsToDiffScope(
console.log(
"Filtering the findings to just the lines which are part of the pull request..."
);
let hasHaltingError = false;

for (let finding of findings) {
const filePath = finding.fileName.replace(process.cwd() + "/", "");
Expand All @@ -141,18 +140,9 @@ function filterFindingsToDiffScope(
if (!isInChangedLines(violation, relevantLines) && !inputs.target) {
continue;
}

const { violationType } = reporter.translateViolationToReport(
filePath,
violation,
finding.engine
);
if (violationType === "Error") {
hasHaltingError = true;
}
reporter.translateViolationToReport(filePath, violation, finding.engine);
}
}
return { hasHaltingError };
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/reporter/annoations-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,5 @@ export class AnnotationsReporter extends BaseReporter<GithubAnnotation> {
message: `${violation.category} ${violation.message}\n${violation.url}`,
title: `${violation.ruleName} (sev: ${violation.severity})`,
});
return { violationType };
}
}
6 changes: 5 additions & 1 deletion src/reporter/comments-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {
} from "./reporter.types";
import { ScannerViolation } from "../sfdxCli";

const ERROR = "Error";

const HIDDEN_COMMENT_PREFIX = "<!--sfdx-scanner-->";

export class CommentsReporter extends BaseReporter<GithubComment> {
Expand Down Expand Up @@ -198,6 +200,9 @@ export class CommentsReporter extends BaseReporter<GithubComment> {
violation,
engine
);
if (violationType === ERROR) {
this.hasHaltingError = true;
}
const commit_id = this.context.payload.pull_request
? this.context.payload.pull_request.head.sha
: this.context.sha;
Expand All @@ -217,7 +222,6 @@ export class CommentsReporter extends BaseReporter<GithubComment> {
commit_id
),
});
return { violationType };
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/reporter/reporter.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export interface Reporter {
filePath: string,
violation: ScannerViolation,
engine: string
): { violationType: string };
): void;
}

type GithubCommentSide = "RIGHT";
Expand All @@ -98,7 +98,7 @@ export abstract class BaseReporter<T> implements Reporter {
_filePath: string,
_violation: ScannerViolation,
_engine: string
): { violationType: string } {
): void {
throw new Error("Method not implemented.");
}

Expand Down

0 comments on commit 3df86f5

Please sign in to comment.