#25017 closed task (wontfix)
[patch] Fix Sonar issues in TagChecker
| Reported by: | Owned by: | team | |
|---|---|---|---|
| Priority: | normal | Milestone: | 26.12 |
| Component: | Core | Version: | |
| Keywords: | Cc: |
Description
The NullPointerException has been fixed. Furthermore, guard clauses have been implemented, curly braces have been added back to control structures, and fields and variables have been declared as "final".
See: https://josm.openstreetmap.de/sonar/project/issues?issueStatuses=CONFIRMED%2COPEN&types=BUG&open=AXvWAEXUyP4JTgY8QMT7&id=josm&s=TYPE_SEVERITY
Attachments (3)
Change History (12)
by , 3 weeks ago
| Attachment: | #25017.patch added |
|---|
by , 3 weeks ago
| Attachment: | #25017_2.patch added |
|---|
follow-up: 3 comment:1 by , 3 weeks ago
comment:2 by , 3 weeks ago
| Milestone: | → 26.12 |
|---|
comment:3 by , 3 weeks ago
Replying to DanProgs <Abenteurer.2901@…>:
Addendum: please also apply the second file to address the second NullPointerException.
See: https://josm.openstreetmap.de/sonar/project/issues?issueStatuses=CONFIRMED%2COPEN&types=BUG&id=josm&open=AXvX5n3hyP4JTgY8QiaT
Looks like a false positve to me. Method Utils.isEmpty() contains a null check.
However, #25017_2.patch changes something else.
comment:4 by , 3 weeks ago
Sorry, I likely pasted the link into the wrong line by mistake. The correct link for the second part regarding 'harmonizedValue.length()' is: https://josm.openstreetmap.de/sonar/project/issues?s=TYPE_SEVERITY&issueStatuses=CONFIRMED%2COPEN&types=BUG&id=josm&open=AXvWAEXUyP4JTgY8QMT8
comment:5 by , 3 weeks ago
In method tryGuess() the patch adds null checks for variable harmonizedValue which cannot be null as Utisl.isEmpty() already checked this:
final String harmonizedValue = harmonizeValue(value); if (Utils.isEmpty(harmonizedValue)) return;
I consider those null checks as confusing and besides that they cause a checkstyle LineLength problem in line 1191
comment:6 by , 3 weeks ago
OK, I’ve revised it once more. Perhaps this version is better overall?
TagChecker:
- Pre-filter candidates based on the length difference between the strings before calculating the Levenshtein distance.
- When iterating through
oftenUsedTags, skip values that have already been checked againstpresetValues. - Determine
maxPresetValueLenbased solely on the actualpresetValues; fall back to unfiltered candidates if all matches are considered deprecated. - Moved the Levenshtein comparison and the creation of
TestErrorobjects into separate helper methods.
TagCheckerTest:
- Added new test cases.
by , 3 weeks ago
| Attachment: | #25017new-Fix-Sonar-issues-in-TagChecker.patch added |
|---|
comment:7 by , 3 weeks ago
Please separate the funtional changes and create a ticket explaining why they are needed/useful. A sonar issue fix should not contain functional changes.
comment:8 by , 3 weeks ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
Closing this ticket as functional enhancements should be kept separate from sonar issue fix.



Addendum: please also apply the second file to address the second NullPointerException.
See: https://josm.openstreetmap.de/sonar/project/issues?issueStatuses=CONFIRMED%2COPEN&types=BUG&id=josm&open=AXvX5n3hyP4JTgY8QiaT