diff --git a/jest.config.ts b/jest.config.ts index b7aa9c1..0b7240b 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -2,7 +2,6 @@ export default { displayName: 'onecx-chat-ui', preset: './jest.preset.js', setupFilesAfterEnv: ['/src/test-setup.ts'], - coverageDirectory: './coverage/onecx-chat-ui', transform: { '^.+\\.(ts|mjs|js|html)$': [ 'jest-preset-angular', @@ -25,4 +24,9 @@ export default { '/src/**/*(*.)@(spec|test).[jt]s?(x)', ], testEnvironment: '@happy-dom/jest-environment', + collectCoverage: true, + coverageDirectory: './reports/coverage/', + coveragePathIgnorePatterns: ['src/app/shared/generated'], + coverageReporters: ['clover', 'json', 'lcov', 'text', 'text-summary', 'html'], + testResultsProcessor: 'jest-sonar-reporter', }; diff --git a/package-lock.json b/package-lock.json index 628fe06..9fa4728 100644 --- a/package-lock.json +++ b/package-lock.json @@ -51,6 +51,7 @@ "primeicons": "^7.0.0", "primeng": "^17.18.8", "rxjs": "~7.8.0", + "sonarqube-scanner": "^4.2.6", "zod": "^3.22.1", "zone.js": "~0.14.3" }, @@ -11374,6 +11375,12 @@ "node": ">= 0.4" } }, + "node_modules/b4a": { + "version": "1.6.7", + "resolved": "http://localhost:4873/b4a/-/b4a-1.6.7.tgz", + "integrity": "sha512-OnAYlL5b7LEkALw87fUVafQw5rVR9RjwGd4KUwNQ6DrrNmaVaUCgLipfVlzrPQ4tWOR9P0IXGNOx50jYCCdSJg==", + "license": "Apache-2.0" + }, "node_modules/babel-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz", @@ -11711,6 +11718,13 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "license": "MIT" }, + "node_modules/bare-events": { + "version": "2.5.3", + "resolved": "http://localhost:4873/bare-events/-/bare-events-2.5.3.tgz", + "integrity": "sha512-pCO3aoRJ0MBiRMu8B7vUga0qL3L7gO1+SW7ku6qlSsMLwuhaawnuvZDyzJY/kyC63Un0XAB0OPUcfF1eTO/V+Q==", + "license": "Apache-2.0", + "optional": true + }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -14593,6 +14607,12 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "license": "MIT" }, + "node_modules/fast-fifo": { + "version": "1.3.2", + "resolved": "http://localhost:4873/fast-fifo/-/fast-fifo-1.3.2.tgz", + "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==", + "license": "MIT" + }, "node_modules/fast-glob": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", @@ -15629,6 +15649,15 @@ "safe-buffer": "~5.1.0" } }, + "node_modules/hpagent": { + "version": "1.2.0", + "resolved": "http://localhost:4873/hpagent/-/hpagent-1.2.0.tgz", + "integrity": "sha512-A91dYTeIB6NoXG+PxTQpCCDDnfHsW9kc06Lvpu1TEe9gnd6ZFeiBoRO9JvzEv6xK7EX97/dUE8g/vBMTqTS3CA==", + "license": "MIT", + "engines": { + "node": ">=14" + } + }, "node_modules/html-encoding-sniffer": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz", @@ -17203,6 +17232,18 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/jest-sonar-reporter": { + "version": "2.0.0", + "resolved": "http://localhost:4873/jest-sonar-reporter/-/jest-sonar-reporter-2.0.0.tgz", + "integrity": "sha512-ZervDCgEX5gdUbdtWsjdipLN3bKJwpxbvhkYNXTAYvAckCihobSLr9OT/IuyNIRT1EZMDDwR6DroWtrq+IL64w==", + "license": "MIT", + "dependencies": { + "xml": "^1.0.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/jest-util": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", @@ -21027,6 +21068,15 @@ "node": ">= 6" } }, + "node_modules/properties-file": { + "version": "3.5.4", + "resolved": "http://localhost:4873/properties-file/-/properties-file-3.5.4.tgz", + "integrity": "sha512-OGQPWZ4j9ENDKBl+wUHqNtzayGF5sLlVcmjcqEMUUHeCbUSggDndii+kjcBDPj3GQvqYB9sUEc4siX36wx4glw==", + "license": "MIT", + "engines": { + "node": "*" + } + }, "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -21175,6 +21225,12 @@ ], "license": "MIT" }, + "node_modules/queue-tick": { + "version": "1.0.1", + "resolved": "http://localhost:4873/queue-tick/-/queue-tick-1.0.1.tgz", + "integrity": "sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==", + "license": "MIT" + }, "node_modules/rambda": { "version": "9.4.1", "resolved": "https://registry.npmjs.org/rambda/-/rambda-9.4.1.tgz", @@ -22225,6 +22281,15 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/slugify": { + "version": "1.6.6", + "resolved": "http://localhost:4873/slugify/-/slugify-1.6.6.tgz", + "integrity": "sha512-h+z7HKHYXj6wJU+AnS/+IH8Uh9fdcX1Lrhg1/VMdf9PwoBQXFcXiAdsy2tSK0P6gKwJLXp02r90ahUCqHk9rrw==", + "license": "MIT", + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/smart-buffer": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", @@ -22277,6 +22342,119 @@ "node": ">= 14" } }, + "node_modules/sonarqube-scanner": { + "version": "4.2.6", + "resolved": "http://localhost:4873/sonarqube-scanner/-/sonarqube-scanner-4.2.6.tgz", + "integrity": "sha512-UK6mCGr290bKo6yML9fYOyLrvPkU7vmnYPLvTWVUIQpxiTbkPm4bmPvhcIcSBBH0dN+cKObcrne1E8zuEYl95g==", + "license": "LGPL-3.0-only", + "dependencies": { + "adm-zip": "0.5.12", + "axios": "1.7.7", + "commander": "12.0.0", + "fs-extra": "11.2.0", + "hpagent": "1.2.0", + "jest-sonar-reporter": "2.0.0", + "node-forge": "^1.3.1", + "properties-file": "3.5.4", + "proxy-from-env": "^1.1.0", + "semver": "7.6.0", + "slugify": "1.6.6", + "tar-stream": "3.1.7" + }, + "bin": { + "sonar-scanner": "bin/sonar-scanner" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/sonarqube-scanner/node_modules/adm-zip": { + "version": "0.5.12", + "resolved": "http://localhost:4873/adm-zip/-/adm-zip-0.5.12.tgz", + "integrity": "sha512-6TVU49mK6KZb4qG6xWaaM4C7sA/sgUMLy/JYMOzkcp3BvVLpW0fXDFQiIzAuxFCt/2+xD7fNIiPFAoLZPhVNLQ==", + "license": "MIT", + "engines": { + "node": ">=6.0" + } + }, + "node_modules/sonarqube-scanner/node_modules/axios": { + "version": "1.7.7", + "resolved": "http://localhost:4873/axios/-/axios-1.7.7.tgz", + "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/sonarqube-scanner/node_modules/commander": { + "version": "12.0.0", + "resolved": "http://localhost:4873/commander/-/commander-12.0.0.tgz", + "integrity": "sha512-MwVNWlYjDTtOjX5PiD7o5pK0UrFU/OYgcJfjjK4RaHZETNtjJqrZa9Y9ds88+A+f+d5lv+561eZ+yCKoS3gbAA==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/sonarqube-scanner/node_modules/fs-extra": { + "version": "11.2.0", + "resolved": "http://localhost:4873/fs-extra/-/fs-extra-11.2.0.tgz", + "integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==", + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, + "node_modules/sonarqube-scanner/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "http://localhost:4873/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "license": "ISC", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/sonarqube-scanner/node_modules/semver": { + "version": "7.6.0", + "resolved": "http://localhost:4873/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "license": "ISC", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/sonarqube-scanner/node_modules/tar-stream": { + "version": "3.1.7", + "resolved": "http://localhost:4873/tar-stream/-/tar-stream-3.1.7.tgz", + "integrity": "sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==", + "license": "MIT", + "dependencies": { + "b4a": "^1.6.4", + "fast-fifo": "^1.2.0", + "streamx": "^2.15.0" + } + }, + "node_modules/sonarqube-scanner/node_modules/yallist": { + "version": "4.0.0", + "resolved": "http://localhost:4873/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "license": "ISC" + }, "node_modules/sorted-array-functions": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/sorted-array-functions/-/sorted-array-functions-1.3.0.tgz", @@ -22519,6 +22697,20 @@ "node": ">= 4.0.0" } }, + "node_modules/streamx": { + "version": "2.21.1", + "resolved": "http://localhost:4873/streamx/-/streamx-2.21.1.tgz", + "integrity": "sha512-PhP9wUnFLa+91CPy3N6tiQsK+gnYyUNuk15S3YG/zjYE7RuPeCjJngqnzpC31ow0lzBHQ+QGO4cNJnd0djYUsw==", + "license": "MIT", + "dependencies": { + "fast-fifo": "^1.3.2", + "queue-tick": "^1.0.1", + "text-decoder": "^1.1.0" + }, + "optionalDependencies": { + "bare-events": "^2.2.0" + } + }, "node_modules/strict-event-emitter": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.5.1.tgz", @@ -23074,6 +23266,15 @@ "node": "*" } }, + "node_modules/text-decoder": { + "version": "1.2.3", + "resolved": "http://localhost:4873/text-decoder/-/text-decoder-1.2.3.tgz", + "integrity": "sha512-3/o9z3X0X0fTupwsYvR03pJ/DjWuqqrfwBgTQzdWDiQSm9KitAyz/9WqsT2JQW7KV2m+bC2ol/zqpW37NHxLaA==", + "license": "Apache-2.0", + "dependencies": { + "b4a": "^1.6.4" + } + }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -24808,6 +25009,12 @@ } } }, + "node_modules/xml": { + "version": "1.0.1", + "resolved": "http://localhost:4873/xml/-/xml-1.0.1.tgz", + "integrity": "sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==", + "license": "MIT" + }, "node_modules/xml-name-validator": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz", diff --git a/package.json b/package.json index 7d1df1d..09cd398 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "lint": "nx lint", "lint:fix": "nx lint --fix", "test": "nx test", - "test:ci": "nx test --watch=false --browsers=ChromeHeadless --code-coverage" + "test:ci": "nx test --watch=false --browsers=ChromeHeadless --coverage" }, "private": true, "dependencies": { @@ -56,6 +56,7 @@ "primeicons": "^7.0.0", "primeng": "^17.18.8", "rxjs": "~7.8.0", + "sonarqube-scanner": "^4.2.6", "zod": "^3.22.1", "zone.js": "~0.14.3" }, diff --git a/sonar-local-project.properties b/sonar-local-project.properties new file mode 100644 index 0000000..11bc109 --- /dev/null +++ b/sonar-local-project.properties @@ -0,0 +1,29 @@ +# sonar.verbose=true +# run locally: +# docker run -p 9000:9000 sonarqube:lts +# user/pwd: admin/admin +# generate project token! +# start: +# npm run sonar +# +sonar.host.url=http://localhost:9000 +sonar.login= +sonar.verbose=true +# +sonar.organization=onecx +sonar.projectKey=onecx-chat-ui +sonar.projectName=onecx-chat-ui +# +sonar.scm.disabled=true +sonar.sources=src +sonar.sourceEncoding=UTF-8 +# +sonar.javascript.coveragePlugin=lcov +sonar.javascript.lcov.reportPaths=./reports/coverage/lcov.info +sonar.testExecutionReportPaths=./reports/sonarqube_report.xml +sonar.working.directory=./reports/.scannerwork +sonar.coverage.exclusions=*.ts,*.js,*.json,*.properties,src/*.ts,helm/**/*,src/*.ico,src/**/*.module.ts,src/**/*.main.ts,src/**/*.bootstrap.ts,src/environments/*,src/assets/**/*,src/app/*,src/app/shared/generated/**/* +sonar.exclusions=src/app/shared/generated/**/* +#sonar.cpd.exclusions= +#sonar.tests=src/app +sonar.test.inclusions=src/app/**/*.spec.ts \ No newline at end of file