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 S2365: Fix code examples #3923

Merged
merged 2 commits into from
May 7, 2024
Merged

Modify S2365: Fix code examples #3923

merged 2 commits into from
May 7, 2024

Conversation

sebastien-marichal
Copy link
Contributor

@@ -9,11 +9,21 @@ include::../why-dotnet.adoc[]
[source,csharp,diff-id=1,diff-type=noncompliant]
----
private List<string> _foo = new List<string> { "a", "b", "c" };
Copy link
Contributor

Choose a reason for hiding this comment

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

(optional) What about adding using statements as well? Specifically the System.Linq

using System.Collections.Generic;
using System.Linq;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The example context is implicitly set to a class.
Adding usings would be incorrect. I would rather not add them.

@@ -23,9 +33,16 @@ public IEnumerable<string> Foo // Noncompliant: expensive ToList call
[source,csharp,diff-id=1,diff-type=compliant]
----
private List<string> _foo = new List<string> { "a", "b", "c" };
private string[] _bar = new string[] { "a", "b", "c" };
Copy link
Contributor

Choose a reason for hiding this comment

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

I would take this opportunity to change the field names as well, they should not begin with an underscore IMO

@@ -8,11 +8,18 @@ include::../why-dotnet.adoc[]

[source,vbnet,diff-id=1,diff-type=noncompliant]
----
Dim foo = {"a", "b", "c" }
Property Foo() As String() ' Noncompliant
Private _foo As New List(Of String) From {"a", "b", "c"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Field names

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the f prefix for the field names as suggested by @pavel-mikula-sonarsource.

@sebastien-marichal sebastien-marichal force-pushed the sma/fix-s2365 branch 2 times, most recently from 8dfad8d to 8c75829 Compare May 7, 2024 08:58
Copy link

sonarqube-next bot commented May 7, 2024

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

sonarqube-next bot commented May 7, 2024

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

Copy link
Contributor

@CristianAmbrosini CristianAmbrosini left a comment

Choose a reason for hiding this comment

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

LGTM!

@sebastien-marichal sebastien-marichal merged commit 855bb4c into master May 7, 2024
10 of 11 checks passed
@sebastien-marichal sebastien-marichal deleted the sma/fix-s2365 branch May 7, 2024 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants