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

Update RSPEC #6899

Merged
merged 2 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions analyzers/rspec/cs/S3655_c#.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p>Nullable value types can hold either a value or <code>null</code>. The value held in the nullable type can be accessed with the <code>Value</code>
property or by casting it to the underlying type, but both operations throw an <code>InvalidOperationException</code> when the value is
<code>null</code>. To avoid the exception, a nullable type should always be tested before the value is accessed.</p>
property or by casting it to the underlying type. Still, both operations throw an <code>InvalidOperationException</code> when the value is
<code>null</code>. A nullable type should always be tested before the value is accessed to avoid the exception.</p>
<h2>Noncompliant Code Example</h2>
<pre>
public void Sample(bool condition)
Expand Down
2 changes: 1 addition & 1 deletion analyzers/rspec/cs/S3900_c#.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h2>Compliant Solution</h2>

private void Xyzzy(MyOtherClass other)
{
this.other = other; // Compliant: method is not publicly accessible
this.other = other.Clone(); // Compliant: method is not publicly accessible
}
}
</pre>
Expand Down
40 changes: 19 additions & 21 deletions analyzers/rspec/vbnet/S3655_vb.net.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
<p>Nullable value types can hold either a value or <code>Nothing</code>. The value stored in the nullable type can be accessed with the
<code>Value</code> property or by casting it to the underlying type. Still, both operations throw an <code>InvalidOperationException</code> when the
value is <code>Nothing</code>. A nullable type should always be tested before <code>Value</code> is accessed to avoid the exception.</p>
value is <code>Nothing</code>. A nullable type should always be tested before the value is accessed to avoid the exception.</p>
<h2>Noncompliant Code Example</h2>
<pre>
Dim nullable As Integer? = Nothing
Console.WriteLine(nullable.Value)
</pre>
<p>or</p>
<pre>
Dim nullable As Integer? = Nothing
Console.WriteLine(CType(nullable, Integer))
Sub Sample(condition As Boolean)
Dim nullableValue As Integer? = If(condition, 42, Nothing)
Console.WriteLine(nullableValue.Value) ' Noncompliant

Dim nullableCast As Integer? = If(condition, 42, Nothing)
Console.WriteLine(CType(nullableCast, Integer)) ' Noncompliant
End Sub
</pre>
<h2>Compliant Solution</h2>
<pre>
Dim nullable As Integer? = Nothing
If nullable.HasValue Then
Console.WriteLine(nullable.Value)
Console.WriteLine(CType(nullable, Integer))
End If
</pre>
<p>or</p>
<pre>
Dim nullable As Integer? = Nothing
If nullable &lt;&gt; Nothing Then
Console.WriteLine(nullable.Value)
Console.WriteLine(CType(nullable, Integer))
End If
Sub Sample(condition As Boolean)
Dim nullableValue As Integer? = If(condition, 42, Nothing)
If nullableValue.HasValue Then
Console.WriteLine(nullableValue.Value)
End If

Dim nullableCast As Integer? = If(condition, 42, Nothing)
If nullableCast.HasValue Then
Console.WriteLine(CType(nullableCast, Integer))
End If
End Sub
</pre>
<h2>See</h2>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion analyzers/src/SonarAnalyzer.CSharp/sonarpedia.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"languages": [
"CSH"
],
"latest-update": "2023-04-14T14:24:26.209592400Z"
"latest-update": "2023-04-18T08:05:49.922275800Z"
}
2 changes: 1 addition & 1 deletion analyzers/src/SonarAnalyzer.VisualBasic/sonarpedia.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"languages": [
"VBNET"
],
"latest-update": "2023-04-14T14:24:45.993980100Z"
"latest-update": "2023-04-18T08:05:22.393227400Z"
}