Skip to content

Commit c80aae3

Browse files
bmanderclaude
andauthored
Restore private on #1875's widened members; disable SyntheticAccessor (#1912) (#1926)
#1875 widened 34 declarations to clear lint's SyntheticAccessor findings: file-`private` Kotlin helpers → `internal` (app-global in this single-module app) and Java `private` → package-private. That traded real encapsulation for a micro-optimization the toolchain already erases — release builds enable R8 with `-allowaccessmodification` (#1868), which inlines/strips the synthetic accessors, and in debug the cost is a handful of trivial methods. Leaving the check enabled also taxed every future file-private helper called from a sibling class. - Opt SyntheticAccessor out in the lint `disable` block with a rationale. - Revert all 34 declarations to `private` (23 Kotlin `internal`→`private`, 11 Java package-private→`private`). Verified each is accessed only within its own file (Kotlin) or only inner↔outer within its own class (Java), so narrowing does not break any caller. No behavior change — visibility only. Compile (`-PwarningsAsErrors=true`, obaGoogle Kotlin + Java) passes clean. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 00cdfd1 commit c80aae3

14 files changed

Lines changed: 44 additions & 35 deletions

File tree

onebusaway-android/build.gradle.kts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,20 @@ android {
190190
// (RouteMapController's `vehicleJob?.isActive`). The one hit is benign and has no cleaner call.
191191
// - ConvertToWebp: an advisory "this image could be smaller as WebP" nudge (wmata.jpg), not a
192192
// correctness signal. Declined.
193+
// - SyntheticAccessor: flags a `private` member accessed across the class/file boundary, whose
194+
// only cost is a compiler-generated accessor method. Satisfying it forces widening real
195+
// encapsulation — file-`private` Kotlin helpers → `internal` (app-global in this single-module
196+
// app) and Java `private` → package-private — for a micro-optimization the toolchain already
197+
// erases: release enables R8 with `-allowaccessmodification` (#1868), which inlines/strips the
198+
// accessors, and in debug the cost is a handful of trivial methods. Leaving it enabled taxes
199+
// every future file-private helper called from a sibling class. #1875 widened 34 declarations
200+
// to clear it; #1912 restored their `private` and opts the check out here.
193201
disable += setOf(
194202
"MissingTranslation", "ExtraTranslation", "LogNotTimber",
195203
"GradleDependency", "NewerVersionAvailable", "AndroidGradlePluginVersion",
196204
"OldTargetApi", "DuplicateStrings",
197-
"InvalidPackage", "PermissionNamingConvention", "MemberExtensionConflict", "ConvertToWebp"
205+
"InvalidPackage", "PermissionNamingConvention", "MemberExtensionConflict", "ConvertToWebp",
206+
"SyntheticAccessor"
198207
)
199208
// Run the FULL lint catalog — including checks that are off by default and library-provided
200209
// ones (Compose, UseKtx, …) — so the checked set is comprehensive and current for the installed

onebusaway-android/src/google/java/org/onebusaway/android/map/googlemapsv2/compose/GoogleComposeAdapter.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ class GoogleComposeAdapter : ObaComposeMapAdapter {
313313
* routes through [routeMarkerTap] (reliable for every marker, static and dynamic, because the dynamic
314314
* markers move at only ~20Hz — see [FRAME_INTERVAL_NANOS]); an info-window tap deep links.
315315
*/
316-
internal fun wireClicks(
316+
private fun wireClicks(
317317
map: GoogleMap,
318318
renderer: GoogleMapRenderer,
319319
infoWindows: GoogleInfoWindows,
@@ -395,7 +395,7 @@ private fun routeMarkerTap(
395395
* render, so the bubble reflects the latest poll (re-rendered via [GoogleInfoWindows.refresh]), not a
396396
* tap-time snapshot.
397397
*/
398-
internal fun GoogleInfoWindows.openVehicleWindow(renderer: GoogleMapRenderer, marker: Marker) {
398+
private fun GoogleInfoWindows.openVehicleWindow(renderer: GoogleMapRenderer, marker: Marker) {
399399
open(marker) {
400400
val live = renderer.vehicleForMarker(marker)
401401
// Deliberate snapshot read, not a reactive subscription: this content is rendered to a bitmap on
@@ -408,7 +408,7 @@ internal fun GoogleInfoWindows.openVehicleWindow(renderer: GoogleMapRenderer, ma
408408
}
409409

410410
/** Builds a [CameraSnapshot] from the Google map's current camera + visible region. */
411-
internal fun snapshot(map: GoogleMap): CameraSnapshot {
411+
private fun snapshot(map: GoogleMap): CameraSnapshot {
412412
val pos = map.cameraPosition
413413
val bounds = map.projection.visibleRegion.latLngBounds
414414
val sw = bounds.southwest
@@ -424,13 +424,13 @@ internal fun snapshot(map: GoogleMap): CameraSnapshot {
424424
}
425425

426426
@SuppressLint("MissingPermission")
427-
internal fun applyMyLocation(map: GoogleMap, context: Context, enabled: Boolean) {
427+
private fun applyMyLocation(map: GoogleMap, context: Context, enabled: Boolean) {
428428
val granted = PermissionUtils.hasGrantedAtLeastOnePermission(context, PermissionUtils.LOCATION_PERMISSIONS)
429429
map.isMyLocationEnabled = enabled && granted
430430
}
431431

432432
/** The map style for the current night-mode state: the dark theme, or POI removal in light mode. */
433-
internal fun resolveMapStyle(context: Context): MapStyleOptions =
433+
private fun resolveMapStyle(context: Context): MapStyleOptions =
434434
if (ThemeUtils.isInDarkMode(context)) {
435435
MapStyleOptions.loadRawResourceStyle(context, R.raw.dark_map)
436436
} else {

onebusaway-android/src/main/java/org/onebusaway/android/analytics/UmamiAnalytics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public void run() {
8282
});
8383
}
8484

85-
void post(String payload) {
85+
private void post(String payload) {
8686
HttpURLConnection conn = null;
8787
try {
8888
conn = (HttpURLConnection) new URL(mSendUrl).openConnection();

onebusaway-android/src/main/java/org/onebusaway/android/api/adapters/TripAdapters.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import kotlin.time.Duration.Companion.seconds
3939
* one-DTO-implements-the-interface pattern the map boundary uses for stops/routes.
4040
*/
4141

42-
internal fun Position.toLocation(): Location = locationOf(lat, lon)
42+
private fun Position.toLocation(): Location = locationOf(lat, lon)
4343

4444
/** Presents a [TripStatus] DTO as an [ObaTripStatus]. */
4545
internal class DtoTripStatus(private val dto: TripStatus) : ObaTripStatus {

onebusaway-android/src/main/java/org/onebusaway/android/api/data/TripVehiclesDataSource.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private fun routeTripsOf(
6666
* double-record). Keying the dedup on `activeTripId` at this one wire→model seam fixes every consumer
6767
* at once; fall back to `tripId` when a status is absent, and preserve first-seen order.
6868
*/
69-
internal fun List<TripDetailsEntry>.dedupeByActiveTripKeepingBestFix(): List<TripDetailsEntry> {
69+
private fun List<TripDetailsEntry>.dedupeByActiveTripKeepingBestFix(): List<TripDetailsEntry> {
7070
if (size < 2) return this
7171
val byKey = LinkedHashMap<String, TripDetailsEntry>(size)
7272
for (entry in this) {

onebusaway-android/src/main/java/org/onebusaway/android/app/di/LocationEntryPoint.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ interface LocationEntryPoint {
5252
fun getSink(context: Context): LocationSink =
5353
accessor(context).locationSink()
5454

55-
internal fun accessor(context: Context): LocationEntryPoint =
55+
private fun accessor(context: Context): LocationEntryPoint =
5656
EntryPointAccessors.fromApplication(context, LocationEntryPoint::class.java)
5757
}
5858
}

onebusaway-android/src/main/java/org/onebusaway/android/database/oba/LegacyDataImporter.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ class LegacyDataImporter(
289289
* [map]; a null return from [map] drops that row. Returns an empty list for a missing table so a
290290
* legacy file at any historical schema version imports cleanly.
291291
*/
292-
internal inline fun <T> SQLiteDatabase.read(table: String, map: Cursor.() -> T?): List<T> {
292+
private inline fun <T> SQLiteDatabase.read(table: String, map: Cursor.() -> T?): List<T> {
293293
if (!tableExists(table)) return emptyList()
294294
return query(table, null, null, null, null, null, null).use { c ->
295295
buildList { while (c.moveToNext()) c.map()?.let { add(it) } }
@@ -300,16 +300,16 @@ private fun SQLiteDatabase.tableExists(table: String): Boolean =
300300
rawQuery("SELECT name FROM sqlite_master WHERE type='table' AND name=?", arrayOf(table))
301301
.use { it.moveToFirst() }
302302

303-
internal fun Cursor.str(name: String): String? =
303+
private fun Cursor.str(name: String): String? =
304304
columnIndex(name)?.takeIf { !isNull(it) }?.let { getString(it) }
305305

306-
internal fun Cursor.int(name: String): Int? =
306+
private fun Cursor.int(name: String): Int? =
307307
columnIndex(name)?.takeIf { !isNull(it) }?.let { getInt(it) }
308308

309-
internal fun Cursor.long(name: String): Long? =
309+
private fun Cursor.long(name: String): Long? =
310310
columnIndex(name)?.takeIf { !isNull(it) }?.let { getLong(it) }
311311

312-
internal fun Cursor.dbl(name: String): Double? =
312+
private fun Cursor.dbl(name: String): Double? =
313313
columnIndex(name)?.takeIf { !isNull(it) }?.let { getDouble(it) }
314314

315315
/** The column's index, or null when the legacy file's schema version predates that column. */

onebusaway-android/src/main/java/org/onebusaway/android/directions/util/DirectionsGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ class DirectionsGenerator(
357357

358358
private const val TAG = "DirectionsGenerator"
359359

360-
internal fun getOrdinal(number: Int, resources: Resources): String? {
360+
private fun getOrdinal(number: Int, resources: Resources): String? {
361361
return when (number) {
362362
1 -> resources.getString(R.string.step_by_step_non_transit_roundabout_ordinal_first)
363363
2 -> resources.getString(R.string.step_by_step_non_transit_roundabout_ordinal_second)

onebusaway-android/src/main/java/org/onebusaway/android/extrapolation/GammaExtrapolator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ internal fun buildH34SpeedDistribution(schedSpeedMps: Double): ProbDistribution
125125
* The scheduled segment speed (m/s) at a given distance along the trip, or null if the schedule has
126126
* too few stops or the distance is out of bounds. Only the gamma model conditions on schedule speed.
127127
*/
128-
internal fun ObaTripSchedule.speedAtDistance(distanceAlongTrip: Double): Double? {
128+
private fun ObaTripSchedule.speedAtDistance(distanceAlongTrip: Double): Double? {
129129
if (stopTimes.size < 2) return null
130130

131131
val segmentStart = try {

onebusaway-android/src/main/java/org/onebusaway/android/extrapolation/math/prob/GammaDistribution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class GammaDistribution(@JvmField val alpha: Double, @JvmField val scale: Double
5656
private const val MAX_ITERATIONS = 200
5757
private const val EPSILON = 1e-10
5858

59-
internal fun regularizedGammaP(a: Double, x: Double): Double {
59+
private fun regularizedGammaP(a: Double, x: Double): Double {
6060
if (x <= 0) return 0.0
6161

6262
return if (x < a + 1) {

0 commit comments

Comments
 (0)