Skip to content

Commit

Permalink
Add description
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien-marichal committed Dec 18, 2024
1 parent 975c89f commit 05cc2be
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
13 changes: 6 additions & 7 deletions rules/S7173/vb6/metadata.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
{
"title": "FIXME",
"title": "\"GoSub\" statements should not be used",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
"constantCost": "5min"
"constantCost": "10min"
},
"tags": [
"brain-overload"
],
"defaultSeverity": "Major",
"ruleSpecification": "RSPEC-7173",
"sqKey": "S7173",
"scope": "All",
"defaultQualityProfiles": ["Sonar way"],
"quickfix": "unknown",
"quickfix": "infeasible",
"code": {
"impacts": {
"MAINTAINABILITY": "HIGH",
"RELIABILITY": "MEDIUM",
"SECURITY": "LOW"
"MAINTAINABILITY": "MEDIUM"
},
"attribute": "CONVENTIONAL"
"attribute": "CLEAR"
}
}
47 changes: 25 additions & 22 deletions rules/S7173/vb6/rule.adoc
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
FIXME: add a description
== Why is this an issue?

// If you want to factorize the description uncomment the following line and create the file.
//include::../description.adoc[]
The `GoSub` statement in VB6 is an unstructured control flow statement. It can lead to complex and difficult-to-maintain code, as well as potential stack overflow errors due to improper return handling.

== Why is this an issue?
Modern programming practices recommend using proper subroutine or function calls instead, which provide better readability, maintainability, and error handling.

FIXME: remove the unused optional headers (that are commented out)
=== Exceptions

//=== What is the potential impact?
`On Error GoSub` statements are ignored as correct error handling.

== How to fix it
//== How to fix it in FRAMEWORK NAME

Replace `GoSub` statements with proper subroutine or function calls.

=== Code examples

==== Noncompliant code example

[source,vb6,diff-id=1,diff-type=noncompliant]
----
FIXME
Sub ExampleProcedure()
GoSub SubRoutine
Exit Sub
SubRoutine:
' ...
Return
End Sub
----

==== Compliant solution

[source,vb6,diff-id=1,diff-type=compliant]
----
FIXME
----
Sub ExampleProcedure()
Call SubRoutine
End Sub
//=== How does this work?

//=== Pitfalls

//=== Going the extra mile
Sub SubRoutine()
' ...
End Sub
----

== Resources
=== Documentation

//== Resources
//=== Documentation
//=== Articles & blog posts
//=== Conference presentations
//=== Standards
//=== External coding guidelines
//=== Benchmarks
* Microsoft Learn - https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/gosubreturn-statement[GoSub...Return statement]

0 comments on commit 05cc2be

Please sign in to comment.