C++17 Static Analysis Tool

Find Code
Smells
Instantly.

7 detectors. Zero dependencies.
One binary. Any C++ codebase.

7
Detectors
84
Tests
33
Source Files
0
Dependencies
smell-detector — zsh — 80×24

7 Detectors.
Every Smell Covered.

Each detector is a self-contained module — enable, disable, or tune thresholds independently via .smellrc.

🦠
God Class
Flags classes with too many methods AND fields — a class that does everything is a class that does nothing well.
max_class_methods = 20  |  max_class_fields = 15
📏
Long Function
A function that is too long is doing too many things. Flags bodies exceeding the configurable line threshold.
max_function_lines = 50
📋
Long Parameter List
Too many parameters indicate a function knows too much about its callers. Group related params into objects.
max_parameters = 4
Duplicate Code
Structurally identical functions via fingerprint hashing. Duplicated logic is a maintenance trap — extract it.
duplicate_threshold = 0.85
👻
Dead Code
Two-pass reference analysis: collect all definitions, collect all references, diff them. Unreferenced = dead.
two-pass heuristic analysis
🔢
Magic Numbers
Bare numeric literals carry no meaning. 86400 tells you nothing. SECONDS_PER_DAY tells you everything.
allowed_literals = 0, 1, -1, 2
🌀
Deep Nesting
Each nesting level adds a condition the reader must hold in memory. Use early returns and guard clauses instead.
max_nesting_depth = 4

Modular.
Extensible by Design.

5-stage pipeline built on Visitor, Strategy, Factory and Template Method patterns. Adding a new detector takes one file and one registration line.

01 Lexer Token.h · Lexer.h/cpp
02 Parser / AST 9 node files · ASTBuilder
03 Detectors SmellDetector + 7 detectors
04 Engine + Factory DetectionEngine · DetectorFactory
05 Report + Formatters Violation · Report · 3 formatters

Up and Running
in 60 Seconds.

One compiler. One command. Works on Linux, macOS, and Windows with MinGW or MSVC.

01
Clone the repo
Get the source code from GitHub. No submodules, no package manager.
# Clone git clone https://github.com/sammykasango/code-smell-detector.git cd code-smell-detector mkdir build
02
Build with g++
Single compile command — all you need is a C++17-capable compiler.
g++ -std=c++17 -Wall -O2 -Isrc \ src/main.cpp \ src/lexer/Lexer.cpp \ src/parser/ASTBuilder.cpp \ -o build/smell-detector
03
Analyze your code
Point it at a file, a folder, or your entire project src directory.
# Single file ./build/smell-detector MyCode.cpp # Entire directory ./build/smell-detector src/
04
Export your report
Three output formats built in. Use JSON for CI pipelines, HTML for sharing.
# JSON for CI ./build/smell-detector --format json \ --output report.json src/ # HTML dashboard ./build/smell-detector --format html \ --output report.html src/

Three Formats.
One Command Flag.

================================================================ CODE SMELL REPORT ================================================================ File: src/OrderProcessor.cpp [HIGH ] Line 5 | GodClass | Class 'OrderProcessor' has 22 methods and 16 fields | likely a God Class (max: 20 methods, 15 fields) [MEDIUM] Line 74 | DeepNesting | Nesting depth 5 in function 'checkEligibility' | exceeds max (4) [LOW ] Line 60 | MagicNumber | Magic number '350' — replace with a named constant ---------------------------------------------------------------- Summary: 32 violation(s) across 1 file(s) High: 1 Medium: 26 Low: 5
{ "summary": { "total_violations": 32, "files_analyzed": 1, "high": 1, "medium": 26, "low": 5 }, "violations": [ { "file": "src/OrderProcessor.cpp", "line": 5, "smell": "GodClass", "severity": "HIGH", "message": "Class 'OrderProcessor' has 22 methods..." } ] }
Self-contained HTML dashboard — dark themed, sortable table, severity badges, summary cards. No external dependencies. Open in any browser. --format html --output report.html src/ Includes: ├── Summary cards (Total / High / Medium / Low) ├── Per-file breakdown with line references ├── Severity badges [HIGH] [MEDIUM] [LOW] └── Dark-mode styled, JetBrains Mono font
C++17
Language Standard
84
Tests Passing
33
Source Files
0
Dependencies
SK
Sammy M. Kasango
@sammykasango
Systems Software & Network Engineer based in Nairobi, Kenya. Building tools at the intersection of engineering depth and design sensibility.