Fix ReplaceSpecialCharacters() silently dropping its dot-collapse step - #48
Open
vertesy wants to merge 2 commits into
Open
Fix ReplaceSpecialCharacters() silently dropping its dot-collapse step#48vertesy wants to merge 2 commits into
vertesy wants to merge 2 commits into
Conversation
The function computed ReplaceRepeatedDots(x) as its second-to-last
statement but never assigned the result back to `x` - it was a bare
expression, so R discarded it. The actual return value came from the
final `if (remove_dots) x <- gsub(...) else x` line, which still
operated on the un-collapsed `x`.
Impact: a direct call to ReplaceSpecialCharacters() on a string with
adjacent special characters returns runs of repeated dots instead of a
single collapsed dot, e.g. ReplaceSpecialCharacters("a[[b]]") returned
"a..b.." instead of "a.b.". Most existing call sites (FixPlotName(),
ParseFullFilePath()) were unaffected in practice, because they each
independently call ReplaceRepeatedDots() again on the result afterward
and so already compensated for this - but any code calling
ReplaceSpecialCharacters() directly got the uncollapsed output.
Fix: assign the result (`x <- ReplaceRepeatedDots(x)`) so the collapse
step actually applies before the optional remove_dots step.
Version bumped 1.2.1 -> 1.2.2 in Development/config.R and DESCRIPTION.
Validation: manually confirmed direct calls now collapse dots correctly
while FixPlotName()/ParseFullFilePath() output is unchanged (as
expected, since they already compensated). R CMD check and the existing
testthat suite (7/7 passing) were run on this branch. Remaining R CMD
check findings (parFlags example error, parsepvalue undocumented
prefix, %!in% Rd name warning, sandbox locale warning) are pre-existing
and out of scope, addressed in other PRs in this batch or
environment-inherent.
…acters-dot-collapse # Conflicts: # DESCRIPTION # Development/config.R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
The function computed
ReplaceRepeatedDots(x)as its second-to-last statement but never assigned the result back tox— it was a bare expression, so R discarded it. The actual return value came from the finalif (remove_dots) x <- gsub(...) else xline, which still operated on the un-collapsedx.Impact
A direct call to
ReplaceSpecialCharacters()on a string with adjacent special characters returns runs of repeated dots instead of a single collapsed dot, e.g.ReplaceSpecialCharacters("a[[b]]")returned"a..b.."instead of"a.b."(verified before/after). Most existing call sites (FixPlotName(),ParseFullFilePath()) were unaffected in practice, because they each independently callReplaceRepeatedDots()again on the result afterward and so already compensated for this — but any code callingReplaceSpecialCharacters()directly got the uncollapsed output.Fix
Assign the result (
x <- ReplaceRepeatedDots(x)) so the collapse step actually applies before the optionalremove_dotsstep.Version bumped 1.2.1 → 1.2.2 in
Development/config.RandDESCRIPTION.Validation
Manually confirmed direct calls now collapse dots correctly while
FixPlotName()/ParseFullFilePath()output is unchanged (as expected, since they already compensated). R CMD check and the existingtestthatsuite (7/7 passing) were run on this branch. Remaining R CMD check findings (parFlagsexample error,parsepvalueundocumentedprefix,%!in%Rd-name warning, sandbox locale warning) are pre-existing and out of scope, addressed in other PRs in this batch or environment-inherent.Generated by Claude Code