Fix edge case in InconsistentCapitalization#4801
Closed
PBoddington wants to merge 1 commit intogoogle:masterfrom
Closed
Fix edge case in InconsistentCapitalization#4801PBoddington wants to merge 1 commit intogoogle:masterfrom
InconsistentCapitalization#4801PBoddington wants to merge 1 commit intogoogle:masterfrom
Conversation
…ent capitalization
PBoddington
commented
Feb 2, 2025
Comment on lines
+218
to
+221
| List<Symbol> matchedFields = fields.get(Ascii.toLowerCase(variableName)); | ||
| if (!matchedFields.isEmpty() | ||
| && matchedFields.stream().map(Symbol::toString).noneMatch(variableName::equals)) { | ||
| matchedParameters.put(getCurrentPath(), matchedFields.getFirst()); |
Author
There was a problem hiding this comment.
I chose to use a List because using matchedFields.getFirst() is the simplest way to choose a matching field in a manner that is obviously deterministic. It would have to be a very weird class for the performance of iterating over the list to be a concern. However, I'd happily change the ListMultimap to something like a Map<String, Map<String, Symbol>> if requested.
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.
Currently,
InconsistentCapitalizationdoes not handle well the case that the class has multiple fields with names that are equivalent except for capitalization.For example, the following code
results in an error
On the other hand, if the order of the fields is swapped, there is no match.
This proposed change improves the behaviour for this edge case, so that the order in which the fields are declared no longer matters. The new behaviour is that a parameter is a match if there is at least one field that is equivalent except for capitalization, but no field matches exactly.