[jsweep] Clean autofix_code_scanning_alert.cjs#11321
Merged
Conversation
- Eliminated unnecessary autofixItem variable - used message directly
- Condensed multiline return objects to single-line format
- Used spread operator {...context.repo} for cleaner code
- Removed unused result variable from github.request call
- Simplified headers object formatting
- Reduced from 163 to 130 lines (33 lines saved)
All validation checks passed:
✓ Format: npm run format:cjs
✓ Lint: npm run lint:cjs
✓ Type check: npm run typecheck
✓ Tests: 15 test cases passing
Contributor
|
@copilot format, lint js |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cleaned
autofix_code_scanning_alert.cjsto use modern JavaScript patterns and reduce verbosity.Context
This file runs in github-script context and handles creating autofixes for code scanning alerts via the GitHub REST API.
Changes Made
Code Improvements
autofixItemintermediate variable, usedmessagedirectly throughout for consistencyreturn { success: false, error: "..." })owner: context.repo.owner, repo: context.repo.repowith...context.reporesultvariable fromgithub.requestcall since it wasn't being usedMetrics
Test Coverage
The file already had comprehensive test coverage with 15 test cases covering:
All tests continue to pass with the cleaned code.
Validation
All required checks passed before creating this PR:
✅ Format:
npm run format:cjs- All files formatted correctly✅ Lint:
npm run lint:cjs- No linting issues✅ Type check:
npm run typecheck- No type errors✅ Tests:
npm run test:js- 15 test cases passingImpact
@ts-checkenabledFile Context: github-script (uses
core,github,contextglobals)Handler Type:
autofix_code_scanning_alertSafe Output: Creates autofixes for code scanning alerts via GitHub REST API