-
Notifications
You must be signed in to change notification settings - Fork 232
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 before 9.23 release #8976
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ <h4>Compliant solution</h4> | |
<pre data-diff-id="1" data-diff-type="compliant"> | ||
bool IsDefault<T>(T value) | ||
{ | ||
if(object.Equals(value, default(T))) | ||
if (EqualityComparer<T>.Default.Equals(value, default(T))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change has been done by @gregory-paidis-sonarsource in the context of SonarSource/rspec#3794. |
||
{ | ||
// ... | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,8 @@ <h3>Exceptions</h3> | |
<li> literals used in attributes </li> | ||
</ul> | ||
<h2>How to fix it</h2> | ||
<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 | ||
single place.</p> | ||
<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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
place.</p> | ||
<h3>Code examples</h3> | ||
<h4>Noncompliant code example</h4> | ||
<pre data-diff-id="1" data-diff-type="noncompliant"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,16 +5,16 @@ <h2>Why is this an issue?</h2> | |
<h3>What is the potential impact?</h3> | ||
<p>Having unused local variables in your code can lead to several issues:</p> | ||
<ul> | ||
<li> Decreased Readability: Unused variables can make your code more difficult to read. They add extra lines and complexity, which can distract from | ||
the main logic of the code. </li> | ||
<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 | ||
misinterpretation of the code’s intent. </li> | ||
<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 | ||
intending to use it in a calculation, but then forgot to do so, your program might not work as expected. </li> | ||
<li> Maintenance Issues: Unused variables can make code maintenance more difficult. If a programmer sees an unused variable, they might think it is | ||
a mistake and try to 'fix' the code, potentially introducing new bugs. </li> | ||
<li> Memory Usage: Although modern compilers are smart enough to ignore unused variables, not all compilers do this. In such cases, unused variables | ||
take up memory space, leading to inefficient use of resources. </li> | ||
<li> <strong>Decreased Readability</strong>: Unused variables can make your code more difficult to read. They add extra lines and complexity, which | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change was done by @jonas-wielage-sonarsource for IaC in the context of SonarSource/rspec#3790. |
||
can distract from the main logic of the code. </li> | ||
<li> <strong>Misunderstanding</strong>: When other developers read your code, they may wonder why a variable is declared but not used. This can lead | ||
to confusion and misinterpretation of the code’s intent. </li> | ||
<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 | ||
declared a variable intending to use it in a calculation, but then forgot to do so, your program might not work as expected. </li> | ||
<li> <strong>Maintenance Issues</strong>: Unused variables can make code maintenance more difficult. If a programmer sees an unused variable, they | ||
might think it is a mistake and try to 'fix' the code, potentially introducing new bugs. </li> | ||
<li> <strong>Memory Usage</strong>: Although modern compilers are smart enough to ignore unused variables, not all compilers do this. In such cases, | ||
unused variables take up memory space, leading to inefficient use of resources. </li> | ||
</ul> | ||
<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 | ||
or inefficient memory use. Therefore, it is best to remove them.</p> | ||
|
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.
This change is related to this PR: SonarSource/rspec#3789
While the change was made in the context of IaC, it is acceptable also in the .NET context too.