Repository navigation
Fix SonarCloud issues: simplify complex methods and clean up - #229
Merged
Merged
Conversation
Critical: split the 7 methods that were too complex (PNG mask import and export, COCO import, the RLE decoder, the mask view's and the image pane's handlers) into smaller ones. Major: MutableMask returns Optional<PixelRegion> instead of int[] or null, loops no longer change their counters, CSV rows are read and imported in separate methods, the load exceptions are no longer nested in an interface, the number input's regex can't backtrack, inner-class fields no longer hide outer ones, and main passes its arguments on. Minor: unnamed catch variables, assertThrows instead of try/fail, method references, an unused import and an unnecessary throws clause. No behavior changes.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #229 +/- ##
============================================
+ Coverage 90.05% 90.25% +0.20%
- Complexity 2374 2389 +15
============================================
Files 135 140 +5
Lines 8901 8963 +62
Branches 865 860 -5
============================================
+ Hits 8016 8090 +74
+ Misses 462 455 -7
+ Partials 423 418 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
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.



Fixes about 40 of the 61 open SonarCloud issues on master. No behavior changes.
Critical: all 7 methods that were too complex
PNGMaskLoadStrategy: reading a single mask file moved into a per-importLoadContext(strategies keep per-call state in a context object). A smallObjectRegionclass collects each object's bounds and category counts.PNGMaskSaveStrategy: converting a shape to a mask (toMask) and painting a mask (paint) are separate methods, which also removes thecontinues.COCOLoadStrategy:readRootchecks the file and its arrays,readAnnotationreads one annotation, and the results moved into the existingLoadContextrecord.COCORunLengthEncoding.decode: reading a single count moved into aCountReader.BoundingMaskViewandEditorImagePaneView: the event-handler bodies became named methods.Major
MutableMask:fillCircle,fillPolygonandstrokeLinereturnOptional<PixelRegion>(a new record) instead of anint[]ornull. Two loops that changed their counter in the body are nowwhileloops.CSVLoadStrategy: the nestedtryblocks becamereadRowandimportRow.ImageAnnotationLoadStrategy; each has its own file.ResizeHandle.handleDragAnchor,VertexHandle.vertexEditing).mainpasses its arguments tolaunch.truncated/occluded/difficult) are handled in their own method.Minor: unnamed
catchvariables (11), a loop withoutcontinueinImageAnnotationSaver,assertThrowsinstead oftry/fail(4 tests), method references, an unused import, an unnecessarythrows, and!=instead of!(==).Left out on purpose
Controller: Move the autosave logic from Controller into AutosaveController #228 changes it heavily, so they follow after it's merged.MainView"monster class": too big a change for a cleanup.transientinBoundingMaskData: it deliberately keeps Gson from serializing masks by reflection.The full suite (291 tests) passes locally.