Kotlin error compiling sonarqube in android

Hi,

We are facing kotlin compiler error in sonarqube, it is working normal without sonarqube, once we implement sonar to the project facing the below error

I tried to exclude these files at project level using uikit/src/androidTest/**/* and it is not working

Sonar Version : 9.5

Task :uikit:compileDebugAndroidTestKotlin FAILED
e: /home/penmapa/jenkins/workspace/sonar-lib-hub/qlv-uikit-lib/qlv-uikit-lib/uikit/src/androidTest/java/com/verizon/common/uikit/tlm/IconMenuGroup.kt: (27, 24): Object is not abstract and does not implement abstract member public abstract fun writeToParcel(p0: Parcel, p1: Int): Unit defined in com.verizon.common.uikit.tlm.TLMView.IconMenuItem
e: /home/penmapa/jenkins/workspace/sonar-lib-hub/qlv-uikit-lib/qlv-uikit-lib/uikit/src/androidTest/java/com/verizon/common/uikit/tlm/IconMenuGroup.kt: (47, 17): 'writeToParcel' overrides nothing
e: /home/penmapa/jenkins/workspace/sonar-lib-hub/qlv-uikit-lib/qlv-uikit-lib/uikit/src/androidTest/java/com/verizon/common/uikit/tlm/MenuGroup.kt: (33, 13): Object is not abstract and does not implement abstract member public abstract fun writeToParcel(p0: Parcel, p1: Int): Unit defined in com.verizon.common.uikit.tlm.TLMView.IconMenuItem
e: /home/penmapa/jenkins/workspace/sonar-lib-hub/qlv-uikit-lib/qlv-uikit-lib/uikit/src/androidTest/java/com/verizon/common/uikit/tlm/MenuGroup.kt: (53, 17): 'writeToParcel' overrides nothing
e: /home/penmapa/jenkins/workspace/sonar-lib-hub/qlv-uikit-lib/qlv-uikit-lib/uikit/src/androidTest/java/com/verizon/common/uikit/tlm/MenuGroup.kt: (58, 13): Object is not abstract and does not implement abstract member public abstract fun writeToParcel(p0: Parcel, p1: Int): Unit defined in com.verizon.common.uikit.tlm.TLMView.IMenuItem

Hi,

Could you provide some more details here? How are you “implement[ing] sonar”?

 
Ann

Hi Ann,
Thanks for looking into the issue

Folder Path needs to exclude: qlv-uikit-lib/uikit/src/androidTest/**

Source scanner :
./gradlew sonarqube
-Dsonar.projectKey=qlv-lib-hub
-Dsonar.host.url=http://
-Dsonar.login=sqp_557cb5046bb43d68a15fb2f520a5068f61ce478c
-Dsonar.exclusions=uikit/src/androidTest/**/*

Jenkins Job :

withSonarQubeEnv(‘sonarqube’) {
sh ‘chmod +x gradlew’
sh ‘./gradlew sonarqube’

UI Exclusion

Hi,

So you’re saying you get an error when you try to analyze, but analysis doesn’t interfere with your compilation?

 
Ann

As compilation error while running the job in Jenkins, after we changed the kotlin version to 1.7.20

Can’t we exclude the folder before sonar analysis go to that folder?

This is Jenkins Job

stage('Clean uikit') {
			steps {
                          dir("qlv-uikit-lib/qlv-uikit-lib") {
                              withCredentials([usernamePassword(
				        credentialsId: 'CI_FM_JENKINS_ARTIFACTORY_PUBLISH', 
					passwordVariable: 'ORG_GRADLE_PROJECT_artifactory_password', 
					usernameVariable: 'ORG_GRADLE_PROJECT_artifactory_user')]) {
					sh 'chmod +x gradlew'
					sh './gradlew clean'
                  }
		
        }
        	}
		} // Cleaning & Setting up the prject
		stage('Sonarqube uikit') {
			steps {
                           dir("qlv-uikit-lib/qlv-uikit-lib") {
				withCredentials([usernamePassword(
					credentialsId: 'CI_FM_JENKINS_ARTIFACTORY_PUBLISH', 
					passwordVariable: 'ORG_GRADLE_PROJECT_artifactory_password', 
					usernameVariable: 'ORG_GRADLE_PROJECT_artifactory_user')]) {
		         	        sh './gradlew --refresh-dependencies'
				withSonarQubeEnv('sonarqube') {
		                        sh 'chmod +x gradlew'
                                        sh './gradlew sonarqube'
						   
                   }
       }
}

This is my Build.gradle file

Hi,

If you got a complie error after upgrading to Kotlin 1.7.20, that seems separate from SonarQube analysis. I think the first step is to get the code to compile again after your Kotlin upgrade. Then come back to us if you’re still having a problem with SonarQube.

 
Ann

Hi,

But the code is working without sonar analysis, once sonar analysis is added, we are getting the compilation error.

Is there any way that sonar to take particular kotlin version.

Thanks!!!

Hi,

Could we have the full job log?

 
Ann