Hi,
we’re successfully importing our eslint json reports into sonarqube as described
here: Importing Third-Party Issues | SonarQube Docs
All imported Eslint Warnings/Errors are “MAJOR” Code Smells, regardless of their severity in the eslint report.
Is this intended or is it a bug?
Here is a sample snippet of our eslint report:
{
"filePath": "/Users/daniel/Documents/Projekte/projekt/application/frontend/apps/app1/src/app/app.component.ts",
"messages": [
{
"ruleId": "@angular-eslint/component-selector",
"severity": 2,
"message": "The selector should start with one of these prefixes: \"imvs\" (https://angular.io/guide/styleguide#style-02-07)",
"line": 13,
"column": 13,
"nodeType": "Literal",
"messageId": "prefixFailure",
"endLine": 13,
"endColumn": 23
},
{
"ruleId": "@typescript-eslint/explicit-module-boundary-types",
"severity": 1,
"message": "Missing return type on function.",
"line": 56,
"column": 3,
"nodeType": "FunctionExpression",
"messageId": "missingReturnType",
"endLine": 56,
"endColumn": 13
},
{
"ruleId": "@typescript-eslint/explicit-module-boundary-types",
"severity": 1,
"message": "Missing return type on function.",
"line": 64,
"column": 3,
"nodeType": "FunctionExpression",
"messageId": "missingReturnType",
"endLine": 64,
"endColumn": 30
}
],
"errorCount": 1,
"warningCount": 2,
"fixableErrorCount": 0,
"fixableWarningCount": 0,
"source": "import { Component, OnInit, ViewChild } from '@angular/core';\nimport { FormControl } from '@angular/forms';\nimport { ActivatedRoute, NavigationStart, Router } from '@angular/router';\nimport { Observable, Subscription } from 'rxjs';\nimport { filter } from 'rxjs/operators';\nimport { NavigationService } from '@frontend/data/shared/src/lib/navigation.service';\nimport { MatSidenav } from '@angular/material/sidenav';\nimport { MigrantentypChangerService } from '@frontend/data/shared/src/lib/migrantentyp-changer.service';\n\nexport let browserRefresh = false;\n\n@Component({\n selector: 'app-root',\n templateUrl: './app.component.html',\n styleUrls: ['./app.component.scss'],\n})\n/**\n * Doku fuer AppComponent\n * Initialer Komponent von Imvs\n * //REFACTOR: Tab Component\n */\nexport class AppComponent implements OnInit {\n @ViewChild(MatSidenav, { static: true }) sidenav: MatSidenav;\n\n selected = new FormControl(0);\n\n navStart: Observable<NavigationStart>;\n subscription: Subscription;\n\n migrantentypFarbeClass: string = null;\n\n constructor(\n private readonly router: Router,\n private readonly activatedRoute: ActivatedRoute,\n private readonly navigationService: NavigationService,\n private readonly colorChangeService: MigrantentypChangerService\n ) {\n // Create a new Observable that publishes only the ImvsNavigationstart event\n this.navStart = router.events.pipe(filter((evt) => evt instanceof NavigationStart)) as Observable<NavigationStart>;\n this.navStart.subscribe((event) => {\n if (event instanceof NavigationStart) {\n browserRefresh = !router.navigated;\n }\n });\n this.colorChangeService.migrantentypChangeEvent.subscribe((migrantentyp) => {\n this.migrantentypFarbeClass = migrantentyp\n ? `migrantenFarbe ${migrantentyp.toLowerCase()}-theme`\n : 'migrantenFarbe none-theme';\n });\n }\n\n /**\n * OnInit\n * werden die gespeicherte Tabs aus LocalStorage wieder ertellt\n */\n ngOnInit() {\n this.navigationService.onChangeEmitter.subscribe((state) => {\n if ((state === true && !this.sidenav.opened) || (state !== true && this.sidenav.opened) || state === null) {\n this.sidenav.toggle();\n }\n });\n }\n\n onSideBarContentActivated() {\n // this.kerndatenService.emitClean();\n }\n}\n",
"usedDeprecatedRules": []
}
In SonarQube the issues are present, but all have the type “Code Smell” and severity “Major”.
I would expect that the first issue has a different severity than the second issue. Maybe ‘critical’?
I’ve noticed the topic How to import issues from eslint report as Bugs but as the severity in the eslint report could be simply mapped to a severity in SonarQube, I think the Eslint Importer could do this.
Versions:
SonarQube Version 8.9.7 (build 52159)
“eslint”: “7.22.0”
Best regards
Daniel