Commit Graph

26 Commits

Author SHA1 Message Date
imfozilbek
42da5127cc docs: update CHANGELOG.md for v0.9.2 2025-11-27 19:28:32 +05:00
imfozilbek
b953956181 docs: update CHANGELOG.md for v0.9.1 2025-11-26 17:39:21 +05:00
imfozilbek
a6b4c69b75 feat: add anemic model detection and refactor hardcoded values (v0.9.0) 2025-11-26 00:09:48 +05:00
imfozilbek
1d6c2a0e00 refactor: extract all hardcoded values to constants (v0.8.1)
Fix all 63 hardcoded value issues from Guardian self-check:
- Remove hardcoded Slack token from documentation
- Remove aws-sdk framework leak from domain layer
- Rename 4 pipeline files to verb-noun convention
- Extract 57 magic strings to SecretExamples.ts constants
- Update SecretViolation, SecretDetector, MagicStringMatcher
- Use typeof for TypeScript literal type in getSeverity()

Result: 0 issues in Guardian self-check (was 63)
All 566 tests passing, build successful
2025-11-25 19:06:33 +05:00
imfozilbek
0b1cc5a79a feat: add secret detection with Secretlint (v0.8.0)
Add critical security feature to detect 350+ types of hardcoded secrets
using industry-standard Secretlint library.

Features:
- Detect AWS keys, GitHub tokens, NPM tokens, SSH keys, API keys, etc.
- All secrets marked as CRITICAL severity
- Context-aware remediation suggestions per secret type
- New SecretDetector using @secretlint/node
- New SecretViolation value object (100% test coverage)
- CLI output with "🔐 Secrets" section
- Async pipeline support for secret detection

Tests:
- Added 47 new tests (566 total, 100% pass rate)
- Coverage: 93.3% statements, 83.74% branches
- SecretViolation: 23 tests, 100% coverage
- SecretDetector: 24 tests

Dependencies:
- @secretlint/node: 11.2.5
- @secretlint/core: 11.2.5
- @secretlint/types: 11.2.5
- @secretlint/secretlint-rule-preset-recommend: 11.2.5
2025-11-25 18:27:27 +05:00
imfozilbek
8d400c9517 refactor: extract detector logic into focused strategy classes
Refactored three largest detectors to improve maintainability and reduce complexity:

- AggregateBoundaryDetector: 381 → 162 lines (57% reduction)
- HardcodeDetector: 459 → 89 lines (81% reduction)
- RepositoryPatternDetector: 479 → 106 lines (78% reduction)

Added 13 new strategy classes:
- FolderRegistry - centralized DDD folder name management
- AggregatePathAnalyzer - path parsing and aggregate extraction
- ImportValidator - import validation logic
- BraceTracker - brace and bracket counting
- ConstantsFileChecker - constants file detection
- ExportConstantAnalyzer - export const analysis
- MagicNumberMatcher - magic number detection
- MagicStringMatcher - magic string detection
- OrmTypeMatcher - ORM type matching
- MethodNameValidator - repository method validation
- RepositoryFileAnalyzer - file role detection
- RepositoryViolationDetector - violation detection logic

All 519 tests passing, zero ESLint errors, no breaking changes.
2025-11-25 17:41:32 +05:00
imfozilbek
5a43fbf116 test: add comprehensive E2E test suite for v0.7.8
- Add 62 new E2E tests (21 + 22 + 19)
- AnalyzeProject.e2e.test.ts: full pipeline testing
- CLI.e2e.test.ts: CLI smoke tests with process spawning
- JSONOutput.e2e.test.ts: JSON structure validation
- 100% test pass rate achieved (519/519 tests)
- Update ROADMAP.md and CHANGELOG.md
- Bump version to 0.7.8
2025-11-25 17:20:56 +05:00
imfozilbek
0b9b8564bf test: improve test coverage for domain files from 46-58% to 92-100%
- Add 31 tests for SourceFile.ts (46% → 100%)
- Add 31 tests for ProjectPath.ts (50% → 100%)
- Add 18 tests for ValueObject.ts (25% → 100%)
- Add 32 tests for RepositoryViolation.ts (58% → 92.68%)
- Total test count: 345 → 457 tests (all passing)
- Overall coverage: 95.4% statements, 86.25% branches, 96.68% functions
- Update version to 0.7.7
- Update ROADMAP.md and CHANGELOG.md
2025-11-25 16:50:00 +05:00
imfozilbek
7fea9a8fdb refactor: split CLI module into focused formatters and groupers
- Created cli/groupers/ViolationGrouper.ts for severity filtering
- Created cli/formatters/OutputFormatter.ts for violation formatting
- Created cli/formatters/StatisticsFormatter.ts for metrics display
- Reduced cli/index.ts from 484 to 260 lines (46% reduction)
- All 345 tests pass, CLI output identical to before
- No breaking changes
2025-11-25 16:30:04 +05:00
imfozilbek
8a2c6fdc0e refactor: split AnalyzeProject into pipeline components
Split 615-line God Use-Case into focused pipeline components:
- FileCollectionStep.ts (66 lines) - file scanning and basic parsing
- ParsingStep.ts (51 lines) - AST parsing and dependency graph
- DetectionPipeline.ts (371 lines) - all 7 detectors
- ResultAggregator.ts (81 lines) - response DTO builder

Reduced AnalyzeProject.ts from 615 to 245 lines (60% reduction).

All 345 tests pass, no breaking changes.
Improved separation of concerns and testability.

Closes #0.7.5 roadmap task.
2025-11-25 16:07:20 +05:00
imfozilbek
2479bde9a8 docs: update CHANGELOG for v0.7.5-beta.1 2025-11-25 15:50:30 +05:00
imfozilbek
1663d191ee docs: update CHANGELOG for v0.7.4 2025-11-25 12:16:17 +05:00
imfozilbek
33d763c41b fix: allow internal bounded context imports in aggregate detection (v0.7.3) 2025-11-25 00:54:03 +05:00
imfozilbek
3cd97c6197 fix: add errors/exceptions folders to DDD non-aggregate list (v0.7.2) 2025-11-25 00:43:41 +05:00
imfozilbek
8dd445995d fix: eliminate magic strings and fix aggregate boundary detection
- Extract DDD folder names and repository method suggestions to constants
- Fix regex pattern to support relative paths (domain/... without leading /)
- Add non-aggregate folder exclusions (constants, shared, factories, etc.)
- Remove findAll, exists, count from ORM_QUERY_METHODS (valid domain methods)
- Add exists, count, countBy patterns to domainMethodPatterns
- Add aggregate boundary test examples
2025-11-25 00:29:02 +05:00
imfozilbek
83b5dccee4 fix: improve repository method name suggestions and patterns
- Add smart context-aware suggestions for repository method names
  - queryUsers() → search, findBy[Property]
  - selectById() → findBy[Property], get[Entity]
  - insertUser() → create, add[Entity], store[Entity]
  - And more intelligent pattern matching

- Expand domain method patterns support
  - find*() methods (findNodes, findNodeById, findSimilar)
  - saveAll() batch operations
  - deleteBy*() methods (deleteByPath, deleteById)
  - deleteAll() clear operations
  - add*() methods (addRelationship, addItem)
  - initializeCollection() initialization

- Remove findAll from ORM blacklist (valid domain method)

- Reduce complexity in suggestDomainMethodName (22 → 9)

Version 0.6.4
2025-11-24 23:49:49 +05:00
imfozilbek
5a648e2c29 fix: reduce false positives in Repository Pattern detection
- Added 11 new valid DDD repository method patterns
- Support for has*(), is*(), exists*(), clear*(), store*() methods
- Support for lifecycle methods: initialize(), close(), connect(), disconnect()
- Fixes issue where valid DDD patterns were flagged as violations
- Better alignment with real-world Domain-Driven Design practices

This reduces false positives in projects using cache repositories,
connection management, and domain-specific query methods.

Version: 0.6.3
2025-11-24 23:04:57 +05:00
imfozilbek
d50cbe1a97 docs: add research-backed documentation for v0.6.2
- Added docs/WHY.md with user-friendly rule explanations and authoritative sources
- Added docs/RESEARCH_CITATIONS.md with 551 lines of academic and industry references
- Updated README.md with micro-citations under each feature
- Enhanced CLI help with 'BACKED BY RESEARCH' section
- Updated AI tools mentions across all docs (GitHub Copilot, Cursor, Windsurf, Claude, ChatGPT, Cline)
- Organized documentation structure: moved RESEARCH_CITATIONS.md to docs/
- Version bump: 0.6.1 -> 0.6.2

Research backing includes:
- Academia: MIT Course 6.031, ScienceDirect studies
- Books: Clean Architecture (Martin 2017), DDD (Evans 2003)
- Industry: Google, Microsoft, Airbnb style guides, SonarQube
- Experts: Martin Fowler, Robert C. Martin, Eric Evans, Alistair Cockburn
2025-11-24 22:51:35 +05:00
imfozilbek
3ddcff1be3 docs: enhance CLI help system for AI agents and users
Improved guardian --help with comprehensive, actionable information:
- Add DETECTS section with quick fix instructions for all 8 violation types
- Add SEVERITY LEVELS explanation (CRITICAL → LOW)
- Add step-by-step WORKFLOW guide
- Add 7 practical EXAMPLES covering common use cases
- Add HOW TO FIX COMMON ISSUES reference section

Technical improvements:
- Extract all help text strings to CLI_HELP_TEXT constants
- Fix 17 hardcoded string violations
- Maintain Single Source of Truth principle
- Zero violations in Guardian's own codebase

The help system now provides complete context for autonomous AI agents
and clear guidance for human developers.
2025-11-24 21:53:41 +05:00
imfozilbek
a72b4ce167 chore: bump version to 0.6.0
- Update version to 0.6.0 (minor release)
- Add comprehensive CHANGELOG entry for v0.6.0
- Document all features, changes, fixes, and removals
2025-11-24 21:31:50 +05:00
imfozilbek
88876a258b feat: add severity-based sorting and filtering for violations (v0.5.2)
- Add CRITICAL/HIGH/MEDIUM/LOW severity levels to all violations
- Sort violations by severity automatically (most critical first)
- Add CLI flags: --min-severity and --only-critical
- Group violations by severity in CLI output with color-coded headers
- Update all violation interfaces to include severity field
- Maintain 90%+ test coverage with all tests passing
- Update CHANGELOG.md, ROADMAP.md, and package version to 0.5.2
2025-11-24 20:41:52 +05:00
imfozilbek
a34ca85241 chore: refactor hardcoded values to constants (v0.5.1)
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
2025-11-24 20:12:08 +05:00
imfozilbek
ae361a4d60 chore: bump version to 0.2.0 for framework leak detection release 2025-11-24 12:57:41 +05:00
imfozilbek
32f5d8dbc5 docs: finalize v0.1.0 documentation with framework leak detection
Updates across all documentation files:

CHANGELOG.md:
- Add Framework Leak Detection as implemented feature in v0.1.0
- Update test count: 159 → 194 tests across 7 files
- Update examples count: 36 → 38 files (29 good + 9 bad)
- Remove framework leak from future releases

README.md:
- Add Framework Leak Detection section in Features
- Document supported frameworks: HTTP, ORM/DB, External services
- Include examples of Express, Prisma, TypeORM, etc.
- Emphasize domain boundary protection

ROADMAP.md:
- Move Framework Leak Detection from v0.2.0 to v0.1.0
- Update v0.1.0 metrics: 194 tests, 38 examples
- Renumber future versions (Entity Exposure now v0.2.0)
- Maintain proper version sequence through v1.0.0

CLAUDE.md:
- Update project description with framework leak detection
- Add to Key features list (5 features total)
- Update Guardian capabilities overview

TODO.md:
- Update current tasks and priorities

All documentation now accurately reflects v0.1.0 release with 5 core features:
1. Hardcode Detection
2. Circular Dependency Detection
3. Naming Convention Enforcement
4. Architecture Violations
5. Framework Leak Detection
2025-11-24 12:54:48 +05:00
imfozilbek
32bcf7d465 chore(guardian): rename package to @samiyev/guardian
Rename package from @puaros/guardian to @samiyev/guardian for npm publication.
Update all references in documentation.
2025-11-24 03:14:54 +05:00
imfozilbek
03705b5264 feat(guardian): add guardian package - code quality analyzer
Add @puaros/guardian package v0.1.0 - code quality guardian for vibe coders and enterprise teams.

Features:
- Hardcode detection (magic numbers, magic strings)
- Circular dependency detection
- Naming convention enforcement (Clean Architecture)
- Architecture violation detection
- CLI tool with comprehensive reporting
- 159 tests with 80%+ coverage
- Smart suggestions for fixes
- Built for AI-assisted development

Built with Clean Architecture and DDD principles.
Works with Claude, GPT, Copilot, Cursor, and any AI coding assistant.
2025-11-24 02:54:39 +05:00