feat: Add getPacks method to retrieve installed CodeQL packs#9
Open
GeekMasher wants to merge 2 commits intomainfrom
Open
feat: Add getPacks method to retrieve installed CodeQL packs#9GeekMasher wants to merge 2 commits intomainfrom
GeekMasher wants to merge 2 commits intomainfrom
Conversation
…te findQueryPack to use async
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the CodeQL service by adding a new getPacks method to retrieve installed CodeQL packs and refactoring the query pack selection logic to use this new method instead of filesystem-based pack discovery.
- Added
getPacksmethod that uses CodeQL CLI to retrieve installed packs with JSON parsing - Refactored
findQueryPackmethod to be async and use the newgetPacksmethod for pack discovery - Updated
runAnalysismethod to handle the asyncfindQueryPackcall
|
|
||
| public async getPacks(): Promise<string[]> { | ||
| this.logger.logServiceCall("CodeQLService", "getPacks", "started"); | ||
| var packs: string[] = []; |
There was a problem hiding this comment.
Use 'const' instead of 'var' for block-scoped variable declaration. Since 'packs' is reassigned through array methods rather than variable reassignment, it can be declared as const.
Suggested change
| var packs: string[] = []; | |
| const packs: string[] = []; |
Comment on lines
+450
to
+451
| if (!packs.includes(packName)) { | ||
| packs.push(packName); |
There was a problem hiding this comment.
Using Array.includes() for duplicate checking has O(n) complexity for each insertion, resulting in O(n²) overall complexity. Consider using a Set for O(1) lookups and convert to array at the end.
Suggested change
| if (!packs.includes(packName)) { | |
| packs.push(packName); | |
| if (!packs.has(packName)) { | |
| packs.add(packName); |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
This pull request introduces enhancements to the
CodeQLServiceclass, focusing on improving the handling of CodeQL packs and query pack selection. The changes include the addition of a new method to retrieve installed CodeQL packs, refactoring of the query pack selection logic to leverage this new method, and improved error handling and logging.Enhancements to CodeQL pack handling:
getPacksmethod: This new method retrieves a list of installed CodeQL packs using the CodeQL CLI, with detailed logging and error handling. It parses the CLI output to extract pack names and ensures no duplicates are included.Refactoring of query pack selection:
Refactored
findQueryPackmethod: The method was converted to an asynchronous function that now uses thegetPacksmethod to identify the appropriate query pack for a given language. It prioritizes language-specific packs and falls back to a default pack if none are found. Enhanced logging provides better visibility into the selection process.Updated usage of
findQueryPack: The call tofindQueryPackin therunAnalysismethod was updated to support its new asynchronous implementation.