Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANDROID-11179 detekt implementation #386

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
23291e2
ANDROID-11179 detekt implementation
jmanriquehiberus Sep 18, 2024
fd59062
ANDROID-11179 using detekt's last version
jmanriquehiberus Sep 18, 2024
6baac3a
ANDROID-11179 excluding files beneath .gradle, build & tmp
jmanriquehiberus Sep 19, 2024
60f8f91
ANDROID-11179 deprecated input replaced with basePath, and now exclud…
jmanriquehiberus Sep 20, 2024
6c144d6
ANDROID-11179 non deprecated config setting
jmanriquehiberus Sep 20, 2024
fe5535a
ANDROID-11179 interface name capitalisation to meet detekt requirements
jmanriquehiberus Sep 20, 2024
01bc970
ANDROID-11179 for loop replaced with repeat in order to fix detekt is…
jmanriquehiberus Sep 20, 2024
5d18440
ANDROID-11179 unused imports removed
jmanriquehiberus Sep 20, 2024
e5ff9b8
ANDROID-11179 too long line detekt issue fixed
jmanriquehiberus Sep 20, 2024
b26150e
ANDROID-11179 multiple variable declaration detekt issue fixed
jmanriquehiberus Sep 20, 2024
75c1a6e
ANDROID-11179 calling error function instead of throwing exception in…
jmanriquehiberus Sep 20, 2024
46d4262
ANDROID-11179 putting composable functions first in order to avoid re…
jmanriquehiberus Sep 20, 2024
4edc4f2
ANDROID-11179 empty constructor removed
jmanriquehiberus Sep 20, 2024
c9afd31
ANDROID-11179 detekt issues fixed LongMethod, CyclomaticComplexMethod
jmanriquehiberus Sep 23, 2024
590835e
ANDROID-11179 detekt issues fixed SwallowedException
jmanriquehiberus Sep 23, 2024
1584599
ANDROID-11179 detekt issue fixed: CyclomaticComplexMethod
jmanriquehiberus Sep 23, 2024
bfdfbac
ANDROID-11179 detekt issue fixed: LongMethod
jmanriquehiberus Sep 24, 2024
b20c76b
ANDROID-11179 detekt added to tests.yml
jmanriquehiberus Sep 24, 2024
910fdad
ANDROID-11179 unused import removed
jmanriquehiberus Sep 24, 2024
533c04d
ANDROID-11179 too long line issue fixed and detekt issues with config…
jmanriquehiberus Sep 24, 2024
81399b7
ANDROID-11179 detekt issues suppressed until further notice (jira tic…
jmanriquehiberus Sep 24, 2024
0e9f6c7
ANDROID-11179 code cleanup
jmanriquehiberus Sep 24, 2024
bada90c
ANDROID-11179 detekt-baseline.xml removed
jmanriquehiberus Sep 24, 2024
ee638a9
ANDROID-11179 error prone icon replaced with stable one
jmanriquehiberus Sep 24, 2024
e93dd76
Merge branch 'main' of github.com:Telefonica/mistica-android into jma…
jmanriquehiberus Sep 24, 2024
3ff5363
ANDROID-11179 link to the library updated
jmanriquehiberus Sep 24, 2024
8305ea3
ANDROID-11179 LongMethod issue ignored on Composable annotated functions
jmanriquehiberus Sep 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v2

- name: "Build Android project"
run: 'bash ./gradlew clean check assemble'
run: 'bash ./gradlew clean check detekt assemble'

- name: Upload Lint results
uses: github/codeql-action/upload-sarif@v2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
![Mistica for Android](doc/images/mistica-android-dark.svg#gh-dark-mode-only)

[![Platform](https://img.shields.io/badge/Platform-Android-brightgreen)](https://github.com/Telefonica/mistica-android)
[![Version](https://maven-badges.herokuapp.com/maven-central/com.telefonica/mistica/badge.png)](https://central.sonatype.com/artifact/com.telefonica/mistica?smo=true)
[![Version](https://img.shields.io/maven-metadata/v.svg?label=maven-central&metadataUrl=https%3A%2F%2Frepo1.maven.org%2Fmaven2%2Fcom%2Ftelefonica%2Fmistica%2Fmaven-metadata.xml)](https://central.sonatype.com/artifact/com.telefonica/mistica)
[![Support](https://img.shields.io/badge/Support-%3E%3D%20Android%205.0-brightgreen)](https://github.com/Telefonica/mistica-android)
[![Kotlin version badge](https://img.shields.io/badge/kotlin-1.8.20-blue.svg)](https://kotlinlang.org/docs/whatsnew1820.html)

Expand Down
6 changes: 6 additions & 0 deletions build-tools/detekt.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

detekt {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No files to adapt in mistica after adding detekt? Did you check this is executed with the ./gradlew check command? (which is the one executed on preintegration GA)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there are 96 issues to address after running detekt.

I am sorry but could not find any preintegration GA in mistica, should there be or should we include detekt in any GA? πŸ€”

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the tests.yml file, the checks which are run on each PR commit, detekt should run as part of them.

Normally, when invoking "check" gradle target (executed on that GA), detekt is also executed with just applying the plugin, but please check it just to ensure it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to add detekt we need to also fix the current issues repository has (or ignoring them someway to do that work afterwards), if it's too complicated, please check with the team how to proceed on next weekly or by chat (I'm on vacations next week).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. By now, I have addressed 53 issues and still have 43 to be fixed (most of them related to long functions or too complex functions). I will address simpler issues alone and will keep potentially troublesome ones to be tackled along with the team.

buildUponDefaultConfig = true
config.from(files("$projectDir/build-tools/detekt/detekt.yml"))
basePath = files("$projectDir")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could exclude some folders like:

    source.from(fileTree(rootProject.projectDir) {
        exclude("**/.gradle/")
        exclude("**/build/")
        exclude("**/tmp/**")
    })

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, just did it, thanks ☺️

39 changes: 39 additions & 0 deletions build-tools/detekt/detekt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
complexity:
TooManyFunctions:
active: false
LongParameterList:
active: false
LongMethod:
ignoreAnnotated: 'Composable'


style:
NewLineAtEndOfFile:
active: false
MagicNumber:
active: false
ReturnCount:
active: false
UnusedImports:
active: true
MaxLineLength:
maxLineLength: 160
UnusedPrivateMember:
ignoreAnnotated: 'Preview'
UnnecessaryAbstractClass:
ignoreAnnotated: "Module"

naming:
FunctionNaming:
active: true
ignoreAnnotated: 'Composable'

empty-blocks:
EmptyFunctionBlock:
active: false

exceptions:
TooGenericExceptionThrown:
active: false
TooGenericExceptionCaught:
active: false
44 changes: 44 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ buildscript {
accompanist_version = "0.32.0"
coil_version = '2.5.0'
constraintComposeVersion = '1.0.1'
detekt_version = '1.23.7'
roborazzi_version = "1.10.1"
}
repositories {
Expand All @@ -23,13 +24,19 @@ buildscript {
classpath "com.android.tools.build:gradle:8.1.4"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "gradle.plugin.com.betomorrow.gradle:appcenter-plugin:2.0.3"
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detekt_version"
}
}

plugins {
id 'org.jetbrains.kotlin.android' version '1.5.21' apply false
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0' apply false
id "io.github.takahirom.roborazzi" version '1.10.1' apply false
id "io.gitlab.arturbosch.detekt" version '1.23.7'
}

dependencies {
apply plugin: "io.gitlab.arturbosch.detekt"
}

allprojects {
Expand All @@ -41,10 +48,47 @@ allprojects {
version = System.getProperty("LIBRARY_VERSION") ?: "undefined"
}

tasks.withType(io.gitlab.arturbosch.detekt.Detekt).all {
exclude("build/")
exclude("**/build/**")
exclude("**/resources/**")
exclude("**/tmp/**")
exclude("**/*Autogenerated.kt")
}

tasks.withType(io.gitlab.arturbosch.detekt.Detekt).configureEach {
reports {
html {
outputLocation.set(file("$buildDir/reports/detekt/detekt-report.html"))
required.set(true)
}
xml {
outputLocation.set(file("$buildDir/reports/detekt/detekt-checkstyle.xml"))
required.set(true)
}
}
}

task detektProjectBaseline(type: io.gitlab.arturbosch.detekt.DetektCreateBaselineTask) {
description = "Overrides current baseline."
ignoreFailures.set(true)
parallel.set(true)
buildUponDefaultConfig.set(true)
setSource(files("$projectDir"))
config.setFrom(files("$projectDir/build-tools/detekt/detekt.yml"))
include("**/*.kt")
include("**/*.kts")
}

repositories {
google()
mavenCentral()
}
}

apply from: "${rootProject.projectDir}/publish_maven_central.gradle"
apply from: "build-tools/detekt.gradle"

tasks.withType(io.gitlab.arturbosch.detekt.Detekt) {
autoCorrect = true
}
Loading
Loading