mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-28 07:16:53 +05:00
refactor: migrate hardcode detector from regex to AST-based analysis
- Replace regex-based matchers with tree-sitter AST traversal - Add duplicate value tracking across files - Implement boolean literal detection - Add value type classification (email, url, ip, api_key, etc.) - Improve context awareness with AST node analysis - Reduce false positives with better constant detection Breaking changes removed: - BraceTracker.ts - ExportConstantAnalyzer.ts - MagicNumberMatcher.ts - MagicStringMatcher.ts New components added: - AstTreeTraverser for AST walking - DuplicateValueTracker for cross-file tracking - AstContextChecker for node context analysis - AstNumberAnalyzer, AstStringAnalyzer, AstBooleanAnalyzer - ValuePatternMatcher for type detection Test coverage: 87.97% statements, 96.75% functions
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { IAnemicModelDetector } from "../../domain/services/IAnemicModelDetector"
|
||||
import { AnemicModelViolation } from "../../domain/value-objects/AnemicModelViolation"
|
||||
import { CLASS_KEYWORDS } from "../../shared/constants"
|
||||
import { LAYERS } from "../../shared/constants/rules"
|
||||
import { ANALYZER_DEFAULTS, ANEMIC_MODEL_FLAGS, LAYERS } from "../../shared/constants/rules"
|
||||
|
||||
/**
|
||||
* Detects anemic domain model violations
|
||||
@@ -224,8 +224,8 @@ export class AnemicModelDetector implements IAnemicModelDetector {
|
||||
lineNumber,
|
||||
methodCount,
|
||||
propertyCount,
|
||||
false,
|
||||
true,
|
||||
ANEMIC_MODEL_FLAGS.HAS_ONLY_GETTERS_SETTERS_FALSE,
|
||||
ANEMIC_MODEL_FLAGS.HAS_PUBLIC_SETTERS_TRUE,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -237,8 +237,8 @@ export class AnemicModelDetector implements IAnemicModelDetector {
|
||||
lineNumber,
|
||||
methodCount,
|
||||
propertyCount,
|
||||
true,
|
||||
false,
|
||||
ANEMIC_MODEL_FLAGS.HAS_ONLY_GETTERS_SETTERS_TRUE,
|
||||
ANEMIC_MODEL_FLAGS.HAS_PUBLIC_SETTERS_FALSE,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -256,8 +256,8 @@ export class AnemicModelDetector implements IAnemicModelDetector {
|
||||
lineNumber,
|
||||
methodCount,
|
||||
propertyCount,
|
||||
false,
|
||||
false,
|
||||
ANALYZER_DEFAULTS.HAS_ONLY_GETTERS_SETTERS,
|
||||
ANALYZER_DEFAULTS.HAS_PUBLIC_SETTERS,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user