`0 Lines of Code` with Automatic Analysis (with `Not recommended`)

Hello,

We’ve imported a private GitHub repository containing multiple languages (mostly JS, but also quite a lot of Objective C and other, with 37% of lines to be ignored, as per screenshot below). The repository does not have any SonarCloud configuration file and the result of the initial analysis shows 0 Lines of Code.

What could be the reason for that?
We don’t see any errors in SonarCloud (if there would be any errors, where can we find them?)

Any subsequent PRs also show 0 Lines of Code.
We use GitHub Actions, but we’d like to use Automatic Analysis, without the need to configure CI-based analysis.

Hi Karol,

Given the typology of your project, there are many possible reasons why the automatic analysis could end badly.

From what I can see you should not be using the Automatic Analysis, it doesn’t support such a complex mix of languages yet.

We currently have 3 flavors of Automatic Analysis: for Java, for .NET, and for uncompiled languages. We then have some rules to select the correct one to run but since your project has a bit of everything, the selected flavor probably won’t be able to run correctly.

You should forget Automatic Analysis until we make it evolve enough to support your use case.
You should keep your dedicated CI, you are also able to compute coverage using a CI which you can’t on Automatic Analysis.

Hi Grégoire,

Thanks for the feeback. We’d like to analyse only Javascript part of our code (which is in a dedicated separate directory), but even with sonar.sources and sonar.exclusions specified in .sonarcloud.properties it still does not work.

Ok I see, it can make sense to use the Automatic Analysis then.
Can you share your .sonarcloud.properties here?
And also if you have the analysis id of one that doesn’t provide the expected result (can be found in the background task page of your project)?

@ Grégoire : Sure, our .sonarcloud.properties is below.

# Sources
sonar.sources=Resources
sonar.exclusions=Resources/interface/**/*, Resources/lang/**/*
# Tests
sonar.tests=ui_tests
# Source encoding
sonar.sourceEncoding=UTF-8

I just attempted to re-import the project again (after deleting it few days ago), and it triggered the following 3 analysis (IDs below) :

  • AYgfoTrrOX-uwTi9rp1a
  • AYgfoTA2nR8fbHxPp2Pc
  • AYgfoK_Vrds7yzT7spER

BTW, is there any debug option to inspect any detailed logs, based on those analysis IDs?

Hi and sorry for the late answer,

BTW, is there any debug option to inspect any detailed logs, based on those analysis IDs?

You see some logs in the background task page, next to the task itself. You can see SonarScanner Context logs for green tasks and some error logs for failed tasks.
Unfortunately, when using Automatic Analysis you can’t see the analysis log by yourself yet.

From the IDs you gave me, I could find the logs of the scanner run on the Automatic Analysis for Java, there are a few logs that I noticed and found weird:

Analysis `AYgfoTrrOX-uwTi9rp1a`

.sonarcloud.properties file is not defined by the user

Seems like you didn’t have the .sonarcloud.properties file on this PR.

INFO: Check ALM binding of project ‘redacted_project_name’
WARN: Failed to check if project ‘redacted_project_name’ is bound
INFO: Detected project binding: ERROR

Is it possible that your project is not correctly bound to the Github repository? Or that your SonarCloud organization is not bound anymore to the Github organization? Do you still have the SonarCloud app installed on your Github organization?

INFO: Included sources: **/pom.xml, **/src/main/**/*
INFO: Excluded sources: **/build-wrapper-dump.json, **/*.vb, **/*.cs, **/*.c, **/*.h, **/*.cc,…
INFO: Included tests: **/src/test/**/*

Seems like it’s using the default configuration and really doesn’t have access to your config file, might explain why there is no file in the resulting analysis.

INFO: 0 files indexed
INFO: 43222 files ignored because of inclusion/exclusion patterns
INFO: 0 files ignored because of scm ignore settings

So indeed wrong configuration and no files are found for this PR.

Analysis `AYgfoTA2nR8fbHxPp2Pc`

Seems like this PR has the .sonarcloud.properties file

INFO: Check ALM binding of project ‘redacted_project_name’
WARN: Failed to check if project ‘redacted_project_name’ is bound
INFO: Detected project binding: ERROR

Here we also have this binding check error.

INFO: Project configuration:
INFO: Included sources: **/pom.xml, **/src/main/**/*
INFO: Excluded sources: **/build-wrapper-dump.json, Resources/interface_1/**/*, Resources/interface_365/**/*, Resources/lang/**/*, Resources/lang-exxon/**/*, Resources/qr/**/*, Resources/slide_template/**/*, **/*.m, **/*.h, **/*.cpp, **/*.java, **/*.mm, **/*.cc, **/*.c++, **/*.vb, **/*.cs, **/*.c, **/*.h, **/*.cc, **/*.cpp, **/*.cxx, **/*.c++, **/*.hh, **/*.hpp, **/*.hxx, **/*.h++, **/*.ipp, **/*.m, **/*.sql, **/*.tab, **/*.pkb, **/src/test/**/*
INFO: Included tests: **/src/test/**/*
INFO: Excluded tests: **/*.vb, **/*.cs, **/*.c, **/*.h, **/*.cc, **/*.cpp, **/*.cxx, **/*.c++, **/*.hh, **/*.hpp, **/*.hxx, **/*.h++, **/*.ipp, **/*.m, **/*.sql, **/*.tab, **/*.pkb
INFO: Excluded sources for coverage: **/*
INFO: Excluded sources for duplication: ui_tests
INFO: 0 files indexed
INFO: 27030 files ignored because of inclusion/exclusion patterns
INFO: 0 files ignored because of scm ignore settings

And it seems like your configuration of the sources is wrong in the .sonarcloud.properties file. Check this doc to define it correctly: https://docs.sonarcloud.io/advanced-setup/analysis-scope/
I’ll also check with my colleagues if we might have an issue with reading the sonar.sources property from the config file on the Automatic Analysis for Java just in case.

Hello @KK_PIT,

I looped with my colleagues and found out that we currently have a limitation in the Automatic Analysis for Java and currently the sonar.sources property from the config file is ignored. We plan to fix that in the near future.

In the meantime, what you can do is set this value in the UI under:
Your Organization > Your Project > Administration - General Settings > Analysis Scope > Files

Hi Grégoire Aubert, thanks for the response.

We’ve tried modifying Analysis Scope > Files (from the UI), but unfortunately the outcome is the same.

Hi Grégoire Aubert,

In the SonarScanner Context I can see the following:

sonar.inclusions=**/pom.xml,**/src/main/**/*

… even though we didn’t specify this anywhere. How can we get rid of this? (seems like this is the culprit here?)

Hello,

So I dug a bit more and it seems like Automatic Analysis for Java also doesn’t take into account the setting from the UI. So you won’t be able to make it work until we resolve this bug.

We will probably work on it in the coming weeks but I can’t give you an ETA. So I think for now you will have to continue using the Github Action.

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