mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-22 13:51:14 +00:00
[AZ-376] [AZ-378] [AZ-379] [AZ-380] Repo cleanup: dead code, logger discipline, ColumnList consts
Batch 23 of refactor 03-code-quality-refactoring (4 tasks, 5 SP):
- AZ-376 (C23): Delete unused FindExistingTileAsync from
ITileRepository / TileRepository. No callers; method also took the
obsolete `version` arg removed by C06/AZ-357.
- AZ-378 (C25): Repository _logger discipline.
TileRepository.GetTilesByRegionAsync now emits LogWarning when the
query exceeds SlowQueryThresholdMs (500 ms). RegionRepository and
RouteRepository drop the unused ILogger<TRepo> field, parameter, and
using; Program.cs DI registrations updated.
- AZ-379 (C26): Extract `private const string ColumnList` per repo
(TileRepository, RegionRepository, RouteRepository); SELECTs use
$@"SELECT {ColumnList} FROM ..." (C# 10+ const interpolation).
INSERT/UPDATE/DELETE unchanged; route_points single-site SELECT left
inline.
- AZ-380 (C27): Delete dead alias GeoUtils.CalculatePolygonDiagonalDistance.
Tests: +9 new (RepositoryRefactorTests x8, GeoUtilsRefactorTests x1)
covering each AC via reflection / file-content assertions; pattern
mirrors ToolingConfigurationTests (b22) and AcceptanceCriteriaRT2Tests
(b19). Unit suite 181 -> 190, all green. dotnet format clean.
Code review: PASS_WITH_WARNINGS (3 Low findings, all informational or
out-of-scope for this batch). See
_docs/03_implementation/reviews/batch_23_review.md.
Cumulative review counter 2/3; next K=3 review fires after batch 24.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
# Refactor: delete unused FindExistingTileAsync
|
||||
|
||||
**Task**: AZ-376_refactor_delete_findexistingtile
|
||||
**Name**: Delete dead FindExistingTileAsync method
|
||||
**Description**: Remove `FindExistingTileAsync` from `ITileRepository` and `TileRepository` — no callers exist and it takes the obsolete `version` argument C06 is removing.
|
||||
**Complexity**: 1 point
|
||||
**Dependencies**: None (verify with one final grep before deletion)
|
||||
**Component**: DataAccess
|
||||
**Tracker**: AZ-376
|
||||
**Epic**: AZ-350
|
||||
|
||||
## Problem
|
||||
|
||||
`SatelliteProvider.DataAccess/Repositories/ITileRepository.cs` declares `FindExistingTileAsync(latitude, longitude, tileSizeMeters, zoomLevel, version)` and `SatelliteProvider.DataAccess/Repositories/TileRepository.cs:51-76` implements it, but no caller exists in the codebase. Dead code that also takes the obsolete `version` argument C06 is removing.
|
||||
|
||||
## Outcome
|
||||
|
||||
- Method removed from both the interface and the implementation.
|
||||
- `dotnet build` succeeds across all consumers.
|
||||
- 37 unit + 5 smoke tests stay green.
|
||||
|
||||
## Scope
|
||||
|
||||
### Included
|
||||
- Verify with `grep -r "FindExistingTileAsync"` that no caller exists outside docs and the implementation file.
|
||||
- Delete the method declaration from `ITileRepository`.
|
||||
- Delete the implementation from `TileRepository`.
|
||||
- Update `_dependencies_table.md` if needed.
|
||||
|
||||
### Excluded
|
||||
- Replacing it with anything (no caller wants it).
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
**AC-1: Method gone**
|
||||
Given the post-refactor source
|
||||
When grepped for `FindExistingTileAsync`
|
||||
Then matches are confined to docs (and even those should be cleaned up if they describe the method as live).
|
||||
|
||||
**AC-2: Build succeeds**
|
||||
Given the post-refactor solution
|
||||
When `dotnet build` runs
|
||||
Then it succeeds with zero errors.
|
||||
|
||||
**AC-3: Tests stay green**
|
||||
Given the post-refactor build
|
||||
When `scripts/run-tests.sh --smoke` runs
|
||||
Then all 37 unit + 5 smoke scenarios pass.
|
||||
|
||||
## Constraints
|
||||
|
||||
- Verify dead-code claim with one final grep at implementation time.
|
||||
|
||||
## Risks & Mitigation
|
||||
|
||||
**Risk 1: reflection / DI / dynamic dispatch consumes it**
|
||||
- *Risk*: a hidden consumer via reflection.
|
||||
- *Mitigation*: per `coderule.mdc` dead-code rule, scan for reflection / DI registrations that name the method. None are expected; verify before deletion.
|
||||
|
||||
Full change entry: `_docs/04_refactoring/03-code-quality-refactoring/list-of-changes.md` (C23).
|
||||
@@ -0,0 +1,60 @@
|
||||
# Refactor: remove unused _logger fields from repositories (or use them)
|
||||
|
||||
**Task**: AZ-378_refactor_repo_logger_fields
|
||||
**Name**: Repo loggers — delete or use
|
||||
**Description**: Either delete the unused `_logger` injection from each repository or use it for a slow-query warning. Recommended split: use it in `TileRepository.GetTilesByRegionAsync`; delete elsewhere.
|
||||
**Complexity**: 1 point
|
||||
**Dependencies**: None
|
||||
**Component**: DataAccess
|
||||
**Tracker**: AZ-378
|
||||
**Epic**: AZ-350
|
||||
|
||||
## Problem
|
||||
|
||||
`SatelliteProvider.DataAccess/Repositories/TileRepository.cs:11`, `RegionRepository.cs:11`, and `RouteRepository.cs` each accept and store `ILogger<TRepo>` but never read the field. Dead injection adds DI cost and noise without value.
|
||||
|
||||
## Outcome
|
||||
|
||||
- Repositories that keep `_logger` actually use it (e.g., slow-query warning).
|
||||
- Repositories that don't keep it have the field, parameter, and DI registration removed.
|
||||
- 37 unit + 5 smoke tests stay green.
|
||||
|
||||
## Scope
|
||||
|
||||
### Included
|
||||
- Recommended: `TileRepository.GetTilesByRegionAsync` measures query duration and emits `_logger.LogWarning` if it exceeds a threshold (e.g., 500 ms — make it a const with a comment).
|
||||
- Delete `_logger` from `RegionRepository`, `RouteRepository`, and any other repository where it isn't used.
|
||||
- Update DI registrations in `Program.cs` for the deleted ones.
|
||||
|
||||
### Excluded
|
||||
- Adding structured query telemetry beyond the slow-query warning.
|
||||
- Promoting the warning to a metric (deferred).
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
**AC-1: Kept loggers are used**
|
||||
Given the post-refactor source
|
||||
When `_logger` survives in any repository
|
||||
Then it is read at least once in that file.
|
||||
|
||||
**AC-2: Unused loggers are removed**
|
||||
Given each remaining repository
|
||||
When the constructor is inspected
|
||||
Then there is no unused `ILogger<TRepo>` parameter.
|
||||
|
||||
**AC-3: Tests stay green**
|
||||
Given the post-refactor build
|
||||
When `scripts/run-tests.sh --smoke` runs
|
||||
Then all 37 unit + 5 smoke scenarios pass.
|
||||
|
||||
## Constraints
|
||||
|
||||
- No public API change.
|
||||
|
||||
## Risks & Mitigation
|
||||
|
||||
**Risk 1: slow-query threshold is arbitrary**
|
||||
- *Risk*: 500 ms may be too tight or too loose.
|
||||
- *Mitigation*: make it a named const with a short comment; tune later as needed.
|
||||
|
||||
Full change entry: `_docs/04_refactoring/03-code-quality-refactoring/list-of-changes.md` (C25).
|
||||
@@ -0,0 +1,59 @@
|
||||
# Refactor: extract repository SELECT column-list constants
|
||||
|
||||
**Task**: AZ-379_refactor_repo_select_columnlist
|
||||
**Name**: One ColumnList per repository
|
||||
**Description**: Extract a per-repository `private const string ColumnList` and interpolate it into each SELECT.
|
||||
**Complexity**: 2 points
|
||||
**Dependencies**: None
|
||||
**Component**: DataAccess
|
||||
**Tracker**: AZ-379
|
||||
**Epic**: AZ-350
|
||||
|
||||
## Problem
|
||||
|
||||
`SatelliteProvider.DataAccess/Repositories/TileRepository.cs` contains the same `id, tile_zoom as TileZoom, tile_x as TileX, ...` column list in 4 SELECTs; `RegionRepository.cs` has 2 such SELECTs; `RouteRepository.cs` similar. Every new column must be added in lockstep across all SELECTs; easy to drift.
|
||||
|
||||
## Outcome
|
||||
|
||||
- Each repository defines `private const string ColumnList = "..."` once and reuses it across all SELECTs.
|
||||
- Generated SQL is byte-for-byte identical.
|
||||
- 37 unit + 5 smoke tests stay green.
|
||||
|
||||
## Scope
|
||||
|
||||
### Included
|
||||
- Per repository: extract the column list once.
|
||||
- Replace each SELECT with `$"SELECT {ColumnList} FROM <table> WHERE ..."`.
|
||||
|
||||
### Excluded
|
||||
- Pulling in `Dapper.Contrib` or a micro-ORM.
|
||||
- Renaming or reordering columns.
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
**AC-1: One ColumnList per repository**
|
||||
Given the post-refactor source
|
||||
When each repository is inspected
|
||||
Then it declares `ColumnList` once and references it from every SELECT.
|
||||
|
||||
**AC-2: SQL byte-identical**
|
||||
Given the post-refactor code
|
||||
When SELECT statements are extracted (e.g., via test interception or Dapper logging)
|
||||
Then the generated SQL matches the pre-refactor output.
|
||||
|
||||
**AC-3: Tests stay green**
|
||||
Given the post-refactor build
|
||||
When `scripts/run-tests.sh --smoke` runs
|
||||
Then all 37 unit + 5 smoke scenarios pass.
|
||||
|
||||
## Constraints
|
||||
|
||||
- No new dependencies.
|
||||
|
||||
## Risks & Mitigation
|
||||
|
||||
**Risk 1: interpolation introduces an injection vector**
|
||||
- *Risk*: `$"..."` interpolation looks like a SQL-injection foot-gun.
|
||||
- *Mitigation*: `ColumnList` is a `const` defined in source; not user input. Standard Dapper parameterization stays for actual values.
|
||||
|
||||
Full change entry: `_docs/04_refactoring/03-code-quality-refactoring/list-of-changes.md` (C26).
|
||||
@@ -0,0 +1,58 @@
|
||||
# Refactor: delete GeoUtils.CalculatePolygonDiagonalDistance dead alias
|
||||
|
||||
**Task**: AZ-380_refactor_delete_polygon_diagonal
|
||||
**Name**: Delete dead alias method
|
||||
**Description**: Remove `GeoUtils.CalculatePolygonDiagonalDistance` — pure alias of `CalculateDistance` with no callers.
|
||||
**Complexity**: 1 point
|
||||
**Dependencies**: None (verify with one final grep before deletion)
|
||||
**Component**: Common
|
||||
**Tracker**: AZ-380
|
||||
**Epic**: AZ-350
|
||||
|
||||
## Problem
|
||||
|
||||
`SatelliteProvider.Common/Utils/GeoUtils.cs:129-132` defines `CalculatePolygonDiagonalDistance(GeoPoint nw, GeoPoint se)` which simply returns `CalculateDistance(nw, se)`. Pure alias, no callers in the codebase. Adds API surface for nothing.
|
||||
|
||||
## Outcome
|
||||
|
||||
- Method removed.
|
||||
- `dotnet build` succeeds across all consumers.
|
||||
- 37 unit + 5 smoke tests stay green.
|
||||
|
||||
## Scope
|
||||
|
||||
### Included
|
||||
- Verify with `grep -r "CalculatePolygonDiagonalDistance"` that no caller exists outside the implementation.
|
||||
- Delete the method.
|
||||
|
||||
### Excluded
|
||||
- Replacing it with anything (no caller wants it).
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
**AC-1: Method gone**
|
||||
Given the post-refactor source
|
||||
When grepped for `CalculatePolygonDiagonalDistance`
|
||||
Then matches are confined to docs (which should be cleaned up if they describe the method as live).
|
||||
|
||||
**AC-2: Build succeeds**
|
||||
Given the post-refactor solution
|
||||
When `dotnet build` runs
|
||||
Then it succeeds with zero errors.
|
||||
|
||||
**AC-3: Tests stay green**
|
||||
Given the post-refactor build
|
||||
When `scripts/run-tests.sh --smoke` runs
|
||||
Then all 37 unit + 5 smoke scenarios pass.
|
||||
|
||||
## Constraints
|
||||
|
||||
- Verify dead-code claim with one final grep at implementation time.
|
||||
|
||||
## Risks & Mitigation
|
||||
|
||||
**Risk 1: reflection / DI / dynamic dispatch consumes it**
|
||||
- *Risk*: hidden consumer via reflection.
|
||||
- *Mitigation*: scan reflection / DI / config for the method name. None are expected; verify before deletion.
|
||||
|
||||
Full change entry: `_docs/04_refactoring/03-code-quality-refactoring/list-of-changes.md` (C27).
|
||||
Reference in New Issue
Block a user