SonarCloud complaints on objective-C code

Hi,

I am try to scan a mobile app project via Azure DevOps and ran into this issue

“The only way to get an accurate analysis of C/C++/Objective-C files is by using the SonarSource build-wrapper
and setting the property “sonar.cfamily.build-wrapper-output”, but it was not specified.”

Below is the tasks I have in the pipeline. Can someone point out where I need to set up the property for cfamily?

  • task: SonarCloudPrepare@1

    inputs:

    SonarCloud: ‘SonarCloud Digital’

    organization: ‘XXXX’

    scannerMode: ‘CLI’

    configMode: ‘manual’

    cliProjectKey: 'XXXXXX

    cliProjectName: ‘mobile app ios’

    cliSources: ‘.’

  • task: SonarCloudAnalyze@1

  • task: SonarCloudPublish@1

    inputs:

    pollingTimeoutSec: ‘300’

Based on this post, auto scan with Azure DevOps is not supported for obj-C. Is this still the case?

Hi @Eliot_Chen,

you should set up the normal sonar-scanner analysis, without using the SonarCloudPrepare, SonarCloudAnalyze and SonarCloudPublish tasks. You could have something like here: cpp-example/generic-build-analyze.sh at main · mpaladin/cpp-example · GitHub.

Thanks for your reply. Are you suggesting to run the shell script as part of Azure Devops pipeline.

Hi @Eliot_Chen ,

What I suggest you is to embed it the way you prefer, but you should use a similar approach as the one in:

@mpaladin, I managed to integrate your yml and sh script in my Azure DevOps pipeline and it kicked off the scan. However, I am getting the error below. could you guide me on what went wrong?

INFO: Sensor CFamily [cpp]

INFO: CFamily plugin version: 6.18.0.29274

INFO: Using build-wrapper output: /home/vsts/work/1/s/bw-output/build-wrapper-dump.json

INFO: Available processors: 2

INFO: Using 2 threads for analysis according to value of “sonar.cfamily.threads” property.

INFO: PCH: unique=0 use=0 (forceInclude=0,throughHeader=0,firstInclude=0) out of 0 (forceInclude=0,throughHeader=0)

INFO: SE: 0 out of 0

INFO: Subprocess(es) done in 6ms

INFO: Cache: 0/0 hits, 136 bytes

INFO: 0 compilation units analyzed

INFO: ------------------------------------------------------------------------

INFO: EXECUTION FAILURE

INFO: ------------------------------------------------------------------------

INFO: Total time: 1:24.998s

INFO: Final Memory: 117M/390M

INFO: ------------------------------------------------------------------------

ERROR: Error during SonarScanner execution

java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found empty. Please make sure that:

  • you are using the latest version of the build-wrapper and the CFamily analyzer

  • your compiler is supported

  • you are wrapping your build correctly

  • you are wrapping a full/clean build

  • if you are building your project inside a Docker container, build-wrapper is wrapping the build process inside the container and not wrapping the external Docker process

@mpaladin ,

Some additional information. I have printed out the content of both bw-output/build-wrapper.log and bw-output/build-wrapper-dump.json

bw-output/build-wrapper-dump.json

# (C) SonarSource SA, 2014-2021, info@sonarsource.com

# All SONARSOURCE programs and content are copyright protected.

# SONARSOURCE and SONARQUBE are trademarks of SonarSource SA. All rights are expressly reserved.

#

# This file is designed exclusively for use with the SONARSOURCE C / C++ / Objective-C Plugin.

# It may not be used in connection with any other software.

# Any other use is prohibited by law and may be grounds for immediate termination of your License.

{

"version":"6.18",

"captures":[

]}

build-wrapper.log (last bit of it)

    Wed Mar 31 11:28:48 2021: env 160: <OLDPWD=/home/vsts/work/1/s/build>

    Wed Mar 31 11:28:48 2021: executing: <cmake --build build>

    Wed Mar 31 11:28:48 2021: initializing json file

    Wed Mar 31 11:28:48 2021: process created with pid: 2520

    Wed Mar 31 11:28:48 2021: parent pid: 2519

    Wed Mar 31 11:28:48 2021: working directory: </home/vsts/work/1/s>

    Wed Mar 31 11:28:48 2021: executable: </home/vsts/work/1/s/build-wrapper-linux-x86/build-wrapper-linux-x86-64>

    Wed Mar 31 11:28:48 2021: argv[0]: </home/vsts/work/1/s/build-wrapper-linux-x86/build-wrapper-linux-x86-64>

    Wed Mar 31 11:28:48 2021: argv[1]: <-c>

    Wed Mar 31 11:28:48 2021: argv[2]: <>

    Wed Mar 31 11:28:48 2021: argv[3]: <cmake>

    Wed Mar 31 11:28:48 2021: argv[4]: <--build>
Wed Mar 31 11:28:48 2021: argv[5]: <build>

Wed Mar 31 11:28:48 2021: skipping process with pid: 2520

Wed Mar 31 11:28:48 2021: process created with pid: 2521

Wed Mar 31 11:28:48 2021: parent pid: 2520

Wed Mar 31 11:28:48 2021: working directory: </home/vsts/work/1/s>

Wed Mar 31 11:28:48 2021: executable: </usr/local/bin/cmake>

Wed Mar 31 11:28:48 2021: argv[0]: <cmake>

Wed Mar 31 11:28:48 2021: argv[1]: <--build>

Wed Mar 31 11:28:48 2021: argv[2]: <build>

Wed Mar 31 11:28:48 2021: skipping process with pid: 2521

Wed Mar 31 11:28:48 2021: finalizing json file

Wed Mar 31 11:28:48 2021: returned with code: 1

Hi @Eliot_Chen ,

could you share the azure pipelines yml file? I can send you a pm if you want to share privately.