# Parse error in javascript

**URL:** <https://community.sonarsource.com/t/parse-error-in-javascript/10209>\
**Category:** SonarQube Server / Community Build\
**Tags:** javascript\
**Created:** [May 28, 2019, 11:43am UTC](https://community.sonarsource.com/t/parse-error-in-javascript/10209 "2019-05-28T11:43:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dhanush\_KC](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/dhanush_kc/32/4066_2.png) [@Dhanush\_KC](https://community.sonarsource.com/u/Dhanush_KC)\
**Post date:** [May 28, 2019, 11:43am UTC](https://community.sonarsource.com/t/parse-error-in-javascript/10209/1 "2019-05-28T11:43:55Z")

</div>

Hi,

Sonarqube not able to analyze javascript code.I am using sonarqube 7.6 and javascript plugin sonar-javascript-plugin-5.1.1.7506.

Below is my code :

ERROR: Parse error at line 14 column 7:

4:   
5: var rows = prompt(“How many rows for your multiplication table?”);  
6: var cols = prompt(“How many columns for your multiplication table?”);  
7: if(rows == “” || rows == null)  
8: rows = 10;  
9: if(cols== “” || cols== null)  
10: cols = 10;  
11: createTable(rows, cols);  
12: function createTable(rows, cols)  
13: {  
14: var j=1;  
^  
15: var output = “\<table border=‘1’ width=‘500’ cellspacing='0’cellpadding=‘5’\>”;  
16: for(i=1;i\<=rows;i++)  
17: {  
18: output = output + “

”;  
19: while(j\<=cols)  
20: {  
21: output = output + “” + i\*j + “”;  
22: j = j+1;  
23: }  
24: output = output + “”;

Thanks  
Dhanush

---

<div class="post-metadata">

**Author:** ![Andrea\_Guarino](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/andrea_guarino/32/54797_2.png) [@Andrea\_Guarino](https://community.sonarsource.com/u/Andrea_Guarino)\
**Post date:** [May 28, 2019, 1:52pm UTC](https://community.sonarsource.com/t/parse-error-in-javascript/10209/2 "2019-05-28T13:52:45Z")

</div>

Hi @Dhanush_KC,

- Are you sure the code you’re analyzing doesn’t actually contain parse errors? Did you verify it somewhere else?
- If you’re sure the code is valid, could you please share a small reproducer (in the example you posted the code seems to be incomplete) and the logs?

Thanks,  
Andrea

---

<div class="post-metadata">

**Author:** ![Dhanush\_KC](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/dhanush_kc/32/4066_2.png) [@Dhanush\_KC](https://community.sonarsource.com/u/Dhanush_KC)\
**Post date:** [May 29, 2019, 7:31am UTC](https://community.sonarsource.com/t/parse-error-in-javascript/10209/3 "2019-05-29T07:31:24Z")

</div>

Thanks for the reply

Below is the code:

 Multiplication Table 

1.Yes,This code will run successfully in the browser but sonarqube is giving parse errors which is indicated above(logs in the sonarqube).

1. Sonarqube says analysis successful but when see in the dashboard it is “This project is empty” is dispalyed.

logs:

INFO: Sensor JavaXmlSensor [java]  
INFO: Sensor JavaXmlSensor [java] (done) | time=1ms  
INFO: Sensor Analyzer for “php.ini” files [php]  
INFO: Sensor Analyzer for “php.ini” files [php] (done) | time=2ms  
INFO: Sensor SonarJS [javascript]  
INFO: 1 source files to be analyzed  
ERROR: Unable to parse file: file:///E:/sonar\_test/mem\_js5/mem\_js5/test5.js  
ERROR: Parse error at line 14 column 3:

4:   
5: var rows = prompt(“How many rows for your multiplication table?”);  
6: var cols = prompt(“How many columns for your multiplication table?”);  
7: if(rows == “” || rows == null)  
8: rows = 10;  
9: if(cols== “” || cols== null)  
10: cols = 10;  
11: createTable(rows, cols);  
12: function createTable(rows, cols)  
13: {  
14: var j=1;  
^  
15: var output = “\<table border=‘1’ width=‘500’ cellspacing='0’cellpadding=‘5’\>”;  
16: for(i=1;i\<=rows;i++)  
17: {  
18: output = output + “

”;  
19: while(j\<=cols)  
20: {  
21: output = output + “” + i\*j + “”;  
22: j = j+1;  
23: }  
24: output = output + “”;

INFO: Sensor SonarJS [javascript] (done) | time=39ms  
INFO: 1/1 source files have been analyzed  
INFO: Sensor ESLint-based SonarJS [javascript]  
INFO: 1 source files to be analyzed  
ERROR: Failed to parse file [file:///E:/sonar\_test/mem\_js5/mem\_js5/test5.js] at line 14: Unexpected token var  
INFO: Sensor ESLint-based SonarJS [javascript] (done) | time=13421ms  
INFO: 1/1 source files have been analyzed  
INFO: Sensor Zero Coverage Sensor  
INFO: Sensor Zero Coverage Sensor (done) | time=11ms  
INFO: Sensor CPD Block Indexer  
INFO: Sensor CPD Block Indexer (done) | time=1ms  
INFO: No SCM system was detected. You can use the ‘sonar.scm.provider’ property to explicitly specify it.  
INFO: Calculating CPD for 0 files  
INFO: CPD calculation finished  
INFO: Analysis report generated in 107ms, dir size=372 KB  
INFO: Analysis reports compressed in 33ms, zip size=68 KB  
INFO: Analysis report uploaded in 1970ms  
INFO: ANALYSIS SUCCESSFUL, you can browse [http://localhost:9000/dashboard/index/mem\_js5](http://localhost:9000/dashboard/index/mem_js5)  
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report  
INFO: More about the report processing at [http://localhost:9000/api/ce/task?id=AWsCcbt1D2q25q8PcBP-](http://localhost:9000/api/ce/task?id=AWsCcbt1D2q25q8PcBP-)  
INFO: Executing post-job Final report  
INFO: Turn debug info on to get more details (sonar-scanner -X -Dsonar.verbose=true …).  
INFO: Executing post-job Final report  
INFO: Turn debug info on to get more details (sonar-scanner -X -Dsonar.verbose=true …).  
INFO: Task total time: 37.863 s  
INFO: ------------------------------------------------------------------------  
INFO: EXECUTION SUCCESS  
INFO: ------------------------------------------------------------------------  
INFO: Total time: 39.469s  
INFO: Final Memory: 16M/328M  
INFO: ------------------------------------------------------------------------

How to fix this issue?

Warm Regards,  
Dhanush

---

<div class="post-metadata">

**Author:** ![agabrys](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/agabrys/32/2744_2.png) [@agabrys](https://community.sonarsource.com/u/agabrys)\
**Post date:** [May 30, 2019, 10:50am UTC](https://community.sonarsource.com/t/parse-error-in-javascript/10209/5 "2019-05-30T10:50:08Z")

</div>

Could you attach this file? I think it may contain some special characters which breaks the parser.

---

<div class="post-metadata">

**Author:** ![Dhanush\_KC](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/dhanush_kc/32/4066_2.png) [@Dhanush\_KC](https://community.sonarsource.com/u/Dhanush_KC)\
**Post date:** [June 13, 2019, 9:28am UTC](https://community.sonarsource.com/t/parse-error-in-javascript/10209/6 "2019-06-13T09:28:55Z")

</div>

Thanks for this help.  
Removed Special characters (\<\>…\</\>) and kept pure javascript code and it is displaying report
