(Nikhil) #1

I’m running code analysis on Swift project on SonarCloud and it was all working fine until few days back where I’m running into this error:

**ERROR: Error during SonarQube Scanner execution**
**java.lang.UnsupportedOperationException: '' is mandatory**
**at com.sonar.cpp.plugin.R.A(na:1573)**
**at java.util.Optional.orElseThrow(**
**at com.sonar.cpp.plugin.R.execute(na:1573)**
**at org.sonar.scanner.sensor.SensorWrapper.analyse(**
**at org.sonar.scanner.phases.SensorsExecutor.execute(**
**at org.sonar.scanner.phases.SensorsExecutor.lambda$execute$1(**
**at org.sonar.scanner.phases.SensorsExecutor.withGlobalStrategy(**
**at org.sonar.scanner.phases.SensorsExecutor.execute(**
**at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(**
**at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(**
**at org.sonar.core.platform.ComponentContainer.startComponents(**
**at org.sonar.core.platform.ComponentContainer.execute(**
**at org.sonar.scanner.scan.ProjectScanContainer.scan(** 

I’ve tried bypassing the wrapper by setting ‘’ in file.
I’ve also excluded all the .c, .cpp, .java, and some other c related files.

How can I just bypass this issue? I only want to run analysis on .swift files.

(Loïc Joly) #2

Hello Nikhil,

You are using the 6.0 version of the CFamily analyzer, that no longer allows you to bypass the build wrapper (it was creating too many issues). So if you want to analyze C, C++ or objective-C code, you have to setup your environment so that you run the build wrapper and then use its output.

If you are only interested in Swift code, the way to go is to exclude source code from the other languages, as you already started to do. You are listing some extensions used by the CFamily analyzer, but not .h (headers) or .m (objective-C). Another option would be to use sonar.inclusions instead of sonar.exclusions to list only the extensions associated with Swift.

There is another option, that might be easier to use if you need inclusions/exclusions for another purpose: Each language has a list of file suffixes it uses to recognize its source files. So you could set those suffixes to values that do not appear in your codebase:


(Evgeny Mandrikov) #3

And current message

is going to be improved to reflect what @JolyLoic explained -

(Nikhil) #4

Thank you @JolyLoic! I forgot to exclude .objc files which was causing the issue. All good now.

(Nikhil) #5

@JolyLoic I was wrong. When I included only the .swift in sonar.inclusions, there were 0 files analyzed because swift classes depend on libraries which have .c, .cpp, .m, .h and other CFamily files.

Now I am back to the same error! How do I fix this?

I use SonarCloud and I run my builds on a Mac.

(Evgeny Mandrikov) #6

@nboin123 Initially you said

if you don’t want to analyze C/C++/Objective-C files and don’t want to see them in SonarQube, then as was already said before, you can exclude them by setting


or if you want to analyze and see only Swift files in SonarQube, then indeed you can include only them by setting


In both cases the fact that Swift classes depend on C/C++/Objective-C libraries won’t bother Swift analyzer.

If you want to analyze C/C++/Objective-C files in SonarQube, then you must set and so must use build-wrapper - please carefully read

Given the information so far provided by you, the above list is IMO exhaustive. So if it doesn’t help, then please be far more precise about what you want, what you have, what exactly you do and how? If the project is Open Source, then the simplest way will be just to show us a link on it. If not, then IMO simplest way will be to demonstrate your difficulties on “hello world” example that you’ll be able to share.