SonarCloud isn’t scanning my entire project

I am integrating SonarCloud with GitHub actions for Objective-c repos. It is working now when I change something in the repo but it only sees the code that changed recently. Is there any way that I can scan the whole repo once and then scan whatever changed in the repo? There is part it says:

A few extra steps are needed for SonarCloud to analyze your code coverage Setup coverage analysis
Here are some screenshots of my project.


Hi,

SonarCloud is analyzing your entire project & the results are reflected on the ‘Overall Code’ tab in your second screenshot. It just defaults to showing you the analysis results on what changed recently.

 
Ann

Hi Ann,

Thanks for responding. How can i change defaults to show overall code analyses? Because I just implement sonarcloud for that repo and i want to see if there is bugs or code duplications for the repo.

Hi,

Just click over to the ‘Overall’ tab. It’s all already there.

 
Ann

Sorry I am trying to understand because this is my first time using sonarcloud. When i click the overall code tab it is all 0 code only 6 code smells. and it says:
A few extra steps are needed for SonarCloud to analyze your code coverage Setup coverage analysis
I don’t see whole repo that analyzed by sonarcloud if you check my second screenshot.

Hi,

What are you looking for to tell you that the whole repo is analyzed?

What I see in that second screenshot is that analysis ran and found ver few issues. :tada: If you want to dig in further and see what code is included in the analysis, use the Code tab not shown in your screenshot:

There you can verify what is / is not being included in analysis.

As for the Coverage message, if you want to feed a coverage report into your analysis, I believe the link in that block should get you started. Or, you can jump straight into the docs

 
HTH,
Ann

So when I click “code” tab it shows some folders and files. I don’t see whole repo. It includes just couple of files and folders. It is a bit repo and it should include some bugs and duplicate codes at least.

Hi,

Can you post / point to the analysis log? Or is this analyzed automatically?

 
Ann

I analyze it with github actions and it creates build wrapper dir and logs in github actions i think. So i don’t know how to get it from github.
But this is my build yml file:

name: Build
on:
  push:
    branches:
      - develop
      - branch-*
  pull_request:
    types: [opened, synchronize, reopened]
    branches:
      - develop
      - branch-*
jobs:
  build:
    name: Build
    runs-on: macos-latest
    env:
      SONAR_SCANNER_VERSION: 4.7.0.2747
      SONAR_SERVER_URL: "https://sonarcloud.io"
      BUILD_WRAPPER_OUT_DIR: . # Directory where build-wrapper output will be placed
      SSH_KEY: ~/.ssh/id_ed25519
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0  #Shallow clones should be disabled for a better relevancy of analysis
      - name: Set up JDK 11
        uses: actions/setup-java@v1
        with:
          java-version: 11
      - name: Set up Ruby 2.6
        uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
        with:
          ruby-version: 2.6
      - uses: webfactory/ssh-agent@v0.5.4
        with:
          ssh-private-key: ${{ secrets.SSH_KEY }}
      - name: Bundle Install
        working-directory: Platform-SDK-iOS
        run: |
          bundle install
          bundle exec pod keys set "PlatformSecret" "anykey" SDK
      - name: CocoaPod Install
        working-directory: Platform-SDK-iOS
        run: |
          gem install cocoapods
          gem install cocoapods-acknowledgements
          gem install --user-install cocoapods-keys
          pod install
      - name: Download and set up sonar-scanner
        env:
          SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-macosx.zip
        run: |
          mkdir -p $HOME/.sonar
          curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
          unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
          echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-macosx/bin" >> $GITHUB_PATH
      - name: Cache SonarCloud packages
        uses: actions/cache@v1
        with:
          path: ~/.sonar/cache
          key: ${{ runner.os }}-sonar
          restore-keys: ${{ runner.os }}-sonar
      - name: Download and set up build-wrapper
        env:
          BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-macosx-x86.zip
        run: |
          curl -sSLo $HOME/.sonar/build-wrapper-macosx-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}
          unzip -o $HOME/.sonar/build-wrapper-macosx-x86.zip -d $HOME/.sonar/
          echo "$HOME/.sonar/build-wrapper-macosx-x86" >> $GITHUB_PATH
      - name: Run build-wrapper
        run: |
          build-wrapper-macosx-x86 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} xcodebuild clean build -workspace Platform-SDK-iOS/SDK.xcworkspace -scheme SDK-iOS -configuration Release -arch arm64 BITCODE_GENERATION_MODE=bitcode ONLY_ACTIVE_ARCH=NO -sdk iphoneos BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
      - name: Run sonar-scanner
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        run: |
          sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"

and sonar properties file:

sonar.projectKey=ios-sdk-platform-sonarcloud
sonar.organization=org

# This is the name and version displayed in the SonarCloud UI.
sonar.projectName=ios-sdk-platform-sonarcloud
sonar.projectVersion=1.0

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
sonar.sources=.

# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8

sonar.cfamily.cache.enabled=true
sonar.cfamily.cache.path=relative_or_absolute_path_to_cache_location

Hi,

Can you characterize what is / isn’t showing up?

 
Ann

In the first screenshot when i click “code” tab and it shows those folders:

But in the second one there are more folders and code:

Hi,

By ‘characterize’ I meant do you see any patterns in what’s included / excluded from analysis?

 
Ann

No i don’t see whats included or excluded. I am saying that based of the shown files in code tab.

Hi,

What files are not analyzed that you expect to be analyzed?

 
Ann

if you check the screenshot that i shared what has been screened and what i actually have in the repo. So in sonarcloud i only see Sfara-Platform-SDK-IOSTest but there are different folders and each folder contain different files. and this is mostly objective-c repo.

Hi,

I get that the two screenshots show different amounts of project contents. But I don’t know your project and I can’t see inside the directories shown in your screenshots. So… without logs and without knowing your project, I’m asking you to help me understand whether there are any commonalities among the things that got left out. Or among the things that did get included.

And BTW I believe you should be able to find your GitHub Action logs there in GitHub if you poke around in your project a bit.

 
Ann

Hi,

Looking at your logs, it seems the commonality among the files that were included is that they were related to pull request #412?

Auto-configuring pull request 412

When you analyze a pull request, it’s expected behavior that only the files in that PR will show up in the UI.

Once you merge your PR, I’m assuming your GH Actions are set up to fire the full pipeline on the updated code. That should get you a full analysis.

 
HTH,
Ann

Sorry for late response. You were right. When i merge the PR it analyzed the whole repo. Thank you so much for your help and time.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.