Skip to content
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

Fix S6966 FP: EntityFrameworks DbContext/DBSet Add/AddRange methods are preferred over their Async counterpart #9318

Merged
merged 5 commits into from
May 23, 2024

Conversation

martin-strecker-sonarsource
Copy link
Contributor

Fixes #9269

@martin-strecker-sonarsource martin-strecker-sonarsource changed the title Fix S6966 FP: EntityFramework DbContext Fix S6966 FP: EntityFrameworks DbContext/DBSet Add/AddRange methods are preferred over there Asnyc counterpart May 23, 2024
@martin-strecker-sonarsource martin-strecker-sonarsource changed the title Fix S6966 FP: EntityFrameworks DbContext/DBSet Add/AddRange methods are preferred over there Asnyc counterpart Fix S6966 FP: EntityFrameworks DbContext/DBSet Add/AddRange methods are preferred over their Asnyc counterpart May 23, 2024
@martin-strecker-sonarsource martin-strecker-sonarsource marked this pull request as ready for review May 23, 2024 12:22
@mary-georgiou-sonarsource mary-georgiou-sonarsource changed the title Fix S6966 FP: EntityFrameworks DbContext/DBSet Add/AddRange methods are preferred over their Asnyc counterpart Fix S6966 FP: EntityFrameworks DbContext/DBSet Add/AddRange methods are preferred over their Async counterpart May 23, 2024
@@ -27,6 +27,7 @@ public sealed class UseAwaitableMethod : SonarDiagnosticAnalyzer
{
private const string DiagnosticId = "S6966";
private const string MessageFormat = "Await {0} instead.";
private static readonly string[] MethodNamesAddAddRange = ["Add", "AddRange"];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private static readonly string[] MethodNamesAddAddRange = ["Add", "AddRange"];
private static readonly string[] ExcludedMethodNames = ["Add", "AddRange"];

Copy link
Contributor

@mary-georgiou-sonarsource mary-georgiou-sonarsource left a comment

Choose a reason for hiding this comment

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

LGTM with a minor comment

@martin-strecker-sonarsource martin-strecker-sonarsource enabled auto-merge (squash) May 23, 2024 16:33
@martin-strecker-sonarsource
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link

Quality Gate Passed Quality Gate passed for 'Sonar .NET Java Plugin'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

@martin-strecker-sonarsource martin-strecker-sonarsource merged commit 8a5a843 into master May 23, 2024
27 checks passed
@martin-strecker-sonarsource martin-strecker-sonarsource deleted the Martin/S6966_EF_Add_FPs branch May 23, 2024 19:09
@costin-zaharia-sonarsource costin-zaharia-sonarsource added this to the 9.26 milestone May 24, 2024
@martin-strecker-sonarsource
Copy link
Contributor Author

Peach validation:
About 40 Add and AddRange FPs lost on peach.

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.

Fix S6966 FP: EntityFrameworks DbContext/DBSet Add/AddRange methods are preferred over their Async counterpart
3 participants