Skip to content

Harden OperationBand index bounds and band-line parsing#229

Open
patrickrb wants to merge 1 commit into
devfrom
feat/operationband-bounds
Open

Harden OperationBand index bounds and band-line parsing#229
patrickrb wants to merge 1 commit into
devfrom
feat/operationband-bounds

Conversation

@patrickrb

Copy link
Copy Markdown
Owner

Context

First fix from the pre-app-store bug bash triage ledger (PR 2 — the highest-confidence cluster of real defects). Triage-verified by reading source; these are genuine crashers reachable from the band/frequency pickers and the bands.txt asset loader.

Bugs fixed

Where Bug Trigger
OperationBand.getBandFreq(int) Guard was index > sizeoff-by-one. index == size slipped through to bandList.get(index)IndexOutOfBounds. Negatives unguarded. Band picker at the list boundary
OperationBand.getBandInfo(int) Returned bandList.get(0) when index >= size → crashes on an empty list (missing/corrupt bands.txt); negatives unguarded. First-run / corrupt asset
OperationBand.Band(String) A truncated line like "20m:" passes isBandLine() (it has a colon) but splits to one field → constructor throws and aborts the entire band-list load, leaving the app with no bands. One malformed line in bands.txt

Approach

  • Centralised the bounds check in a single isValidBandIndex() helper used by every accessor (rejects both negatives and index >= size).
  • getBandInfo falls back to the default band when the list is empty.
  • Extracted the asset parse loop into parseBandLines(), which logs and skips an individual malformed line instead of aborting the whole load.
  • No behaviour change for valid input.

Tests

OperationBandTest (now 34 tests, all green) gains coverage for: the off-by-one (index == size), negative indices on both accessors, empty-list getBandInfo, and parseBandLines skipping truncated / non-numeric / comment / blank lines while keeping valid neighbours.

Run: cmd.exe /c "gradlew.bat testDebugUnitTest --tests com.bg7yoz.ft8cn.database.OperationBandTest"

🤖 Generated with Claude Code

Pre-store bug bash (PR 2 of the triage ledger). Three real defects in the
band-list accessors, all reachable from the band/frequency pickers and the
asset loader:

- getBandFreq(int): the guard was `index > bandList.size()`, an off-by-one
  that let `index == size` fall through into `bandList.get(index)` and throw
  IndexOutOfBounds. Negative indices were unguarded too.
- getBandInfo(int): returned `bandList.get(0)` whenever `index >= size`, which
  crashes when the list is empty (missing/corrupt bands.txt); negatives unguarded.
- Band(String): a truncated line such as "20m:" passes isBandLine() (it has a
  colon) but splits to a single field, so the constructor threw and aborted the
  entire band-list load, leaving the app with no bands.

Fixes centralise the bounds check in a single tested `isValidBandIndex()` helper
used by every accessor, make getBandInfo fall back to the default band when the
list is empty, and route the asset loader through a new `parseBandLines()` that
logs and skips an individual malformed line instead of aborting the load. No
behaviour change for valid input.

Tests: OperationBandTest gains coverage for the off-by-one (index == size),
negative indices, empty-list getBandInfo, and parseBandLines skipping
truncated/non-numeric/comment/blank lines while keeping valid neighbours.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 8.32%. Comparing base (4e7fadc) to head (978c065).
⚠️ Report is 2 commits behind head on dev.

Files with missing lines Patch % Lines
.../java/com/bg7yoz/ft8cn/database/OperationBand.java 88.88% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##               dev    #229      +/-   ##
==========================================
+ Coverage     8.28%   8.32%   +0.03%     
- Complexity     794     802       +8     
==========================================
  Files          289     289              
  Lines        32597   32606       +9     
  Branches      5197    5199       +2     
==========================================
+ Hits          2702    2714      +12     
+ Misses       29682   29679       -3     
  Partials       213     213              
Files with missing lines Coverage Δ
.../java/com/bg7yoz/ft8cn/database/OperationBand.java 66.34% <88.88%> (+6.34%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant