Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error parsing JSON eslint-angular #12

Open
ominocervello opened this issue Nov 29, 2016 · 18 comments
Open

Error parsing JSON eslint-angular #12

ominocervello opened this issue Nov 29, 2016 · 18 comments

Comments

@ominocervello
Copy link

Hi,
I have installed:

  • sonar v.4.5.7
  • sonar-web-frontend-plugin 2.1
  • sonar-web-frontend-reporters

When I configure gulp to start scan on a single js file, it generates a valid JSON report, but when I select all project, I have this error:

15:45:05.818 INFO - Sensor JsHintQualitySensor done: 38140 ms 15:45:05.834 INFO - Sensor EslintAngularQualitySensor... 15:45:06.115 ERROR - failed to parse json file. Cause: Unexpected end-of-input: expected close marker for ARRAY (from [Source: java.io.InputStreamReader@7444d60 d; line: 5, column: 19]) at [Source: java.io.InputStreamReader@7444d60d; line: 345187, column: 327] (thr ough reference chain: fr.sii.sonar.report.core.quality.domain.report.QualityRepo rt["files"]) 15:45:06.115 DEBUG - Release semaphore on project : org.sonar.api.resources.Proj ect@119655f1[id=6804,key=cdfe,qualifier=TRK], with key batch-cdfe INFO: ------------------------------------------------------------------------ INFO: EXECUTION FAILURE INFO: ------------------------------------------------------------------------ Total time: 2:27.374s Final Memory: 23M/191M INFO: ------------------------------------------------------------------------ ERROR: Error during Sonar runner execution org.sonar.runner.impl.RunnerException: Unable to execute Sonar at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher .java:91) at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75) at java.security.AccessController.doPrivileged(Native Method) at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69) at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50) at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102 ) at org.sonar.runner.api.Runner.execute(Runner.java:100) at org.sonar.runner.Main.executeTask(Main.java:70) at org.sonar.runner.Main.execute(Main.java:59) at org.sonar.runner.Main.main(Main.java:53) Caused by: java.lang.IllegalArgumentException: Cannot parse report E:\cdil0\cdfe 0_SRC\.\reports\sonar\eslint-angular.json at fr.sii.sonar.report.core.common.ReportSensor.analyse(ReportSensor.jav a:109) at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor. java:79) at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:7 0) at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:119) at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanConta iner.java:194) at org.sonar.api.platform.ComponentContainer.startComponents(ComponentCo ntainer.java:93) at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer. java:78) at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.j ava:233) at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScan Container.java:228) at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanCon tainer.java:221) at org.sonar.api.platform.ComponentContainer.startComponents(ComponentCo ntainer.java:93) at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer. java:78) at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:64) at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:51) at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.ja va:125) at org.sonar.api.platform.ComponentContainer.startComponents(ComponentCo ntainer.java:93) at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer. java:78) at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapCon tainer.java:173) at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95) at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67) at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java :48) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher .java:87) ... 9 more

My project has js files in multiple directories, please help me.

@cedric-legallo
Copy link
Contributor

Could you please post or (private message) the json report file ? The console output of the reporter task (from jenkins or the PC who launched the gulp task)

@ominocervello
Copy link
Author

The json file is more than 350000 lines, the structure is like this:

"language" : "reports/sonar/eslint-angular.json", "project" : "cdfe", "projectPath" : ".", "version" : "1.1.0", "files" : [ {

@cedric-legallo
Copy link
Contributor

cedric-legallo commented Nov 29, 2016

And how does it end ?, it might be a bit too big to be process in RAM end not have the closing part

@ominocervello
Copy link
Author

"nbFiles" : 1971,
"nbLines" : 690900,
"nbCloc" : 659095,
"nbComments" : 0,
"violations" : {
"blocker" : 0,
"critical" : 37185,
"major" : 2514,
"minor" : 0,
"info" : 0
}
}

@cedric-legallo
Copy link
Contributor

Ok the end is valid, so not a size problem

@cedric-legallo
Copy link
Contributor

if you can, mail me the whole file : [email protected]
if you cant (confidential or something) pass it to a JSON validator service like http://jsonviewer.stack.hu/

@ominocervello
Copy link
Author

With http://jsonviewer.stack.hu/ -- > Invalid JSON variable

@cedric-legallo
Copy link
Contributor

Just a question, you wanna really scan 2K files and 690 000 lines of code (it's huge) or did you scan vendors folder too ?
The bugs seems to be some malformation in the json somewhere, jsonviewer did not give you the fautive line ?

@cedric-legallo
Copy link
Contributor

is you sonar-web-frontend-reporters at version 2.1.2 ?

@ominocervello
Copy link
Author

Sonar-web-frontend-reporters is 2.2.1, now I have scanned a subfolder of the project but the error is the same

@ominocervello
Copy link
Author

sorry, 2.1.1

@cedric-legallo
Copy link
Contributor

upgrade to 2.1.2 (it will be compatible with the 2.1 plugin and it probably will fix your error)

@ominocervello
Copy link
Author

Ok, I will try.

@ominocervello
Copy link
Author

Ok, now I have a global idea of the situation: the plugin 2.1.1 works fine, the problem is in a js file that has a bad encoding. This file (or more than one) is located in one of 200 folders, i have to find it.

@ominocervello
Copy link
Author

I have found the file js that corrupts JSON. This is the eslint-angular.json

{ "language" : "reports/sonar/eslint-angular.json", "project" : "test-fail", "projectPath" : ".", "version" : "1.1.0", "files" : [ { "name" : "SalvadanaioWPController.js", "path" : "SalvadanaioWPController.js", "nbLines" : 1024, "nbComments" : 0, "nbCloc" : 978, "issues" : [ { "name" : "SalvadanaioWPController.js", "path" : "SalvadanaioWPController.js", "nbLines" : 1024, "nbComments" : 0, "nbCloc" : 978, "issues" : [{ "line" : 120, "message" : "Parsing error: Duplicate data property in object literal not allowed in strict mode", "description" : "", "rulekey" : "undefined", "severity" : "CRITICAL", "reporter" : "eslint", "creationDate" : 1480927872367 }], "violations" : { "blocker" : 0, "critical" : 1, "major" : 0, "minor" : 0, "info" : 0 }}], "nbFiles" : 2, "nbLines" : 2048, "nbCloc" : 1956, "nbComments" : 0, "violations" : { "blocker" : 0, "critical" : 2, "major" : 0, "minor" : 0, "info" : 0 } }

@cedric-legallo
Copy link
Contributor

Wow it is self contained is some sort of recursive parse. Can you see what in the files cause that problem ?

@ominocervello
Copy link
Author

I have noticed if i remove the literal expression 'use strict' , the plugin works fine.

@cedric-legallo
Copy link
Contributor

Thanks, so it is a problem with this particular eslint issue, we will investigate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants