Skip to content

Commit 46d4609

Browse files
authored
Merge pull request #13 from ECP-Solutions/Rubberduck_code_inspection
Rubberduck code inspection
2 parents da42595 + 13db78c commit 46d4609

File tree

10 files changed

+182
-205
lines changed

10 files changed

+182
-205
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
All notable changes for ASF. This file combines the release notes from the project's releases.
44

5+
## [v2.0.4] - 2026-01-22
6+
https://github.com/ECP-Solutions/ASF/releases/tag/v2.0.4
7+
8+
## Summary
9+
10+
ASF v2.0.4 is a code clean-up for the library.
11+
12+
---
13+
14+
## Highlights
15+
16+
- **Improved**:
17+
- Code: Rubberduck code inspection.
18+
19+
20+
---
21+
**Full Changelog**: https://github.com/ECP-Solutions/ASF/compare/v2.0.3...v2.0.4
22+
523
## [v2.0.3] - 2026-01-21
624
https://github.com/ECP-Solutions/ASF/releases/tag/v2.0.3
725

src/ASF.cls

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ End Function
3131
Public Function SetGlobals(aGlobals As ASF_Globals)
3232
Set GLOBALS_ = aGlobals
3333
End Function
34-
Public Sub InjectVariable(varName As String, varValue As Variant)
35-
VM_.InjectVariable varName, varValue
34+
Public Sub InjectVariable(varName As String, VarValue As Variant)
35+
VM_.InjectVariable varName, VarValue
3636
End Sub
3737
Private Sub INIT_()
3838
Set GLOBALS_ = New ASF_Globals
@@ -89,13 +89,13 @@ End Property
8989
Public Sub ClearCallStack()
9090
VM_.ClearCallStack
9191
End Sub
92-
Public Function ReadTextFile(FilePath As String) As String
92+
Public Function ReadTextFile(filePath As String) As String
9393
Dim EOFile As Long
9494
Dim FileHandled As Integer
9595
Dim OutputStr As String
9696

9797
FileHandled = FreeFile
98-
Open FilePath For Binary As #FileHandled
98+
Open filePath For Binary As #FileHandled
9999
EOFile = LOF(FileHandled)
100100
OutputStr = Space$(EOFile)
101101
Get #FileHandled, , OutputStr

src/ASF_Compiler.cls

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ Compiler_MainLoop:
187187
Next j
188188
Else
189189
ReDim pa(0 To 0)
190-
pa(0) = ""
190+
pa(0) = vbNullString
191191
End If
192192
GLOBALS_.gFuncParams.Add fname, pa
193193

@@ -520,7 +520,7 @@ Private Function ParseStatementTokensToAST(stmtTokens As Collection) As ASF_Map
520520

521521
' assignment: find top-level "=" operator position or compound-assignment like "+=", "-=", "*=", etc.
522522
Dim assignPos As Long: assignPos = 0
523-
Dim compoundOp As String: compoundOp = ""
523+
Dim compoundOp As String: compoundOp = vbNullString
524524
Dim ii As Long
525525
Dim depthB As Long, depthP As Long, depthBr As Long
526526
For ii = 1 To stmtTokens.count
@@ -583,7 +583,7 @@ Private Function ParseStatementTokensToAST(stmtTokens As Collection) As ASF_Map
583583
End If
584584

585585
Dim rhsNode As ASF_Map
586-
If compoundOp <> "" Then
586+
If compoundOp <> vbNullString Then
587587
' For compound assignments like "a += 3" produce:
588588
' Assign { left: lhsNode, right: Binary { left: (clone of lhsNode), op: <op>, right: <rhsExpr> } }
589589
Dim innerOp As String: innerOp = left$(compoundOp, Len(compoundOp) - 1)
@@ -1283,7 +1283,7 @@ Private Function ParsePrimaryNode(types() As String, vals() As Variant, n As Lon
12831283
Dim s As String: s = CStr(name)
12841284
Dim poss As Long: poss = 1
12851285
Dim L As Long: L = Len(s)
1286-
Dim ident As String: ident = ""
1286+
Dim ident As String: ident = vbNullString
12871287
Dim propName As String
12881288

12891289
' read leading ident
@@ -1301,7 +1301,7 @@ Private Function ParsePrimaryNode(types() As String, vals() As Variant, n As Lon
13011301
Dim ch As String: ch = mid$(s, poss, 1)
13021302
If ch = "." Then
13031303
poss = poss + 1
1304-
propName = ""
1304+
propName = vbNullString
13051305
Do While poss <= L
13061306
Dim ch2 As String: ch2 = mid$(s, poss, 1)
13071307
If ch2 = "." Or ch2 = "[" Then Exit Do
@@ -1806,7 +1806,7 @@ Private Function ParseForAST(stmtTokens As Collection) As ASF_Map
18061806

18071807
' Try to detect "for (<left> in <right>)" or "for (<left> of <right>)"
18081808
Dim foundPos As Long: foundPos = 0
1809-
Dim foundKind As String: foundKind = ""
1809+
Dim foundKind As String: foundKind = vbNullString
18101810
If initTok.count > 0 Then
18111811
Dim depthP As Long: depthP = 0
18121812
Dim depthB As Long: depthB = 0
@@ -2384,7 +2384,6 @@ Private Function NormalizeNodeRecursive(node As ASF_Map) As ASF_Map
23842384
Dim initNode As ASF_Map
23852385
Dim condNode As ASF_Map
23862386
Dim stepNode As ASF_Map
2387-
Dim body As Collection
23882387
Dim nInit As ASF_Map, nCond As ASF_Map, nStep As ASF_Map
23892388
Dim na As ASF_Map
23902389
Dim L As ASF_Map
@@ -2739,7 +2738,7 @@ Private Function ParseTemplateStringToNode(ByVal rawBacktickString As String) As
27392738
Dim parts As New Collection
27402739
Dim i As Long: i = 1
27412740
Dim Ls As Long: Ls = Len(inner)
2742-
Dim curLit As String: curLit = ""
2741+
Dim curLit As String: curLit = vbNullString
27432742

27442743
Do While i <= Ls
27452744
Dim ch As String: ch = mid$(inner, i, 1)
@@ -2756,7 +2755,7 @@ Private Function ParseTemplateStringToNode(ByVal rawBacktickString As String) As
27562755
Dim litNode As ASF_Map: Set litNode = MakeNode("Literal")
27572756
litNode.SetValue "value", curLit
27582757
parts.Add litNode
2759-
curLit = ""
2758+
curLit = vbNullString
27602759
End If
27612760
' capture expression until matching brace
27622761
i = i + 2
@@ -2777,7 +2776,7 @@ Private Function ParseTemplateStringToNode(ByVal rawBacktickString As String) As
27772776
Loop
27782777
Dim exprLen As Long: exprLen = i - exprStart - 1
27792778
Dim exprSrc As String
2780-
If exprLen >= 0 Then exprSrc = mid$(inner, exprStart, exprLen) Else exprSrc = ""
2779+
If exprLen >= 0 Then exprSrc = mid$(inner, exprStart, exprLen) Else exprSrc = vbNullString
27812780
' parse expression string to an AST node (reuse existing helper)
27822781
Dim exprNode As ASF_Map: Set exprNode = ParseExprFromStringToNode(exprSrc)
27832782
parts.Add exprNode
@@ -2817,7 +2816,7 @@ Private Function ParseTemplatePartsFromString(ByVal tokenStr As String) As Colle
28172816

28182817
Dim i As Long: i = 2 ' start after opening backtick
28192818
Dim Ls As Long: Ls = Len(tokenStr)
2820-
Dim curLit As String: curLit = ""
2819+
Dim curLit As String: curLit = vbNullString
28212820
Dim ch As String
28222821
Dim nx As String
28232822
Dim curExpr As String
@@ -2848,7 +2847,7 @@ Private Function ParseTemplatePartsFromString(ByVal tokenStr As String) As Colle
28482847
' flush current literal (outside placeholders)
28492848
If Len(curLit) > 0 Then
28502849
parts.Add Array("LITERAL", curLit)
2851-
curLit = ""
2850+
curLit = vbNullString
28522851
End If
28532852

28542853
' consume "${"
@@ -2859,7 +2858,7 @@ Private Function ParseTemplatePartsFromString(ByVal tokenStr As String) As Colle
28592858
' - backslash inside placeholder escapes the next char if equal to '{' or '$' or '}'
28602859
' - unescaped "${" starts a nested split: flush current expr (if any) and start collecting nested
28612860
' - unescaped "}" closes the *current* placeholder chunk and the collected text is added as an EXPR
2862-
curExpr = ""
2861+
curExpr = vbNullString
28632862
depth = 1
28642863

28652864
Do While i <= Ls And depth > 0
@@ -2891,7 +2890,7 @@ Private Function ParseTemplatePartsFromString(ByVal tokenStr As String) As Colle
28912890
If c2 = "$" And i < Ls And mid$(tokenStr, i + 1, 1) = "{" Then
28922891
If Len(curExpr) > 0 Then
28932892
parts.Add Array("EXPR", curExpr)
2894-
curExpr = ""
2893+
curExpr = vbNullString
28952894
End If
28962895
' consume nested "${" and increase depth
28972896
depth = depth + 1
@@ -2907,7 +2906,7 @@ Private Function ParseTemplatePartsFromString(ByVal tokenStr As String) As Colle
29072906
' only add non-empty expression fragments
29082907
If Len(curExpr) > 0 Then
29092908
parts.Add Array("EXPR", curExpr)
2910-
curExpr = ""
2909+
curExpr = vbNullString
29112910
End If
29122911
' if depth > 0 we continue collecting outer-level remainder into a new expr (will be added later or at another close)
29132912
GoTo ContinuePlaceholderLoop
@@ -2923,7 +2922,7 @@ ContinuePlaceholderLoop:
29232922
' If the placeholder wasn't properly closed (unterminated), treat whatever collected as an EXPR
29242923
If Len(curExpr) > 0 Then
29252924
parts.Add Array("EXPR", curExpr)
2926-
curExpr = ""
2925+
curExpr = vbNullString
29272926
End If
29282927

29292928
' continue scanning main template loop
@@ -2932,7 +2931,7 @@ ContinuePlaceholderLoop:
29322931

29332932
' closing backtick ends template (outside any placeholder)
29342933
If ch = "`" Then
2935-
If Len(curLit) > 0 Then parts.Add Array("LITERAL", curLit): curLit = ""
2934+
If Len(curLit) > 0 Then parts.Add Array("LITERAL", curLit): curLit = vbNullString
29362935
i = i + 1 ' consume closing backtick
29372936
Exit Do
29382937
End If
@@ -2974,7 +2973,7 @@ Private Function ParseClassDecl(toks As Collection, ByRef i As Long) As ASF_Map
29742973
Loop
29752974

29762975
' Check for extends
2977-
Dim superClass As String: superClass = ""
2976+
Dim superClass As String: superClass = vbNullString
29782977
If i <= toks.count And LCase$(toks(i)(1)) = "extends" Then
29792978
i = i + 1
29802979
Do While i <= toks.count And safeTVRetInner(toks, i, 0) = "COMMENT"

src/ASF_Map.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Private tmpBuffer As Variant
2323
Private Sub Class_Initialize()
2424
BufferInit
2525
End Sub
26-
26+
2727
Private Sub BufferInit()
2828
pItems.Capacity = 64
2929
pItems.index = -1

src/ASF_Parser.cls

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Public Sub SetGlobals(ByRef aGlobals As ASF_Globals)
1717
Set GLOBALS_ = aGlobals
1818
End Sub
1919
Private Function ReplaceDQuotes(src As String) As String
20-
ReplaceDQuotes = Replace(src, ChrW(34), "'")
20+
ReplaceDQuotes = Replace(src, ChrW$(34), "'")
2121
End Function
2222

2323
Public Function Tokenize(src As String) As Collection
@@ -88,7 +88,6 @@ Tokenize_MainLoop:
8888
Case "`"
8989
' consume opening backtick
9090
i = i + 1
91-
Dim tplParts As New Collection
9291
Dim curLit As String: curLit = "`"
9392
Dim Ls As Long: Ls = n
9493
Dim c As String
@@ -148,11 +147,11 @@ ContinueTemplateLoop:
148147
Case "<", ">"
149148
Dim two As String
150149
Dim three As String
151-
If i < n Then two = mid$(sourceCode, i, 2) Else two = ""
150+
If i < n Then two = mid$(sourceCode, i, 2) Else two = vbNullString
152151
If two = ">=" Or two = "<=" Then
153152
toks.Add Array("OP", two): i = i + 2
154153
Else
155-
If i < n Then three = mid$(sourceCode, i, 3) Else three = ""
154+
If i < n Then three = mid$(sourceCode, i, 3) Else three = vbNullString
156155
If three = "<<=" Or three = ">>=" Then 'Support for compound shift assignment
157156
toks.Add Array("OP", three): i = i + 3
158157
Else
@@ -173,7 +172,7 @@ ContinueTemplateLoop:
173172
toks.Add Array("OP", ch): i = i + 1: GoTo Tokenize_SkipToLoopEnd
174173
Case "'"
175174
j = i + 1
176-
Dim sb As String: sb = ""
175+
Dim sb As String: sb = vbNullString
177176
Do While j <= n
178177
Dim cj As String: cj = mid$(sourceCode, j, 1)
179178
If cj = "\" Then
@@ -225,7 +224,7 @@ ContinueDo:
225224
j3 = j3 + 1
226225
Loop
227226
tmpIdent = mid$(sourceCode, i, j3 - i)
228-
If LCase(tmpIdent) <> "let" Then
227+
If LCase$(tmpIdent) <> "let" Then
229228
toks.Add Array("IDENT", tmpIdent)
230229
End If
231230
i = j3
@@ -234,7 +233,7 @@ ContinueDo:
234233
ElseIf ch = "@" And i < n And mid$(sourceCode, i + 1, 1) = "(" Then
235234
Dim jvb As Long: jvb = i + 2
236235
Dim depthVB As Long: depthVB = 1
237-
Dim vbContent As String: vbContent = ""
236+
Dim vbContent As String: vbContent = vbNullString
238237
Do While jvb <= n And depthVB > 0
239238
Dim cjvb As String: cjvb = mid$(sourceCode, jvb, 1)
240239
If cjvb = "(" Then
@@ -293,7 +292,7 @@ End Function
293292

294293

295294
Public Function JoinTokens(tokens As Collection) As String
296-
Dim s As String: s = ""
295+
Dim s As String: s = vbNullString
297296
Dim i As Long
298297
For i = 1 To tokens.count
299298
If tokens(i)(0) = "STRING" Then

0 commit comments

Comments
 (0)