Skip to content

Fix check_extra_field_values assignment #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2025

Conversation

ezraporter
Copy link
Collaborator

Description

This PR fixes a small bug that was causing check_extra_field_values to report the wrong field when REDCapTidieR finds data values that don't match any labels in the metadata.

Proposed Changes

  • Update multi_choice_to_labels() to check if the result of check_extra_field_values() is NULL before replacing values.

The issue was that indexing into a list with NULL always drops the item you're indexing even it was already NULL:

x <- list(1, NULL, 3)

x[2] <- NULL

x

#> [[1]]
#> [1] 1
#> 
#> [[2]]
#> [1] 3

PR Checklist

Before submitting this PR, please check and verify below that the submission meets the below criteria:

  • New/revised functions have associated tests
  • New/revised functions that update downstream outputs have associated static testing files (.RDS) updated under inst/testdata/create_test_data.R
  • New/revised functions use appropriate naming conventions
  • New/revised functions don't repeat code
  • Code changes are less than 250 lines total
  • Issues linked to the PR using GitHub's list of keywords
  • The appropriate reviewer is assigned to the PR
  • The appropriate developers are assigned to the PR
  • Pre-release package version incremented using usethis::use_version()

Code Review

This section to be used by the reviewer and developers during Code Review after PR submission

Code Review Checklist

  • I checked that new files follow naming conventions and are in the right place
  • I checked that documentation is complete, clear, and without typos
  • I added/edited comments to explain "why" not "how"
  • I checked that all new variable and function names follow naming conventions
  • I checked that new tests have been written for key business logic and/or bugs that this PR fixes
  • I checked that new tests address important edge cases

@ezraporter ezraporter requested a review from rsh52 May 20, 2025 13:49
@ezraporter ezraporter self-assigned this May 20, 2025
Copy link
Collaborator

@rsh52 rsh52 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and simple enough change that it shouldn't really warrant a new test. 🚀

@ezraporter ezraporter merged commit 1a6ddf8 into main May 20, 2025
4 checks passed
@ezraporter ezraporter deleted the fix-extra_field_values-warning branch May 20, 2025 16:57
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