Enabling JS in SonarCloud 00/103300/6
authorandre.schmid <andre.schmid@est.tech>
Fri, 6 Mar 2020 14:42:45 +0000 (14:42 +0000)
committerOfir Sonsino <ofir.sonsino@intl.att.com>
Mon, 27 Apr 2020 08:01:07 +0000 (08:01 +0000)
Configures jest test coverage and missing sonar
properties for javascript file scan and report.

Change-Id: I9170a176cc4e580ac14f669c334ee949942503f6
Issue-ID: SDC-2741
Signed-off-by: andre.schmid <andre.schmid@est.tech>
catalog-ui/package.json
catalog-ui/pom.xml
catalog-ui/src/app/ng2/pages/composition/palette/services/palette.service.spec.ts
catalog-ui/src/tsconfig.json
pom.xml

index 1625802..fc99b35 100644 (file)
     "designer": "npm start -- --env.role designer",
     "admin": "npm start -- --env.role admin",
     "start": "webpack-dev-server",
-    "build": "npm run test && webpack --config webpack.config.js",
-    "build:prod": "npm run test && webpack --config webpack.production.js",
+    "build": "webpack --config webpack.config.js",
+    "build:prod": "webpack --config webpack.production.js",
     "lint": "ng lint",
     "pree2e": "webdriver-manager update --standalone false --gecko false --quiet",
-    "test": "jest",
+    "test": "jest --coverage",
     "test:watch": "jest --watch",
     "cypress": "cypress run",
     "cypress-headless": "start-server-and-test start http-get://localhost:9000 cypress"
   "jest": {
     "preset": "jest-preset-angular",
     "collectCoverageFrom": [
-      "src/app/ng2/pages/composition/**/*.ts"
+      "<rootDir>/src/app/ng2/**/*.ts"
+    ],
+    "coverageDirectory": "<rootDir>/target/code-coverage/",
+    "coverageReporters": [
+      "lcov"
     ],
     "setupTestFrameworkScriptFile": "<rootDir>/src/jest/setup-jest.ts",
     "transformIgnorePatterns": [
-      "node_modules/(?!onap-ui-angular)"
+      "<rootDir>/node_modules/(?!onap-ui-angular)"
     ],
     "verbose": true,
     "roots": [
index f08fb64..f8d4e3f 100644 (file)
         <version>1.7.0-SNAPSHOT</version>
     </parent>
 
+    <properties>
+        <sonar.nodejs.executable>${project.basedir}/node/node</sonar.nodejs.executable>
+        <sonar.sources>src/app/ng2</sonar.sources>
+    </properties>
+
     <build>
         <plugins>
             <plugin>
@@ -26,7 +31,6 @@
                             <goal>clean</goal>
                         </goals>
                         <configuration>
-
                             <filesets>
                                 <fileset>
                                     <directory>${project.parent.basedir}/catalog-fe/src/main/webapp</directory>
@@ -72,7 +76,7 @@
                 <groupId>com.github.eirslett</groupId>
                 <artifactId>frontend-maven-plugin</artifactId>
                 <configuration>
-                    <installDirectory>${project.parent.basedir}</installDirectory>
+                    <installDirectory>${project.basedir}</installDirectory>
                 </configuration>
 
                 <executions>
                             <arguments>run build:prod</arguments>
                         </configuration>
                     </execution>
+
+                    <execution>
+                        <id>npm_test</id>
+                        <goals>
+                            <goal>npm</goal>
+                        </goals>
+                        <phase>test</phase>
+                        <configuration>
+                            <arguments>test</arguments>
+                            <skip>${skipTests}</skip>
+                        </configuration>
+                    </execution>
                 </executions>
             </plugin>
             <plugin>
index 3a660c1..7234c12 100644 (file)
@@ -23,7 +23,7 @@ describe('palette component', () => {
             providers: [CompositionPaletteService,
                 {provide: HttpClient, useValue: httpServiceMock},
                 {provide: SdcConfigToken, useValue: sdcConfigToken},
-                               {provide: WorkspaceService, useValue{}}
+                {provide: WorkspaceService, useValue: {}}
             ]
         });
 
index 81d527b..af1d58c 100644 (file)
@@ -5,7 +5,6 @@
     "emitDecoratorMetadata": true,
     "experimentalDecorators": true,
     "allowJs": true,
-    "mapRoot": "./",
     "module": "commonjs",
     "moduleResolution": "node",
     "outDir": "../dist/out-tsc",
       "es6",
       "dom"
     ],
-    "paths": {
-      "@angular/*": [
-        "../node_modules/@angular/*"
-     ]
-    },
     "sourceMap": true,
     "target": "es5",
     "typeRoots": [
diff --git a/pom.xml b/pom.xml
index 5fe1cb5..1a8c9b8 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -131,13 +131,16 @@ Modifications copyright (c) 2018-2019 Nokia
     <sdc-tosca-parser.version>1.6.5</sdc-tosca-parser.version>
 
     <!-- sonar -->
+    <sonar.projectVersion>${project.version}</sonar.projectVersion>
+    <sonar.nodejs.executable>${project.basedir}/node/node</sonar.nodejs.executable>
+    <sonar.surefire.reportsPath>${project.build.directory}/surefire-reports</sonar.surefire.reportsPath>
+    <sonar.javascript.lcov.reportPaths>${project.build.directory}/code-coverage/lcov.info</sonar.javascript.lcov.reportPaths>
     <sonar.coverage.jacoco.xmlReportPaths>
       ${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml
     </sonar.coverage.jacoco.xmlReportPaths>
     <sonar.sourceEncoding>${project.build.sourceEncoding}</sonar.sourceEncoding>
     <sonar.projectBaseDir>${project.basedir}</sonar.projectBaseDir>
-    <sonar.branch>${project.version}</sonar.branch>
-
+    <sonar.coverage.exclusions>pom.xml,src/test</sonar.coverage.exclusions>
     <!--cassandra -->
     <cassandra.driver.version>3.6.0</cassandra.driver.version>
     <libthrift.version>0.12.0</libthrift.version>