From 05cc2bedc1acef8c8d8131c68be7d7646b694cd9 Mon Sep 17 00:00:00 2001 From: Sebastien Marichal Date: Wed, 18 Dec 2024 11:43:24 +0100 Subject: [PATCH] Add description --- rules/S7173/vb6/metadata.json | 13 +++++----- rules/S7173/vb6/rule.adoc | 47 +++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/rules/S7173/vb6/metadata.json b/rules/S7173/vb6/metadata.json index 0a4321d5a28..b5ce6dbd588 100644 --- a/rules/S7173/vb6/metadata.json +++ b/rules/S7173/vb6/metadata.json @@ -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" } } diff --git a/rules/S7173/vb6/rule.adoc b/rules/S7173/vb6/rule.adoc index 70626f3be4c..d2b6d47ea81 100644 --- a/rules/S7173/vb6/rule.adoc +++ b/rules/S7173/vb6/rule.adoc @@ -1,16 +1,16 @@ -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 @@ -18,27 +18,30 @@ FIXME: remove the unused optional headers (that are commented out) [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]