diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 223607196f27acd112b57e95baa801c08c37a3f3..ee36959f9ccfc8b4543b45e959006f79241d4a20 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,6 +38,10 @@ lint: stage: build script: - ./gradlew lintRelease + - ./gradlew detekt + artifacts: + paths: + - build/reports/detekt/ build: diff --git a/app/detekt-baseline.xml b/app/detekt-baseline.xml new file mode 100644 index 0000000000000000000000000000000000000000..1475cca0df99984abe70fba8f31f1ea21e62b134 --- /dev/null +++ b/app/detekt-baseline.xml @@ -0,0 +1,54 @@ + + + + + EmptyDefaultConstructor:AccountAddedReceiver.kt$AccountAddedReceiver$() + EmptyElseBlock:SyncTask.kt$SyncTask$if (filePath.isEmpty()) return + MagicNumber:FileDiffUtils.kt$FileDiffUtils$1000 + MagicNumber:SyncProxy.kt$SyncProxy$1000 + MagicNumber:SyncProxy.kt$SyncProxy$18000 + MagicNumber:SyncProxy.kt$SyncProxy$3 + MagicNumber:SyncProxy.kt$SyncProxy$3600 + MagicNumber:SyncProxy.kt$SyncProxy$7200 + MagicNumber:SyncWorker.kt$SyncWorker$30 + MaxLineLength:FullScanWorker.kt$FullScanWorker$if (isFileSyncDisabled(account)) return false + MaxLineLength:FullScanWorker.kt$FullScanWorker$private + MaxLineLength:RootSyncedFolderProvider.kt$RootSyncedFolderProvider$private + MaxLineLength:RootSyncedFolderProvider.kt$RootSyncedFolderProvider$private val REMOTE_ROM_SETTINGS_PATH = PATH_SEPARATOR + "Devices" + PATH_SEPARATOR + BRAND + "_" + MODEL + "_" + Build.getSerial() + "/rom_settings/" + MaxLineLength:SyncProxy.kt$SyncProxy$private val syncRequestQueue: ConcurrentLinkedQueue<SyncRequest> = ConcurrentLinkedQueue() //could we use channel instead ? + MaxLineLength:SyncTask.kt$SyncTask$if + NewLineAtEndOfFile:AccountAddedReceiver.kt$foundation.e.drive.account.receivers.AccountAddedReceiver.kt + NewLineAtEndOfFile:AppConstants.kt$foundation.e.drive.utils.AppConstants.kt + NewLineAtEndOfFile:FileDiffUtils.kt$foundation.e.drive.periodicScan.contentScanner.FileDiffUtils.kt + NewLineAtEndOfFile:FileUtils.kt$foundation.e.drive.utils.FileUtils.kt + NewLineAtEndOfFile:FullScanWorker.kt$foundation.e.drive.periodicScan.FullScanWorker.kt + NewLineAtEndOfFile:RootSyncedFolderProvider.kt$foundation.e.drive.utils.RootSyncedFolderProvider.kt + NewLineAtEndOfFile:StateMachine.kt$foundation.e.drive.synchronization.StateMachine.kt + NewLineAtEndOfFile:SyncProxy.kt$foundation.e.drive.synchronization.SyncProxy.kt + NewLineAtEndOfFile:SyncTask.kt$foundation.e.drive.synchronization.SyncTask.kt + NewLineAtEndOfFile:SyncWorker.kt$foundation.e.drive.synchronization.SyncWorker.kt + NewLineAtEndOfFile:SyncedFileState.kt$foundation.e.drive.models.SyncedFileState.kt + ReturnCount:AccountAddedReceiver.kt$AccountAddedReceiver$private fun canStart( accountName: String, accountType: String, prefs: SharedPreferences, context: Context ): Boolean + ReturnCount:FileDiffUtils.kt$FileDiffUtils$@JvmStatic fun getActionForFileDiff(remoteFile: RemoteFile, fileState: SyncedFileState): Action + ReturnCount:FullScanWorker.kt$FullScanWorker$override fun doWork(): Result + ReturnCount:FullScanWorker.kt$FullScanWorker$private fun checkStartConditions(account: Account?, prefs : SharedPreferences, requestCollector: SyncRequestCollector): Boolean + ReturnCount:FullScanWorker.kt$FullScanWorker$private fun scanLocalFiles(syncedFolders: List<SyncedFolder>): HashMap<Int, SyncRequest> + ReturnCount:FullScanWorker.kt$FullScanWorker$private fun scanRemoteFiles(account: Account, syncedFolders: List<SyncedFolder>): HashMap<Int, SyncRequest> + ReturnCount:StateMachine.kt$StateMachine$private fun setPeriodicScanState(): Boolean + ReturnCount:SyncProxy.kt$SyncProxy$override fun onPeriodicScanStart(application: Application): Boolean + ReturnCount:SyncProxy.kt$SyncProxy$override fun queueSyncRequest(request: SyncRequest, context: Context): Boolean + ReturnCount:SyncProxy.kt$SyncProxy$override fun startSynchronization(context: Context) + ReturnCount:SyncProxy.kt$SyncProxy$private fun skipBecauseOfPreviousFail(request: SyncRequest, context: Context): Boolean + ReturnCount:SyncTask.kt$SyncTask$private fun canStart(): Boolean + ReturnCount:SyncTask.kt$SyncTask$private fun runDownload(syncWrapper: SyncWrapper): Boolean + ReturnCount:SyncTask.kt$SyncTask$private fun runUpload(syncWrapper: SyncWrapper): Boolean + ReturnCount:SyncTask.kt$SyncTask$private fun updateFailureCounter(request: SyncRequest, success: Boolean) + ReturnCount:SyncWorker.kt$SyncWorker$override fun doWork(): Result + SwallowedException:FileUtils.kt$FileUtils$e: java.lang.NullPointerException + TooGenericExceptionCaught:FullScanWorker.kt$FullScanWorker$exception: Exception + TooGenericExceptionCaught:SyncWorker.kt$SyncWorker$exception: Exception + TooManyFunctions:SyncProxy.kt$SyncProxy : SyncRequestCollectorSyncManager + WildcardImport:AccountAddedReceiver.kt$import foundation.e.drive.work.WorkRequestFactory.* + WildcardImport:SyncTask.kt$import foundation.e.drive.models.SyncRequest.Type.* + + diff --git a/build.gradle b/build.gradle index 2d560f5fea0b4f87ee1048719049ceb63400a562..766ad4a879b844c738a26f8f4b79d94c98b3a85f 100644 --- a/build.gradle +++ b/build.gradle @@ -3,8 +3,29 @@ plugins { id 'com.android.application' version '7.1.3' apply false id 'com.android.library' version '7.1.3' apply false id 'org.jetbrains.kotlin.android' version '1.8.20-RC' apply false + id 'io.gitlab.arturbosch.detekt' version '1.23.1' } task clean(type: Delete) { delete rootProject.buildDir } + +subprojects { + detekt { + toolVersion = "1.23.1" + + source = files( + "src/main/java" + ) + + config.setFrom("detekt.yml") + baseline = file("detekt-baseline.xml") + parallel = false + buildUponDefaultConfig = true + allRules = false + disableDefaultRuleSets = false + debug = false + ignoreFailures = false + basePath = projectDir + } +} diff --git a/detekt.yml b/detekt.yml new file mode 100644 index 0000000000000000000000000000000000000000..4efb86519050178026690426c89a3500c666d82e --- /dev/null +++ b/detekt.yml @@ -0,0 +1,22 @@ +# Naming rules +naming: + + ConstructorParameterNaming: + active: false + + VariableNaming: + active: false + + +# Style rules +style: + + ForbiddenComment: + active: false + + +# Complexity rules +complexity: + + TooManyFunctions: + ignorePrivate: true