Pablissimo / SonarTsPlugin

SonarQube plugin for TypeScript files
MIT License
185 stars 106 forks source link

No valid rules and sonar can not find a test files. #184

Closed Aziaev closed 6 years ago

Aziaev commented 6 years ago

I have an issue with analyzing code in TS popject. Here is my sonar propreties:

sonar.projectName=foobar-pl
sonar.projectKey= foobar-pl
sonar.projectVersion=1.0.0
sonar.sources=app
sonar.sourceEncoding=UTF-8
sonar.exclusions=container.tsx,**/initial-state.ts,**/interfaces.tsx,**/processes*.tsx,**/container.tsx,constants.ts,rm/helpers,rm/index,schemas.ts,**/styled.tsx,**/*.scss.d.ts,**/validation-schema.ts,**/*.view.tsx
sonar.ts.coverage.lcovReportPath=coverage/lcov.info
sonar.ts.tslint.configPath=tslint.json
sonar.ts.tslint.projectPath=app
sonar.ts.tslint.enabled=true
sonar.ts.tslint.path=node_modules/tslint/dist/tslint
sonar.ts.tslint.rulesDir=node_modules/tslint-eslint-rules/dist/rules

tsconfig:

  "compilerOptions": {
    "outDir": "./build/",
    "baseUrl": ".",
    "target": "es5",
    "noImplicitAny": false,
    "sourceMap": true,
    "jsx": "react",
    "module": "commonjs",
    "paths": {
      "modules/*": [ "./app/modules/*" ],
      "shared/*": [ "./app/shared/*" ]
    }
  },
  "files": [
    "./node_modules/foo-bar-lib/typings/globals/react/index.d.ts",
   "./node_modules/foo-bar-lib/typings/globals/react-dom/index.d.ts",
    "./node_modules/foo-bar-lib/typings/globals/EventListener/index.d.ts",
    "./node_modules/foo-bar-lib/typings/globals/jquery/index.d.ts",
    "./node_modules/foo-bar-lib/typings/globals/es6-promise/index.d.ts",
    "./node_modules/foo-bar-lib/typings/globals/moment/index.d.ts",
    "./node_modules/foo-bar-lib/typings/globals/redux/index.d.ts",
    "./node_modules/foo-bar-lib/typings/modules/axios/index.d.ts",
    "./node_modules/foo-bar-lib/typings/globals/classnames/index.d.ts",
    "./node_modules/foo-bar-lib/typings/globals/moment-node/index.d.ts",
    "./node_modules/foo-bar-lib/typings/globals/assertion-error/index.d.ts",
    "./node_modules/@types/jest/index.d.ts",
    "./declarations.d.ts",
    "./app/modules/rm/index-foo.tsx",
    "./app/modules/rm/index-create-bar.tsx",
    "./node_modules/foo-bar-lib-forms/types.d.ts"
  ],
  "include": [ "app/**/*" ],
  "exclude": [
    "node_modules"
  ]
}

tslint.cfg

    "extends": "tslint:recommended",
    "rules": {
        "curly": true,
        "eofline": false,
        "align": [true, "parameters"],
        "class-name": true,
        "indent": [true, "spaces"],
        "max-line-length": [true, 150],
        "no-consecutive-blank-lines": true,
        "no-trailing-whitespace": true,
        "no-duplicate-variable": true,
        "no-var-keyword": true,
        "no-empty": true,
        "no-unused-expression": true,
        "no-unused-variable": true,
        "no-use-before-declare": true,
        "no-var-requires": true,
        "no-require-imports": true,
        "one-line": [true,
            "check-else",
            "check-whitespace",
            "check-open-brace"],
        "quotemark": [true,
            "single",
            "avoid-escape"],
        "semicolon": [true, "always"],
        "typedef-whitespace": [true, {
            "call-signature": "nospace",
            "index-signature": "nospace",
            "parameter": "nospace",
            "property-declaration": "nospace",
            "variable-declaration": "nospace"
        }],
        "whitespace": [true,
            "check-branch",
            "check-decl",
            "check-operator",
            "check-separator",
            "check-type"],

        "interface-name": {
            "options": [true, "never-prefix"]
        },
        "object-literal-sort-keys": false
    },
    "jsRules": {
        "object-literal-sort-keys": false
    },
    "env": {
        "browser": true,
        "node": true,
        "jest": true
    }
}

My log:

11:41:28.782 INFO  - Sensor TypeScript Sensor
11:41:28.825 INFO  - 0/0 source files have been analyzed
11:41:32.742 ERROR - No valid rules have been specified
11:41:32.924 ERROR - Failed to find a source file matching path /u01/jenkins_slave/workspace/FB/foobar-pl-codecoverage/app/modules/dataSearch/__tests__/includes-query.test.ts in program created with /u01/jenkins_slave/workspace/FB/foobar-pl-codecoverage/tsconfig.json
a few same errors
11:41:35.563 INFO  - Sensor TypeScript Sensor (done) | time=6781ms
11:41:35.563 INFO  - Sensor TypeScript LCOV Coverage Sensor
11:41:35.564 INFO  - Sensor TypeScript LCOV Coverage Sensor (done) | time=0ms

My coverage in SonarQube iz zero. I have spent a week on this

nixel2007 commented 6 years ago

Are you sure, you use this ts plugin and not the official one?

Aziaev commented 6 years ago

Yes, I'm sure. After adding "include": [ "app/**/*" ], in tsconfig, I have no issues with "Failed to find a source file matching path...". But still have issue with "No valid rules have been specified"

Aziaev commented 6 years ago

No valid rules have been specified - I have this issue now

Aziaev commented 6 years ago

No valid rules have been specified - this issu is resolved. But I still have 0% of coverage in SonarQube. My build log:

Tests:       154 passed, 154 total
Snapshots:   0 total
Time:        16.797s
Ran all test suites.
SonarQube Runner 2.4
Java 1.8.0_72 Oracle Corporation (64-bit)
Linux 2.6.32-696.1.1.el6.x86_64 amd64
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: blalbalblal/conf/sonar-runner.properties
INFO: Project configuration file: /b007/jenkins_server/workspace/FB/foo-bar-pl-codecoverage/sonar-project.properties
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: /b007/jenkins_server/workspace/FB/foo-bar-pl-codecoverage/.sonar
INFO: SonarQube Server 5.6.6
09:49:14.522 INFO  - Load global repositories
09:49:15.318 INFO  - Load global repositories (done) | time=797ms
09:49:15.459 INFO  - Server id: 1364ced59849de1
09:49:15.504 INFO  - User cache: /b007/jenkins_server/.sonar/cache
09:49:16.874 INFO  - Load plugins index
09:49:16.880 INFO  - Load plugins index (done) | time=6ms
09:49:26.739 INFO  - governance licensed to Sberbank, PRODUCTION [Expiration: 2018-12-06, Server: 1364ced59849de1]
09:49:27.121 INFO  - Process project properties
09:49:27.470 INFO  - Load project repositories
09:49:28.140 INFO  - Load project repositories (done) | time=670ms
09:49:28.174 INFO  - Execute project builders
09:49:28.190 INFO  - Execute project builders (done) | time=16ms
09:49:28.276 INFO  - Load quality profiles
09:49:28.522 INFO  - Load quality profiles (done) | time=246ms
09:49:28.545 INFO  - Load active rules
09:49:34.949 INFO  - Load active rules (done) | time=6404ms
09:49:35.022 INFO  - Publish mode
09:49:35.024 INFO  - -------------  Scan FB-foo-bar-pl
09:49:38.680 INFO  - Load server rules
09:49:39.156 INFO  - Load server rules (done) | time=475ms
09:49:39.685 INFO  - Base dir: /b007/jenkins_server/workspace/FB/foo-bar-pl-codecoverage
09:49:39.685 INFO  - Working dir: /b007/jenkins_server/workspace/FB/foo-bar-pl-codecoverage/.sonar
09:49:39.693 INFO  - Source paths: app
09:49:39.693 INFO  - Source encoding: UTF-8, default locale: en_US
09:49:39.693 INFO  - Index files
09:49:39.703 INFO  - Excluded sources: 
09:49:39.703 INFO  -   **/*.test.ts
09:49:39.703 INFO  -   container.tsx
09:49:39.703 INFO  -   **/initial-state.ts
09:49:39.703 INFO  -   **/interfaces.tsx
09:49:39.703 INFO  -   **/processes*.tsx
09:49:39.703 INFO  -   **/container.tsx
09:49:39.703 INFO  -   constants.ts
09:49:39.703 INFO  -   rm/helpers
09:49:39.703 INFO  -   rm/index
09:49:39.703 INFO  -   schemas.ts
09:49:39.703 INFO  -   **/styled.tsx
09:49:39.703 INFO  -   **/*.scss.d.ts
09:49:39.703 INFO  -   **/validation-schema.ts
09:49:39.703 INFO  -   **/*.view.tsx
09:49:39.833 INFO  - ============== getFileSuffixes() called ====================
09:49:39.833 INFO  - conf
09:49:39.833 INFO  - esql
09:49:39.833 INFO  - subflow
09:49:39.833 INFO  - msgflow
09:49:39.834 INFO  - xsd
09:49:39.834 INFO  - mqsc
09:49:39.834 INFO  - project
09:49:39.834 INFO  - bpml
09:49:39.834 INFO  - map
09:49:39.834 INFO  - wsdl
09:49:39.834 INFO  - =========================================================
===================== handling files ===================================
conf
esql
subflow
msgflow
xsd
mqsc
project
bpml
map
wsdl
========================================================
09:49:42.434 INFO  - 34 files indexed
09:49:42.435 INFO  - 59 files ignored because of inclusion/exclusion patterns
09:49:42.441 INFO  - Quality profile for ts: TsLint
09:49:50.638 INFO  - Sensor Lines Sensor
09:49:50.701 INFO  - Sensor Lines Sensor (done) | time=63ms
09:49:50.703 INFO  - Sensor au.com.bettercodingtools.sonar.messagebrokersonarplugin.entry.MessageBrokerSensor
09:49:51.563 WARN  - MessageBrokerProjectHelper getDiagramOutputPath called
09:49:51.563 WARN  - DIAGRAM_OUTPUT_KEY = null
09:49:51.568 WARN  - =======================================================================
09:49:51.568 WARN  - outputPath=null
09:49:51.568 INFO  - Sensor au.com.bettercodingtools.sonar.messagebrokersonarplugin.entry.MessageBrokerSensor (done) | time=865ms
09:49:51.568 INFO  - Sensor SCM Sensor
09:49:51.569 INFO  - SCM Publisher is disabled
09:49:51.569 INFO  - Sensor SCM Sensor (done) | time=1ms
09:49:51.569 INFO  - Sensor Embedded CSS Analyzer Sensor
09:49:52.863 INFO  - 0 source files to be analyzed
09:49:52.882 INFO  - Sensor Embedded CSS Analyzer Sensor (done) | time=1313ms
09:49:52.882 INFO  - Sensor C# Unit Test Results Import
09:49:52.884 INFO  - Sensor C# Unit Test Results Import (done) | time=2ms
09:49:52.884 INFO  - Sensor SonarJavaXmlFileSensor
09:49:52.885 INFO  - Sensor SonarJavaXmlFileSensor (done) | time=1ms
09:49:52.885 INFO  - Sensor TypeScript Sensor
09:49:52.894 INFO  - 0/0 source files have been analyzed
09:50:02.701 INFO  - Sensor TypeScript Sensor (done) | time=9816ms
09:50:02.701 INFO  - Sensor TypeScript LCOV Coverage Sensor
09:50:02.701 INFO  - Sensor TypeScript LCOV Coverage Sensor (done) | time=0ms
09:50:02.702 INFO  - Sensor Visual Basic .NET Unit Test Results Import
09:50:02.702 INFO  - Sensor Visual Basic .NET Unit Test Results Import (done) | time=0ms
09:50:02.702 INFO  - Sensor CxxXunitSensor
09:50:02.705 INFO  - Undefined report path value for key 'sonar.cxx.xunit.reportPath'
09:50:02.705 INFO  - Sensor CxxXunitSensor (done) | time=3ms
09:50:02.705 INFO  - Sensor Unit Test Results Import
09:50:02.705 INFO  - Sensor Unit Test Results Import (done) | time=0ms
09:50:02.706 INFO  - Sensor Zero Coverage Sensor
09:50:02.879 INFO  - Sensor Zero Coverage Sensor (done) | time=173ms
09:50:02.891 INFO  - Sensor Code Colorizer Sensor
09:50:02.892 INFO  - Sensor Code Colorizer Sensor (done) | time=1ms
09:50:02.893 INFO  - Sensor CPD Block Indexer
09:50:02.899 INFO  - DefaultCpdBlockIndexer is used for ts
09:50:02.899 INFO  - Sensor CPD Block Indexer (done) | time=6ms
09:50:02.948 INFO  - Calculating CPD for 25 files
09:50:03.049 INFO  - CPD calculation finished
09:50:03.459 INFO  - Analysis report generated in 375ms, dir size=156 KB
09:50:03.627 INFO  - Analysis reports compressed in 168ms, zip size=87 KB
09:50:03.861 INFO  - Analysis report uploaded in 233ms
09:50:03.862 INFO  - ANALYSIS SUCCESSFUL, you can browse http://zonar-node-001.blablalba:9000/dashboard/index/foo-bar-pl
09:50:03.862 INFO  - Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
Total time: 55.672s
Final Memory: 47M/562M
INFO: ------------------------------------------------------------------------
Notifying upstream projects of job completion
Finished: SUCCESS
Aziaev commented 6 years ago

I have had an issue in sonar-project.properties my report path was: sonar.ts.lcov.reportPath=coverage/lcov.info

After changing it to sonar.typescript.lcov.reportPaths=coverage/lcov.info Issue was resolved