Skip to content

Commit

Permalink
(WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
Godin committed Oct 31, 2024
1 parent 5439dac commit b197d9f
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.sonar.api.issue.NoSonarFilter
import org.sonar.api.measures.FileLinesContextFactory
import org.sonarsource.analyzer.commons.ProgressReport
import org.sonarsource.kotlin.api.checks.hasCacheEnabled
import org.sonarsource.kotlin.api.common.KOTLIN_LANGUAGE_VERSION
import org.sonarsource.kotlin.api.common.KotlinLanguage
import org.sonarsource.kotlin.api.common.measureDuration
import org.sonarsource.kotlin.api.frontend.bindingContext
Expand All @@ -46,6 +47,7 @@ import org.sonarsource.kotlin.metrics.IssueSuppressionVisitor
import org.sonarsource.kotlin.metrics.MetricVisitor
import org.sonarsource.kotlin.metrics.SyntaxHighlighter
import org.sonarsource.kotlin.api.visiting.KtChecksVisitor
import kotlin.jvm.optionals.getOrDefault

import kotlin.jvm.optionals.getOrElse

Expand All @@ -57,8 +59,8 @@ class KotlinSensor(
checkFactory: CheckFactory,
private val fileLinesContextFactory: FileLinesContextFactory,
private val noSonarFilter: NoSonarFilter,
language: KotlinLanguage
): AbstractKotlinSensor(
language: KotlinLanguage,
) : AbstractKotlinSensor(
checkFactory, language, KOTLIN_CHECKS
) {
override fun describe(descriptor: SensorDescriptor) {
Expand All @@ -67,11 +69,18 @@ class KotlinSensor(
.name(language.name + " Sensor")
}

override fun execute(sensorContext: SensorContext) {
sensorContext.config()[KOTLIN_LANGUAGE_VERSION].ifPresent { value ->
sensorContext.addTelemetryProperty("kotlin.languageVersion", value)
}
super.execute(sensorContext)
}

override fun getExecuteContext(
sensorContext: SensorContext,
filesToAnalyze: Iterable<InputFile>,
progressReport: ProgressReport,
filenames: List<String>
filenames: List<String>,
) = object : AbstractKotlinSensorExecuteContext(
sensorContext, filesToAnalyze, progressReport, visitors(sensorContext), filenames, LOG
) {
Expand Down

0 comments on commit b197d9f

Please sign in to comment.