Opened 17 hours ago
Last modified 8 hours ago
#24951 new task
refactor: Fix Sonar issues in recent Grid Layer and OAuth
| Reported by: | Owned by: | team | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Core | Version: | |
| Keywords: | Cc: |
Attachments (2)
Change History (7)
by , 17 hours ago
| Attachment: | 24951.patch added |
|---|
comment:2 by , 8 hours ago
| Summary: | refactor: replaces deprecated "URL" → refactor: Fix Sonar issues in recent Grid Layer and OAuth |
|---|
follow-up: 5 comment:3 by , 8 hours 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?
by , 8 hours ago
| Attachment: | sonar-grid-oauth.patch added |
|---|
comment:5 by , 8 hours 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 namedEMPTY_DIRECTION. Perhaps you could adjust this as well?
Patch and comment above updated. I've also closed off 24949 as duplicate now.



Attached is a patch against r19646.
The deprecated
URLconstructor inOsmConnectionTestcame 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.layerandGridPreference.TranslatedRenderer.nameare nowtransient(S1948).AlignGridRotationAction.getSelectedDirection()returns a sharedEMPTY_DIRECTIONconstant instead ofnull(S1168). The callers andGridActionsTestnow 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 twoassertNullchecks ongetSelectedDirection()inGridActionsTest. 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 intoaddMeridian(), to go with the existingaddParallel(). 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)<=": the!(x > 0)checks were written that way on purpose so that NaN gets rejected too, and a plainx <= 0would let NaN through. They now call a smallisPositive()helper inMapGridPaintable. InGridPreference, where the value is parsed from user input, the check isDouble.isNaN(value) || value <= 0. The one inaddParallel()never sees NaN, so it is simplymaxLon <= minLon.There is no change in behaviour.
GridActionsTest,MapGridPaintableTest,ShowTileBordersActionTest,TileSourceDisplaySettingsTest,GridPreferenceTestandOsmConnectionTestall pass, and checkstyle andant pmdreport nothing in the changed files.