Skip to content

CHANGE: @W-19419849@: Adding option to generate the violations only for the changed files - #110

Closed
namrata111f wants to merge 3 commits into
mainfrom
ng-pr-changes
Closed

CHANGE: @W-19419849@: Adding option to generate the violations only for the changed files#110
namrata111f wants to merge 3 commits into
mainfrom
ng-pr-changes

Conversation

@namrata111f

@namrata111f namrata111f commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

Adding option to generate the violations only for the changed files. We have added new param: changed-files-only which controls if only the files with changes would be considered when reporting the violation counts.
Testing:

Screen.Recording.2025-12-02.at.1.12.12.PM.mov

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Salesforce Code Analyzer found 13 violations, including 10 in files changed by this pull request. See job summary page.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Salesforce Code Analyzer found 13 violations, including 10 in files changed by this pull request. See job summary page.

@namrata111f namrata111f changed the title CHANGE: @W-19419849@: Update dependencies to latest where possible CHANGE: @W-19419849@: Adding option to generate the violations only for the changed files Dec 2, 2025
Comment thread src/main.ts
let violations: Violation[]

// Use all violations
violations = results.getViolationsSortedBySeverity()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@namrata111f : Can we move this to the else block of if (changedFiles && changedFiles.length > 0) { ?

Comment thread src/main.ts
).length

const summaryBody = MESSAGE_FCNS.REVIEW_BODY(
results.getTotalViolationCount(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@namrata111f : Shouldn't it show the filtered count ?

Comment thread src/main.ts
` num-sev3-violations: ${results.getSev3ViolationCount()}\n` +
` num-sev4-violations: ${results.getSev4ViolationCount()}\n` +
` num-sev5-violations: ${results.getSev5ViolationCount()}`
`Parsed results from ${jsonOutputFile}: found ${results.getTotalViolationCount()} total violations across all files`

@emypaulson-1993 emypaulson-1993 Dec 3, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@namrata111f : If changedFilesOnly is true then we should only show the filtered count . Right ?

Comment thread src/summary.ts
const sev2Count = violationsToShow.filter(v => v.getSeverity() === 2).length
const sev3Count = violationsToShow.filter(v => v.getSeverity() === 3).length
const sev4Count = violationsToShow.filter(v => v.getSeverity() === 4).length
const sev5Count = violationsToShow.filter(v => v.getSeverity() === 5).length

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm , It's good to optimize this mutiple iterations .

`// Calculate counts for the violations we're showing (single pass)
let totalCount = 0
let sev1Count = 0
let sev2Count = 0
let sev3Count = 0
let sev4Count = 0
let sev5Count = 0

for (const violation of violationsToShow) {
totalCount++
const severity = violation.getSeverity()
if (severity === 1) sev1Count++
else if (severity === 2) sev2Count++
else if (severity === 3) sev3Count++
else if (severity === 4) sev4Count++
else if (severity === 5) sev5Count++
}`

@namrata111f

Copy link
Copy Markdown
Contributor Author

Discussed with team and we need to just add the output variables here.

@namrata111f namrata111f closed this Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants