Skip to content

Commit

Permalink
Deploying to gh-pages from @ 826213e 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien-marichal committed Dec 18, 2024
1 parent b5918a6 commit 19f35ed
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 112 deletions.
93 changes: 15 additions & 78 deletions rules/S6146/default-description.html
Original file line number Diff line number Diff line change
@@ -1,102 +1,39 @@
<div class="sect1">
<h2 id="_description">Description</h2>
<div class="sectionbody">

<div class="paragraph">
<p>FIXME: add a description</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_why_is_this_an_issue">Why is this an issue?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>There are several compilations options available for Visual Basic source code and <code>Option Explicit</code> defines compiler behavior for implicit variable declarations. Specifying <code>Option Explicit Off</code> will allow creating a variable by it&#8217;s first usage. This behavior can lead to unexpected runtime errors due to typos in variable names.</p>
<p>FIXME: remove the unused optional headers (that are commented out)</p>
</div>
<div class="paragraph">
<p><code>Option Explicit</code> can be set in project properties or overridden in individual source files.</p>
</div>
</div>
<div class="sect1">
<h2 id="_how_to_fix_it">How to fix it</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_noncompliant_code_example">Noncompliant code example</h3>
<h3 id="_code_examples">Code examples</h3>
<div class="sect3">
<h4 id="_noncompliant_code_example">Noncompliant code example</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-text" data-lang="text">Option Explicit Off ' Noncompliant

Module MainMod

Public Sub DoSomething(First As String, Second As String)
Parameter = Fist ' New local variable "Fist" is created and assigned to new local variable "Parameter" instead of "First" argument.
DoSomething(Parameter)
Parametr = Second ' "Second" argument is assigned to newly created variable "Parametr" instead of intended "Parameter".
DoSomething(Parameter) ' Value of "Parameter" is always Nothing
End Sub

Private Sub DoSomething(Parameter As String)
' ...
End Sub

End Module</code></pre>
<pre class="highlight"><code class="language-vb6" data-lang="vb6">FIXME</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_compliant_solution">Compliant solution</h3>
<div class="sect3">
<h4 id="_compliant_solution">Compliant solution</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-text" data-lang="text">Option Explicit On

Module MainMod

Public Sub DoSomething(First As String, Second As String)
Dim Parameter As String = First
DoSomething(Parameter)
Parameter = Second
DoSomething(Parameter)
End Sub

Private Sub DoSomething(Parameter As String)
' ...
End Sub

End Module</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_resources">Resources</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/option-explicit-statement">Visual Basic documentation - Option Explicit Statement</a></p>
</li>
</ul>
</div>
<hr>
</div>
</div>
<div class="sect1">
<h2 id="_implementation_specification">Implementation Specification</h2>
<div class="sectionbody">
<div class="paragraph">
<p>(visible only on this page)</p>
</div>
<div class="sect2">
<h3 id="_message">Message</h3>
<div class="ulist">
<ul>
<li>
<p>Change this to 'Option Explicit On'.</p>
</li>
<li>
<p>Configure 'Option Explicit On' for assembly '{0}'.</p>
</li>
</ul>
<pre class="highlight"><code class="language-vb6" data-lang="vb6">FIXME</code></pre>
</div>
</div>
<div class="sect2">
<h3 id="_highlighting">Highlighting</h3>
<div class="paragraph">
<p>"Option Explicit Off" statement</p>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion rules/S6146/default-metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"title":"\"Option Explicit\" should be enabled","type":"CODE_SMELL","code":{"impacts":{"MAINTAINABILITY":"HIGH"},"attribute":"COMPLETE"},"status":"ready","remediation":{"func":"Constant/Issue","constantCost":"3h"},"tags":["bad-practice"],"extra":{"replacementRules":[],"legacyKeys":[]},"defaultSeverity":"Critical","ruleSpecification":"RSPEC-6146","sqKey":"S6146","scope":"All","defaultQualityProfiles":["Sonar way"],"quickfix":"unknown","allKeys":["S6146"],"branch":"master","languagesSupport":[{"name":"vbnet","status":"ready"}]}
{"title":"\"Option Explicit\" should be enabled","type":"CODE_SMELL","code":{"impacts":{"MAINTAINABILITY":"HIGH"},"attribute":"COMPLETE"},"status":"ready","remediation":{"func":"Constant/Issue","constantCost":"3h"},"tags":["bad-practice"],"extra":{"replacementRules":[],"legacyKeys":[]},"defaultSeverity":"Critical","ruleSpecification":"RSPEC-6146","sqKey":"S6146","scope":"All","defaultQualityProfiles":["Sonar way"],"quickfix":"unknown","allKeys":["S6146"],"prUrl":"https://github.com/SonarSource/rspec/pull/4582","branch":"rule/S6146-add-vb6","languagesSupport":[{"name":"vb6","status":"ready"},{"name":"vbnet","status":"ready"}]}
40 changes: 40 additions & 0 deletions rules/S6146/vb6-description.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<div class="sect1">
<h2 id="_description">Description</h2>
<div class="sectionbody">
<div class="paragraph">
<p>FIXME: add a description</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_why_is_this_an_issue">Why is this an issue?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>FIXME: remove the unused optional headers (that are commented out)</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_how_to_fix_it">How to fix it</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_code_examples">Code examples</h3>
<div class="sect3">
<h4 id="_noncompliant_code_example">Noncompliant code example</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vb6" data-lang="vb6">FIXME</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_compliant_solution">Compliant solution</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vb6" data-lang="vb6">FIXME</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
1 change: 1 addition & 0 deletions rules/S6146/vb6-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"title":"\"Option Explicit\" should be enabled","type":"CODE_SMELL","code":{"impacts":{"MAINTAINABILITY":"HIGH"},"attribute":"COMPLETE"},"status":"ready","remediation":{"func":"Constant/Issue","constantCost":"3h"},"tags":["bad-practice"],"extra":{"replacementRules":[],"legacyKeys":[]},"defaultSeverity":"Critical","ruleSpecification":"RSPEC-6146","sqKey":"S6146","scope":"All","defaultQualityProfiles":["Sonar way"],"quickfix":"unknown","allKeys":["S6146"],"prUrl":"https://github.com/SonarSource/rspec/pull/4582","branch":"rule/S6146-add-vb6","languagesSupport":[{"name":"vb6","status":"ready"},{"name":"vbnet","status":"ready"}]}
2 changes: 1 addition & 1 deletion rules/S6146/vbnet-metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"title":"\"Option Explicit\" should be enabled","type":"CODE_SMELL","code":{"impacts":{"MAINTAINABILITY":"HIGH"},"attribute":"COMPLETE"},"status":"ready","remediation":{"func":"Constant/Issue","constantCost":"3h"},"tags":["bad-practice"],"extra":{"replacementRules":[],"legacyKeys":[]},"defaultSeverity":"Critical","ruleSpecification":"RSPEC-6146","sqKey":"S6146","scope":"All","defaultQualityProfiles":["Sonar way"],"quickfix":"unknown","allKeys":["S6146"],"branch":"master","languagesSupport":[{"name":"vbnet","status":"ready"}]}
{"title":"\"Option Explicit\" should be enabled","type":"CODE_SMELL","code":{"impacts":{"MAINTAINABILITY":"HIGH"},"attribute":"COMPLETE"},"status":"ready","remediation":{"func":"Constant/Issue","constantCost":"3h"},"tags":["bad-practice"],"extra":{"replacementRules":[],"legacyKeys":[]},"defaultSeverity":"Critical","ruleSpecification":"RSPEC-6146","sqKey":"S6146","scope":"All","defaultQualityProfiles":["Sonar way"],"quickfix":"unknown","allKeys":["S6146"],"prUrl":"https://github.com/SonarSource/rspec/pull/4582","branch":"rule/S6146-add-vb6","languagesSupport":[{"name":"vb6","status":"ready"},{"name":"vbnet","status":"ready"}]}
84 changes: 55 additions & 29 deletions rules/S907/vb6-description.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,75 @@ <h2 id="_why_is_this_an_issue">Why is this an issue?</h2>
<p><code>GoTo</code> is an unstructured control flow statement. It makes code less readable and maintainable. Structured control flow statements such as <code>If</code>, <code>For</code>, <code>While</code>, or <code>Exit</code> should be used instead.</p>
</div>
<div class="sect2">
<h3 id="_noncompliant_code_example">Noncompliant code example</h3>
<h3 id="_exceptions">Exceptions</h3>
<div class="paragraph">
<p><code>On Error GoTo</code> statements are ignored as correct error handling.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_how_to_fix_it">How to fix it</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Replace <code>GoTo</code> statements with structured control flow statements.</p>
</div>
<div class="sect2">
<h3 id="_code_examples">Code examples</h3>
<div class="sect3">
<h4 id="_noncompliant_code_example">Noncompliant code example</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vb6" data-lang="vb6"> Sub gotoStatementDemo()
Dim number As Integer = 1
Dim sampleString As String
' Evaluate number and branch to appropriate label.
If number = 1 Then GoTo Line1 Else GoTo Line2
<pre class="highlight"><code class="language-vb6" data-lang="vb6">Sub gotoStatementDemo()
Dim number As Integer = 1
Dim sampleString As String
' Evaluate number and branch to appropriate label.
If number = 1 Then GoTo Line1 Else GoTo Line2
Line1:
sampleString = "Number equals 1"
GoTo LastLine
sampleString = "Number equals 1"
GoTo LastLine
Line2:
' The following statement never gets executed because number = 1.
sampleString = "Number equals 2"
' The following statement never gets executed because number = 1.
sampleString = "Number equals 2"
LastLine:
' Write "Number equals 1" in the Debug window.
Debug.WriteLine(sampleString)
End Sub</code></pre>
' Write "Number equals 1" in the Debug window.
Debug.WriteLine(sampleString)
End Sub</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_compliant_solution">Compliant solution</h3>
<div class="sect3">
<h4 id="_compliant_solution">Compliant solution</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-vb6" data-lang="vb6"> Sub gotoStatementDemo()
Dim number As Integer = 1
Dim sampleString As String
' Evaluate number and branch to appropriate label.
If number = 1 Then
sampleString = "Number equals 1"
Else
sampleString = "Number equals 2"
End If
Debug.WriteLine(sampleString)
End Sub</code></pre>
<pre class="highlight"><code class="language-vb6" data-lang="vb6">Sub gotoStatementDemo()
Dim number As Integer = 1
Dim sampleString As String
' Evaluate number and branch to appropriate label.
If number = 1 Then
sampleString = "Number equals 1"
Else
sampleString = "Number equals 2"
End If
Debug.WriteLine(sampleString)
End Sub</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_resources">Resources</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_exceptions">Exceptions</h3>
<div class="paragraph">
<p><code>On Error GoTo</code> statements are ignored as correct error handling.</p>
<h3 id="_documentation">Documentation</h3>
<div class="ulist">
<ul>
<li>
<p>Microsoft Learn - <a href="https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/goto-statement">GoTo statement</a></p>
</li>
</ul>
</div>
<hr>
</div>
Expand Down
2 changes: 1 addition & 1 deletion rules/rule-index-aggregates.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"langs":{"abap":123,"apex":70,"cfamily":923,"csharp":598,"default":3707,"flex":100,"go":56,"java":978,"javascript":575,"jcl":21,"kotlin":158,"php":329,"python":428,"rpg":94,"ruby":42,"scala":43,"swift":149,"plsql":216,"dart":115,"vbnet":266,"html":106,"pli":34,"tsql":86,"vb6":66,"xml":60,"cobol":225,"css":28,"ansible":17,"azureresourcemanager":32,"cloudformation":28,"docker":45,"kubernetes":24,"terraform":51,"secrets":123,"text":2},"tags":{"convention":233,"cert":361,"misra-c++2008":59,"pitfall":328,"based-on-misra":208,"cppcoreguidelines":86,"suspicious":189,"brain-overload":88,"misra":28,"bad-practice":140,"unused":84,"clumsy":181,"lock-in":49,"cwe":435,"error-handling":68,"psr2":8,"error-reporting":3,"user-experience":26,"sql":103,"obsolete":58,"android":26,"accessibility":48,"react":77,"wcag2-a":10,"injection":1,"html5":5,"cross-browser":4,"design":60,"bug":37,"confusing":147,"unpredictable":46,"es2015":22,"type-dependent":73,"redundant":25,"performance":195,"since-c++11":62,"multi-threading":55,"leak":15,"denial-of-service":18,"symbolic-execution":67,"data-science":20,"numpy":15,"pytorch":9,"microfocus":1,"logging":15,"jsp-jsf":6,"deprecated":12,"pep":6,"preprocessor":11,"java8":24,"tests":65,"junit":23,"phpunit":12,"security":5,"python3":18,"psr1":3,"per":2,"finding":12,"i18n":1,"serialization":18,"hibernate":9,"spring":47,"django":12,"express.js":17,"fastapi":2,"flask":6,"privacy":13,"api-design":31,"singleton":1,"AWS":1,"overflow":3,"jasmine":1,"jest":1,"mocha":4,"node":1,"struts":4,"misra-c2012":12,"backbone":3,"misra-c2004":19,"docker":2,"angularjs":1,"ejb":3,"jee":6,"chai":5,"syntax":4,"jquery":1,"assertj":7,"mockito":5,"msvc":1,"swing":1,"deadlock":3,"async-await":8,"php-ini":6,"typing":22,"maven":9,"since-c++14":5,"c11":1,"gnu":3,"xsd":18,"defign":1,"localisation":4,"duplicate":1,"mef":3,"winforms":1,"event":1,"regex":40,"wpf":1,"xaml":1,"proficiency":5,"aws":33,"azure":24,"gcp":20,"rules":1,"antipattern":1,"jsx":8,"yield":1,"debug":1,"java7":1,"guava":1,"java9":2,"full-project":3,"ssl":2,"phishing":1,"java14":6,"dockerfile":11,"governor-limits":5,"since-c++17":24,"unittest":2,"java15":1,"since-c++20":65,"java16":12,"java10":1,"java17":1,"startup-time":2,"coroutines":12,"cwe-284":1,"javadoc":12,"java18":9,"floating-point":1,"numbers":1,"precision":1,"architecture":8,"async":1,"promise":1,"sans-top25-insecure":1,"enum":2,"object":1,"string":1,"shell":1,"assertion":1,"function":1,"type":1,"es2020":1,"nullish-coalescing":1,"rspec-showcase":3,"Gradle":2,"gradle":10,"es2022":1,"es2018":1,"jspecify":1,"nullability":1,"scientific-computing":4,"pandas":9,"graphql":2,"blazor":9,"paths":1,"best-practice":1,"java21":15,"datetime":7,"sustainability":10,"java":1,"jpa":1,"machine-learning":18,"tensorflow":7,"susceptibility":1,"asp.net":11,"scikit-learn":5,"since-c++23":6,"respectful":1,"assembler":1},"qualityProfiles":{"Sonar way":2525,"Drupal":1}}
{"langs":{"abap":123,"apex":70,"cfamily":923,"csharp":598,"default":3707,"flex":100,"go":56,"java":978,"javascript":575,"jcl":21,"kotlin":158,"php":329,"python":428,"rpg":94,"ruby":42,"scala":43,"swift":149,"plsql":216,"dart":115,"vbnet":266,"html":106,"pli":34,"tsql":86,"vb6":67,"xml":60,"cobol":225,"css":28,"ansible":17,"azureresourcemanager":32,"cloudformation":28,"docker":45,"kubernetes":24,"terraform":51,"secrets":123,"text":2},"tags":{"convention":233,"cert":361,"misra-c++2008":59,"pitfall":328,"based-on-misra":208,"cppcoreguidelines":86,"suspicious":189,"brain-overload":88,"misra":28,"bad-practice":140,"unused":84,"clumsy":181,"lock-in":49,"cwe":435,"error-handling":68,"psr2":8,"error-reporting":3,"user-experience":26,"sql":103,"obsolete":58,"android":26,"accessibility":48,"react":77,"wcag2-a":10,"injection":1,"html5":5,"cross-browser":4,"design":60,"bug":37,"confusing":147,"unpredictable":46,"es2015":22,"type-dependent":73,"redundant":25,"performance":195,"since-c++11":62,"multi-threading":55,"leak":15,"denial-of-service":18,"symbolic-execution":67,"data-science":20,"numpy":15,"pytorch":9,"microfocus":1,"logging":15,"jsp-jsf":6,"deprecated":12,"pep":6,"preprocessor":11,"java8":24,"tests":65,"junit":23,"phpunit":12,"security":5,"python3":18,"psr1":3,"per":2,"finding":12,"i18n":1,"serialization":18,"hibernate":9,"spring":47,"django":12,"express.js":17,"fastapi":2,"flask":6,"privacy":13,"api-design":31,"singleton":1,"AWS":1,"overflow":3,"jasmine":1,"jest":1,"mocha":4,"node":1,"struts":4,"misra-c2012":12,"backbone":3,"misra-c2004":19,"docker":2,"angularjs":1,"ejb":3,"jee":6,"chai":5,"syntax":4,"jquery":1,"assertj":7,"mockito":5,"msvc":1,"swing":1,"deadlock":3,"async-await":8,"php-ini":6,"typing":22,"maven":9,"since-c++14":5,"c11":1,"gnu":3,"xsd":18,"defign":1,"localisation":4,"duplicate":1,"mef":3,"winforms":1,"event":1,"regex":40,"wpf":1,"xaml":1,"proficiency":5,"aws":33,"azure":24,"gcp":20,"rules":1,"antipattern":1,"jsx":8,"yield":1,"debug":1,"java7":1,"guava":1,"java9":2,"full-project":3,"ssl":2,"phishing":1,"java14":6,"dockerfile":11,"governor-limits":5,"since-c++17":24,"unittest":2,"java15":1,"since-c++20":65,"java16":12,"java10":1,"java17":1,"startup-time":2,"coroutines":12,"cwe-284":1,"javadoc":12,"java18":9,"floating-point":1,"numbers":1,"precision":1,"architecture":8,"async":1,"promise":1,"sans-top25-insecure":1,"enum":2,"object":1,"string":1,"shell":1,"assertion":1,"function":1,"type":1,"es2020":1,"nullish-coalescing":1,"rspec-showcase":3,"Gradle":2,"gradle":10,"es2022":1,"es2018":1,"jspecify":1,"nullability":1,"scientific-computing":4,"pandas":9,"graphql":2,"blazor":9,"paths":1,"best-practice":1,"java21":15,"datetime":7,"sustainability":10,"java":1,"jpa":1,"machine-learning":18,"tensorflow":7,"susceptibility":1,"asp.net":11,"scikit-learn":5,"since-c++23":6,"respectful":1,"assembler":1},"qualityProfiles":{"Sonar way":2525,"Drupal":1}}
2 changes: 1 addition & 1 deletion rules/rule-index-store.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion rules/rule-index.json

Large diffs are not rendered by default.

0 comments on commit 19f35ed

Please sign in to comment.