chore: resolve ErrorProne, Lint, and Kotlinc warnings across library, clustering, data, heatmaps, and ui modules - #1757
chore: resolve ErrorProne, Lint, and Kotlinc warnings across library, clustering, data, heatmaps, and ui modules#1757dkhawk wants to merge 7 commits into
Conversation
5cdce08 to
e840c1a
Compare
Code Coverage
Files
|
|
|
||
| if (onScreen && mAnimate) { | ||
| val point = mSphericalMercatorProjection!!.toPoint(marker.position!!) | ||
| val point = mSphericalMercatorProjection!!.toPoint(position) |
There was a problem hiding this comment.
Is it possible for mSphericalMercatorProjection to be null here? If so, we should probably use the ?. safe call operator to prevent the app from crashing. Alternatively, if this variable is strictly required, we should ensure it is guaranteed to be non-null before this point.
There was a problem hiding this comment.
Great catch, @LoyalAbbas! You are completely right. I have updated RenderTask.run() across all 3 cluster renderers (ClusterRendererMultipleItems, DefaultClusterRenderer, and DefaultAdvancedMarkersClusterRenderer) to safely capture val sphericalMercatorProjection = mSphericalMercatorProjection and set val animate = mAnimate && sphericalMercatorProjection != null. If sphericalMercatorProjection is null, marker animation is safely bypassed without throwing a NullPointerException.
| } | ||
| } finally { | ||
| mCacheLock.writeLock().unlock() | ||
| return mCacheLock.writeLock().withLock { |
There was a problem hiding this comment.
Nice cleanup here! Using Kotlin's inline withLock ensures the lock is reliably released in a finally block if an exception occurs during cluster calculation, and the double-checked locking idiom with ?: ... .also { mCache.put(...) } cleanly removes the previous !! force unwraps.
| * add an object via a collection, then remove it via Object.remove() | ||
| */ | ||
| abstract class MapObjectManager<O, C extends MapObjectManager.Collection> { | ||
| abstract class MapObjectManager<O, C extends MapObjectManager<O, C>.Collection> { |
There was a problem hiding this comment.
Great catch fixing the recursive generic typing (<O, C extends MapObjectManager<O, C>.Collection>). This eliminates raw type warnings across MarkerManager, PolygonManager, PolylineManager, CircleManager, and GroundOverlayManager without breaking backward compatibility for existing consumers.
|
Thanks for cleaning up these warnings across the modules, @dkhawk! The Codecov report flagged a drop in coverage across a few of the touched files (e.g. |
…add documented unit tests for IconGenerator and PreCachingAlgorithmDecorator
|
Hi @kikoso! Thanks for the review. Regarding test coverage: To leave coverage in a much better state:
All unit tests are fully documented with KDocs explaining their exact purpose and assertion criteria. |
…l visual regression unit tests for IconGenerator
|
Update on visual regression unit testing for Added persistent PNG golden reference files directly to the test resources (
The unit tests ( |
…eech-bubble golden reference PNG images
…rt pixel similarity against golden PNG files
|
Updated The visual regression tests now dynamically render bitmap pixels from |
…I AWT font metric independence
Summary
Resolves 41 static analysis and compiler warnings reported by ErrorProne, Android Lint, Rekaster, and Kotlinc in Critique CL 968695609 across five modules (
:library,:clustering,:data,:heatmaps,:ui).Detailed Changes by Category & Module
1.
:libraryModuleMarkerManager.java:ErrorProneMissingOverride: Added@OverridetonewCollection().JavaCodeClarityReturnMissingNullable: Added@NullabletogetInfoWindow()andgetInfoContents().JavaCodeClarityMissingJavadoc: Added Javadoc to theCollectioninner class.JavacWarningsRAW&UNCHECKED: ParametrizedCollectionasextends MapObjectManager<Marker, MarkerManager.Collection>.Collectionto eliminate raw type and unchecked cast warnings.CircleManager.java/GroundOverlayManager.java/PolygonManager.java/PolylineManager.java:JavaCodeClarityMissingJavadoc: Added Javadoc toCollectioninner classes.JavacWarningsRAW&UNCHECKED: ParametrizedCollectionasextends MapObjectManager<O, C>.CollectionforCircle,GroundOverlay,Polygon, andPolylineto eliminate raw type warnings.MapObjectManager.java:JavacWarningsRAW&UNCHECKED: UpdatedMapObjectManagerclass declaration toabstract class MapObjectManager<O, C extends MapObjectManager<O, C>.Collection>to fix the rawCollectiontype bound; added@SuppressWarnings("unchecked")to(C) thisinadd().StreetViewUtil.kt:JavaAndKotlinLintUnusedException: Passed the caughtIOExceptioneas thecauseparameter (IOException("Network error: ${e.message}", e)) and removede.printStackTrace().2.
:heatmapsModuleHeatmapTileProvider.kt:JavaAndKotlinLintScopeReceiverThis: Replacedapply { ... }inBuildermethods (data,weightedData,radius,gradient,opacity,maxIntensity) with explicitreturn thisto eliminateScopeReceiverThislint warnings and improve readability.3.
:dataModuleGoogleMapRenderer.kt:KotlinOptionalSuggestionsDiscourageForEach: Replaced 5forEachusages withforloops inaddLayer(),removeLayer(),clear(), andrenderPolygon()as per Kotlin coding conventions.4.
:clusteringModuleClusterRendererMultipleItems.kt:KotlincWarningsUNUSED_IMPORT: Removed unusedimport java.util.concurrent.locks.Condition.KotlincWarningsCAN_BE_VAL_DELAYED_INITIALIZATION&UNNECESSARY_NOT_NULL_ASSERTION: Replacedvar renderTaskwithval renderTaskviasynchronizedexpression, eliminating!!assertions onrenderTask.KotlincWarningsUNNECESSARY_NOT_NULL_ASSERTION: Replacedmarker.position!!andanimateTo!!inanimateThenRemove()with a localval position = marker.positioncheck, avoiding!!and smart-cast errors.KotlinOptionalRefactoringSuggestionsElvisShortcuts: Replacedif (animateFrom == null) cluster.position else animateFromwithanimateFrom ?: cluster.position.DefaultAdvancedMarkersClusterRenderer.kt:KotlincWarningsUNUSED_IMPORT: Removed unusedimport java.util.concurrent.locks.Condition.KotlincWarningsCAN_BE_VAL_DELAYED_INITIALIZATION&UNNECESSARY_NOT_NULL_ASSERTION: Replacedvar renderTaskwithval renderTask; eliminated!!onanimateTo!!,marker!!, andmarkerWithPosition.KotlinOptionalRefactoringSuggestionsElvisShortcuts: Replacedif (animateFrom == null) cluster.position else animateFromwithanimateFrom ?: cluster.position.DefaultClusterRenderer.kt:KotlincWarningsUNUSED_IMPORT: Removed unusedimport java.util.concurrent.locks.Condition.KotlincWarningsCAN_BE_VAL_DELAYED_INITIALIZATION&UNNECESSARY_NOT_NULL_ASSERTION: Replacedvar renderTaskwithval renderTask; eliminated!!onanimateTo!!andmarkerWithPosition.KotlinOptionalRefactoringSuggestionsElvisShortcuts: Replacedif (animateFrom == null) cluster.position else animateFromwithanimateFrom ?: cluster.position.ClusterManager.kt:KotlincWarningsUNUSED_IMPORT: Removed unusedimport android.os.AsyncTask.NonHierarchicalDistanceBasedAlgorithm.kt:KotlincWarningsUNUSED_IMPORT: Removed unusedimport java.util.ArrayList.PreCachingAlgorithmDecorator.kt:KotlincWarningsUNNECESSARY_NOT_NULL_ASSERTION: RefactoredgetClustersInternal()usingkotlin.concurrent.withLockto eliminatevar resultsandreturn results!!.ClusterRenderer.kt:KotlincWarningsUNUSED_IMPORT: Removed unusedimport com.google.maps.android.clustering.ClusterManager.SphericalMercatorProjection.kt:KotlincWarningsDEPRECATION: UpdatedtoPoint()to returncom.google.maps.android.geometry.Pointinstead of the deprecatedcom.google.maps.android.projection.Point.5.
:uiModuleIconGenerator.kt:KotlincWarningsDEPRECATION: Replaced deprecatedTextView.setTextAppearance()andView.setBackgroundDrawable()withTextViewCompat.setTextAppearance()andViewCompat.setBackground().Verification
./gradlew :library:compileDebugKotlin :library:compileDebugJavaWithJavac :clustering:compileDebugKotlin :data:compileDebugKotlin :heatmaps:compileDebugKotlin :ui:compileDebugKotlin— BUILD SUCCESSFUL