Skip to content

Commit 9478382

Browse files
Update RSPEC before 9.23 release (#8976)
1 parent 8a64975 commit 9478382

File tree

8 files changed

+39
-39
lines changed

8 files changed

+39
-39
lines changed

analyzers/rspec/cs/S1192.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ <h3>Exceptions</h3>
99
<li> literals used in attributes </li>
1010
</ul>
1111
<h2>How to fix it</h2>
12-
<p>Instead, use constants to replace the duplicated string literals. Constants can be referenced from many places, but only need to be updated in a
13-
single place.</p>
12+
<p>Use constants to replace the duplicated string literals. Constants can be referenced from many places, but only need to be updated in a single
13+
place.</p>
1414
<h3>Code examples</h3>
1515
<h4>Noncompliant code example</h4>
1616
<pre data-diff-id="1" data-diff-type="noncompliant">

analyzers/rspec/cs/S1481.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ <h2>Why is this an issue?</h2>
55
<h3>What is the potential impact?</h3>
66
<p>Having unused local variables in your code can lead to several issues:</p>
77
<ul>
8-
<li> Decreased Readability: Unused variables can make your code more difficult to read. They add extra lines and complexity, which can distract from
9-
the main logic of the code. </li>
10-
<li> Misunderstanding: When other developers read your code, they may wonder why a variable is declared but not used. This can lead to confusion and
11-
misinterpretation of the code’s intent. </li>
12-
<li> Potential for Bugs: If a variable is declared but not used, it might indicate a bug or incomplete code. For example, if you declared a variable
13-
intending to use it in a calculation, but then forgot to do so, your program might not work as expected. </li>
14-
<li> Maintenance Issues: Unused variables can make code maintenance more difficult. If a programmer sees an unused variable, they might think it is
15-
a mistake and try to 'fix' the code, potentially introducing new bugs. </li>
16-
<li> Memory Usage: Although modern compilers are smart enough to ignore unused variables, not all compilers do this. In such cases, unused variables
17-
take up memory space, leading to inefficient use of resources. </li>
8+
<li> <strong>Decreased Readability</strong>: Unused variables can make your code more difficult to read. They add extra lines and complexity, which
9+
can distract from the main logic of the code. </li>
10+
<li> <strong>Misunderstanding</strong>: When other developers read your code, they may wonder why a variable is declared but not used. This can lead
11+
to confusion and misinterpretation of the code’s intent. </li>
12+
<li> <strong>Potential for Bugs</strong>: If a variable is declared but not used, it might indicate a bug or incomplete code. For example, if you
13+
declared a variable intending to use it in a calculation, but then forgot to do so, your program might not work as expected. </li>
14+
<li> <strong>Maintenance Issues</strong>: Unused variables can make code maintenance more difficult. If a programmer sees an unused variable, they
15+
might think it is a mistake and try to 'fix' the code, potentially introducing new bugs. </li>
16+
<li> <strong>Memory Usage</strong>: Although modern compilers are smart enough to ignore unused variables, not all compilers do this. In such cases,
17+
unused variables take up memory space, leading to inefficient use of resources. </li>
1818
</ul>
1919
<p>In summary, unused local variables can make your code less readable, more confusing, and harder to maintain, and they can potentially lead to bugs
2020
or inefficient memory use. Therefore, it is best to remove them.</p>

analyzers/rspec/cs/S2955.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ <h4>Compliant solution</h4>
2727
<pre data-diff-id="1" data-diff-type="compliant">
2828
bool IsDefault&lt;T&gt;(T value)
2929
{
30-
if(object.Equals(value, default(T)))
30+
if (EqualityComparer&lt;T&gt;.Default.Equals(value, default(T)))
3131
{
3232
// ...
3333
}

analyzers/rspec/cs/S6934.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ <h2>Why is this an issue?</h2>
2020

2121
public class PersonController
2222
{
23-
// Conventional routing:
24-
// Matches e.g. /Person/Index/123
25-
public IActionResult Index(int? id) =&gt; View();
23+
// Conventional routing:
24+
// Matches e.g. /Person/Index/123
25+
public IActionResult Index(int? id) =&gt; View();
2626

27-
// Attribute routing:
28-
// Matches e.g. /Age/Ascending (and model binds "Age" to sortBy and "Ascending" to direction)
29-
// but does not match /Person/List/Age/Ascending
30-
[HttpGet(template: "{sortBy}/{direction}")]
31-
public IActionResult List(string sortBy, SortOrder direction) =&gt; View();
27+
// Attribute routing:
28+
// Matches e.g. /Age/Ascending (and model binds "Age" to sortBy and "Ascending" to direction)
29+
// but does not match /Person/List/Age/Ascending
30+
[HttpGet(template: "{sortBy}/{direction}")]
31+
public IActionResult List(string sortBy, SortOrder direction) =&gt; View();
3232
}
3333
</pre>
3434
<h2>How to fix it in ASP.NET Core</h2>
@@ -39,7 +39,7 @@ <h2>How to fix it in ASP.NET Core</h2>
3939
<h3>Code examples</h3>
4040
<h4>Noncompliant code example</h4>
4141
<pre data-diff-id="1" data-diff-type="noncompliant">
42-
public class PersonController: Controller
42+
public class PersonController : Controller
4343
{
4444
// Matches /Person/Index/123
4545
public IActionResult Index(int? id) =&gt; View();
@@ -53,7 +53,7 @@ <h4>Noncompliant code example</h4>
5353
<h4>Compliant solution</h4>
5454
<pre data-diff-id="1" data-diff-type="compliant">
5555
[Route("[controller]/{action=Index}")]
56-
public class PersonController: Controller
56+
public class PersonController : Controller
5757
{
5858
// Matches /Person/Index/123
5959
[Route("{id?}")]
@@ -73,15 +73,15 @@ <h4>Compliant solution</h4>
7373
defaults: new { action = "List" } ); // Matches Person/List/Age/Ascending
7474

7575
// Option 2. Use a binding, that does not depend on route templates
76-
public class PersonController: Controller
76+
public class PersonController : Controller
7777
{
7878
// Matches Person/List?sortBy=Age&amp;direction=Ascending
7979
[HttpGet] // Compliant: Parameters are bound from the query string
8080
public IActionResult List(string sortBy, SortOrder direction) =&gt; View();
8181
}
8282

8383
// Option 3. Use an absolute route
84-
public class PersonController: Controller
84+
public class PersonController : Controller
8585
{
8686
// Matches Person/List/Age/Ascending
8787
[HttpGet("/[controller]/[action]/{sortBy}/{direction}")] // Illustrate the expected route by starting with "/"

analyzers/rspec/vbnet/S1192.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ <h3>Exceptions</h3>
99
<li> literals used in attributes </li>
1010
</ul>
1111
<h2>How to fix it</h2>
12-
<p>Instead, use constants to replace the duplicated string literals. Constants can be referenced from many places, but only need to be updated in a
13-
single place.</p>
12+
<p>Use constants to replace the duplicated string literals. Constants can be referenced from many places, but only need to be updated in a single
13+
place.</p>
1414
<h3>Code examples</h3>
1515
<h4>Noncompliant code example</h4>
1616
<pre data-diff-id="1" data-diff-type="noncompliant">

analyzers/rspec/vbnet/S1481.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ <h2>Why is this an issue?</h2>
55
<h3>What is the potential impact?</h3>
66
<p>Having unused local variables in your code can lead to several issues:</p>
77
<ul>
8-
<li> Decreased Readability: Unused variables can make your code more difficult to read. They add extra lines and complexity, which can distract from
9-
the main logic of the code. </li>
10-
<li> Misunderstanding: When other developers read your code, they may wonder why a variable is declared but not used. This can lead to confusion and
11-
misinterpretation of the code’s intent. </li>
12-
<li> Potential for Bugs: If a variable is declared but not used, it might indicate a bug or incomplete code. For example, if you declared a variable
13-
intending to use it in a calculation, but then forgot to do so, your program might not work as expected. </li>
14-
<li> Maintenance Issues: Unused variables can make code maintenance more difficult. If a programmer sees an unused variable, they might think it is
15-
a mistake and try to 'fix' the code, potentially introducing new bugs. </li>
16-
<li> Memory Usage: Although modern compilers are smart enough to ignore unused variables, not all compilers do this. In such cases, unused variables
17-
take up memory space, leading to inefficient use of resources. </li>
8+
<li> <strong>Decreased Readability</strong>: Unused variables can make your code more difficult to read. They add extra lines and complexity, which
9+
can distract from the main logic of the code. </li>
10+
<li> <strong>Misunderstanding</strong>: When other developers read your code, they may wonder why a variable is declared but not used. This can lead
11+
to confusion and misinterpretation of the code’s intent. </li>
12+
<li> <strong>Potential for Bugs</strong>: If a variable is declared but not used, it might indicate a bug or incomplete code. For example, if you
13+
declared a variable intending to use it in a calculation, but then forgot to do so, your program might not work as expected. </li>
14+
<li> <strong>Maintenance Issues</strong>: Unused variables can make code maintenance more difficult. If a programmer sees an unused variable, they
15+
might think it is a mistake and try to 'fix' the code, potentially introducing new bugs. </li>
16+
<li> <strong>Memory Usage</strong>: Although modern compilers are smart enough to ignore unused variables, not all compilers do this. In such cases,
17+
unused variables take up memory space, leading to inefficient use of resources. </li>
1818
</ul>
1919
<p>In summary, unused local variables can make your code less readable, more confusing, and harder to maintain, and they can potentially lead to bugs
2020
or inefficient memory use. Therefore, it is best to remove them.</p>

analyzers/src/SonarAnalyzer.CSharp/sonarpedia.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"languages": [
44
"CSH"
55
],
6-
"latest-update": "2024-03-20T08:56:52.732098400Z",
6+
"latest-update": "2024-03-22T15:44:44.508271500Z",
77
"options": {
88
"no-language-in-filenames": true
99
}

analyzers/src/SonarAnalyzer.VisualBasic/sonarpedia.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"languages": [
44
"VBNET"
55
],
6-
"latest-update": "2024-03-20T08:59:07.028699300Z",
6+
"latest-update": "2024-03-22T15:45:04.138667400Z",
77
"options": {
88
"no-language-in-filenames": true
99
}

0 commit comments

Comments
 (0)