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

New rule S6802: Using lambda expressions in loops should be avoided in Blazor markup section #8277

Closed
sebastien-marichal opened this issue Oct 30, 2023 · 1 comment · Fixed by #8301
Assignees
Labels
Area: C# C# rules related issues. Type: New Rule Implementation for a rule that HAS been specified.
Milestone

Comments

@sebastien-marichal
Copy link
Contributor

S6802: SonarSource/rspec#3215

@antonioaversa antonioaversa added Area: C# C# rules related issues. Type: New Rule Implementation for a rule that HAS been specified. labels Nov 1, 2023
@antonioaversa antonioaversa added this to the 9.14 milestone Nov 1, 2023
@sebastien-marichal sebastien-marichal self-assigned this Nov 2, 2023
@sebastien-marichal sebastien-marichal changed the title New rule S6802: Using lambda expressions in loops should be avoided New rule S6802: Using lambda expressions in loops should be avoided in Blazor markup section Nov 3, 2023
@antonioaversa
Copy link
Contributor

@sebastien-marichal I think we may have a few FPs on mudblazor
In this scenario, the lambda applies to the collection being iterated, that is evaluated only once, and the @foreach is outer-most, as far as I can tell.
Same applies here and here.

I think the IsWithinLoop check is a bit too generic:

node.AncestorsAndSelf().Any(x => x is ForStatementSyntax or ForEachStatementSyntax or WhileStatementSyntax or DoStatementSyntax)
foreach (var item in Collection.Where(x => x.Id == "idToFind")) {}

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Type: New Rule Implementation for a rule that HAS been specified.
Projects
None yet
3 participants