Skip to content

Commit

Permalink
Feature/change table orientation (#57)
Browse files Browse the repository at this point in the history
Change Table Orientation and  Update README Image
  • Loading branch information
mitchspano authored May 28, 2023
1 parent ccf9d63 commit 486f289
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

Binary file modified images/sfdx-scan-pull-request.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 35 additions & 9 deletions src/reporter/comments-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,23 +202,49 @@ export class CommentsReporter extends BaseReporter<GithubComment> {
? this.context.payload.pull_request.head.sha
: this.context.sha;

const commentHeader = `${HIDDEN_COMMENT_PREFIX}
| Engine | Category | Rule | Severity | Type | Message | File |
| --- | --- | --- | --- | --- | --- | --- |`;
this.issues.push({
commit_id,
path: filePath,
start_line: startLine,
start_side: "RIGHT",
side: "RIGHT",
line: endLine,
body: `${commentHeader}
| ${engine} | ${violation.category} | ${violation.ruleName} | ${
violation.severity
} | ${violationType} | [${violation.message.trim()}](${
violation.url
}) | [${filePath}](${getGithubFilePath(commit_id, filePath)}) |`,
body: this.getFormattedBody(
engine,
violationType,
violation,
filePath,
commit_id
),
});
return { violationType };
}

/**
* @description Formats the body of a review comment as a table
* @param engine - reporting engine responsible for identifying the violation
* @param violationType - error or warning depending on threshold and strictly enforced rules
* @param violation - raw violation from the scan
* @param filePath - path to the file
* @param commit_id - Id of the commit to generate a link to the file
*/
getFormattedBody(
engine: string,
violationType: string,
violation: ScannerViolation,
filePath: string,
commit_id: string
): string {
const commentHeader = `${HIDDEN_COMMENT_PREFIX}
| Attribute | Value |
| --- | --- |`;
return `${commentHeader}
| Engine | ${engine}|
| Category | ${violation.category} |
| Rule | ${violation.ruleName} |
| Severity | ${violation.severity} |
| Type | ${violationType} |
| Message| [${violation.message.trim()}](${violation.url}) |
| File | [${filePath}](${getGithubFilePath(commit_id, filePath)}) |`;
}
}

0 comments on commit 486f289

Please sign in to comment.