-
Notifications
You must be signed in to change notification settings - Fork 16
Sync Main (autogenerated) #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Rust: accept test changes for now
… query with a PrintAst name from QlRefInlineExpectations.
This allows the string of package feeds to be constructed once and used repeatedly in the parallel restore loop as well.
…a given set of feeds.
…us-id Docs: add guidance for `previous-id` metadata
JS: `got` package modeling
…stinlineexpect QL4QL: Exclude PrintAst like tests from being reported as having missing InlineExpectations.
In particular for `postForm` `putForm` `patchForm` `getUri`.
Co-authored-by: Asger F <asgerf@github.com>
Co-authored-by: Michael Nebel <michaelnebel@github.com>
…rof-rewriting Java buildless: add buildless-maven variant with a wildcard mirrorOf spec
…-swift Misc: Add another path prefix to accept-expected-changes-from-ci.py
Rust: rename several entities to their more natural names
…e-bom-downloads Java: add test exercising Gradle download pruning
Merge rc/3.17 into main
Actions: rename changenote file
Javascript, add missing `*` to changenote
Release preparation for version 2.21.0
Compatible with the latest released version of the CodeQL CLI
if (nugetConfigs.Count > 0) | ||
{ | ||
// We don't have to get the feeds from each of the folders from below, it would be enought to check the folders that recursively contain the others. | ||
allFeeds = nugetConfigs | ||
.Select(config => | ||
{ | ||
logger.LogWarning($"Failed to get directory of '{config}': {exc}"); | ||
} | ||
return null; | ||
}) | ||
.Where(folder => folder != null) | ||
.SelectMany(folder => GetFeeds(() => dotnet.GetNugetFeedsFromFolder(folder!))) | ||
.ToHashSet(); | ||
try | ||
{ | ||
return new FileInfo(config).Directory?.FullName; | ||
} | ||
catch (Exception exc) | ||
{ | ||
logger.LogWarning($"Failed to get directory of '{config}': {exc}"); | ||
} | ||
return null; | ||
}) | ||
.Where(folder => folder != null) | ||
.SelectMany(folder => GetFeeds(() => dotnet.GetNugetFeedsFromFolder(folder!))) | ||
.ToHashSet(); | ||
} | ||
else | ||
{ | ||
// If we haven't found any `nuget.config` files, then obtain a list of feeds from the root source directory. | ||
allFeeds = GetFeeds(() => dotnet.GetNugetFeedsFromFolder(this.fileProvider.SourceDir.FullName)).ToHashSet(); | ||
} |
Check notice
Code scanning / CodeQL
Missed ternary opportunity Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, we will replace the if
statement with a ternary operator to assign the value to the allFeeds
variable. We will also move the logging statements outside the ternary operator to ensure they are executed appropriately based on the condition.
- Replace the
if
statement on lines 821-845 with a ternary operator. - Move the logging statements to be executed based on the condition separately.
-
Copy modified lines R819-R820 -
Copy modified lines R835-R840 -
Copy modified line R844
@@ -818,8 +818,4 @@ | ||
// todo: this could be improved. | ||
HashSet<string>? allFeeds = null; | ||
|
||
if (nugetConfigs.Count > 0) | ||
{ | ||
// We don't have to get the feeds from each of the folders from below, it would be enought to check the folders that recursively contain the others. | ||
allFeeds = nugetConfigs | ||
HashSet<string>? allFeeds = nugetConfigs.Count > 0 | ||
? nugetConfigs | ||
.Select(config => | ||
@@ -838,3 +834,8 @@ | ||
.SelectMany(folder => GetFeeds(() => dotnet.GetNugetFeedsFromFolder(folder!))) | ||
.ToHashSet(); | ||
.ToHashSet() | ||
: GetFeeds(() => dotnet.GetNugetFeedsFromFolder(this.fileProvider.SourceDir.FullName)).ToHashSet(); | ||
|
||
if (nugetConfigs.Count > 0) | ||
{ | ||
logger.LogInfo($"Found {allFeeds.Count} Nuget feeds (with inherited ones) in nuget.config files: {string.Join(", ", allFeeds.OrderBy(f => f))}"); | ||
} | ||
@@ -842,8 +843,5 @@ | ||
{ | ||
// If we haven't found any `nuget.config` files, then obtain a list of feeds from the root source directory. | ||
allFeeds = GetFeeds(() => dotnet.GetNugetFeedsFromFolder(this.fileProvider.SourceDir.FullName)).ToHashSet(); | ||
logger.LogDebug("No Nuget feeds found in nuget.config files."); | ||
} | ||
|
||
logger.LogInfo($"Found {allFeeds.Count} Nuget feeds (with inherited ones) in nuget.config files: {string.Join(", ", allFeeds.OrderBy(f => f))}"); | ||
|
||
return (explicitFeeds, allFeeds); |
catch (Exception exc) | ||
{ | ||
logger.LogWarning($"Failed to get directory of '{config}': {exc}"); | ||
} |
Check notice
Code scanning / CodeQL
Generic catch clause Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, we should catch specific exceptions that are likely to occur during the operation of getting the directory of a file. The most relevant exceptions in this context are DirectoryNotFoundException
, UnauthorizedAccessException
, and IOException
. By catching these specific exceptions, we can handle each case appropriately and avoid masking other potential issues.
- Modify the catch block on line 831 to catch specific exceptions.
- Ensure that the logging remains intact to help with diagnosing issues.
-
Copy modified line R831 -
Copy modified lines R833-R841
@@ -830,5 +830,13 @@ | ||
} | ||
catch (Exception exc) | ||
catch (DirectoryNotFoundException exc) | ||
{ | ||
logger.LogWarning($"Failed to get directory of '{config}': {exc}"); | ||
logger.LogWarning($"Directory not found for '{config}': {exc}"); | ||
} | ||
catch (UnauthorizedAccessException exc) | ||
{ | ||
logger.LogWarning($"Unauthorized access to directory for '{config}': {exc}"); | ||
} | ||
catch (IOException exc) | ||
{ | ||
logger.LogWarning($"IO error while accessing directory for '{config}': {exc}"); | ||
} |
This PR syncs the latest changes from
codeql-cli/latest
intomain
.