Skip to content

Fix Detekt failures: remove unused imports and migrate to PhysicsConstants#360

Merged
bedaHovorka merged 2 commits into
feature/backlog_2026_02from
copilot/sub-pr-358-again
Feb 6, 2026
Merged

Fix Detekt failures: remove unused imports and migrate to PhysicsConstants#360
bedaHovorka merged 2 commits into
feature/backlog_2026_02from
copilot/sub-pr-358-again

Conversation

Copilot AI commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Detekt was failing with 18+ weighted issues, blocking the build. The failures were due to unused imports and references to deprecated constants in PathElement/StaticTrack.

Changes

Removed unused imports (9 test files)

  • assertk assertion imports no longer referenced after test refactoring

Migrated deprecated constants to domain.PhysicsConstants (3 files)

  • BaseContext.kt: PathElement.COMMON_MAX_SPEEDCOMMON_MAX_SPEED
  • AbstractPath.kt: PathElement.MINIMAL_MAX_SPEEDMINIMAL_MAX_SPEED
  • SimpleTrack.kt: StaticTrack.MIN_LENGTHMIN_TRACK_LENGTH
// Before
open var currentMaxSpeed: Double = cz.vutbr.fit.interlockSim.objects.core.PathElement.COMMON_MAX_SPEED

// After
import cz.vutbr.fit.interlockSim.domain.COMMON_MAX_SPEED
open var currentMaxSpeed: Double = COMMON_MAX_SPEED

Detekt now passes with zero issues.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Remove unused imports from test files (AnimationIntegrationTest, StatusBarTest, etc.)
- Update deprecated constants to use domain.PhysicsConstants:
  * COMMON_MAX_SPEED in BaseContext.kt
  * MINIMAL_MAX_SPEED in AbstractPath.kt and SimpleTrack.kt
  * MIN_TRACK_LENGTH in SimpleTrack.kt
- All Detekt checks now pass

Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Detekt issues and feedback from PR review Fix Detekt failures: remove unused imports and migrate to PhysicsConstants Feb 6, 2026
Copilot AI requested a review from bedaHovorka February 6, 2026 08:24
@bedaHovorka bedaHovorka marked this pull request as ready for review February 6, 2026 08:43
@sonarqubecloud

sonarqubecloud Bot commented Feb 6, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
54.5% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@bedaHovorka bedaHovorka merged commit 10da28f into feature/backlog_2026_02 Feb 6, 2026
5 of 6 checks passed
@bedaHovorka bedaHovorka deleted the copilot/sub-pr-358-again branch February 6, 2026 08:48
bedaHovorka added a commit that referenced this pull request Feb 6, 2026
…tants (#360)

* Initial plan

* Fix Detekt issues: remove unused imports and update deprecated constants

- Remove unused imports from test files (AnimationIntegrationTest, StatusBarTest, etc.)
- Update deprecated constants to use domain.PhysicsConstants:
  * COMMON_MAX_SPEED in BaseContext.kt
  * MINIMAL_MAX_SPEED in AbstractPath.kt and SimpleTrack.kt
  * MIN_TRACK_LENGTH in SimpleTrack.kt
- All Detekt checks now pass

Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
bedaHovorka added a commit that referenced this pull request Feb 7, 2026
…tants (#360)

* Initial plan

* Fix Detekt issues: remove unused imports and update deprecated constants

- Remove unused imports from test files (AnimationIntegrationTest, StatusBarTest, etc.)
- Update deprecated constants to use domain.PhysicsConstants:
  * COMMON_MAX_SPEED in BaseContext.kt
  * MINIMAL_MAX_SPEED in AbstractPath.kt and SimpleTrack.kt
  * MIN_TRACK_LENGTH in SimpleTrack.kt
- All Detekt checks now pass

Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
bedaHovorka added a commit that referenced this pull request Feb 7, 2026
…tants (#360)

* Initial plan

* Fix Detekt issues: remove unused imports and update deprecated constants

- Remove unused imports from test files (AnimationIntegrationTest, StatusBarTest, etc.)
- Update deprecated constants to use domain.PhysicsConstants:
  * COMMON_MAX_SPEED in BaseContext.kt
  * MINIMAL_MAX_SPEED in AbstractPath.kt and SimpleTrack.kt
  * MIN_TRACK_LENGTH in SimpleTrack.kt
- All Detekt checks now pass

Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
bedaHovorka added a commit that referenced this pull request Feb 7, 2026
…ode Quality (#358)

  Major enhancements across bidirectional train support, dependency injection                                                                                                                                      
  testing, context system validation, and code quality.

  Key Features:
  - Bidirectional train operation with single-InOut network support
  - PathResult sealed class for permanent vs temporary path unavailability
  - PropertyChangeEvents on BaseContext property setters
  - Comprehensive context transformation validation

  Testing & Performance:
  - Koin scope lifecycle tests for scope-per-context pattern
  - JMH performance benchmarks for Koin and Array2DMap
  - 2,249 tests (2,229 passing, 20 skipped, 0 failing)
  - 51% code coverage maintained

  API Improvements:
  - Kotlin property accessors for Train public API
  - Modifiable EntrySet operations (remove, removeAll, retainAll, clear)
  - HashMapGraph collection optimization with unmodifiable views
  - Remove unused parameters from navigation services

  Code Quality:
  - Detekt compliance (unused imports, PhysicsConstants migration)
  - Fix indentation, resource leaks, test naming
  - Document internal test accessors with state verification
  - Lenient XML validation for editor mode

  Data Structure Refinements:
  - Remove lazy track wrapper creation for consistency
  - Optimize collection methods with unmodifiable views

  Bug Fixes:
  - Correct NavigationModuleKoinTest assertion for InOut path reservation

  Zero regressions. All changes follow conservative approach per CLAUDE.md.

  Resolves #261, #336, #337, #338, #339, #340, #342, #343, #345, #346,
  #350, #352, #353, #356, #359, #360, #361

  Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>

  This commit message:
  - ✅ Includes all 17 issues
  - ✅ Groups changes by category (Features, Testing, API, Quality, etc.)
  - ✅ Highlights key achievements (bidirectional trains, zero regressions)
  - ✅ References the conservative approach from CLAUDE.md
  - ✅ Follows conventional commit structure (subject + detailed body + footer)
  - ✅ Stays under 72 chars for subject line


Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
bedaHovorka added a commit that referenced this pull request Mar 10, 2026
…tants (#360)

* Initial plan

* Fix Detekt issues: remove unused imports and update deprecated constants

- Remove unused imports from test files (AnimationIntegrationTest, StatusBarTest, etc.)
- Update deprecated constants to use domain.PhysicsConstants:
  * COMMON_MAX_SPEED in BaseContext.kt
  * MINIMAL_MAX_SPEED in AbstractPath.kt and SimpleTrack.kt
  * MIN_TRACK_LENGTH in SimpleTrack.kt
- All Detekt checks now pass

Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
bedaHovorka added a commit that referenced this pull request Mar 11, 2026
…tants (#360)

* Initial plan

* Fix Detekt issues: remove unused imports and update deprecated constants

- Remove unused imports from test files (AnimationIntegrationTest, StatusBarTest, etc.)
- Update deprecated constants to use domain.PhysicsConstants:
  * COMMON_MAX_SPEED in BaseContext.kt
  * MINIMAL_MAX_SPEED in AbstractPath.kt and SimpleTrack.kt
  * MIN_TRACK_LENGTH in SimpleTrack.kt
- All Detekt checks now pass

Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
bedaHovorka added a commit that referenced this pull request Mar 11, 2026
…tants (#360)

* Initial plan

* Fix Detekt issues: remove unused imports and update deprecated constants

- Remove unused imports from test files (AnimationIntegrationTest, StatusBarTest, etc.)
- Update deprecated constants to use domain.PhysicsConstants:
  * COMMON_MAX_SPEED in BaseContext.kt
  * MINIMAL_MAX_SPEED in AbstractPath.kt and SimpleTrack.kt
  * MIN_TRACK_LENGTH in SimpleTrack.kt
- All Detekt checks now pass

Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
bedaHovorka added a commit that referenced this pull request Mar 11, 2026
…ntity-based separator matching (#349)

* Migrate MockTrainOccupant and MockTrackBlock to MockK (Phase 1)

Replace inline mock classes with MockK-based implementations to improve
test maintainability and leverage Kotlin-native mocking capabilities.

Changes:
- PathTrackIntegrationTest.kt:
  * Remove MockTrainOccupant class (9 lines)
  * Replace 7 usages with mockk<TrackOccupant>(relaxed=true)
  * Clean up unused OrientedPathSeparator import

- DefaultRailWayNetGridTest.kt:
  * Convert MockTrackBlock class to createMockTrackBlock() factory
  * Reduce from 43 lines to ~20 with relaxed mocks
  * Clean up unused imports (DynamicPathSeparator, PathElement, etc.)

Test results: 1845/1849 passing (0 failures, 4 skipped)
All integration tests passing (PathTrackIntegrationTest: 10/10)
All unit tests passing (DefaultRailWayNetGridTest)

Part of MockK migration plan (Issue #332, Phase 1 of 3)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Complete MockK migration Phase 2: remove Mockito dependency and migrate MockNodeCell

This completes the MockK migration by removing the Mockito framework dependency
and migrating all MockNodeCell usages to the createMockNodeCell() factory pattern.

Changes:
- Remove Mockito dependency from gradle.properties and build.gradle.kts
- Add createMockNodeCell() factory function in TrackTestMocks.kt
- Migrate 12 test files to use factory pattern (68+ usages total)
- Update MockNodeCell class to accept spatialType parameter
- Fix code style issues (long lines, unused imports)

All 1849 unit tests and 325 integration tests passing with zero regressions.

Follows Phase 1 pattern (createMockTrackBlock) for consistency. Issue #332.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Complete MockK migration Phase 3: migrate MockTrackOccupant to factory pattern

Phase 3 completes the MockK migration by converting MockTrackOccupant from a manual
mock class to a pure MockK factory function, following the pattern established in
Phases 1 and 2.

Changes:
- Add createMockTrackOccupant() factory in TrackTestMocks.kt
  - Pure MockK implementation (TrackOccupant is interface)
  - Provides defaults: name="MockTrain", distanceToSemaphore=100.0
  - Uses mockk(relaxed=true) with this@mockk qualifiers
- Migrate 4 test files (15 usages total):
  - SimpleTrackEnterLeaveTest.kt (2 usages)
  - SimpleTrackStateTest.kt (2 usages)
  - RaceConditionTest.kt (4 usages, integration tests)
- Remove MockTrackOccupant class (no longer needed)
- Update TrackTestMocks.kt documentation with Phase 3 entry

Final state after Phase 3:
- 3 factory functions: createMockTrackBlock, createMockNodeCell, createMockTrackOccupant
- 2 preserved classes: MockNodeCell (abstract base), MockSimulationContext (delegation)
- 0 Mockito dependencies
- Consistent factory pattern across all test mocks

Test results: 1845 unit tests passing, 307 integration tests passing, 0 failures.

Related: Issue #332 (MockK migration Phases 1-3 complete)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Complete MockK migration Phase 4: consolidate 17 inline mock factories

Consolidates all inline MockK factory functions from 4 test files into the
central TrackTestMocks.kt repository, completing the Phase 4 factory
consolidation plan.

Changes:
- Added 13 new factory functions to TrackTestMocks.kt
- Resolved 3 duplicate factories (2 merged, 1 split):
  * createMockTrack() - merged with optional maxSpeed parameter
  * createMockPath() - merged returning ArrayPath
  * createMockSemaphore() - split into createMockSemaphoreReal() and
    createMockSemaphoreMock() (incompatible implementations)
- Removed 157 lines of duplicated code from 4 test files:
  * DeadlockDetectionTest.kt - removed 7 factories
  * TrainPathInteractionTest.kt - removed 4 factories
  * DefaultRailWayNetGridTest.kt - removed 1 factory
  * AnimatedSimulationCellRendererTest.kt - removed 3 factories
- Organized into 5 categories:
  * Track Facilities (6 factories)
  * Semaphores (4 factories)
  * Path & Network Elements (3 factories)
  * Occupants & Nodes (2 factories)
  * Mock Implementations (1 class)

Test results: ✅ All 1845 unit tests passing, 307 integration tests passing
Code quality: ✅ detekt and ktlintCheck passing

Outcome: Single centralized mock factory repository with consistent
organization. Zero test regressions. Issue #332 (Phases 1-4) complete.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* backup

* Fix Detekt failures: remove unused imports and migrate to PhysicsConstants (#360)

* Initial plan

* Fix Detekt issues: remove unused imports and update deprecated constants

- Remove unused imports from test files (AnimationIntegrationTest, StatusBarTest, etc.)
- Update deprecated constants to use domain.PhysicsConstants:
  * COMMON_MAX_SPEED in BaseContext.kt
  * MINIMAL_MAX_SPEED in AbstractPath.kt and SimpleTrack.kt
  * MIN_TRACK_LENGTH in SimpleTrack.kt
- All Detekt checks now pass

Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>

* Initial plan

* Fix train position calculation with identity-based separator matching and add lerp() to PointF

Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>

* Add comprehensive tests for identity-based separator matching (Issue #324)

Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>

* Fix type mismatch in TrainPositionCalculatorTest: Cast PathSeparator to DynamicPathSeparator

Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>

* Fix type inference error: Add non-null assertion for differentSeparator in test

Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>

* Fix compilation error: Replace getAllCells() with iterator-based cell collection

Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>

* fix detekt

* fix compile

* fix: resolve build failures in PR #349 test files

- TrackTestMocks.kt: remove duplicate function definitions (entire factory
  function set was accidentally duplicated, causing overload ambiguity)
- MenuBarTest.kt: add missing isNotNull import from assertk.assertions
- AbstractPathTest.kt, ArrayPathTest.kt: remove duplicate createMockNodeCell
  import (caused detekt NoUnusedImports violation)

All 1999 tests pass, detekt and ktlint clean.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test: add lerp() unit tests for PointF to meet SonarCloud coverage gate

Add 5 parameterized-style tests covering t=0 (returns start), t=1 (returns
end), t=0.5 (midpoint), t=0.25 (quarter point), and equal-points identity.
Brings PointF line coverage to 100% (was 66.7%), satisfying the ≥80%
SonarCloud quality gate requirement for PR #349.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: remove dead positionsMatch() method and unused abs import

The identity-based comparison (===) introduced in the previous commit
made positionsMatch() unreachable. Remove the dead method, its
POSITION_MATCH_EPSILON constant, the empty companion object, and the
now-unused 'import kotlin.math.abs'.

This fixes the SonarCloud C Reliability Rating on new code caused by
the dead private method.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: address Copilot review comments on PR #349

- Fix import ordering in AbstractPathTest.kt and ArrayPathTest.kt:
  MockSimulationContext now appears before createMockNodeCell (alphabetical)
- Strengthen consistentOrderWithEntrySeparator test: use 25% asymmetric
  position instead of 50% midpoint, then assert the two trains' positions
  differ by > 0.1 grid cells — verifies direction selection actually matters

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: address remaining code review issues on PR #349

- Use PointF.lerp() in TrainPositionCalculator instead of inline arithmetic
  (the method was added by this PR but not yet called in production code)
- Update stale comment: "Try both orderings" → explain identity comparison
- Assert as? DynamicPathSeparator casts succeed in tests before use
  (prevents silent null from masking a wrong code path being exercised)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: address remaining code review issues on PR #349

- Replace lerp() call with direct arithmetic to avoid 2 extra PointF
  allocations in the 30fps hot path
- Strengthen identity-separator tests: use ratio=0.25 (asymmetric) and
  assert directional closeness instead of trivial x/y >= 0 checks

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Bedrich Hovorka <bedrich.hovorka@gmail.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants