Javascript "Semicolon" rule and es2015 class declarations

108 views
Skip to first unread message

gordon.d...@gmail.com

unread,
Dec 29, 2015, 5:25:39 PM12/29/15
to SonarQube
Sonar raises a "javascript:Semicolon" issue against line 3 of the code included below. This is Angular code using es2015 class declarations. We're using v2.5 of the Sonar Javascript plugin. I believe this code to be correct and a semicolon is not desirable immediately after "class MyBlahClass {".

(() => { 'use strict';

 
class MyBlahClass { // <-- This line is improperly flagged with issue "Each statement should end with a semicolon" aka "javascript:Semicolon". This wouldn't make sense:  class MyBlahClass {;
    constructor
() {
   
// Code removed for brevity
   
}
 
}
 
 
static directiveFactory(){
   
MyBlahClass.instance = new MyBlahClass();
   
return MyBlahClass.instance;
 
}

 
// More classes were removed for brevity

  angular
.module('blah.common.directives.my-blah-lookup')
   
.controller('myCtrl', MyCtrl)
   
.directive('myBlahClass', MyBlahClass.directiveFactory);
})();


Please consider improving this rule so that it doesn't flag es2015 class declarations.

Scott B.

unread,
Dec 29, 2015, 6:21:11 PM12/29/15
to SonarQube, gordon.d...@gmail.com
Update your plugin. I could not reproduce it with version 2.9.

ige...@gmail.com

unread,
Jan 4, 2016, 4:40:06 PM1/4/16
to SonarQube, gordon.d...@gmail.com
Still seeing the error after upgrading to version 2.9.
SonarQube Version: 4.5.4
Java Script Version: 2.9

Elena Vilchik

unread,
Jan 12, 2016, 10:59:22 AM1/12/16
to SonarQube, gordon.d...@gmail.com
Hello,

Thank you for the feedback! Here is the ticket https://jira.sonarsource.com/browse/SONARJS-603
Reply all
Reply to author
Forward
0 new messages