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

[EC5003] - Groovy: sonar scanner crash if "minifyEnabled false" in the project #82

Closed
jhertout opened this issue Dec 1, 2023 · 1 comment
Labels
codenarc 💉 bug Something isn't working

Comments

@jhertout
Copy link
Contributor

jhertout commented Dec 1, 2023

Describe the bug
If minifyEnabled is set to false in the build.gradle, the sonar analysis crashes

To Reproduce

  • Create a default Android project (default fragment project for example)
  • Configure the project for sonarqube analysis (see build.gradle later)
  • Run the sonar analysis

Nb. changing the value of minifyEnable to "true" fix the issue (but throw an issue in sonar analysis).

Expected behavior

The scan does not crash.

Stacktrace

Caused by: groovy.lang.MissingMethodException: No signature of method: java.lang.Boolean.plus() is applicable for argument types: (java.lang.String) values: [ = true]
Possible solutions: is(java.lang.Object), use([Ljava.lang.Object;), split(groovy.lang.Closure), wait(), any(), dump()
	at org.codenarc.rule.ecocode.EC5003AstVisitor$_visitMethodCallExpression_closure1.doCall(EC5003.groovy:47)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at org.codenarc.rule.ecocode.EC5003AstVisitor.visitMethodCallExpression(EC5003.groovy:46)
	at org.codenarc.rule.ecocode.EC5003AstVisitor.super$2$visitMethodCallExpression(EC5003.groovy)
	at jdk.internal.reflect.GeneratedMethodAccessor1207.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at org.codenarc.rule.ecocode.EC5003AstVisitor.visitMethodCallExpression(EC5003.groovy:54)
	at org.codenarc.rule.ecocode.EC5003AstVisitor.super$2$visitMethodCallExpression(EC5003.groovy)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at org.codenarc.rule.ecocode.EC5003AstVisitor.visitMethodCallExpression(EC5003.groovy:54)
	at org.codenarc.rule.ecocode.EC5003AstVisitor.super$2$visitMethodCallExpression(EC5003.groovy)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at org.codenarc.rule.ecocode.EC5003AstVisitor.visitMethodCallExpression(EC5003.groovy:54)
	at org.codenarc.rule.AbstractAstVisitor.visitMethod(AbstractAstVisitor.java:155)
	at org.codenarc.rule.AbstractAstVisitor.visitClass(AbstractAstVisitor.java:132)
	at org.codenarc.rule.AbstractAstVisitorRule.applyTo(AbstractAstVisitorRule.java:97)

Desktop (please complete the following information):

  • SonarQube 10.3

app build.gradle

plugins {
    id 'com.android.application'
    id 'org.sonarqube' version '4.4.1.3373'
}

def multidex = true

android {
    namespace 'com.example.myapplication'
    compileSdk 34

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdk 24
        targetSdk 34
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildFeatures {
        viewBinding true
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.10.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.navigation:navigation-fragment:2.5.3'
    implementation 'androidx.navigation:navigation-ui:2.5.3'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

sonarqube {
    properties {
        property "sonar.sources", "."
        property "sonar.exclusions", "**/build/**"
    }
}
@jhertout jhertout added 💉 bug Something isn't working codenarc labels Dec 1, 2023
@jhertout
Copy link
Contributor Author

The rule will be removed. Not necessary to fix : #88.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codenarc 💉 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant