tech-debt-score 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DEVELOPMENT.md +147 -0
- package/LICENSE +21 -0
- package/README.md +200 -0
- package/SETUP_COMPLETE.md +188 -0
- package/TECHNICAL_DESIGN.md +563 -0
- package/dist/adapters/input/FileSystemReader.d.ts +11 -0
- package/dist/adapters/input/FileSystemReader.d.ts.map +1 -0
- package/dist/adapters/input/FileSystemReader.js +41 -0
- package/dist/adapters/input/FileSystemReader.js.map +1 -0
- package/dist/adapters/input/TypeScriptParser.d.ts +17 -0
- package/dist/adapters/input/TypeScriptParser.d.ts.map +1 -0
- package/dist/adapters/input/TypeScriptParser.js +305 -0
- package/dist/adapters/input/TypeScriptParser.js.map +1 -0
- package/dist/adapters/output/JsonExporter.d.ts +11 -0
- package/dist/adapters/output/JsonExporter.d.ts.map +1 -0
- package/dist/adapters/output/JsonExporter.js +46 -0
- package/dist/adapters/output/JsonExporter.js.map +1 -0
- package/dist/adapters/output/TerminalReporter.d.ts +13 -0
- package/dist/adapters/output/TerminalReporter.d.ts.map +1 -0
- package/dist/adapters/output/TerminalReporter.js +82 -0
- package/dist/adapters/output/TerminalReporter.js.map +1 -0
- package/dist/application/config/AnalysisConfig.d.ts +36 -0
- package/dist/application/config/AnalysisConfig.d.ts.map +1 -0
- package/dist/application/config/AnalysisConfig.js +19 -0
- package/dist/application/config/AnalysisConfig.js.map +1 -0
- package/dist/application/ports/IFileReader.d.ts +32 -0
- package/dist/application/ports/IFileReader.d.ts.map +1 -0
- package/dist/application/ports/IFileReader.js +6 -0
- package/dist/application/ports/IFileReader.js.map +1 -0
- package/dist/application/ports/IParser.d.ts +35 -0
- package/dist/application/ports/IParser.d.ts.map +1 -0
- package/dist/application/ports/IParser.js +6 -0
- package/dist/application/ports/IParser.js.map +1 -0
- package/dist/application/ports/IReporter.d.ts +24 -0
- package/dist/application/ports/IReporter.d.ts.map +1 -0
- package/dist/application/ports/IReporter.js +6 -0
- package/dist/application/ports/IReporter.js.map +1 -0
- package/dist/application/services/AnalysisService.d.ts +31 -0
- package/dist/application/services/AnalysisService.d.ts.map +1 -0
- package/dist/application/services/AnalysisService.js +161 -0
- package/dist/application/services/AnalysisService.js.map +1 -0
- package/dist/application/services/DependencyAnalyzer.d.ts +29 -0
- package/dist/application/services/DependencyAnalyzer.d.ts.map +1 -0
- package/dist/application/services/DependencyAnalyzer.js +128 -0
- package/dist/application/services/DependencyAnalyzer.js.map +1 -0
- package/dist/application/services/DuplicationDetector.d.ts +46 -0
- package/dist/application/services/DuplicationDetector.d.ts.map +1 -0
- package/dist/application/services/DuplicationDetector.js +165 -0
- package/dist/application/services/DuplicationDetector.js.map +1 -0
- package/dist/cli/commands/analyze.d.ts +2 -0
- package/dist/cli/commands/analyze.d.ts.map +1 -0
- package/dist/cli/commands/analyze.js +58 -0
- package/dist/cli/commands/analyze.js.map +1 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +76 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/domain/entities/Finding.d.ts +42 -0
- package/dist/domain/entities/Finding.d.ts.map +1 -0
- package/dist/domain/entities/Finding.js +40 -0
- package/dist/domain/entities/Finding.js.map +1 -0
- package/dist/domain/entities/Metric.d.ts +38 -0
- package/dist/domain/entities/Metric.d.ts.map +1 -0
- package/dist/domain/entities/Metric.js +36 -0
- package/dist/domain/entities/Metric.js.map +1 -0
- package/dist/domain/entities/Rule.d.ts +41 -0
- package/dist/domain/entities/Rule.d.ts.map +1 -0
- package/dist/domain/entities/Rule.js +15 -0
- package/dist/domain/entities/Rule.js.map +1 -0
- package/dist/domain/entities/Score.d.ts +62 -0
- package/dist/domain/entities/Score.d.ts.map +1 -0
- package/dist/domain/entities/Score.js +40 -0
- package/dist/domain/entities/Score.js.map +1 -0
- package/dist/domain/index.d.ts +12 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +14 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/rules/CircularDependencyRule.d.ts +13 -0
- package/dist/domain/rules/CircularDependencyRule.d.ts.map +1 -0
- package/dist/domain/rules/CircularDependencyRule.js +47 -0
- package/dist/domain/rules/CircularDependencyRule.js.map +1 -0
- package/dist/domain/rules/ComplexityRule.d.ts +15 -0
- package/dist/domain/rules/ComplexityRule.d.ts.map +1 -0
- package/dist/domain/rules/ComplexityRule.js +63 -0
- package/dist/domain/rules/ComplexityRule.js.map +1 -0
- package/dist/domain/rules/DuplicationRule.d.ts +15 -0
- package/dist/domain/rules/DuplicationRule.d.ts.map +1 -0
- package/dist/domain/rules/DuplicationRule.js +51 -0
- package/dist/domain/rules/DuplicationRule.js.map +1 -0
- package/dist/domain/rules/SizeRule.d.ts +16 -0
- package/dist/domain/rules/SizeRule.d.ts.map +1 -0
- package/dist/domain/rules/SizeRule.js +70 -0
- package/dist/domain/rules/SizeRule.js.map +1 -0
- package/dist/domain/rules/TypeSafetyRule.d.ts +13 -0
- package/dist/domain/rules/TypeSafetyRule.d.ts.map +1 -0
- package/dist/domain/rules/TypeSafetyRule.js +45 -0
- package/dist/domain/rules/TypeSafetyRule.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/shared/types.d.ts +16 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +5 -0
- package/dist/shared/types.js.map +1 -0
- package/package.json +47 -0
- package/src/adapters/input/FileSystemReader.ts +51 -0
- package/src/adapters/input/TypeScriptParser.ts +367 -0
- package/src/adapters/output/JsonExporter.ts +48 -0
- package/src/adapters/output/TerminalReporter.ts +88 -0
- package/src/application/config/AnalysisConfig.ts +50 -0
- package/src/application/ports/IFileReader.ts +36 -0
- package/src/application/ports/IParser.ts +40 -0
- package/src/application/ports/IReporter.ts +26 -0
- package/src/application/services/AnalysisService.ts +199 -0
- package/src/application/services/DependencyAnalyzer.ts +158 -0
- package/src/application/services/DuplicationDetector.ts +207 -0
- package/src/cli/commands/analyze.ts +76 -0
- package/src/cli/index.ts +81 -0
- package/src/domain/entities/Finding.ts +79 -0
- package/src/domain/entities/Metric.ts +70 -0
- package/src/domain/entities/Rule.ts +49 -0
- package/src/domain/entities/Score.ts +94 -0
- package/src/domain/index.ts +15 -0
- package/src/domain/rules/CircularDependencyRule.ts +65 -0
- package/src/domain/rules/ComplexityRule.ts +88 -0
- package/src/domain/rules/DuplicationRule.ts +70 -0
- package/src/domain/rules/SizeRule.ts +98 -0
- package/src/domain/rules/TypeSafetyRule.ts +63 -0
- package/src/index.ts +0 -0
- package/src/shared/types.ts +18 -0
- package/tests/application/index.test.ts +12 -0
- package/tests/domain/index.test.ts +14 -0
- package/tests/e2e/index.test.ts +13 -0
- package/tsconfig.json +31 -0
package/DEVELOPMENT.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Development Guide
|
|
2
|
+
|
|
3
|
+
## Project Structure
|
|
4
|
+
|
|
5
|
+
The project follows **Hexagonal Architecture** (Ports & Adapters pattern):
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
src/
|
|
9
|
+
├── domain/ # ✅ Pure business logic (COMPLETE)
|
|
10
|
+
│ ├── entities/ # Score, Metric, Rule, Finding
|
|
11
|
+
│ └── rules/ # ComplexityRule, SizeRule, TypeSafetyRule
|
|
12
|
+
│
|
|
13
|
+
├── application/ # ✅ Use cases & orchestration (COMPLETE)
|
|
14
|
+
│ ├── services/ # AnalysisService
|
|
15
|
+
│ ├── ports/ # Interface definitions
|
|
16
|
+
│ └── config/ # AnalysisConfig
|
|
17
|
+
│
|
|
18
|
+
├── adapters/ # 🚧 External integrations (PARTIAL)
|
|
19
|
+
│ ├── input/ # FileSystemReader (TODO: implement scan)
|
|
20
|
+
│ │ # TypeScriptParser (TODO: implement AST parsing)
|
|
21
|
+
│ └── output/ # TerminalReporter, JsonExporter (COMPLETE)
|
|
22
|
+
│
|
|
23
|
+
├── cli/ # ✅ Command-line interface (COMPLETE)
|
|
24
|
+
│ └── commands/ # analyze command
|
|
25
|
+
│
|
|
26
|
+
└── shared/ # ✅ Shared types (COMPLETE)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Current Status
|
|
30
|
+
|
|
31
|
+
### ✅ Completed
|
|
32
|
+
|
|
33
|
+
- [x] Complete hexagonal architecture setup
|
|
34
|
+
- [x] Domain layer (all entities and rules)
|
|
35
|
+
- [x] Application layer (services, ports, config)
|
|
36
|
+
- [x] CLI entry point and analyze command
|
|
37
|
+
- [x] Output adapters (Terminal and JSON reporters)
|
|
38
|
+
- [x] Build system configured and working
|
|
39
|
+
- [x] TypeScript strict mode enabled
|
|
40
|
+
|
|
41
|
+
### 🚧 TODO - High Priority
|
|
42
|
+
|
|
43
|
+
1. **Implement FileSystemReader.scan()** (Currently returns empty array)
|
|
44
|
+
- Use `fast-glob` or `glob` library
|
|
45
|
+
- Implement file pattern matching
|
|
46
|
+
- Respect ignore patterns
|
|
47
|
+
|
|
48
|
+
2. **Implement TypeScriptParser.parse()** (Currently only counts LOC)
|
|
49
|
+
- Use `@typescript-eslint/parser` or TypeScript Compiler API
|
|
50
|
+
- Extract all metrics:
|
|
51
|
+
- Function length
|
|
52
|
+
- Cyclomatic complexity
|
|
53
|
+
- Nesting depth
|
|
54
|
+
- Parameter count
|
|
55
|
+
- `any` usage (TypeScript)
|
|
56
|
+
- TODO/FIXME comments
|
|
57
|
+
|
|
58
|
+
3. **Add Dependencies**
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm install fast-glob
|
|
62
|
+
npm install @typescript-eslint/parser @typescript-eslint/typescript-estree
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
4. **Write Tests**
|
|
66
|
+
- Domain layer unit tests (high priority)
|
|
67
|
+
- Application layer integration tests
|
|
68
|
+
- E2E tests with sample codebases
|
|
69
|
+
|
|
70
|
+
### 📋 TODO - Medium Priority
|
|
71
|
+
|
|
72
|
+
- [ ] Add more sophisticated scoring algorithm
|
|
73
|
+
- [ ] Implement code duplication detection
|
|
74
|
+
- [ ] Add test coverage integration
|
|
75
|
+
- [ ] Create configuration file support (`.tech-debt-score.json`)
|
|
76
|
+
- [ ] Add CLI flags for customization
|
|
77
|
+
- [ ] Better error handling and user feedback
|
|
78
|
+
|
|
79
|
+
### 🎯 TODO - Future Enhancements
|
|
80
|
+
|
|
81
|
+
- [ ] Git integration for trend tracking
|
|
82
|
+
- [ ] Additional output formats (HTML, Markdown)
|
|
83
|
+
- [ ] VS Code extension
|
|
84
|
+
- [ ] CI/CD examples (GitHub Actions, GitLab CI)
|
|
85
|
+
- [ ] Multi-language support (Python, Go, Java)
|
|
86
|
+
|
|
87
|
+
## Quick Commands
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Build the project
|
|
91
|
+
npm run build
|
|
92
|
+
|
|
93
|
+
# Run analysis (placeholder - needs implementation)
|
|
94
|
+
npm run analyze
|
|
95
|
+
|
|
96
|
+
# Run with specific path
|
|
97
|
+
npm run dev -- ./path/to/code
|
|
98
|
+
|
|
99
|
+
# Run tests (when implemented)
|
|
100
|
+
npm test
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Architecture Guidelines
|
|
104
|
+
|
|
105
|
+
### Dependency Rule
|
|
106
|
+
|
|
107
|
+
Dependencies point **inward only**:
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
CLI → Application → Domain
|
|
111
|
+
↓
|
|
112
|
+
Adapters (depend on Domain interfaces)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Domain Layer Rules
|
|
116
|
+
|
|
117
|
+
- ❌ NO filesystem access
|
|
118
|
+
- ❌ NO CLI dependencies
|
|
119
|
+
- ❌ NO Node.js APIs
|
|
120
|
+
- ❌ NO external libraries (except utilities)
|
|
121
|
+
- ✅ Pure TypeScript/JavaScript logic only
|
|
122
|
+
- ✅ 100% unit testable
|
|
123
|
+
|
|
124
|
+
### Testing Strategy
|
|
125
|
+
|
|
126
|
+
1. **Domain Tests**: No mocks needed, test pure logic
|
|
127
|
+
2. **Application Tests**: Use mock adapters
|
|
128
|
+
3. **E2E Tests**: Test with real codebases
|
|
129
|
+
|
|
130
|
+
## Next Steps
|
|
131
|
+
|
|
132
|
+
1. **Implement file scanning** - Get FileSystemReader working
|
|
133
|
+
2. **Implement AST parsing** - Extract real metrics from code
|
|
134
|
+
3. **Test with real code** - Run against this project itself!
|
|
135
|
+
4. **Write tests** - Start with domain layer
|
|
136
|
+
5. **Publish to npm** - Make it available for others
|
|
137
|
+
|
|
138
|
+
## Contributing
|
|
139
|
+
|
|
140
|
+
When adding new features:
|
|
141
|
+
|
|
142
|
+
1. Start with domain layer (pure logic)
|
|
143
|
+
2. Define ports (interfaces) in application layer
|
|
144
|
+
3. Implement adapters for external dependencies
|
|
145
|
+
4. Wire everything together in CLI commands
|
|
146
|
+
|
|
147
|
+
This ensures clean separation and testability!
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 panduken
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# tech-debt-score
|
|
2
|
+
|
|
3
|
+
> Quantify technical debt you can actually control.
|
|
4
|
+
> **Built by developers, for developers.**
|
|
5
|
+
|
|
6
|
+
`tech-debt-score` is an open-source CLI and engine that analyzes your codebase and produces a **single, actionable Technical Debt Score**, along with a breakdown of the factors that impact it.
|
|
7
|
+
|
|
8
|
+
The goal is not to find _everything that could be wrong_, but to measure **what your team can realistically improve**.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Why tech-debt-score?
|
|
13
|
+
|
|
14
|
+
Most tools focus on:
|
|
15
|
+
|
|
16
|
+
- Lint errors
|
|
17
|
+
- Code smells
|
|
18
|
+
- Best practices
|
|
19
|
+
|
|
20
|
+
But engineering teams need answers to questions like:
|
|
21
|
+
|
|
22
|
+
- _How bad is our technical debt, really?_
|
|
23
|
+
- _Is it getting better or worse over time?_
|
|
24
|
+
- _Where should we focus first?_
|
|
25
|
+
|
|
26
|
+
`tech-debt-score` provides:
|
|
27
|
+
|
|
28
|
+
- A normalized **0–100 score**
|
|
29
|
+
- Clear ownership (team-controllable factors)
|
|
30
|
+
- CI-friendly output
|
|
31
|
+
- A foundation for long-term debt tracking
|
|
32
|
+
- **Designed with developers in mind: fast, minimal friction, and easy to integrate**
|
|
33
|
+
|
|
34
|
+
> ⚡ **We made it by devs, for devs. Focus on your code, not the tooling.**
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## What it measures (v1 scope)
|
|
39
|
+
|
|
40
|
+
The first version focuses only on **signals fully controlled by the engineering team**:
|
|
41
|
+
|
|
42
|
+
- Code complexity (cyclomatic, nesting)
|
|
43
|
+
- File and function size
|
|
44
|
+
- Code duplication
|
|
45
|
+
- Test coverage (if available)
|
|
46
|
+
- Type safety indicators
|
|
47
|
+
- Project structure consistency
|
|
48
|
+
|
|
49
|
+
> ⚠️ External factors such as deprecated dependencies, security vulnerabilities, or runtime risks are intentionally **out of scope for v1**.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## How it works (high level)
|
|
54
|
+
|
|
55
|
+
1. Scan the codebase
|
|
56
|
+
2. Collect raw metrics using AST parsing
|
|
57
|
+
3. Normalize metrics into signals
|
|
58
|
+
4. Apply weighted scoring
|
|
59
|
+
5. Generate:
|
|
60
|
+
- Global score
|
|
61
|
+
- Category breakdown
|
|
62
|
+
- Human-readable report
|
|
63
|
+
- Optional JSON output
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
|
|
69
|
+
Install as a dev dependency:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm install --save-dev tech-debt-score
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Usage
|
|
78
|
+
|
|
79
|
+
### Analyze current directory
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npx tech-debt-score
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Analyze specific directory
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
npx tech-debt-score ./src
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Output Options
|
|
92
|
+
|
|
93
|
+
Generate a JSON report for CI/CD integration:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npx tech-debt-score . --json report.json
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Development
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Build the project
|
|
103
|
+
npm run build
|
|
104
|
+
|
|
105
|
+
# Run analysis on current project
|
|
106
|
+
npm run analyze
|
|
107
|
+
|
|
108
|
+
# Run self-scan verification
|
|
109
|
+
npm run scan
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Project Structure
|
|
115
|
+
|
|
116
|
+
This project follows **Hexagonal Architecture** (Ports & Adapters):
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
src/
|
|
120
|
+
├── domain/ # Pure business logic (no dependencies)
|
|
121
|
+
│ ├── entities/ # Core entities: Score, Metric, Rule, Finding
|
|
122
|
+
│ └── rules/ # Scoring rules: ComplexityRule, SizeRule, etc.
|
|
123
|
+
│
|
|
124
|
+
├── application/ # Use cases & orchestration
|
|
125
|
+
│ ├── services/ # AnalysisService
|
|
126
|
+
│ ├── ports/ # Interface definitions (IFileReader, IParser, IReporter)
|
|
127
|
+
│ └── config/ # Configuration
|
|
128
|
+
│
|
|
129
|
+
├── adapters/ # External integrations
|
|
130
|
+
│ ├── input/ # FileSystemReader, TypeScriptParser
|
|
131
|
+
│ └── output/ # TerminalReporter, JsonExporter
|
|
132
|
+
│
|
|
133
|
+
├── cli/ # Command-line interface (entry point)
|
|
134
|
+
│ └── commands/ # CLI commands
|
|
135
|
+
│
|
|
136
|
+
└── shared/ # Shared types and utilities
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Architecture Principles
|
|
142
|
+
|
|
143
|
+
- **Clean Architecture**: Domain layer has zero dependencies
|
|
144
|
+
- **Dependency Inversion**: Dependencies point inward
|
|
145
|
+
- **Testability**: Pure business logic, easy to unit test
|
|
146
|
+
- **Extensibility**: Easy to add new parsers, rules, or output formats
|
|
147
|
+
|
|
148
|
+
For detailed architecture information, see [TECHNICAL_DESIGN.md](./TECHNICAL_DESIGN.md)
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Development Status
|
|
153
|
+
|
|
154
|
+
**Current Version:** 0.1.0 (Beta)
|
|
155
|
+
|
|
156
|
+
### ✅ Completed
|
|
157
|
+
|
|
158
|
+
- [x] Hexagonal architecture setup
|
|
159
|
+
- [x] Domain layer (entities and rules)
|
|
160
|
+
- [x] Application layer (services and ports)
|
|
161
|
+
- [x] **Full AST parsing implementation**
|
|
162
|
+
- [x] **File scanning with fast-glob**
|
|
163
|
+
- [x] **Code Duplication detection**
|
|
164
|
+
- [x] **Circular Dependency detection**
|
|
165
|
+
- [x] CLI entry point with JSON export
|
|
166
|
+
|
|
167
|
+
### 🚧 Roadmap v0.2.0
|
|
168
|
+
|
|
169
|
+
- [ ] Configuration file support (`.tech-debt-score.json`)
|
|
170
|
+
- [ ] Git integration for trend tracking
|
|
171
|
+
- [ ] Ignore patterns configuration
|
|
172
|
+
- [ ] Unit tests coverage improvement
|
|
173
|
+
|
|
174
|
+
### 📋 Roadmap
|
|
175
|
+
|
|
176
|
+
- [ ] Additional rules (duplication, test coverage)
|
|
177
|
+
- [ ] Configuration file support
|
|
178
|
+
- [ ] Enhanced CLI with options
|
|
179
|
+
- [ ] Git integration for trend tracking
|
|
180
|
+
- [ ] VS Code extension
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Contributing
|
|
185
|
+
|
|
186
|
+
Contributions are welcome! Please read our contributing guidelines (coming soon).
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
MIT © @panduken
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Links
|
|
197
|
+
|
|
198
|
+
- **GitHub**: [github.com/panduken/tech-debt-score](https://github.com/panduken/tech-debt-score)
|
|
199
|
+
- **Issues**: [Report a bug](https://github.com/panduken/tech-debt-score/issues)
|
|
200
|
+
- **Technical Design**: [TECHNICAL_DESIGN.md](./TECHNICAL_DESIGN.md)
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Project Setup Complete! 🎉
|
|
2
|
+
|
|
3
|
+
## What Was Created
|
|
4
|
+
|
|
5
|
+
Your **tech-debt-score** project now has a complete **Hexagonal Architecture** implementation with:
|
|
6
|
+
|
|
7
|
+
### ✅ Core Structure (20 files created)
|
|
8
|
+
|
|
9
|
+
#### **Domain Layer** (Pure Business Logic - Zero Dependencies)
|
|
10
|
+
|
|
11
|
+
- `src/domain/entities/`
|
|
12
|
+
- `Metric.ts` - Core metric entity with builder pattern
|
|
13
|
+
- `Finding.ts` - Issue representation with builder pattern
|
|
14
|
+
- `Score.ts` - Score entity with calculator service
|
|
15
|
+
- `Rule.ts` - Rule interface and base class
|
|
16
|
+
- `src/domain/rules/`
|
|
17
|
+
- `ComplexityRule.ts` - Evaluates cyclomatic complexity and nesting
|
|
18
|
+
- `SizeRule.ts` - Evaluates file/function size and parameters
|
|
19
|
+
- `TypeSafetyRule.ts` - Detects TypeScript `any` usage
|
|
20
|
+
|
|
21
|
+
#### **Application Layer** (Orchestration)
|
|
22
|
+
|
|
23
|
+
- `src/application/ports/` (Interfaces)
|
|
24
|
+
- `IFileReader.ts` - File system abstraction
|
|
25
|
+
- `IParser.ts` - AST parser abstraction
|
|
26
|
+
- `IReporter.ts` - Output abstraction
|
|
27
|
+
|
|
28
|
+
- `src/application/services/`
|
|
29
|
+
- `AnalysisService.ts` - Main orchestration service
|
|
30
|
+
|
|
31
|
+
- `src/application/config/`
|
|
32
|
+
- `AnalysisConfig.ts` - Configuration with defaults
|
|
33
|
+
|
|
34
|
+
#### **Adapters Layer** (External Integrations)
|
|
35
|
+
|
|
36
|
+
- `src/adapters/input/`
|
|
37
|
+
- `FileSystemReader.ts` - File I/O adapter (⚠️ scan() needs implementation)
|
|
38
|
+
- `TypeScriptParser.ts` - AST parser adapter (⚠️ needs full implementation)
|
|
39
|
+
|
|
40
|
+
- `src/adapters/output/`
|
|
41
|
+
- `TerminalReporter.ts` - Beautiful console output ✅
|
|
42
|
+
- `JsonExporter.ts` - JSON report export ✅
|
|
43
|
+
|
|
44
|
+
#### **CLI Layer** (Entry Point)
|
|
45
|
+
|
|
46
|
+
- `src/cli/`
|
|
47
|
+
- `index.ts` - CLI entry point with help
|
|
48
|
+
- `commands/analyze.ts` - Analyze command (wires everything together)
|
|
49
|
+
|
|
50
|
+
#### **Shared**
|
|
51
|
+
|
|
52
|
+
- `src/shared/types.ts` - Common types
|
|
53
|
+
|
|
54
|
+
### 📄 Documentation
|
|
55
|
+
|
|
56
|
+
- `TECHNICAL_DESIGN.md` - Complete architecture specification
|
|
57
|
+
- `README.md` - Updated with usage and structure
|
|
58
|
+
- `DEVELOPMENT.md` - Development guide with TODO list
|
|
59
|
+
|
|
60
|
+
### 🧪 Test Structure
|
|
61
|
+
|
|
62
|
+
- `tests/domain/` - Unit tests placeholder
|
|
63
|
+
- `tests/application/` - Integration tests placeholder
|
|
64
|
+
- `tests/e2e/` - End-to-end tests placeholder
|
|
65
|
+
|
|
66
|
+
### ⚙️ Configuration
|
|
67
|
+
|
|
68
|
+
- Updated `package.json` with:
|
|
69
|
+
- `type: "module"` for ES modules
|
|
70
|
+
- Build scripts (`build`, `dev`, `analyze`)
|
|
71
|
+
- CLI bin entry point
|
|
72
|
+
- `.gitignore` - Comprehensive ignore rules
|
|
73
|
+
|
|
74
|
+
## Build Status
|
|
75
|
+
|
|
76
|
+
✅ **Project builds successfully!**
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm run build
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
All TypeScript strict mode checks pass.
|
|
83
|
+
|
|
84
|
+
## What's Next?
|
|
85
|
+
|
|
86
|
+
The architecture is complete, but **two adapters need implementation** to make it functional:
|
|
87
|
+
|
|
88
|
+
### 🚧 High Priority TODOs
|
|
89
|
+
|
|
90
|
+
1. **FileSystemReader.scan()**
|
|
91
|
+
- Currently returns empty array
|
|
92
|
+
- Needs: `fast-glob` implementation
|
|
93
|
+
2. **TypeScriptParser.parse()**
|
|
94
|
+
- Currently only counts lines
|
|
95
|
+
- Needs: Full AST parsing with `@typescript-eslint/parser`
|
|
96
|
+
- Should extract: complexity, nesting, parameters, `any` usage, comments
|
|
97
|
+
|
|
98
|
+
3. **Add Required Dependencies**
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm install fast-glob
|
|
102
|
+
npm install @typescript-eslint/parser @typescript-eslint/typescript-estree
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
4. **Write Tests**
|
|
106
|
+
- Start with domain layer (easiest - no I/O)
|
|
107
|
+
- Add integration tests
|
|
108
|
+
- Create E2E tests with sample code
|
|
109
|
+
|
|
110
|
+
## Architecture Highlights
|
|
111
|
+
|
|
112
|
+
### Clean Separation
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
┌─────────────────────────────────────────┐
|
|
116
|
+
│ CLI (Entry Point) │
|
|
117
|
+
│ No Business Logic │
|
|
118
|
+
└─────────────────┬───────────────────────┘
|
|
119
|
+
↓
|
|
120
|
+
┌─────────────────────────────────────────┐
|
|
121
|
+
│ Application (Orchestration) │
|
|
122
|
+
│ AnalysisService coordinates everything│
|
|
123
|
+
└───┬──────────────────────────────────┬──┘
|
|
124
|
+
↓ ↓
|
|
125
|
+
┌───────────┐ ┌─────────────┐
|
|
126
|
+
│ Adapters │ │ Domain │
|
|
127
|
+
│ (I/O) │ │ (Pure Logic)│
|
|
128
|
+
└───────────┘ └─────────────┘
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Key Benefits
|
|
132
|
+
|
|
133
|
+
✅ **100% Testable** - Domain layer has zero dependencies
|
|
134
|
+
✅ **Extensible** - Easy to add new parsers, rules, outputs
|
|
135
|
+
✅ **Type-Safe** - Full TypeScript strict mode
|
|
136
|
+
✅ **Portable** - Domain logic works anywhere (Node, Deno, Browser)
|
|
137
|
+
✅ **Maintainable** - Clear separation of concerns
|
|
138
|
+
|
|
139
|
+
## Try It Out
|
|
140
|
+
|
|
141
|
+
Even though the parsers aren't complete, you can still build and run:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Build
|
|
145
|
+
npm run build
|
|
146
|
+
|
|
147
|
+
# See CLI help
|
|
148
|
+
node dist/cli/index.js --help
|
|
149
|
+
|
|
150
|
+
# Try to analyze (will show you the flow)
|
|
151
|
+
node dist/cli/index.js .
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Files Summary
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
Created: 20 TypeScript source files
|
|
158
|
+
Created: 3 test placeholder files
|
|
159
|
+
Created: 4 documentation files
|
|
160
|
+
Updated: package.json, README.md
|
|
161
|
+
Total: 28 files
|
|
162
|
+
|
|
163
|
+
Lines of Code: ~1,500+ LOC
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Architecture Compliance
|
|
167
|
+
|
|
168
|
+
✅ **Domain Layer**: Zero external dependencies
|
|
169
|
+
✅ **Dependency Rule**: All deps point inward
|
|
170
|
+
✅ **Interface Segregation**: Clean port definitions
|
|
171
|
+
✅ **Pure Functions**: Domain logic is side-effect free
|
|
172
|
+
|
|
173
|
+
## Resources Generated
|
|
174
|
+
|
|
175
|
+
- [TECHNICAL_DESIGN.md](./TECHNICAL_DESIGN.md) - Full specification
|
|
176
|
+
- [DEVELOPMENT.md](./DEVELOPMENT.md) - Dev guide
|
|
177
|
+
- [README.md](./README.md) - User documentation
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
**Ready to implement the parsers and make this fully functional!** 🚀
|
|
182
|
+
|
|
183
|
+
The foundation is rock-solid. Now just need to:
|
|
184
|
+
|
|
185
|
+
1. Wire up file scanning
|
|
186
|
+
2. Implement AST parsing
|
|
187
|
+
3. Test it on real code
|
|
188
|
+
4. Ship it! 📦
|