SonarQube doesn't add JavaScript coverage - javascript
We have a multi module maven project that has Java and JavaScript sub projects.
For SonarQube analysis we have added configuration to JavaScript module.
<sonar.sources>src</sonar.sources>
<sonar.exclusions>src/test/**/*, src/**/resources/simple/**/*</sonar.exclusions>
<sonar.coverage.exclusions>src/**/resources/simple/**/*, src/registerServiceWorker.js</sonar.coverage.exclusions>
<sonar.projectBaseDir>.</sonar.projectBaseDir>
<sonar.javascript.coveragePlugin>lcov</sonar.javascript.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.javascript.jstest.reportsPath>opui-client/target/surefire-reports</sonar.javascript.jstest.reportsPath>
<sonar.javascript.lcov.reportPath>coverage/lcov.info</sonar.javascript.lcov.reportPath>
<sonar.language>js</sonar.language>
SonarQube shows the analysis logs.
Analysing [C:\Users\mzafar\opui-19dec\path\to\file\coverage\lcov.info]
[WARNING] Problem during processing LCOV report: can't save DA data for line 1491 (Line with number 1491 doesn't belong to file src/modules/core/NagraGrid.js).
Part of lcov.info is like this:
SF:C:\Users\mzafar\path\to\js\code\src\modules\core\search\opuiSearch\AdvancedSearchOptionsPopup.js
FN:89,(anonymous_0)
FN:100,(anonymous_1)
FN:113,(anonymous_2)
FN:119,(anonymous_3)
FN:125,(anonymous_4)
FN:129,(anonymous_5)
FN:167,(anonymous_6)
FN:179,(anonymous_7)
FN:188,(anonymous_8)
FN:197,(anonymous_9)
FN:200,(anonymous_10)
FN:209,(anonymous_11)
FNF:12
FNH:10
FNDA:8,(anonymous_0)
FNDA:4,(anonymous_1)
FNDA:1,(anonymous_2)
FNDA:1,(anonymous_3)
FNDA:1,(anonymous_4)
FNDA:26,(anonymous_5)
FNDA:26,(anonymous_6)
FNDA:0,(anonymous_7)
FNDA:26,(anonymous_8)
FNDA:1,(anonymous_9)
FNDA:1,(anonymous_10)
FNDA:0,(anonymous_11)
DA:10,3
DA:82,3
DA:90,8
DA:91,8
DA:101,4
DA:102,4
DA:114,1
DA:120,1
DA:121,1
DA:126,1
DA:130,26
DA:131,0
DA:134,26
DA:136,2
DA:148,2
DA:160,22
DA:168,26
DA:180,0
DA:189,26
DA:198,1
DA:201,1
DA:210,0
DA:211,0
LF:23
LH:19
BRDA:101,0,0,4
BRDA:101,0,1,0
BRDA:120,1,0,1
BRDA:120,1,1,0
BRDA:130,2,0,0
BRDA:130,2,1,26
BRDA:130,3,0,26
BRDA:130,3,1,0
BRDA:134,4,0,2
BRDA:134,4,1,2
BRDA:134,4,2,22
BRDA:195,5,0,11
BRDA:195,5,1,15
BRDA:232,6,0,25
BRDA:232,6,1,1
BRDA:247,7,0,0
BRDA:247,7,1,26
BRDA:265,8,0,0
BRDA:265,8,1,26
BRDA:275,9,0,26
BRDA:275,9,1,0
BRDA:276,10,0,26
BRDA:276,10,1,0
BRF:23
BRH:15
end_of_record
But still JavaScript files coverage is 0. We are using SonarQube 6.7. Can someone help me if some configuration is wrong?
I added the latest sonar property
<sonar.javascript.lcov.reportPaths>path/to/lcov.info</sonar.javascript.lcov.reportPaths>
And this solved the issue for me.
Related
Eclipse 2021-09 is not showing outline for javascript files
I have eclipse 2021-09 (4.21.0) installed with Wild Web Developer 0.11.0 and Node.js embedder included. Javascript files are opened with Generic Text Editor, syntax highlighting is shown but outline view is empty. Even for the most simple *.js files. Take a look at the included screenshot: What might be wrong? How to fix it? EDIT: The same problems exist in a fresh, newly created workspace, with the same example javascript file. Quick Outline (Ctrl+O) produces java.util.concurrent.TimeoutException with the following message: LanguageServer not initialized after 10s Exception Stack Trace: java.util.concurrent.TimeoutException at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1950) at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2085) at org.eclipse.lsp4e.LanguageServerWrapper.getServerCapabilities(LanguageServerWrapper.java:706) at org.eclipse.lsp4e.LanguageServiceAccessor.lambda$12(LanguageServiceAccessor.java:557) at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:176) at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133) at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) at org.eclipse.lsp4e.LanguageServiceAccessor.getLSPDocumentInfosFor(LanguageServiceAccessor.java:558) at org.eclipse.lsp4e.operations.symbols.LSPSymbolInFileHandler.execute(LSPSymbolInFileHandler.java:40) at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:283) at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:97) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:156) at org.eclipse.core.commands.Command.executeWithChecks(Command.java:488) at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:487) at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213) at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:308) at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:580) at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:647) at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:439) at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:96) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1270) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1059) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1084) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1069) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1111) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1107) at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1536) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4875) at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:345) at org.eclipse.swt.widgets.Control.windowProc(Control.java:4753) at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4958) at org.eclipse.swt.internal.win32.OS.DispatchMessage(Native Method) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3624) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1150) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1041) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) at org.eclipse.equinox.launcher.Main.run(Main.java:1467) Session data: eclipse.buildId=4.21.0.I20210906-0500 java.version=15.0.1 java.vendor=Oracle Corporation BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US Framework arguments: -product org.eclipse.epp.package.jee.product Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product
It seems like a symptom of https://github.com/eclipse/wildwebdeveloper/issues/294 . Monitor the issue for potential workarounds and resolutions.
How to solve BuildJobExitNonZero on Digital Ocean
Hi guys its my first time trying digital ocean, I am deploying my app via Launch App and my code are hosted on github however when i try importing the code and building i am getting the below error and i have no idea what that is Please help 2021-08-03T21:47:06.796342084Z => Initializing build 2021-08-03T21:47:06.832099453Z => Retrieving source code to /workspace 2021-08-03T21:47:06.860459803Z => Selecting branch "main" 2021-08-03T21:47:09.561399472Z => Checking out commit "9be192339cd0a8c93919eaf5959bd43c5ff06927" 2021-08-03T21:47:12.318858786Z => Got source_dir: / 2021-08-03T21:47:12.344366201Z => Using workspace root /workspace 2021-08-03T21:47:12.414846752Z 2021-08-03T21:47:12.414907116Z => Building app using buildpacks 2021-08-03T21:47:12.704652275Z => Injecting app environment variables: 2021-08-03T21:47:12.704707986Z QUEUE_CONNECTION DB_HOST SESSION_LIFETIME TWILIO_ACCOUNT_SID SENTRY_TRACES_SAMPLE_RATE APP_URL SENTRY_LARAVEL_DSN TWILIO_AUTH_TOKEN MAIL_MAILER TEXTTAWK_ENVIRONMENT DB_PASSWORD API_SECRET TWILIO_PHONE_NUMBER PERSONAL_CLIENT_ID MAIL_USERNAME MAIL_FROM_ADDRESS PERSONAl_CLIENT_SECRET MULTI_DB_ENABLED BROADCAST_DRIVER APP_ENV GOOGLE_CLIENT_ID EXPANDED_LOGGING ERROR_EMAIL MAIL_PASSWORD GOOGLE_CLIENT_SECRET APP_NAME TRUSTED_PROXIES MAIL_HOST DB_CONNECTION APP_DEBUG DB_USERNAME GOOGLE_REDIRECT_URI APP_KEY CACHE_DRIVER MAIL_ENCRYPTION SESSION_DRIVER INTERNAL_QUEUE_ENABLED MAIL_FROM_NAME DB_PORT DB_DATABASE MAIL_PORT TEXTTAWK_ORGANIZATION_ID 2021-08-03T21:47:12.736297358Z => Configuring custom build command to be run at the end of the build: 2021-08-03T21:47:12.761828497Z composer install 2021-08-03T21:47:13.365839056Z => Running buildpack detection 2021-08-03T21:47:13.365923629Z 2021-08-03T21:47:14.074627212Z heroku/nodejs-engine 0.5.0 2021-08-03T21:47:14.074682595Z digitalocean/node 0.3.4 2021-08-03T21:47:14.074757668Z digitalocean/php-appdetect 0.0.3 2021-08-03T21:47:14.074803894Z heroku/php 0.188.4 2021-08-03T21:47:14.075038595Z digitalocean/procfile 0.0.3 2021-08-03T21:47:14.075058351Z digitalocean/custom 0.1.0 2021-08-03T21:47:14.202672749Z 2021-08-03T21:47:14.202717224Z For documentation on the buildpacks used to build your app, please see: 2021-08-03T21:47:14.202743590Z Node.js: https://do.co/apps-buildpack-node 2021-08-03T21:47:14.202798824Z PHP: https://do.co/apps-buildpack-php 2021-08-03T21:47:14.818696983Z 2021-08-03T21:47:14.818882813Z => Building app 2021-08-03T21:47:14.818924263Z 2021-08-03T21:47:15.093655477Z ---> Node.js Buildpack 2021-08-03T21:47:15.108387965Z ---> Installing toolbox 2021-08-03T21:47:15.129668030Z ---> - jq 2021-08-03T21:47:15.847171368Z ---> - yj 2021-08-03T21:47:16.137897473Z ---> Getting Node version 2021-08-03T21:47:16.185826122Z ---> Resolving Node version 2021-08-03T21:47:18.820896954Z ---> Downloading and extracting Node v12.22.4 2021-08-03T21:47:33.310168979Z ---> Parsing package.json 2021-08-03T21:47:34.458500684Z ---> No file to start server 2021-08-03T21:47:34.458547440Z ---> either use 'docker run' to start container or add index.js or server.js 2021-08-03T21:47:34.543028305Z Error: package-lock.json does not exist. Please commit either a package-lock.json or yarn.lock file to your repository and try again. 2021-08-03T21:47:34.543513537Z project does not contain a package manager lockfile 2021-08-03T21:47:34.546474624Z [31;1mERROR: [0mfailed to build: exit status 1 2021-08-03T21:47:37.973947707Z 2021-08-03T21:47:37.974088341Z For documentation on the buildpacks used to build your app, please see: 2021-08-03T21:47:37.974111872Z Node.js: https://do.co/apps-buildpack-node 2021-08-03T21:47:37.974199168Z PHP: https://do.co/apps-buildpack-php 2021-08-03T21:47:37.977558349Z 2021-08-03T21:47:37.977966439Z [31m ! Build failed (145)[0m
For anyone who might face this same challenge in the future, for me the problem was "package.json" if you deploying a Laravel API you need to delete the package.json file from your project. For me that was the issue that was preventing my project from building Happy coding
I had a similar error and fixed it a different way. Since the error said "package-lock.json does not exist.", I added a package-lock.json file by running the npm install command in the root directory of the app, the one with the package.json file. After that the app deployed successfully.
Parse error in 'test/step_definitions/requester.js': (1:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty
I am developing an API automated test case using cucumber and JavaScript and I am getting this error: Error: Parse error in 'test/step_definitions/requester.js': (1:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got '//const fetch = require('node-fetch');' I have a .feature file within 'features' folder. In addition, I have two .js files within 'step_definitions' folder. Files are 'my_steps' and 'requester.js'. The Gruntfile.js contains this line to run it: command: './node_modules/.bin/cucumber-js /features/*.feature -r /Users/alfredo.bazo/XCore-ContentLibrary-Tests/API-Test/test/step_definitions/*.js', As per error thrown, it seems that requester.js file is considered as a feature file. Why? How can I fix it? Thanks in advance.
Import Angular unit test report into Sonarqube
Context In an Angular5 project using karma and jasmine for unit testing, I am generating this report file for my unit tests using karma-sonarqube-unit-reporter. <testExecutions version="1"> <file path="src/app/app.component.spec.ts"> <testCase name="app/app.component.spec.ts should create the app" duration="314"/> <testCase name="app/app.component.spec.ts should have as title 'Projet de test Angular5'" duration="104"/> <testCase name="src/app/app.component.spec.ts should render title in a h1 tag" duration="114"/> </file> <file path="src/app/client-add/client-add.component.spec.ts"> <testCase name="client-add/client-add.component.spec.ts should create" duration="107"/> </file> <file path="app/client.service.spec"> <testCase name="app/client.service.spec #getClients should return an Observable<Client[]>" duration="38"/> </file> <file path="src/app/message.service"> <testCase name="app/message.service should be created" duration="35"/> </file> </testExecutions> But when I import it into Sonarqube (v6.7) (via Jenkins), I get the following INFO: Sensor Generic Test Executions Report WARN: Property 'sonar.genericcoverage.unitTestReportPaths' is deprecated. Please use 'sonar.testExecutionReportPaths' instead. INFO: Parsing C:\Users\adminpp\.jenkins\workspace\ELIS JustElis Beta WEB\reports\ut_report.xml INFO: Imported test execution data for 0 files INFO: Test execution data ignored for 4 unknown files, including: src/app/app.component.spec.ts src/app/client-add/client-add.component.spec.ts src/app/client.service.spec src/app/message.service INFO: Sensor Generic Test Executions Report (done) | time=110ms Here are my sonar properties for excluding and including sources and test codes. sonar.sourceEncoding=UTF-8 sonar.sources=. sonar.exclusions=**/node_modules/** sonar.test.inclusions = **/*.spec.ts sonar.import_unkown_files=true sonar.typescript.lcov.reportPaths=coverage/lcov.info sonar.testExecutionReportPaths=reports/ut_report.xml I checked and I have my *.spec.ts files where they are supposed to be. Questions Why Sonarqube doesn't find my files? Have I missed a property or an important step? (Is this property sonar.test.inclusions = **/*.spec.ts important?)
can you try to add property sonar.tests=. (value set to current directory) – Tibor Blenessy Adding this property in the sonar config worked for me. I got an error when I had the property sonar.tests set but not sonar.test.inclusions though but with the two, everything works fine.
Is it a bug in SonarQube's JavaScript plugin that it doesn't pick up Surefire test results of tests that are in a subdirectory?
I have a Surefire results directory with 2 files: TEST-Chrome_4202311135_Windows.dashboard.MonkeyTest.xml and TEST-Chrome_4202311135_Windows.PersonTest.xml. Thus, my tests have the following directory structure: -tests -PersonTest.js -dashboard -MonkeyTest.js When I run Sonar Runner it picks up PersonTest.js but it says that dashboard/MonkeyTest.js doesn't exist: 18:24:58.747 WARN - Test result will not be saved for test class "dashboard.MonkeyTest", because SonarQube associated resource has not been found using file name: "dashboard/MonkeyTest.js" Has anybody encountered this? Looks to me like a bug because the file is there.
Well, I've delved into the SonarQube's JavaScript Plugin code to debug it. Found the bug. Looks like this bug only happens on Windows. What the code does is iterates over all the test files, in my case "PersonTest.js" and "dashboard/MonkeyTest.js", and looks for the file "dashboard\MonkeyTest.js". But because "dashboard/MonkeyTest.js" does not equal to "dashboard\MonkeyTest.js" it ignores the results of this test. To be honest iterates over ALL the test files for every test result is inefficient to begin with. Below is the Java method. I'll try to get in contact with the author. protected InputFile getTestFileRelativePathToBaseDir(String fileName) { for (InputFile inputFile : fileSystem.inputFiles(testFilePredicate)) { LOG.warn("Slava: '" + inputFile.file().getAbsolutePath() + "'"); if (inputFile.file().getAbsolutePath().endsWith(fileName)) { LOG.debug("Found potential test file corresponding to file name: {}", fileName); LOG.debug("Will fetch SonarQube associated resource with (logical) relative path to project base directory: {}", inputFile.relativePath()); return inputFile; } } return null; }