mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-28 07:16:53 +05:00
Major internal refactoring to eliminate hardcoded values and improve maintainability. Guardian now fully passes its own quality checks! Changes: - Extract all RepositoryViolation messages to domain constants - Extract all framework leak template strings to centralized constants - Extract all layer paths to infrastructure constants - Extract all regex patterns to IMPORT_PATTERNS constant - Add 30+ new constants for better maintainability New files: - src/infrastructure/constants/paths.ts (layer paths, patterns) - src/domain/constants/Messages.ts (25+ repository messages) - src/domain/constants/FrameworkCategories.ts (framework categories) - src/shared/constants/layers.ts (layer names) Impact: - Reduced hardcoded values from 37 to 1 (97% improvement) - Guardian passes its own src/ directory checks with 0 violations - All 292 tests still passing (100% pass rate) - No breaking changes - fully backwards compatible Test results: - 292 tests passing (100% pass rate) - 96.77% statement coverage - 83.82% branch coverage
96 lines
1.9 KiB
TypeScript
96 lines
1.9 KiB
TypeScript
/**
|
|
* Default file scanning options
|
|
*/
|
|
export const DEFAULT_EXCLUDES = [
|
|
"node_modules",
|
|
"dist",
|
|
"build",
|
|
"coverage",
|
|
".git",
|
|
".puaros",
|
|
"tests",
|
|
"test",
|
|
"__tests__",
|
|
"examples",
|
|
] as const
|
|
|
|
export const DEFAULT_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx"] as const
|
|
|
|
/**
|
|
* Allowed numbers that are not considered magic numbers
|
|
*/
|
|
export const ALLOWED_NUMBERS = new Set([-1, 0, 1, 2, 10, 100, 1000])
|
|
|
|
/**
|
|
* Default context extraction size (characters)
|
|
*/
|
|
export const CONTEXT_EXTRACT_SIZE = 30
|
|
|
|
/**
|
|
* String length threshold for magic string detection
|
|
*/
|
|
export const MIN_STRING_LENGTH = 3
|
|
|
|
/**
|
|
* Single character limit for string detection
|
|
*/
|
|
export const SINGLE_CHAR_LIMIT = 1
|
|
|
|
/**
|
|
* Git defaults
|
|
*/
|
|
export const GIT_DEFAULTS = {
|
|
REMOTE: "origin",
|
|
BRANCH: "main",
|
|
} as const
|
|
|
|
/**
|
|
* Tree-sitter node types for function detection
|
|
*/
|
|
export const TREE_SITTER_NODE_TYPES = {
|
|
FUNCTION_DECLARATION: "function_declaration",
|
|
ARROW_FUNCTION: "arrow_function",
|
|
FUNCTION_EXPRESSION: "function_expression",
|
|
} as const
|
|
|
|
/**
|
|
* Detection keywords for hardcode analysis
|
|
*/
|
|
export const DETECTION_KEYWORDS = {
|
|
TIMEOUT: "timeout",
|
|
DELAY: "delay",
|
|
RETRY: "retry",
|
|
LIMIT: "limit",
|
|
MAX: "max",
|
|
MIN: "min",
|
|
PORT: "port",
|
|
INTERVAL: "interval",
|
|
TEST: "test",
|
|
DESCRIBE: "describe",
|
|
CONSOLE_LOG: "console.log",
|
|
CONSOLE_ERROR: "console.error",
|
|
HTTP: "http",
|
|
API: "api",
|
|
} as const
|
|
|
|
/**
|
|
* Code patterns for detecting exported constants
|
|
*/
|
|
export const CODE_PATTERNS = {
|
|
EXPORT_CONST: "export const ",
|
|
EXPORT: "export ",
|
|
IMPORT: "import ",
|
|
AS_CONST: " as const",
|
|
AS_CONST_OBJECT: "} as const",
|
|
AS_CONST_ARRAY: "] as const",
|
|
AS_CONST_END_SEMICOLON_OBJECT: "};",
|
|
AS_CONST_END_SEMICOLON_ARRAY: "];",
|
|
OBJECT_START: "= {",
|
|
ARRAY_START: "= [",
|
|
} as const
|
|
|
|
/**
|
|
* File encoding
|
|
*/
|
|
export const FILE_ENCODING = "utf-8" as const
|