Skip to content

Commit 27e5fc7

Browse files
abdulraqeeb33AR Abdul Azeez
andauthored
chore: adding detekt (#2376)
* detekt * excluding tests * add git add build.gradle detekt null check * updating detekt --------- Co-authored-by: AR Abdul Azeez <abdul@onesignal.com>
1 parent 1b17943 commit 27e5fc7

File tree

12 files changed

+1185
-1
lines changed

12 files changed

+1185
-1
lines changed

OneSignalSDK/build.gradle

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ buildscript {
99
minSdkVersion: 21
1010
]
1111
androidGradlePluginVersion = '8.8.2'
12+
detektVersion = '1.21.0'
1213
googleServicesGradlePluginVersion = '4.3.10'
1314
huaweiAgconnectVersion = '1.9.1.304'
1415
huaweiHMSPushVersion = '6.3.0.304'
1516
huaweiHMSLocationVersion = '4.0.0.300'
1617
kotlinVersion = '1.7.10'
1718
coroutinesVersion = '1.7.3'
1819
kotestVersion = '5.8.0'
20+
ioMockVersion = '1.13.2'
1921
// AndroidX Lifecycle and Activity versions
2022
lifecycleVersion = '2.6.2'
2123
activityVersion = '1.7.2'
@@ -35,6 +37,7 @@ buildscript {
3537
"com.google.gms:google-services:$googleServicesGradlePluginVersion",
3638
"com.huawei.agconnect:agcp:$huaweiAgconnectVersion",
3739
"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion",
40+
"io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detektVersion",
3841
"com.diffplug.spotless:spotless-plugin-gradle:$spotlessVersion",
3942
"com.vanniktech.maven.publish:com.vanniktech.maven.publish.gradle.plugin:0.32.0"
4043
]
@@ -77,3 +80,27 @@ allprojects {
7780
}
7881
}
7982
}
83+
84+
subprojects {
85+
plugins.withId("io.gitlab.arturbosch.detekt") {
86+
afterEvaluate {
87+
def configureDetektTask = { task ->
88+
// Only analyze main source sets
89+
task.source = files(
90+
"$projectDir/src/main/java",
91+
"$projectDir/src/main/kotlin"
92+
)
93+
// Exclude all test-related files and directories
94+
task.exclude "**/test/**", "**/androidTest/**", "**/src/test/**", "**/src/androidTest/**",
95+
"**/*Test.kt", "**/*Tests.kt", "**/*Spec.kt",
96+
"**/*Test.java", "**/*Tests.java", "**/*Spec.java"
97+
98+
// Enable type resolution to catch !! operator
99+
task.jvmTarget = "1.8"
100+
}
101+
102+
tasks.withType(io.gitlab.arturbosch.detekt.Detekt).configureEach(configureDetektTask)
103+
tasks.withType(io.gitlab.arturbosch.detekt.DetektCreateBaselineTask).configureEach(configureDetektTask)
104+
}
105+
}
106+
}

OneSignalSDK/detekt/detekt-baseline-core.xml

Lines changed: 487 additions & 0 deletions
Large diffs are not rendered by default.

OneSignalSDK/detekt/detekt-baseline-in-app-messages.xml

Lines changed: 133 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" ?>
2+
<SmellBaseline>
3+
<ManuallySuppressedIssues></ManuallySuppressedIssues>
4+
<CurrentIssues>
5+
<ID>ComplexMethod:LocationManager.kt$LocationManager$override suspend fun requestPermission(): Boolean</ID>
6+
<ID>ConstructorParameterNaming:GmsLocationController.kt$GmsLocationController$private val _applicationService: IApplicationService</ID>
7+
<ID>ConstructorParameterNaming:GmsLocationController.kt$GmsLocationController$private val _fusedLocationApiWrapper: IFusedLocationApiWrapper</ID>
8+
<ID>ConstructorParameterNaming:GmsLocationController.kt$GmsLocationController.GoogleApiClientListener$private val _parent: GmsLocationController</ID>
9+
<ID>ConstructorParameterNaming:GmsLocationController.kt$GmsLocationController.LocationUpdateListener$private val _applicationService: IApplicationService</ID>
10+
<ID>ConstructorParameterNaming:GmsLocationController.kt$GmsLocationController.LocationUpdateListener$private val _fusedLocationApiWrapper: IFusedLocationApiWrapper</ID>
11+
<ID>ConstructorParameterNaming:GmsLocationController.kt$GmsLocationController.LocationUpdateListener$private val _parent: GmsLocationController</ID>
12+
<ID>ConstructorParameterNaming:HmsLocationController.kt$HmsLocationController$private val _applicationService: IApplicationService</ID>
13+
<ID>ConstructorParameterNaming:HmsLocationController.kt$HmsLocationController.LocationUpdateListener$private val _applicationService: IApplicationService</ID>
14+
<ID>ConstructorParameterNaming:HmsLocationController.kt$HmsLocationController.LocationUpdateListener$private val _parent: HmsLocationController</ID>
15+
<ID>ConstructorParameterNaming:LocationBackgroundService.kt$LocationBackgroundService$private val _applicationService: IApplicationService</ID>
16+
<ID>ConstructorParameterNaming:LocationBackgroundService.kt$LocationBackgroundService$private val _capturer: ILocationCapturer</ID>
17+
<ID>ConstructorParameterNaming:LocationBackgroundService.kt$LocationBackgroundService$private val _locationManager: ILocationManager</ID>
18+
<ID>ConstructorParameterNaming:LocationBackgroundService.kt$LocationBackgroundService$private val _prefs: ILocationPreferencesService</ID>
19+
<ID>ConstructorParameterNaming:LocationBackgroundService.kt$LocationBackgroundService$private val _time: ITime</ID>
20+
<ID>ConstructorParameterNaming:LocationCapturer.kt$LocationCapturer$private val _applicationService: IApplicationService</ID>
21+
<ID>ConstructorParameterNaming:LocationCapturer.kt$LocationCapturer$private val _controller: ILocationController</ID>
22+
<ID>ConstructorParameterNaming:LocationCapturer.kt$LocationCapturer$private val _prefs: ILocationPreferencesService</ID>
23+
<ID>ConstructorParameterNaming:LocationCapturer.kt$LocationCapturer$private val _propertiesModelStore: PropertiesModelStore</ID>
24+
<ID>ConstructorParameterNaming:LocationCapturer.kt$LocationCapturer$private val _time: ITime</ID>
25+
<ID>ConstructorParameterNaming:LocationManager.kt$LocationManager$private val _applicationService: IApplicationService</ID>
26+
<ID>ConstructorParameterNaming:LocationManager.kt$LocationManager$private val _capturer: ILocationCapturer</ID>
27+
<ID>ConstructorParameterNaming:LocationManager.kt$LocationManager$private val _locationController: ILocationController</ID>
28+
<ID>ConstructorParameterNaming:LocationManager.kt$LocationManager$private val _locationPermissionController: LocationPermissionController</ID>
29+
<ID>ConstructorParameterNaming:LocationManager.kt$LocationManager$private val _prefs: IPreferencesService</ID>
30+
<ID>ConstructorParameterNaming:LocationPermissionController.kt$LocationPermissionController$private val _applicationService: IApplicationService</ID>
31+
<ID>ConstructorParameterNaming:LocationPermissionController.kt$LocationPermissionController$private val _requestPermission: IRequestPermissionService</ID>
32+
<ID>ConstructorParameterNaming:LocationPreferencesService.kt$LocationPreferencesService$private val _prefs: IPreferencesService</ID>
33+
<ID>ForbiddenComment:GmsLocationController.kt$GmsLocationController$// TODO: google api client has a blocking connect with timeout, use that instead of our withTimeout?</ID>
34+
<ID>LongMethod:GmsLocationController.kt$GmsLocationController$override suspend fun start(): Boolean</ID>
35+
<ID>LongMethod:HmsLocationController.kt$HmsLocationController$override suspend fun start(): Boolean</ID>
36+
<ID>LongMethod:LocationManager.kt$LocationManager$override suspend fun requestPermission(): Boolean</ID>
37+
<ID>MagicNumber:GmsLocationController.kt$GmsLocationController.LocationUpdateListener$1.5</ID>
38+
<ID>MagicNumber:HmsLocationController.kt$HmsLocationController.LocationUpdateListener$1.5</ID>
39+
<ID>MagicNumber:LocationBackgroundService.kt$LocationBackgroundService$1000</ID>
40+
<ID>MagicNumber:LocationCapturer.kt$LocationCapturer$7</ID>
41+
<ID>MagicNumber:LocationManager.kt$LocationManager$29</ID>
42+
<ID>MayBeConst:GmsLocationController.kt$GmsLocationController.Companion$val API_FALLBACK_TIME = 30000</ID>
43+
<ID>PrintStackTrace:GoogleApiClientCompatProxy.kt$GoogleApiClientCompatProxy$t</ID>
44+
<ID>ProtectedMemberInFinalClass:GmsLocationController.kt$GmsLocationController$LocationHandlerThread : HandlerThread</ID>
45+
<ID>SwallowedException:GmsLocationController.kt$GmsLocationController$e: TimeoutCancellationException</ID>
46+
<ID>SwallowedException:LocationUtils.kt$LocationUtils$e: NoClassDefFoundError</ID>
47+
<ID>TooGenericExceptionCaught:FusedLocationApiWrapperImpl.kt$FusedLocationApiWrapperImpl$t: Throwable</ID>
48+
<ID>TooGenericExceptionCaught:GoogleApiClientCompatProxy.kt$GoogleApiClientCompatProxy$t: Throwable</ID>
49+
<ID>TooGenericExceptionCaught:HmsLocationController.kt$HmsLocationController$e: Exception</ID>
50+
<ID>TooGenericExceptionCaught:LocationManager.kt$LocationManager$t: Throwable</ID>
51+
<ID>TooGenericExceptionThrown:GmsLocationController.kt$GmsLocationController.LocationUpdateListener$throw Exception("googleApiClient not connected, cannot listen!")</ID>
52+
</CurrentIssues>
53+
</SmellBaseline>

0 commit comments

Comments
 (0)