Modify ↓

Opened 3 weeks ago

Closed 3 weeks ago

Last modified 3 weeks ago

#25017 closed task (wontfix)

[patch] Fix Sonar issues in TagChecker

Reported by: DanProgs <Abenteurer.2901@…> 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)

#25017.patch​ (29.5 KB ) - added by DanProgs <Abenteurer.2901@…> 3 weeks ago.
#25017_2.patch​ (1.0 KB ) - added by DanProgs <Abenteurer.2901@…> 3 weeks ago.
#25017new-Fix-Sonar-issues-in-TagChecker.patch​ (43.3 KB ) - added by DanProgs <Abenteurer.2901@…> 3 weeks ago.

Download all attachments as: .zip

Change History (12)

by DanProgs <Abenteurer.2901@…>, 3 weeks ago

Attachment: #25017.patch​ added

by DanProgs <Abenteurer.2901@…>, 3 weeks ago

Attachment: #25017_2.patch​ added

comment:1 by DanProgs <Abenteurer.2901@…>, 3 weeks ago

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

comment:2 by stoecker, 3 weeks ago

Milestone: → 26.12

in reply to:  1 comment:3 by GerdP, 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 DanProgs <Abenteurer.2901@…>, 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 GerdP, 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 DanProgs <Abenteurer.2901@…>, 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 against presetValues.
  • Determine maxPresetValueLen based solely on the actual presetValues; fall back to unfiltered candidates if all matches are considered deprecated.
  • Moved the Levenshtein comparison and the creation of TestError objects into separate helper methods.

TagCheckerTest:

  • Added new test cases.

by DanProgs <Abenteurer.2901@…>, 3 weeks ago

comment:7 by GerdP, 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 DanProgs <Abenteurer.2901@…>, 3 weeks ago

Resolution: → wontfix
Status: new → closed

Closing this ticket as functional enhancements should be kept separate from sonar issue fix.

comment:9 by DanProgs <Abenteurer.2901@…>, 3 weeks ago

The test cases were moved to #25026.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.