detekt / sonar-detekt

SonarQube plugin for Kotlin
https://detekt.dev
GNU Lesser General Public License v3.0
493 stars 52 forks source link

DetektSensor time increased after SonarQube DataCenter version upgrade. #169

Open EaseTheWorld opened 1 year ago

EaseTheWorld commented 1 year ago

Hello, DetektSensor team. My team has been using Jenkins(running sonar-scanner) - SonarQube DataCenter Edition. After upgrade SonarQube DataCenter Edition 9.4 -> 9.9, DetektSensor processing time increased from 2~3min to 2~3hours.

sonar-scanner log is like this(simplified)

|[2023-07-24T12:43:20.195Z] INFO: Sensor DetektSensor [detekt] // A |[2023-07-24T12:46:26.713Z] complexity - 32d 2h debt TooManyFunctions, ComplexConditions, blabla, … [2023-07-24T12:46:29.490Z] Overall debt: 478d 15h 37min [2023-07-24T12:46:29.490Z] INFO: RuleSet: complexity - 2310 [2023-07-24T12:46:29.490Z] INFO: No file found for // B [2023-07-24T14:37:44.862Z] INFO: No file found for /project/root/…/schema/s1.kt No file found for all /schema/….kt [2023-07-24T14:37:44.862Z] INFO: No file found for /project/root/…/schema/s9.kt [2023-07-24T14:37:51.418Z] INFO: Sensor DetektSensor [detekt] (done) | time=6871251ms // C

(if I add '/schema/' to detekt path filter in sonar project setting, ’No error found’ error is gone(they are generated code and excluded from coverage), but that’s not the point here. the time doesn’t change.)

A-B part is didn’t change before/after upgrade. but B-C part is increased significantly. line count is same, only time is increased.

Q1 : It seems in B-C, IssueReporter revisits the issues found from A-B. why revisit? Q2 : In B-C, is it purely local job? or it communicates with server? Q3 : Why server upgrade slow down B-C? DetektSensor version has been always 2.5.0.

I’m quite new to sonar ecosystem. Any hint will be appreciated.

ohmerhe commented 1 year ago

Same issue happened to me. Do we have any update?

arturbosch commented 1 year ago

Hm it is caused by this code path:

        val inputFile = fileSystem.inputFile(fileSystem.predicates().`is`(pathOfIssue))
        if (inputFile == null) {
            logger.info("No file found for ${finding.location.filePath.absolutePath}")
            return
        }

We are using the sonar api to find files. it seems like an internal change on sonar's side maybe ? Do you have any symbolic links or something where the filesystem engine gets confused ?

You could try out https://github.com/detekt/sonar-detekt/releases/tag/2.6.0-RC1 where I set the sonarqube baseline to 9.9 LTS.

EaseTheWorld commented 1 year ago

Hmm. no symbolic link... No source change actually. "No file found..." error occurred for special specific path. so I excluded them but the slow-scan-issue is still same in 9.9 LTS.

You said 2.6.0 set baseline for 9.9 LTS. Does it mean 2.5.0 had some compatibility issue in 9.9 LTS?

arturbosch commented 1 year ago

Hmm. no symbolic link... No source change actually. "No file found..." error occurred for special specific path. so I excluded them but the slow-scan-issue is still same in 9.9 LTS.

You said 2.6.0 set baseline for 9.9 LTS. Does it mean 2.5.0 had some compatibility issue in 9.9 LTS?

No, no known compatibility issues. I had to fix a regression from https://github.com/detekt/sonar-detekt/pull/167 but that was never released. Also no deprecations or anything from sonar-api update. Just some house keeping after two years and set the new minimal version to newest LTS.

how big (LOC) is your project ? Do you also have these performance issues with a 10.X release? I try to test 9.9 on some bigger projects later.

EaseTheWorld commented 1 year ago

LOC is about 200K and detected issue count is 100K. If you see the log in my original post,

My corp has't upgrade to 10.X yet. still 9.9.