Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Feb 22, 2024

@antonioaversa

  • Made sure this rule does not apply in ASP.NET MVC (HTTP attributes to not take a route template as input).
  • Checked that this rule is valid for previous ASP.NET core MVC versions (5, 6, 7, and 8).
  • I haven't checked if this is applicable in VB - it should be, but I prefer to add the rspec there in a separate PR.

Implementation PR SonarSource/sonar-dotnet#8954

@mary-georgiou-sonarsource mary-georgiou-sonarsource changed the title Create rule S6934 Create rule S6934: You should ensure that the routing system can correctly map incoming HTTP requests to the appropriate action methods or endpoints Feb 22, 2024
@mary-georgiou-sonarsource mary-georgiou-sonarsource changed the title Create rule S6934: You should ensure that the routing system can correctly map incoming HTTP requests to the appropriate action methods or endpoints Create rule S6934: You should specify the RouteAttribute when an HttpMethodAttribute is specified at an action level Feb 23, 2024
@mary-georgiou-sonarsource mary-georgiou-sonarsource force-pushed the rule/add-RSPEC-S6934 branch 3 times, most recently from f0c3861 to abf4c94 Compare February 23, 2024 14:32
@sonarqube-next
Copy link

Quality Gate passed Quality Gate passed for 'rspec-tools'

Issues
0 New issues
0 Fixed issues
0 Accepted issues

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

See analysis details on SonarQube

@sonarqube-next
Copy link

Quality Gate passed Quality Gate passed for 'rspec-frontend'

Issues
0 New issues
0 Fixed issues
0 Accepted issues

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

See analysis details on SonarQube

[source,csharp]
----
public class PersonController: Controller
Copy link
Contributor

Choose a reason for hiding this comment

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

The entire code is indented by 4 chars, which makes the code less readable on small screens or large zoom.
I would remove the 4 chars of indentation, and have it coherent with most of the other C# and VB.NET examples in the RSPEC repo.

Copy link
Contributor

Choose a reason for hiding this comment

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

The indent of the signature has been reduced by one, but not the body, which was indented by 8 chars.
I have reduced the indentation of the body too.

//=== Conference presentations
//=== Standards
//=== External coding guidelines
//=== Benchmarks
Copy link
Contributor

Choose a reason for hiding this comment

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

We should add the rspecator.adoc, indicating:

  • what we plan to highlight in the code
  • what we plan to issue as message

Copy link
Contributor

Choose a reason for hiding this comment

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

I have updated the message, taking into account the changes done at the implementation level.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have also updated the highlight for secondary locations, as it was inconsistent with the implementation, which doesn't highlight the route template of the controller action, but the identifier of the controller action.

@antonioaversa
Copy link
Contributor

@mary-georgiou-sonarsource I would start the review from this comment, as it may change quite a bit the content of the RSPEC.

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.

Looks good - some minor comments.

// C#
* ASP.NET
* ASP.NET Core
* ASP.NET MVC 4.x

Choose a reason for hiding this comment

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

See also #3668

Choose a reason for hiding this comment

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

According to https://dotnet.microsoft.com/en-us/platform/support/policy/aspnet asp.net mvc 4.x is no longer supported.

Are we sure we want to support it?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's true I think there has been maybe some confusion.
@antonioaversa @martin-strecker-sonarsource maybe we should review the two rules we merged already?

Choose a reason for hiding this comment

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

The 4.x in "Asp.MVC 4.x" refers to the 4 in e.g. .Net Framework 4.8. The term is taken from this website:
https://learn.microsoft.com/en-us/aspnet/core/
It links to the documentation for the ASP MVC releases for the old .Net Framework 4.8. This includes ASP.NET MVC 5 which is still in support. So by referring to "Asp.MVC 4.x " we refer to "ASP.NET MVC 5"
I know this is highly confusing, but something we discussed with Denis and concluded is the best solution.

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.

@antonioaversa antonioaversa self-requested a review March 22, 2024 15:05
Copy link
Contributor

@antonioaversa antonioaversa left a comment

Choose a reason for hiding this comment

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

Looks good to me too!
I have resolved most of the threads that I have opened myself and made minor modifications for the remaining.

@sonarqube-next
Copy link

Quality Gate passed Quality Gate passed for 'rspec-tools'

Issues
0 New issues
0 Fixed issues
0 Accepted issues

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

See analysis details on SonarQube

@sonarqube-next
Copy link

Quality Gate passed Quality Gate passed for 'rspec-frontend'

Issues
0 New issues
0 Fixed issues
0 Accepted issues

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

See analysis details on SonarQube

@costin-zaharia-sonarsource costin-zaharia-sonarsource marked this pull request as ready for review March 22, 2024 15:12
@antonioaversa antonioaversa changed the title Create rule S6934: You should specify the RouteAttribute when an HttpMethodAttribute is specified at an action level Create rule S6934: A Route attribute should be added to the controller when a route template is specified at the action level Mar 22, 2024
@antonioaversa antonioaversa merged commit 71960b5 into master Mar 22, 2024
@antonioaversa antonioaversa deleted the rule/add-RSPEC-S6934 branch March 22, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants