mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-28 07:16:53 +05:00
- 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
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
import { HardcodedValue } from "../value-objects/HardcodedValue"
|
|
|
|
export interface ValueLocation {
|
|
file: string
|
|
line: number
|
|
context: string
|
|
}
|
|
|
|
export interface DuplicateInfo {
|
|
value: string | number | boolean
|
|
locations: ValueLocation[]
|
|
count: number
|
|
}
|
|
|
|
/**
|
|
* Interface for tracking duplicate hardcoded values across files
|
|
*
|
|
* Helps identify values that are used in multiple places
|
|
* and should be extracted to a shared constant.
|
|
*/
|
|
export interface IDuplicateValueTracker {
|
|
/**
|
|
* Adds a hardcoded value to tracking
|
|
*/
|
|
track(violation: HardcodedValue, filePath: string): void
|
|
|
|
/**
|
|
* Gets all duplicate values (values used in 2+ places)
|
|
*/
|
|
getDuplicates(): DuplicateInfo[]
|
|
|
|
/**
|
|
* Gets duplicate locations for a specific value
|
|
*/
|
|
getDuplicateLocations(value: string | number | boolean, type: string): ValueLocation[] | null
|
|
|
|
/**
|
|
* Checks if a value is duplicated
|
|
*/
|
|
isDuplicate(value: string | number | boolean, type: string): boolean
|
|
|
|
/**
|
|
* Gets statistics about duplicates
|
|
*/
|
|
getStats(): {
|
|
totalValues: number
|
|
duplicateValues: number
|
|
duplicatePercentage: number
|
|
}
|
|
|
|
/**
|
|
* Clears all tracked values
|
|
*/
|
|
clear(): void
|
|
}
|