Sonarqube: Is there a bug for sonarqube compute the LOCs

The steps as follow:

  1. Active the SonarQube using the evaluation license,and the database using default H2.
  2. Create a new (c++) project which run analysis on Windows. SonarQube showed the below command

sonar-scanner.bat -D"sonar.projectKey=GxDirectShow" -D"sonar.sources=."
-D"sonar.host.url=http://192.168.42.137:9000"
-D"sonar.login=d6d974e6911f7a8cf4726c5facfb9652bc6e4a92"
-D"sonar.cfamily.build-wrapper-output=.

  1. I analyze my project which LOC is 32K, the LOCs computed in [administrator->configuration->license manager] showed 32K Lines currently analyzed
  2. I execute the same command (step 2) with another project, which LOCs is 7K. the LOCs computed in [administrator->configuration->license manager] showed 7K Lines currently analyzed

But, in step 4, I think the LOC usage should be 3.2K. why this happen?

Hi @JunLiangYu,

you might be analyzing third party dependencies, I invite you to review you analysis properties and check the set of files imported into SonarQube. A nice page read: https://docs.sonarqube.org/latest/project-administration/narrowing-the-focus/.

thanks for your reply.
but im not analyzing third party dependencies. i only evaluated how sonarqube computed the LOCs. i have 1 test case:
1、 analyzed one project A (32K LOCs)using the token “d6d974e6911f7a8cf4726c5facfb9652bc6e4a92” . after that, i re-analyzed the peoject A using the same token with nothing changed. the LOCs used in [administrator->configuration->license manager] showed 32 K Lines currently analyzed.
2、i using the same token with step 1 to analyze another project,which code size is 7K lines. after the sonarqube analyzed, the LOCs used in [administrator->configuration->license manager] showed 7 K Lines currently analyzed.

but, i think after step 2, the LOCs computed by sonarqube is 32 K instead of 7KB. is it a bug?

@mpaladin

Hi @JunLiangYu,

first of all there is no need to ping.

I have troubles understanding your problem, if you are analyzing two projects, one with 32K and one with 7K you should get a total of 39K. Are you using distinct project keys for the two projects?

hi @mpaladin

no, i analyzed two projects using the same project key .

Hi @JunLiangYu,

then you have your answer, you should use different project keys for different projects.

@mpaladin

If I persist in doing this(distinct Projects using the same project key), what will I lose? Or what’s the benefit of different key for different project?

i only need the sonarqube to help me find the code smell issue, bug issue and so on.

Hi @JunLiangYu,

if you use the same project key for two projects each time you analyze one project you override the previous results not being able to browse the results of the two projects at the same time and to also track its history. That is why it is called project key, it identifies a single project.