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

Modify rule S6932: Update code example #4563

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

mary-georgiou-sonarsource
Copy link
Contributor

No description provided.

Comment on lines 166 to 170
public IActionResult Post()
{
var origin = Request.Headers[HeaderNames.Origin]; // Compliant: Access via variable
var name = Request.Form["name"]; // Compliant: Access via constant and variable keys is mixed
var birthdate = DateTime.Parse(Request.Form["Birthdate"]); // Compliant: Access via constant and variable keys is mixed

Choose a reason for hiding this comment

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

Suggested change
public IActionResult Post()
{
var origin = Request.Headers[HeaderNames.Origin]; // Compliant: Access via variable
var name = Request.Form["name"]; // Compliant: Access via constant and variable keys is mixed
var birthdate = DateTime.Parse(Request.Form["Birthdate"]); // Compliant: Access via constant and variable keys is mixed
public IActionResult Post()
{
var origin = Request.Headers[HeaderNames.Origin]; // Compliant: Access via non-constant field
var nameField = "name";
var name = Request.Form[nameField]; // Compliant: Access via local
var birthdate = DateTime.Parse(Request.Form["Birthdate"]); // Compliant: Access via constant and variable keys is mixed.
// Model binding would only work partially in the method, so we do not raise here.
return Ok();

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

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

@mary-georgiou-sonarsource mary-georgiou-sonarsource merged commit 5e18970 into master Dec 17, 2024
9 of 10 checks passed
@mary-georgiou-sonarsource mary-georgiou-sonarsource deleted the mary/rule-S6932 branch December 17, 2024 16:28
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.

2 participants