-
Notifications
You must be signed in to change notification settings - Fork 3.6k
R1C1 conversion should handle absolute A1 references #2060
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
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
aeb21f7
R1C1 conversion should handle absolute A1 references
ndench c7f65bb
Update CHANGELOG.md with R1C1 conversion change
ndench c2fa059
Remove complexity from AddressHelper::convertToR1C1
ndench 1adc188
Use named regex groups and constants for regex strings
ndench File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
R1C1 conversion should handle absolute A1 references
- Loading branch information
commit aeb21f7537a1a07247c27e41750622b2fbd85caf
There are no files selected for viewing
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be easier to extract the
$for absolutes, the column address and row id directly through individual capture groups in the regexp rather than using substring? Then you can also eliminate theelsecondition in theseifstatements, which reduces the complexity of the code for path coverageThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. I originally went this way to not increase the complexity of the regex, but I think your way is cleaner. I'll push an update today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed that change now. Much cleaner 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those changes to the regex don't add any significant cost to execution, as you're already executing the regex anyway; but do eliminate the
substr()function calls.The only thing I'd be tempted to change now would be to use named capture groups in the regex, so you could reference
or
as associative rather than enumerated, which adds to the readability of the code.
I've only recently started using named capture groups myself. It gives the benefit of improved readability of purpose, but It does add to the complexity of the expression. I can understand if you wouldn't want to use them though.
One last change I'd suggest would be to extract the regex to a class constant, which can then be made public, because potentially there's other places in the codebase that could use it (such as the
coordinateFromString()method inCell\Coordinate... it might be better located there as a public class constant anyway).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that named groups are much more readable, I just stuck with non-named to match the existing code style.
I've updated it to use named groups and also moved the regex into a constant and reused it in Cell\Coordinate. Which is outside of scope for this PR, but I think the regexes should be reused constants which will minimize future bugs. Happy to undo this change if you want, but the tests still pass so it should be fine?