Skip to content

Commit

Permalink
Update RSPEC before 9.20 release (#8775)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Pohlmann authored Feb 16, 2024
1 parent 9161bc0 commit e3ef756
Show file tree
Hide file tree
Showing 20 changed files with 59 additions and 61 deletions.
2 changes: 1 addition & 1 deletion analyzers/rspec/cs/S107.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h2>Why is this an issue?</h2>
<p>Methods with a long parameter list are difficult to use, as maintainers must figure out the role of each parameter and keep track of their
<p>Methods with a long parameter list are difficult to use because maintainers must figure out the role of each parameter and keep track of their
position.</p>
<pre>
void SetCoordinates(int x1, int y1, int z1, int x2, int y2, int z2) // Noncompliant
Expand Down
10 changes: 5 additions & 5 deletions analyzers/rspec/cs/S1135.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<h2>Why is this an issue?</h2>
<p>Developers often use <code>TODO</code> tags to mark areas in the code where additional work or improvements are needed but are not implemented
immediately. However, these <code>TODO</code> tags sometimes get overlooked or forgotten, leading to incomplete or unfinished code. This code smell
class aims to identify and address such unattended <code>TODO</code> tags to ensure a clean and maintainable codebase. This description will explore
why this is a problem and how it can be fixed to improve the overall code quality.</p>
immediately. However, these <code>TODO</code> tags sometimes get overlooked or forgotten, leading to incomplete or unfinished code. This rule aims to
identify and address unattended <code>TODO</code> tags to ensure a clean and maintainable codebase. This description explores why this is a problem
and how it can be fixed to improve the overall code quality.</p>
<h3>What is the potential impact?</h3>
<p>Unattended <code>TODO</code> tags in code can have significant implications for the development process and the overall codebase.</p>
<p>Incomplete Functionality: When developers leave <code>TODO</code> tags without implementing the corresponding code, it results in incomplete
Expand All @@ -11,8 +11,8 @@ <h3>What is the potential impact?</h3>
Delayed bug fixes can result in more severe issues and increase the effort required to resolve them later.</p>
<p>Impact on Collaboration: In team-based development environments, unattended <code>TODO</code> tags can hinder collaboration. Other team members
might not be aware of the intended changes, leading to conflicts or redundant efforts in the codebase.</p>
<p>Codebase Bloat: Accumulation of unattended <code>TODO</code> tags over time can clutter the codebase and make it difficult to distinguish between
work in progress and completed code. This bloat can make it challenging to maintain an organized and efficient codebase.</p>
<p>Codebase Bloat: The accumulation of unattended <code>TODO</code> tags over time can clutter the codebase and make it difficult to distinguish
between work in progress and completed code. This bloat can make it challenging to maintain an organized and efficient codebase.</p>
<p>Addressing this code smell is essential to ensure a maintainable, readable, reliable codebase and promote effective collaboration among
developers.</p>
<h3>Noncompliant code example</h3>
Expand Down
4 changes: 2 additions & 2 deletions analyzers/rspec/cs/S3603.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h2>Why is this an issue?</h2>
<p>Marking a method with the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.contracts.pureattribute"><code>Pure</code></a>
attribute indicates that the method doesn’t make any visible state changes. Therefore, a <code>Pure</code> method should return a result otherwise it
indicates a no-operation call.</p>
attribute indicates that the method doesn’t make any visible state changes. Therefore, a <code>Pure</code> method should return a result. Otherwise,
it indicates a no-operation call.</p>
<p>Using <code>Pure</code> on a <code>void</code> method is either by mistake or the method is not doing a meaningful task.</p>
<h2>How to fix it</h2>
<h3>Code examples</h3>
Expand Down
8 changes: 4 additions & 4 deletions analyzers/rspec/cs/S3776.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ <h2>Why is this an issue?</h2>
<h3>Which syntax in code does impact cognitive complexity score?</h3>
<p>Here are the core concepts:</p>
<ul>
<li> <strong>Cognitive complexity is incremented each time the code breaks the normal linear reading flow.</strong><br> This concerns, for example:
Loop structures, Conditionals, Catches, Switches, Jumps to label and mixed operators in condition. </li>
<li> <strong>Each nesting level adds a malus to the breaking call.</strong><br> During code reading, the deeper you go through nested layers, the
harder it becomes to keep the context in mind. </li>
<li> <strong>Cognitive complexity is incremented each time the code breaks the normal linear reading flow.</strong><br> This concerns, for example,
loop structures, conditionals, catches, switches, jumps to labels, and conditions mixing multiple operators. </li>
<li> <strong>Each nesting level increases complexity.</strong><br> During code reading, the deeper you go through nested layers, the harder it
becomes to keep the context in mind. </li>
<li> <strong>Method calls are free</strong><br> A well-picked method name is a summary of multiple lines of code. A reader can first explore a
high-level view of what the code is performing then go deeper and deeper by looking at called functions content.<br> <em>Note:</em> This does not
apply to recursive calls, those will increment cognitive score. </li>
Expand Down
9 changes: 4 additions & 5 deletions analyzers/rspec/cs/S4830.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<p>This vulnerability makes it possible that an encrypted communication is intercepted.</p>
<h2>Why is this an issue?</h2>
<p>Transport Layer Security (TLS) provides secure communication between systems over the internet by encrypting the data sent between them. The role
of certificate validation in this process is to ensure that a system is indeed the one it claims to be, adding an extra layer of trust and
security.</p>
<p>When certificate validation is disabled, the client skips this critical check. This creates an opportunity for attackers to pose as a trusted
<p>Transport Layer Security (TLS) provides secure communication between systems over the internet by encrypting the data sent between them.
Certificate validation adds an extra layer of trust and security to this process to ensure that a system is indeed the one it claims to be.</p>
<p>When certificate validation is disabled, the client skips a critical security check. This creates an opportunity for attackers to pose as a trusted
entity and intercept, manipulate, or steal the data being transmitted.</p>
<h3>What is the potential impact?</h3>
<p>Establishing trust in a secure way is a non-trivial task. When you disable certificate validation, you are removing a key mechanism designed to
build this trust in internet communication, opening your system up to a number of potential threats.</p>
<h4>Identity spoofing</h4>
<p>If a system does not validate certificates, it cannot confirm the identity of the other party involved in the communication. An attacker can
exploit this by creating a fake server and masquerading it as a legitimate one. For example, they might set up a server that looks like your bank’s
exploit this by creating a fake server and masquerading as a legitimate one. For example, they might set up a server that looks like your bank’s
server, tricking your system into thinking it is communicating with the bank. This scenario, called identity spoofing, allows the attacker to collect
any data your system sends to them, potentially leading to significant data breaches.</p>
<h4>Loss of data integrity</h4>
Expand Down
4 changes: 2 additions & 2 deletions analyzers/rspec/cs/S6803.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ <h2>Why is this an issue?</h2>
href="https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.supplyparameterfromqueryattribute">SupplyParameterFromQuery</a>
attribute is used to specify that a component parameter of a routable component comes from the <a
href="https://en.wikipedia.org/wiki/Query_string">query string</a>.</p>
<p>In the case non-routable components the <code>SupplyParameterFromQuery</code> does not contribute to the functionality and removing it will not
affect the behavior.</p>
<p>In the case of non-routable components, the <code>SupplyParameterFromQuery</code> does not contribute to the functionality, and removing it will
not affect the behavior.</p>
<h2>How to fix it</h2>
<p>Either make the component routable or remove the <code>SupplyParameterFromQuery</code> attribute.</p>
<h3>Code examples</h3>
Expand Down
8 changes: 4 additions & 4 deletions analyzers/rspec/cs/S927.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ <h2>Why is this an issue?</h2>
<p>Parameters are part of the <a
href="https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/methods#method-signatures">method signature</a> and its
identity.</p>
<p>Implementing a method from an interface, a base class, or a partial method and changing one of its parameters' names will confuse and impact its
readability.</p>
<p>Implementing a method from an interface, a base class, or a partial method and changing one of its parameters' names will confuse and impact the
method’s readability.</p>
<pre data-diff-id="1" data-diff-type="noncompliant">
interface IBankAccount
{
Expand All @@ -18,8 +18,8 @@ <h2>Why is this an issue?</h2>
}
}
</pre>
<p>To avoid any ambiguity in the code, parameters' names should match the initial declaration, whether its initial declaration is from an interface, a
base class, or a partial method.</p>
<p>To avoid any ambiguity in the code, a parameter’s name should match the initial declaration, whether its initial declaration is from an interface,
a base class, or a partial method.</p>
<pre data-diff-id="1" data-diff-type="compliant">
interface IBankAccount
{
Expand Down
2 changes: 1 addition & 1 deletion analyzers/rspec/vbnet/S107.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h2>Why is this an issue?</h2>
<p>Procedures with a long parameter list are difficult to use, as maintainers must figure out the role of each parameter and keep track of their
<p>Procedures with a long parameter list are difficult to use because maintainers must figure out the role of each parameter and keep track of their
position.</p>
<pre>
Sub SetCoordinates(x1 As Integer, y1 As Integer, z1 As Integer, x2 As Integer, y2 As Integer, z2 As Integer) ' Noncompliant
Expand Down
4 changes: 2 additions & 2 deletions analyzers/rspec/vbnet/S1110.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h2>Why is this an issue?</h2>
<p>The use of parentheses, even those not required to enforce a desired order of operations, can clarify the intent behind a piece of code. But
redundant pairs of parentheses could be misleading, and should be removed.</p>
<p>The use of parentheses, even those not required to enforce a desired order of operations, can clarify the intent behind a piece of code. However,
redundant pairs of parentheses could be misleading and should be removed.</p>
<h3>Noncompliant code example</h3>
<pre data-diff-id="1" data-diff-type="noncompliant">
If a AndAlso ((x + y &gt; 0)) Then ' Noncompliant
Expand Down
10 changes: 5 additions & 5 deletions analyzers/rspec/vbnet/S1135.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<h2>Why is this an issue?</h2>
<p>Developers often use <code>TODO</code> tags to mark areas in the code where additional work or improvements are needed but are not implemented
immediately. However, these <code>TODO</code> tags sometimes get overlooked or forgotten, leading to incomplete or unfinished code. This code smell
class aims to identify and address such unattended <code>TODO</code> tags to ensure a clean and maintainable codebase. This description will explore
why this is a problem and how it can be fixed to improve the overall code quality.</p>
immediately. However, these <code>TODO</code> tags sometimes get overlooked or forgotten, leading to incomplete or unfinished code. This rule aims to
identify and address unattended <code>TODO</code> tags to ensure a clean and maintainable codebase. This description explores why this is a problem
and how it can be fixed to improve the overall code quality.</p>
<h3>What is the potential impact?</h3>
<p>Unattended <code>TODO</code> tags in code can have significant implications for the development process and the overall codebase.</p>
<p>Incomplete Functionality: When developers leave <code>TODO</code> tags without implementing the corresponding code, it results in incomplete
Expand All @@ -11,8 +11,8 @@ <h3>What is the potential impact?</h3>
Delayed bug fixes can result in more severe issues and increase the effort required to resolve them later.</p>
<p>Impact on Collaboration: In team-based development environments, unattended <code>TODO</code> tags can hinder collaboration. Other team members
might not be aware of the intended changes, leading to conflicts or redundant efforts in the codebase.</p>
<p>Codebase Bloat: Accumulation of unattended <code>TODO</code> tags over time can clutter the codebase and make it difficult to distinguish between
work in progress and completed code. This bloat can make it challenging to maintain an organized and efficient codebase.</p>
<p>Codebase Bloat: The accumulation of unattended <code>TODO</code> tags over time can clutter the codebase and make it difficult to distinguish
between work in progress and completed code. This bloat can make it challenging to maintain an organized and efficient codebase.</p>
<p>Addressing this code smell is essential to ensure a maintainable, readable, reliable codebase and promote effective collaboration among
developers.</p>
<h3>Noncompliant code example</h3>
Expand Down
14 changes: 7 additions & 7 deletions analyzers/rspec/vbnet/S2178.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<h2>Why is this an issue?</h2>
<p><a href="https://en.wikipedia.org/wiki/Short-circuit_evaluation">Short-circuit evaluation</a> is an evaluation strategy for <a
href="https://en.wikipedia.org/wiki/Logical_connective">Boolean operators</a>, that doesn’t evaluates the second argument of the operator if it is not
href="https://en.wikipedia.org/wiki/Logical_connective">Boolean operators</a>, that doesn’t evaluate the second argument of the operator if it is not
needed to determine the result of the operation.</p>
<p>VB.NET provides logical operators that implement short-circuit evaluation: <code>AndAlso</code> and <code>OrElse</code>, as well as
non-short-circuit versions: <code>And</code> and <code>Or</code>. Unlike short-circuit operators, non-short-circuit ones evaluate both operands and
afterwards perform the logical operation.</p>
<p>For example <code>False AndAlso FunctionCall</code> always results in <code>False</code>, even when <code>FunctionCall</code> invocation would
raise an exception. Instead, <code>False &amp; FunctionCall</code> also evaluates <code>FunctionCall</code>, and results in an exception if
<p>VB.NET provides logical operators that implement short-circuiting evaluations <code>AndAlso</code> and <code>OrElse</code>, as well as the
non-short-circuiting versions <code>And</code> and <code>Or</code>. Unlike short-circuiting operators, the non-short-circuiting operators evaluate
both operands and afterward perform the logical operation.</p>
<p>For example <code>False AndAlso FunctionCall</code> always results in <code>False</code> even when the <code>FunctionCall</code> invocation would
raise an exception. In contrast, <code>False And FunctionCall</code> also evaluates <code>FunctionCall</code>, and results in an exception if
<code>FunctionCall</code> raises an exception.</p>
<p>Similarly, <code>True OrElse FunctionCall</code> always results in <code>True</code>, no matter what the return value of <code>FunctionCall</code>
would be.</p>
<p>The use of non-short-circuit logic in a boolean context is likely a mistake - one that could cause serious program errors as conditions are
<p>The use of non-short-circuit logic in a boolean context is likely a mistake, one that could cause serious program errors as conditions are
evaluated under the wrong circumstances.</p>
<h2>How to fix it</h2>
<h3>Code examples</h3>
Expand Down
4 changes: 2 additions & 2 deletions analyzers/rspec/vbnet/S2551.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ <h2>Why is this an issue?</h2>
<ul>
<li> a reference to <a
href="https://learn.microsoft.com/en-us/dotnet/visual-basic/programming-guide/program-structure/me-my-mybase-and-myclass#me">Me</a>: if the instance
is publicly accessibly, the lock might be shared </li>
<li> a <a href="https://learn.microsoft.com/en-us/dotnet/api/system.type">Type</a> object: if the type class is publicly accessibly, the lock might
is publicly accessible, the lock might be shared </li>
<li> a <a href="https://learn.microsoft.com/en-us/dotnet/api/system.type">Type</a> object: if the type class is publicly accessible, the lock might
be shared </li>
<li> a <a href="https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/data-types/string-data-type">string</a> literal or
instance: if any other part of the program uses the same string, the lock is shared because of interning </li>
Expand Down
6 changes: 3 additions & 3 deletions analyzers/rspec/vbnet/S3449.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ <h2>Why is this an issue?</h2>
href="https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/bit-shift-operators">operators</a>, but the right operand of
the operation needs to be an <code>int</code> or a type that has an <a
href="https://learn.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/data-types/implicit-and-explicit-conversions">implicit
conversion</a> to <code>int</code>. However, when the left operand is an <code>object</code>, the compiler’s type checking is turned off, so you can
pass anything to the right of a shift operator and have it compile. And if the argument can’t be implicitly converted to <code>int</code> at runtime,
then a <a href="https://learn.microsoft.com/en-us/dotnet/api/microsoft.csharp.runtimebinder.runtimebinderexception">RuntimeBinderException</a> will be
conversion</a> to <code>int</code>. However, when the left operand is an <code>object</code>, the compiler’s type checking is turned off, therfore you
can pass anything to the right of a shift operator and have it compile. If the argument can’t be implicitly converted to <code>int</code> at runtime,
a <a href="https://learn.microsoft.com/en-us/dotnet/api/microsoft.csharp.runtimebinder.runtimebinderexception">RuntimeBinderException</a> will be
raised.</p>
<pre>
Dim o As Object = 5
Expand Down
4 changes: 2 additions & 2 deletions analyzers/rspec/vbnet/S3603.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h2>Why is this an issue?</h2>
<p>Marking a method with the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.contracts.pureattribute"><code>Pure</code></a>
attribute indicates that the method doesn’t make any visible state changes. Therefore, a <code>Pure</code> method should return a result otherwise it
indicates a no-operation call.</p>
attribute indicates that the method doesn’t make any visible state changes. Therefore, a <code>Pure</code> method should return a result. Otherwise,
it indicates a no-operation call.</p>
<p>Using <code>Pure</code> on a <code>void</code> method is either by mistake or the method is not doing a meaningful task.</p>
<h2>How to fix it</h2>
<h3>Code examples</h3>
Expand Down
8 changes: 4 additions & 4 deletions analyzers/rspec/vbnet/S3776.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ <h2>Why is this an issue?</h2>
<h3>Which syntax in code does impact cognitive complexity score?</h3>
<p>Here are the core concepts:</p>
<ul>
<li> <strong>Cognitive complexity is incremented each time the code breaks the normal linear reading flow.</strong><br> This concerns, for example:
Loop structures, Conditionals, Catches, Switches, Jumps to label and mixed operators in condition. </li>
<li> <strong>Each nesting level adds a malus to the breaking call.</strong><br> During code reading, the deeper you go through nested layers, the
harder it becomes to keep the context in mind. </li>
<li> <strong>Cognitive complexity is incremented each time the code breaks the normal linear reading flow.</strong><br> This concerns, for example,
loop structures, conditionals, catches, switches, jumps to labels, and conditions mixing multiple operators. </li>
<li> <strong>Each nesting level increases complexity.</strong><br> During code reading, the deeper you go through nested layers, the harder it
becomes to keep the context in mind. </li>
<li> <strong>Method calls are free</strong><br> A well-picked method name is a summary of multiple lines of code. A reader can first explore a
high-level view of what the code is performing then go deeper and deeper by looking at called functions content.<br> <em>Note:</em> This does not
apply to recursive calls, those will increment cognitive score. </li>
Expand Down
Loading

0 comments on commit e3ef756

Please sign in to comment.