-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SONARFLEX-187 Update rule metadata (#197)
- Loading branch information
1 parent
bae5be0
commit 005476c
Showing
43 changed files
with
348 additions
and
194 deletions.
There are no files selected for viewing
5 changes: 3 additions & 2 deletions
5
flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/CommentedCode.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<h2>Why is this an issue?</h2> | ||
<p>Programmers should not comment out code as it bloats programs and reduces readability.</p> | ||
<p>Unused code should be deleted and can be retrieved from source control history if required.</p> | ||
<p>Commented-out code distracts the focus from the actual executed code. It creates a noise that increases maintenance code. And because it is never | ||
executed, it quickly becomes out of date and invalid.</p> | ||
<p>Commented-out code should be deleted and can be retrieved from source control history if required.</p> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10
flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/S1066.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/S1066.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 4 additions & 13 deletions
17
flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/S1068.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/S107.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/S1116.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 14 additions & 4 deletions
18
flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/S1117.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 13 additions & 11 deletions
24
flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/S1144.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 20 additions & 6 deletions
26
flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/S115.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
<p>Constants should be named consistently to communicate intent and improve maintainability. Rename your constants to follow your project’s naming | ||
convention to address this issue.</p> | ||
<h2>Why is this an issue?</h2> | ||
<p>Shared coding conventions allow teams to collaborate efficiently. This rule checks that all constant names match a provided regular expression.</p> | ||
<h3>Noncompliant code example</h3> | ||
<p>With the default regular expression <code>^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$</code>:</p> | ||
<pre> | ||
<p>Constants are variables whose value does not change during the runtime of a program after initialization. Oftentimes, constants are used in | ||
multiple locations across different subroutines.</p> | ||
<p>It is important that the names of constants follow a consistent and easily recognizable pattern. This way, readers immediately understand that the | ||
referenced value does not change, which simplifies debugging.</p> | ||
<p>This rule checks that all constant names match a given regular expression.</p> | ||
<h3>What is the potential impact?</h3> | ||
<p>Ignoring the naming convention for constants makes the code less readable since constants and variables are harder to tell apart. Code that is hard | ||
to understand is also difficult to maintain between different team members.</p> | ||
<h2>How to fix it</h2> | ||
<p>First, familiarize yourself with the particular naming convention of the project in question. Then, update the name of the constant to match the | ||
convention, as well as all usages of the name. For many IDEs, you can use built-in renaming and refactoring features to update all usages of a | ||
constant at once.</p> | ||
<h3>Code examples</h3> | ||
<h4>Noncompliant code example</h4> | ||
<p>The following example assumes that constant names should match the default regular expression <code>^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$</code>:</p> | ||
<pre data-diff-id="1" data-diff-type="noncompliant"> | ||
public static const first:String = "first"; | ||
</pre> | ||
<h3>Compliant solution</h3> | ||
<pre> | ||
<h4>Compliant solution</h4> | ||
<pre data-diff-id="1" data-diff-type="compliant"> | ||
public static const FIRST:String = "first"; | ||
</pre> | ||
|
20 changes: 13 additions & 7 deletions
20
flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/S116.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
<h2>Why is this an issue?</h2> | ||
<p>Sharing some naming conventions is a key point to make it possible for a team to efficiently collaborate. This rule allows to check that field | ||
names match a provided regular expression.</p> | ||
<h3>Noncompliant code example</h3> | ||
<p>With the default regular expression <code>^[_a-z][a-zA-Z0-9]*$</code>:</p> | ||
<pre> | ||
<p>A naming convention in software development is a set of guidelines for naming code elements like variables, functions, and classes.</p> | ||
<p>The goal of a naming convention is to make the code more readable and understandable, which makes it easier to maintain and debug. It also ensures | ||
consistency in the code, especially when multiple developers are working on the same project.</p> | ||
<p>This rule checks that field names match a provided regular expression.</p> | ||
<p>Using the regular expression <code>^[_a-z][a-zA-Z0-9]*$</code>, the noncompliant code below:</p> | ||
<pre data-diff-id="1" data-diff-type="noncompliant"> | ||
class MyClass { | ||
public var my_field:int; | ||
} | ||
</pre> | ||
<h3>Compliant solution</h3> | ||
<pre> | ||
<p>Should be replaced with:</p> | ||
<pre data-diff-id="1" data-diff-type="compliant"> | ||
public class MyClass { | ||
public var myField:int; | ||
} | ||
</pre> | ||
<h2>Resources</h2> | ||
<h3>Documentation</h3> | ||
<ul> | ||
<li> Wikipedia - <a href="https://en.wikipedia.org/wiki/Naming_convention_(programming)">Naming Convention (programming)</a> </li> | ||
</ul> | ||
|
52 changes: 46 additions & 6 deletions
52
flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/S117.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,61 @@ | ||
<p>Local variables and function parameters should be named consistently to communicate intent and improve maintainability. Rename your local variable | ||
or function parameter to follow your project’s naming convention to address this issue.</p> | ||
<h2>Why is this an issue?</h2> | ||
<p>Shared naming conventions allow teams to collaborate effectively. This rule raises an issue when a local variable or function parameter name does | ||
not match the provided regular expression.</p> | ||
<h3>Noncompliant code example</h3> | ||
<p>A naming convention in software development is a set of guidelines for naming code elements like variables, functions, and classes.<br> Local | ||
variables and function parameters hold the meaning of the written code. Their names should be meaningful and follow a consistent and easily | ||
recognizable pattern.<br> Adhering to a consistent naming convention helps to make the code more readable and understandable, which makes it easier to | ||
maintain and debug. It also ensures consistency in the code, especially when multiple developers are working on the same project.</p> | ||
<p>This rule checks that local variable and function parameter names match a provided regular expression.</p> | ||
<h3>What is the potential impact?</h3> | ||
<p>Inconsistent naming of local variables and function parameters can lead to several issues in your code:</p> | ||
<ul> | ||
<li> <strong>Reduced Readability</strong>: Inconsistent local variable and function parameter names make the code harder to read and understand; | ||
consequently, it is more difficult to identify the purpose of each variable, spot errors, or comprehend the logic. </li> | ||
<li> <strong>Difficulty in Identifying Variables</strong>: The local variables and function parameters that don’t adhere to a standard naming | ||
convention are challenging to identify; thus, the coding process slows down, especially when dealing with a large codebase. </li> | ||
<li> <strong>Increased Risk of Errors</strong>: Inconsistent or unclear local variable and function parameter names lead to misunderstandings about | ||
what the variable represents. This ambiguity leads to incorrect assumptions and, consequently, bugs in the code. </li> | ||
<li> <strong>Collaboration Difficulties</strong>: In a team setting, inconsistent naming conventions lead to confusion and miscommunication among | ||
team members. </li> | ||
<li> <strong>Difficulty in Code Maintenance</strong>: Inconsistent naming leads to an inconsistent codebase. The code is difficult to understand, | ||
and making changes feels like refactoring constantly, as you face different naming methods. Ultimately, it makes the codebase harder to maintain. | ||
</li> | ||
</ul> | ||
<p>In summary, not adhering to a naming convention for local variables and function parameters can lead to confusion, errors, and inefficiencies, | ||
making the code harder to read, understand, and maintain.</p> | ||
<h2>How to fix it</h2> | ||
<p>First, familiarize yourself with the particular naming convention of the project in question. Then, update the name to match the convention, as | ||
well as all usages of the name. For many IDEs, you can use built-in renaming and refactoring features to update all usages at once.</p> | ||
<h3>Code examples</h3> | ||
<h4>Noncompliant code example</h4> | ||
<p>With the default regular expression <code>^[_a-z][a-zA-Z0-9]*$</code>:</p> | ||
<pre> | ||
<pre data-diff-id="1" data-diff-type="noncompliant"> | ||
public function doSomething(my_param:int):void | ||
{ | ||
var LOCAL:int; | ||
... | ||
} | ||
</pre> | ||
<h3>Compliant solution</h3> | ||
<pre> | ||
<h4>Compliant solution</h4> | ||
<pre data-diff-id="1" data-diff-type="compliant"> | ||
public function doSomething(myParam):void | ||
{ | ||
var local; | ||
... | ||
} | ||
</pre> | ||
<h2>Resources</h2> | ||
<h3>Documentation</h3> | ||
<ul> | ||
<li> Wikipedia - <a href="https://en.wikipedia.org/wiki/Naming_convention_(programming)">Naming Convention (programming)</a> </li> | ||
</ul> | ||
<h3>Related rules</h3> | ||
<ul> | ||
<li> {rule:flex:S100} - Function names should comply with a naming convention </li> | ||
<li> {rule:flex:S101} - Class names should comply with a naming convention </li> | ||
<li> {rule:flex:S115} - Constant names should comply with a naming convention </li> | ||
<li> {rule:flex:S116} - Field names should comply with a naming convention </li> | ||
<li> {rule:flex:S120} - Package names should comply with a naming convention </li> | ||
<li> {rule:flex:S1312} - Loggers should be "private static const" and should share naming convention </li> | ||
</ul> | ||
|
Oops, something went wrong.