-
Notifications
You must be signed in to change notification settings - Fork 28
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
Conversation
rules/S2365/csharp/rule.adoc
Outdated
@@ -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" }; |
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.
(optional) What about adding using statements as well? Specifically the System.Linq
using System.Collections.Generic;
using System.Linq;
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.
The example context is implicitly set to a class.
Adding usings would be incorrect. I would rather not add them.
rules/S2365/csharp/rule.adoc
Outdated
@@ -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" }; |
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 would take this opportunity to change the field names as well, they should not begin with an underscore IMO
rules/S2365/vbnet/rule.adoc
Outdated
@@ -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"} |
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.
Field names
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 added the f
prefix for the field names as suggested by @pavel-mikula-sonarsource.
8dfad8d
to
8c75829
Compare
8c75829
to
f10c8f3
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.
LGTM!
See SonarSource/sonar-dotnet#9254