Zero LoC reported for some files

Hello,
we are using SonarQube Developer Edition 9.2.4 with sonar-maven-plugin 3.9.1.2184.
Our project is quite huge - 1.6MLoC, but I just found out, that many of our files are reported as zero LoC.
Example folder with files:

Example file measures:

Example file analysis:

We’ve got thousands of similar files (example folder is one of our system plugin - we have tens of such plugins), that have zero LoC measures - I think sonar does it for all javascript files in those plugins.
In other part of a system js files are analyzed corectly, but I can embed only three screens in a post as a fresh user.

How can I determine the reason of recognizing all those files as zero-loc?
I guess due to zero-loc recognition, they are not analyzed at all - this is main problem of course.

PS. Happy New Year :-).

Sorry to reply for my own post second later, but here example of correctly analyzed js file, that couldn’t be attached in a previuos post:

Hey there.

Turning up your log level to DEBUG (mvn sonar:sonar -X) and searching for the file name of a file where no lines of code are reported, do you find anything interesting (parsing errors, warnings, etc.)?

Thanks for hint. Since our build lasts about 9 hours, I will reconfigure bamboo and analyze it tomorrow. Be back with any conclusions.

Hello again.
We are using bamboo to build sonar (with bamboo plugin), so at first I didn’t add -X argument, but checked Debug logging in build log of this task - Logs all details about the task into the build log Enable it when you troubleshooting this task option in bamboo’s task.
There are two things, that bother me:
After flood of analyze output (sensors and found files), I’ve got:

build	05-Jan-2022 03:29:59	[e[1;34mINFOe[m] CPD Executor CPD calculation finished (done) | time=2457ms
build	05-Jan-2022 03:29:59	[e[1;34mINFOe[m] Load New Code definition
build	05-Jan-2022 03:29:59	[e[1;34mINFOe[m] Load New Code definition (done) | time=61ms
build	05-Jan-2022 03:30:08	[e[1;34mINFOe[m] Analysis report generated in 6692ms, dir size=234.2 MB
build	05-Jan-2022 03:30:51	[e[1;34mINFOe[m] Analysis report compressed in 43511ms, zip size=92.7 MB
build	05-Jan-2022 03:31:07	[e[1;34mINFOe[m] Analysis report uploaded in 15905ms
build	05-Jan-2022 03:31:07	[e[1;34mINFOe[m] ANALYSIS SUCCESSFUL, you can browse https://URL/dashboard?id=EIS_eis-coverholder&branch=dev%2FATA%2FDEVEL-1270-all-tune-sonarqube-analysis-scope
build	05-Jan-2022 03:31:07	[e[1;34mINFOe[m] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
build	05-Jan-2022 03:31:07	[e[1;34mINFOe[m] More about the report processing at https://URL/api/ce/task?id=AX4oE0Qejj0VetSviWF2

Followed by:

build	05-Jan-2022 03:31:17	[e[1;33mWARNINGe[m] Failed to close server
build	05-Jan-2022 03:31:17	java.net.ConnectException: Failed to connect to /127.0.0.1:44293
build	05-Jan-2022 03:31:17		at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:265)
build	05-Jan-2022 03:31:17		at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:183)
build	05-Jan-2022 03:31:17		at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.java:224)
build	05-Jan-2022 03:31:17		at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.java:108)
build	05-Jan-2022 03:31:17		at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.java:88)
build	05-Jan-2022 03:31:17		at okhttp3.internal.connection.Transmitter.newExchange(Transmitter.java:169)
build	05-Jan-2022 03:31:17		at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:41)
build	05-Jan-2022 03:31:17		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
build	05-Jan-2022 03:31:17		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
build	05-Jan-2022 03:31:17		at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
build	05-Jan-2022 03:31:17		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
build	05-Jan-2022 03:31:17		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
build	05-Jan-2022 03:31:17		at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
build	05-Jan-2022 03:31:17		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
build	05-Jan-2022 03:31:17		at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
build	05-Jan-2022 03:31:17		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
build	05-Jan-2022 03:31:17		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
build	05-Jan-2022 03:31:17		at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:221)
build	05-Jan-2022 03:31:17		at okhttp3.RealCall.execute(RealCall.java:81)
build	05-Jan-2022 03:31:17		at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.request(EslintBridgeServerImpl.java:247)
build	05-Jan-2022 03:31:17		at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.clean(EslintBridgeServerImpl.java:332)
build	05-Jan-2022 03:31:17		at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.stop(EslintBridgeServerImpl.java:364)
build	05-Jan-2022 03:31:17		at org.sonar.core.platform.StartableCloseableSafeLifecyleStrategy.stop(StartableCloseableSafeLifecyleStrategy.java:52)
build	05-Jan-2022 03:31:17		at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.stop(AbstractInjectionFactory.java:88)
build	05-Jan-2022 03:31:17		at org.picocontainer.behaviors.AbstractBehavior.stop(AbstractBehavior.java:179)
build	05-Jan-2022 03:31:17		at org.picocontainer.behaviors.Stored$RealComponentLifecycle.stop(Stored.java:141)
build	05-Jan-2022 03:31:17		at org.picocontainer.behaviors.Stored.stop(Stored.java:118)
build	05-Jan-2022 03:31:17		at org.picocontainer.DefaultPicoContainer.stopAdapters(DefaultPicoContainer.java:1048)
build	05-Jan-2022 03:31:17		at org.picocontainer.DefaultPicoContainer.stop(DefaultPicoContainer.java:803)
build	05-Jan-2022 03:31:17		at org.sonar.core.platform.ComponentContainer.stopComponents(ComponentContainer.java:166)
build	05-Jan-2022 03:31:17		at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:125)
build	05-Jan-2022 03:31:17		at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:136)
build	05-Jan-2022 03:31:17		at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
build	05-Jan-2022 03:31:17		at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
build	05-Jan-2022 03:31:17		at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
build	05-Jan-2022 03:31:17		at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
build	05-Jan-2022 03:31:17		at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
build	05-Jan-2022 03:31:17		at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
build	05-Jan-2022 03:31:17		at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
build	05-Jan-2022 03:31:17		at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
build	05-Jan-2022 03:31:17		at java.base/java.lang.reflect.Method.invoke(Method.java:566)
build	05-Jan-2022 03:31:17		at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
build	05-Jan-2022 03:31:17		at com.sun.proxy.$Proxy24.execute(Unknown Source)
build	05-Jan-2022 03:31:17		at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
build	05-Jan-2022 03:31:17		at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
build	05-Jan-2022 03:31:17		at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:65)
build	05-Jan-2022 03:31:17		at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.java:108)
build	05-Jan-2022 03:31:17		at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
build	05-Jan-2022 03:31:17		at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
build	05-Jan-2022 03:31:17		at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
build	05-Jan-2022 03:31:17		at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
build	05-Jan-2022 03:31:17		at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
build	05-Jan-2022 03:31:17		at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
build	05-Jan-2022 03:31:17		at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
build	05-Jan-2022 03:31:17		at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
build	05-Jan-2022 03:31:17		at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
build	05-Jan-2022 03:31:17		at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
build	05-Jan-2022 03:31:17		at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
build	05-Jan-2022 03:31:17		at org.apache.maven.cli.MavenCli.execute(MavenCli.java:972)
build	05-Jan-2022 03:31:17		at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)
build	05-Jan-2022 03:31:17		at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
build	05-Jan-2022 03:31:17		at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
build	05-Jan-2022 03:31:17		at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
build	05-Jan-2022 03:31:17		at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
build	05-Jan-2022 03:31:17		at java.base/java.lang.reflect.Method.invoke(Method.java:566)
build	05-Jan-2022 03:31:17		at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
build	05-Jan-2022 03:31:17		at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
build	05-Jan-2022 03:31:17		at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
build	05-Jan-2022 03:31:17		at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
build	05-Jan-2022 03:31:17	Caused by: java.net.ConnectException: Connection refused (Connection refused)
build	05-Jan-2022 03:31:17		at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
build	05-Jan-2022 03:31:17		at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
build	05-Jan-2022 03:31:17		at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
build	05-Jan-2022 03:31:17		at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
build	05-Jan-2022 03:31:17		at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
build	05-Jan-2022 03:31:17		at java.base/java.net.Socket.connect(Socket.java:609)
build	05-Jan-2022 03:31:17		at okhttp3.internal.platform.Platform.connectSocket(Platform.java:130)
build	05-Jan-2022 03:31:17		at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:263)
build	05-Jan-2022 03:31:17		... 68 common frames omitted
build	05-Jan-2022 03:31:17	
build	05-Jan-2022 03:31:18	[e[1;34mINFOe[m] Analysis total time: 8:14:59.821 s

Meanwhile I’ve added -Dsonar.javascript.node.maxspace=8192 and upgraded NodeJS (11->14).
Since our project is 200+ modules, I’ve tried just one - same as 0-LoC reported previuosly and…
It was analyzed correctly.
I will add -X to bamboo execution and check results next day.

This is actually pretty important, as NodeJS 11 does not mix well with analysis.

So your problem may very well be solved on your next full scan!

After all mention steps all files where analyzed :-).

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