GCC Code Coverage Report


Directory: ../
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 85.7% 24 / 0 / 28
Functions: 85.7% 6 / 0 / 7
Branches: 55.9% 19 / 0 / 34

src/linter/LintPass.cpp
Line Branch Exec Source
1 // Copyright (c) 2021-2026 ChilliBits. All rights reserved.
2
3 #include "LintPass.h"
4
5 #include <ast/ASTNodes.h>
6 #include <linter/rules/CyclomaticComplexityRule.h>
7 #include <linter/rules/NamingConventionRule.h>
8 #include <linter/rules/TooManyParametersRule.h>
9
10 namespace spice::compiler {
11
12 3 LintPass::LintPass(GlobalResourceManager &resourceManager, SourceFile *sourceFile) : CompilerPass(resourceManager, sourceFile) {
13 // Register all built-in lint rules here. Adding a rule never requires touching the traversal below.
14
2/4
✓ Branch 6 → 7 taken 3 times.
✗ Branch 6 → 26 not taken.
✓ Branch 8 → 9 taken 3 times.
✗ Branch 8 → 22 not taken.
3 rules.push_back(std::make_unique<NamingConventionRule>());
15
2/4
✓ Branch 11 → 12 taken 3 times.
✗ Branch 11 → 32 not taken.
✓ Branch 13 → 14 taken 3 times.
✗ Branch 13 → 28 not taken.
3 rules.push_back(std::make_unique<TooManyParametersRule>());
16
2/4
✓ Branch 16 → 17 taken 3 times.
✗ Branch 16 → 38 not taken.
✓ Branch 18 → 19 taken 3 times.
✗ Branch 18 → 34 not taken.
3 rules.push_back(std::make_unique<CyclomaticComplexityRule>());
17 3 }
18
19 3 std::vector<LintFinding> LintPass::lint(ASTNode *ast) {
20
1/2
✓ Branch 2 → 3 taken 3 times.
✗ Branch 2 → 8 not taken.
3 visit(ast);
21 6 return std::move(findings);
22 }
23
24 7 std::any LintPass::visitFctDef(FctDefNode *node) {
25
2/2
✓ Branch 17 → 4 taken 21 times.
✓ Branch 17 → 18 taken 7 times.
35 for (const std::unique_ptr<LintRule> &rule : rules)
26
1/2
✓ Branch 7 → 8 taken 21 times.
✗ Branch 7 → 20 not taken.
21 rule->checkFctDef(node, findings);
27 7 return visitChildren(node);
28 }
29
30 1 std::any LintPass::visitProcDef(ProcDefNode *node) {
31
2/2
✓ Branch 17 → 4 taken 3 times.
✓ Branch 17 → 18 taken 1 time.
5 for (const std::unique_ptr<LintRule> &rule : rules)
32
1/2
✓ Branch 7 → 8 taken 3 times.
✗ Branch 7 → 20 not taken.
3 rule->checkProcDef(node, findings);
33 1 return visitChildren(node);
34 }
35
36 2 std::any LintPass::visitStructDef(StructDefNode *node) {
37
2/2
✓ Branch 17 → 4 taken 6 times.
✓ Branch 17 → 18 taken 2 times.
10 for (const std::unique_ptr<LintRule> &rule : rules)
38
1/2
✓ Branch 7 → 8 taken 6 times.
✗ Branch 7 → 20 not taken.
6 rule->checkStructDef(node, findings);
39 2 return visitChildren(node);
40 }
41
42 std::any LintPass::visitInterfaceDef(InterfaceDefNode *node) {
43 for (const std::unique_ptr<LintRule> &rule : rules)
44 rule->checkInterfaceDef(node, findings);
45 return visitChildren(node);
46 }
47
48 2 std::any LintPass::visitGlobalVarDef(GlobalVarDefNode *node) {
49
2/2
✓ Branch 17 → 4 taken 6 times.
✓ Branch 17 → 18 taken 2 times.
10 for (const std::unique_ptr<LintRule> &rule : rules)
50
1/2
✓ Branch 7 → 8 taken 6 times.
✗ Branch 7 → 20 not taken.
6 rule->checkGlobalVarDef(node, findings);
51 2 return visitChildren(node);
52 }
53
54 } // namespace spice::compiler
55