Modify ↓

Opened 3 weeks ago

Closed 10 days ago

Last modified 10 days ago

#24951 closed task (fixed)

[PATCH] Fix Sonar issues in recent Grid Layer and OAuth

Reported by: DanProgs <Abenteurer.2901@…> Owned by: team
Priority: normal Milestone: 26.09
Component: Core Version:
Keywords: Cc:

Description

Attachments (2)

24951.patch​ (3.7 KB ) - added by DanProgs <Abenteurer.2901@…> 3 weeks ago.
sonar-grid-oauth.patch​ (15.6 KB ) - added by wangi 3 weeks ago.

Download all attachments as: .zip

Change History (11)

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

Attachment: 24951.patch​ added

comment:1 by wangi, 3 weeks ago

Attached is a patch against r19646.

The deprecated URL constructor in OsmConnectionTest came from my patch for #24925. While I was looking at it I noticed that the other Sonar issues in the new code period also come from my grid patch (#8464, r19640), so this patch fixes those as well. It clears every issue in that list except the four S1309 ones about the existing PMD suppressions.

#24925 (this ticket)

  • OsmConnectionTest: new URL(…) → URI.create(…).toURL() (S1874)

#8464 grid

  • MapFrame.gridOverlay, ShowTileBordersAction.layer and GridPreference.TranslatedRenderer.name are now transient (S1948).
  • AlignGridRotationAction.getSelectedDirection() returns a shared EMPTY_DIRECTION constant instead of null (S1168). The callers and GridActionsTest now check the length. This is the same change as #24949, and the constant is taken from that patch, thanks DanProgs. This patch also updates the other two assertNull checks on getSelectedDirection() in GridActionsTest. The #24949 patch only changes the first, so the test would fail with it.
  • GridPreference: GBC.HORIZONTAL/GBC.BOTH → GridBagConstraints.HORIZONTAL/BOTH (S3252)
  • MapGridPaintable.getLatLonGridLines(): the meridian loop is moved out into addMeridian(), to go with the existing addParallel(). This brings the cognitive complexity down from 19 to under 15 (S3776).
  • MapGridPaintable.mapView: volatile → AtomicReference (S3077)
  • MapGridPaintable.projectionUnitsPerMetre(): removed the unnecessary (ILatLon) cast (S1905)
  • S1940 "use <=": the !(x > 0) checks were written that way on purpose so that NaN gets rejected too, and a plain x <= 0 would let NaN through. They now call a small isPositive() helper in MapGridPaintable. In GridPreference, where the value is parsed from user input, the check is Double.isNaN(value) || value <= 0. The one in addParallel() never sees NaN, so it is simply maxLon <= minLon.

There is no change in behaviour. GridActionsTest, MapGridPaintableTest, ShowTileBordersActionTest, TileSourceDisplaySettingsTest, GridPreferenceTest and OsmConnectionTest all pass, and checkstyle and ant pmd report nothing in the changed files.

Last edited 3 weeks ago by wangi (previous) (diff)

comment:2 by wangi, 3 weeks ago

Summary: refactor: replaces deprecated "URL" → refactor: Fix Sonar issues in recent Grid Layer and OAuth

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

Please also take ticket #24949 into account in this context. It includes the change to new EastNorth[0] adapted by 'wangi', but implemented as a static constant named EMPTY_DIRECTION. Perhaps you could adjust this as well?

comment:4 by wangi, 3 weeks ago

Ticket #24949 has been marked as a duplicate of this ticket.

by wangi, 3 weeks ago

Attachment: sonar-grid-oauth.patch​ added

in reply to:  3 comment:5 by wangi, 3 weeks ago

Replying to DanProgs <Abenteurer.2901@…>:

Please also take ticket #24949 into account in this context. It includes the change to new EastNorth[0] adapted by 'wangi', but implemented as a static constant named EMPTY_DIRECTION. Perhaps you could adjust this as well?

Patch and comment above updated. I've also closed off 24949 as duplicate now.

comment:6 by wangi, 3 weeks ago

Summary: refactor: Fix Sonar issues in recent Grid Layer and OAuth → [PATCH] Fix Sonar issues in recent Grid Layer and OAuth

comment:7 by stoecker, 2 weeks ago

Milestone: → 26.09

comment:8 by stoecker, 10 days ago

Resolution: → fixed
Status: new → closed

In 19654/josm:

fix #24951 - Fix Sonar issues in recent Grid Layer and OAuth - patches by DanProgs & wangi

comment:9 by stoecker, 10 days ago

In 19655/josm:

fix #24951 - Fix Sonar issues in recent Grid Layer and OAuth - patches by DanProgs & wangi

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.