insideapp-oss / sonar-apple

SonarQube plugin for Swift / Objective-C
Other
97 stars 2 forks source link

Swift files not indexed with SonarQube 10.4 #82

Closed zippy1978 closed 7 months ago

zippy1978 commented 7 months ago

New Issue Checklist

Issue Description

After installing the plugin (version 0.4.0) on SonarQube 10.4. I noticed Swift files are not indexed anymore. Watching at the logs (with -X) it says "indexed with no language" when indexing .swift files.

The same project is ok when analysis is performed on a SonarQube 9.9.

Environment

SonarQube 10.4 Community Edition SonarScanner 5.0.1 Java 17.0.7 macOS 14.2

gaelfoppolo commented 7 months ago

I reproduce the issue. In the logs I also noticed this, which might be something to investigate:

11:21:55.521 DEBUG: Declared patterns of language CloudFormation were converted to sonar.lang.patterns.cloudformation : 
11:21:55.521 DEBUG: Declared patterns of language Swift were converted to sonar.lang.patterns.swift : 
11:21:55.521 DEBUG: Declared patterns of language YAML were converted to sonar.lang.patterns.yaml : **/*.yaml,**/*.yml
11:21:55.521 DEBUG: Declared patterns of language Go were converted to sonar.lang.patterns.go : **/*.go
....
11:21:55.523 DEBUG: Declared patterns of language AzureResourceManager were converted to sonar.lang.patterns.azureresourcemanager : **/*.bicep
11:21:55.523 DEBUG: Declared patterns of language Objective-C were converted to sonar.lang.patterns.objc : 
11:21:55.523 DEBUG: Declared patterns of language TypeScript were converted to sonar.lang.patterns.ts : **/*.ts,**/*.tsx,**/*.cts,**/*.mts

For Swift and Objective-C, no patterns seems declared. Also in SonarQube, Administration > Configuration > Languages, there is no Swift or Objective-C. All of this seems related.

gaelfoppolo commented 7 months ago

After some extensive trial and error, I was able to pinpoint the issue.

It looks like it has something to do arounding this commit but it does not help us.

Others languages are working fine, so I tried to compare what they do and we don't. Some hours later, I finally managed to find what we were missing. Adding a property definition to define the language file suffixes (sonar.XXX.file.suffixes with XXX the language) seems to fix the issu. I don't understand why, since we are already doing that in the language (getFileSuffixes), but well..

Adding sonar.swift.file.suffixes make the indexing of Swift files working again.

static final PropertyDefinition FILE_SUFFIXES = PropertyDefinition
        .builder("sonar.swift.file.suffixes")
        .name("File Suffixes")
        .description("List of suffixes of Swift files to analyze.")
        .multiValues(true)
        .onQualifiers(Qualifiers.PROJECT)
        .defaultValue("swift")
        .build();

I'll try to come up with a working PR later.

For references: Kotlin : https://github.com/SonarSource/sonar-kotlin/blob/3e0775957e3782545a69b9ec65c5209dfd305dbc/sonar-kotlin-plugin/src/main/java/org/sonarsource/kotlin/plugin/KotlinPlugin.kt#L78 Python : https://github.com/SonarSource/sonar-python/blob/master/sonar-python-plugin/src/main/java/org/sonar/plugins/python/PythonPlugin.java#L63

gaelfoppolo commented 7 months ago

Closing, resolved with #84.