kamiazya/scopes

Enhance Konsist rules for broader test framework support

开放

#127 创建于 2025年8月31日

 (0 条评论) (0 个反应) (0 位负责人)Kotlin (3 个派生)auto 404
enhancementgood first issuehacktoberfest

仓库指标

星标
 (2 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Background

CodeRabbit review of PR #119 suggested several enhancements to our Konsist architecture validation rules to make them more comprehensive and reduce false positives.

Suggested Improvements

DatabaseTestingRulesTest.kt

  1. Broaden lifecycle hooks detection

    • Support Kotest beforeSpec/afterSpec and JUnit @BeforeAll/@AfterAll
    • Recognize use {} and try/finally patterns for resource closing
  2. Include other SqlDelight drivers

    • Support NativeSqliteDriver and AndroidSqliteDriver
    • Improve in-memory database detection patterns
  3. Better property state detection

    • Use anchored regex for var/val detection
    • Avoid false positives from comments

EventSourcingArchitectureTest.kt

  1. Detect injected clocks

    • Support clock.now() pattern for dependency-injected clocks
    • Not just Clock.System.now()
  2. Allow negative test cases

    • Permit future timestamps when test explicitly asserts failure
    • Detect shouldThrow, shouldBeLeft, etc.
  3. Support virtual time testing

    • Recognize TestClock, FixedClock usage
    • Support coroutine test utilities

General Improvements

  • File-level enforcement instead of per-class for some rules
  • Consider DB-level constraints as valid validation strategy
  • Narrow scope to domain packages to avoid framework classes

Priority

Low - Current rules work well, these are enhancements for edge cases

Related

  • PR #119 (initial Konsist rules implementation)
  • Issue #125 (runTest migration)

贡献者指南