-
Notifications
You must be signed in to change notification settings - Fork 231
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 S6797: Blazor query parameter should be of supported type #8333
Conversation
63d9dfe
to
10533ff
Compare
analyzers/src/SonarAnalyzer.CSharp/Rules/BlazorQueryParameterTypeShouldBeSupported.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Rules/BlazorQueryParameterTypeShouldBeSupported.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Rules/BlazorQueryParameterTypeShouldBeSupported.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Rules/BlazorQueryParameterTypeShouldBeSupported.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Rules/BlazorQueryParameterTypeShouldBeSupported.cs
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/Rules/BlazorQueryParameterTypeShouldBeSupportedTest.cs
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/Rules/BlazorQueryParameterTypeShouldBeSupportedTest.cs
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/Rules/BlazorQueryParameterTypeShouldBeSupportedTest.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this rule and S6803 both target the same properties and do the same checks I think we should sync to create a baseclass that will do the context validation and return the relevant nodes:
- Registration
- Generic check to exclude non razor stuff
- Checks for Route attribute
- Checks properties attributes
- Return properties
WDYT?
aa06090
to
a3aee08
Compare
80a96e0
to
1557789
Compare
1350ba0
to
7bb6a1b
Compare
analyzers/src/SonarAnalyzer.CSharp/Rules/BlazorQueryParameterRoutableComponent.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Rules/BlazorQueryParameterRoutableComponent.cs
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/BlazorQueryParameterRoutableComponent.razor
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/BlazorQueryParameterRoutableComponent.razor
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/BlazorQueryParameterRoutableComponent.razor
Show resolved
Hide resolved
...tests/SonarAnalyzer.UnitTest/TestCases/BlazorQueryParameterRoutableComponent_Noncompliant.cs
Outdated
Show resolved
Hide resolved
...tests/SonarAnalyzer.UnitTest/TestCases/BlazorQueryParameterRoutableComponent_Noncompliant.cs
Outdated
Show resolved
Hide resolved
...tests/SonarAnalyzer.UnitTest/TestCases/BlazorQueryParameterRoutableComponent_Noncompliant.cs
Outdated
Show resolved
Hide resolved
its/src/test/java/com/sonar/it/csharp/RazorClassLibProjectTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should also be feasible to bump the coverage to 100% 👍
20476b8
to
838932a
Compare
50f1d96
to
18c4ef3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are close!
analyzers/src/SonarAnalyzer.CSharp/Rules/BlazorQueryParameterRoutableComponent.cs
Show resolved
Hide resolved
...arAnalyzer.UnitTest/TestCases/SupplyParameterFromQueryNeedsRoutableComponent_Noncompliant.cs
Show resolved
Hide resolved
...ests/SonarAnalyzer.UnitTest/TestCases/BlazorQueryParameterRoutableComponent_Partial.razor.cs
Show resolved
Hide resolved
...rs/tests/SonarAnalyzer.UnitTest/TestCases/BlazorQueryParameterRoutableComponent_Compliant.cs
Outdated
Show resolved
Hide resolved
...s/tests/SonarAnalyzer.UnitTest/TestCases/BlazorQueryParameterRoutableComponent_Partial.razor
Outdated
Show resolved
Hide resolved
...ests/SonarAnalyzer.UnitTest/TestCases/BlazorQueryParameterRoutableComponent_Partial.razor.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I left one optional comment, I'll let you choose whether to merge it as is or not
@@ -0,0 +1 @@ | |||
@page "/query-parameters" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one might have explicit @namespace RazorClassLib.S6797
as well
Kudos, SonarCloud Quality Gate passed! |
Kudos, SonarCloud Quality Gate passed! |
Fixes #8274