Skip to content

Fix basic_burden_sanity() crashing on failed checks - #18

Merged
david-mears-2 merged 4 commits into
mainfrom
fix/basic-burden-sanity-vector-condition
Nov 4, 2026
Merged

david-mears-2 merged 4 commits into
mainfrom
fix/basic-burden-sanity-vector-condition

Conversation

Copilot AI commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Copilot informed me about a bug in vimcheck so I asked it to fix it. The bug report was:

basic_burden_sanity() errors with "the condition has length > 1" whenever any check produces a warning, because of if (mes == mes_start) comparing a vector (an error since R ≥ 4.2). It's worth a fix upstream in vimc/vimcheck.

I don't speak R so would appreciate a review.

Copilot's PR description

Bug validation

Confirmed on R 4.3.3: missing values, negative estimates, non-numeric estimates, and combined missing/negative estimates each produce the condition has length > 1. Clean numeric estimates return the header and PASS..

This is a bug, not an intentional rejection of invalid estimates. The documented return value is a character vector of check messages, and the function explicitly accumulates those messages. These are strings prefixed with Warning:, not emitted R warning conditions. Once a failed check appends a message, mes == mes_start is a logical vector rather than the scalar required by if. On older R versions, using its first (always TRUE) element also incorrectly appends PASS. alongside failed-check messages.

Changes

  • Replace the vector comparison with identical(mes, mes_start) so PASS. is appended only when no failed-check messages were added.
  • Preserve existing diagnostic wording, ordering, checks, and clean-input behaviour.
  • Add regression coverage for clean numeric/integer/empty estimates; missing values including NaN; negative and non-numeric estimates; and simultaneous missing/negative values. Assert exact output and absence of emitted conditions.
  • Document the fix in NEWS.md.

Validation

The full tests/testthat/test-burden_diagnostics.R file passes on R 4.3.3 (36 expectations), with repository R sources and example data loaded. git diff --check passes.

Review requested from @kgaythorpe and @david-mears-2.

Use a scalar comparison so failed checks return their documented messages without appending PASS or erroring on modern R. Add regression coverage for clean estimates and each failed-check path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@david-mears-2

Copy link
Copy Markdown
Contributor

@copilot You should increment the patch version when you do a bugfix. Increment it and document this requirement.

Co-authored-by: david-mears-2 <60350599+david-mears-2@users.noreply.github.com>

Copilot AI commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot You should increment the patch version when you do a bugfix. Increment it and document this requirement.

Bumped DESCRIPTION to 0.0.6 and documented the patch-version rule in CONTRIBUTING.md. Commit: c9f8b88.

Comment thread NEWS.md Resolved
Co-authored-by: david-mears-2 <60350599+david-mears-2@users.noreply.github.com>
@david-mears-2
david-mears-2 merged commit 79e3648 into main Nov 4, 2026
11 checks passed
@david-mears-2
david-mears-2 deleted the fix/basic-burden-sanity-vector-condition branch November 4, 2026 10:53
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.

3 participants