Pablissimo / SonarTsPlugin

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

Problem analyzing typescript files #180

Open blearner opened 6 years ago

blearner commented 6 years ago

Hi Team,

I started working on angular typescript project to setup with SonarTS on my mac. Seems after running the sonar scanner i get the error below error for all the Typescript files.

blearner-mbp:SampleApp blearner$ /Users/blearner/Documents/sonar-scanner/bin/sonar-scanner -X 15:16:57.248 INFO: Scanner configuration file: /Users/blearner/Documents/sonar-scanner/conf/sonar-scanner.properties 15:16:57.252 INFO: Project root configuration file: /Users/blearner/Documents/Sample/SampleApp/sonar-project.properties 15:16:57.266 INFO: SonarQube Scanner 3.0.3.778 15:16:57.266 INFO: Java 1.8.0_121 Oracle Corporation (64-bit) 15:16:57.266 INFO: Mac OS X 10.12.6 x86_64 15:16:57.367 DEBUG: keyStore is : 15:16:57.367 DEBUG: keyStore type is : jks 15:16:57.367 DEBUG: keyStore provider is : 15:16:57.367 DEBUG: init keystore 15:16:57.367 DEBUG: init keymanager of type SunX509 15:16:57.438 INFO: User cache: /Users/blearner/.sonar/cache 15:16:57.438 DEBUG: Extract sonar-scanner-api-batch in temp... 15:16:57.445 DEBUG: Get bootstrap index... 15:16:57.445 DEBUG: Download: http://localhost:9000/batch/index 15:16:57.482 DEBUG: Get bootstrap completed 15:16:57.483 DEBUG: Create isolated classloader... 15:16:57.490 DEBUG: Start temp cleaning... 15:16:57.498 DEBUG: Temp cleaning done 15:16:57.498 DEBUG: Execution getVersion 15:16:57.501 DEBUG: Execution start 15:16:57.628 DEBUG: Publish global mode 15:16:57.710 INFO: Load global settings 15:16:57.742 DEBUG: GET 200 http://localhost:9000/api/settings/values.protobuf | time=27ms 15:16:57.754 INFO: Load global settings (done) | time=45ms 15:16:57.771 INFO: User cache: /Users/blearner/.sonar/cache 15:16:57.948 INFO: Load plugins index 15:16:57.951 DEBUG: GET 200 http://localhost:9000/deploy/plugins/index.txt | time=3ms 15:16:57.952 INFO: Load plugins index (done) | time=4ms 15:16:57.953 DEBUG: Load plugins 15:16:57.963 DEBUG: Load plugins (done) | time=10ms 15:16:57.970 DEBUG: API compatibility mode is enabled on plugin Git [scmgit] (built with API lower than 5.2) 15:16:57.971 DEBUG: API compatibility mode is enabled on plugin SVN [scmsvn] (built with API lower than 5.2) 15:16:58.049 DEBUG: Plugins: 15:16:58.049 DEBUG: C# 5.10.1.1411 (csharp) 15:16:58.049 DEBUG: SonarPython 1.8.0.1496 (python) 15:16:58.049 DEBUG: SonarJava 4.12.0.11033 (java) 15:16:58.049 DEBUG: Flex 2.3 (flex) 15:16:58.049 DEBUG: Git 1.2 (scmgit) 15:16:58.049 DEBUG: SonarXML 1.4.3.1027 (xml) 15:16:58.049 DEBUG: SonarPHP 2.10.0.2087 (php) 15:16:58.049 DEBUG: TypeScript 1.2.0-rc1 (typescript) 15:16:58.050 DEBUG: SVN 1.5.0.715 (scmsvn) 15:16:58.050 DEBUG: SonarJS 3.1.1.5128 (javascript) 15:16:58.060 DEBUG: Execution getVersion 15:16:58.060 INFO: SonarQube server 6.5.0 15:16:58.060 INFO: Default locale: "en_US", source code encoding: "UTF-8" 15:16:58.061 DEBUG: Work directory: /Users/blearner/Documents/Sample/SampleApp/.scannerwork 15:16:58.061 DEBUG: Execution getVersion 15:16:58.061 DEBUG: Execution execute 15:16:58.363 INFO: Process project properties 15:16:58.367 DEBUG: Process project properties (done) | time=5ms 15:16:58.385 INFO: Load project repositories 15:16:58.602 DEBUG: GET 200 http://localhost:9000/batch/project.protobuf?key=Sample | time=217ms 15:16:58.647 INFO: Load project repositories (done) | time=263ms 15:16:58.719 DEBUG: Available languages: 15:16:58.719 DEBUG: C# => "cs" 15:16:58.719 DEBUG: Python => "py" 15:16:58.719 DEBUG: Java => "java" 15:16:58.719 DEBUG: Flex => "flex" 15:16:58.719 DEBUG: XML => "xml" 15:16:58.719 DEBUG: PHP => "php" 15:16:58.719 DEBUG: TypeScript => "ts" 15:16:58.719 DEBUG: JavaScript => "js" 15:16:58.724 INFO: Load quality profiles 15:16:58.843 DEBUG: GET 200 http://localhost:9000/api/qualityprofiles/search.protobuf?projectKey=Sample | time=118ms 15:16:58.848 INFO: Load quality profiles (done) | time=124ms 15:16:58.851 INFO: Load active rules 15:16:58.906 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AV8Ch-si5QTOVkPZXW-Z&p=1&ps=500 | time=53ms 15:16:59.016 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AV8Ch-vf5QTOVkPZXXFY&p=1&ps=500 | time=77ms 15:16:59.064 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AV8Ch-xE5QTOVkPZXXKz&p=1&ps=500 | time=32ms 15:16:59.080 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AV8Ch-xo5QTOVkPZXXLy&p=1&ps=500 | time=11ms 15:16:59.103 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AV8Ch-125QTOVkPZXXUv&p=1&ps=500 | time=23ms 15:16:59.133 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AV8Ch-yy5QTOVkPZXXN2&p=1&ps=500 | time=27ms 15:16:59.152 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AV8Ch-yE5QTOVkPZXXMV&p=1&ps=500 | time=18ms 15:16:59.184 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AV8rQUOm2gOvbMcJNMwC&p=1&ps=500 | time=30ms 15:16:59.202 INFO: Load active rules (done) | time=351ms 15:16:59.204 INFO: Load metrics repository 15:16:59.215 DEBUG: GET 200 http://localhost:9000/api/metrics/search?f=name,description,direction,qualitative,custom&ps=500&p=1 | time=11ms 15:16:59.250 INFO: Load metrics repository (done) | time=45ms 15:16:59.256 DEBUG: SCM Step is disabled by configuration 15:16:59.257 INFO: Publish mode 15:16:59.257 INFO: Project key: Sample 15:16:59.257 DEBUG: Start recursive analysis of project modules 15:16:59.257 INFO: ------------- Scan Sample 15:16:59.341 INFO: Load server rules 15:16:59.422 DEBUG: GET 200 http://localhost:9000/api/rules/list.protobuf | time=81ms 15:16:59.434 INFO: Load server rules (done) | time=93ms 15:16:59.497 DEBUG: Declared extensions of language C# were converted to sonar.lang.patterns.cs : /*.cs 15:16:59.497 DEBUG: Declared extensions of language Python were converted to sonar.lang.patterns.py : */.py 15:16:59.497 DEBUG: Declared extensions of language Java were converted to sonar.lang.patterns.java : /*.java,/*.jav 15:16:59.497 DEBUG: Declared extensions of language Flex were converted to sonar.lang.patterns.flex : */.as 15:16:59.497 DEBUG: Declared extensions of language XML were converted to sonar.lang.patterns.xml : /*.xml,/*.xsd,*/.xsl 15:16:59.498 DEBUG: Declared extensions of language PHP were converted to sonar.lang.patterns.php : /*.php,/*.php3,*/.php4,/*.php5,/*.phtml,*/.inc 15:16:59.498 DEBUG: Declared extensions of language TypeScript were converted to sonar.lang.patterns.ts : /*.ts,/*.tsx 15:16:59.498 DEBUG: Declared extensions of language JavaScript were converted to sonar.lang.patterns.js : */.js,/*.jsx,*/.vue 15:16:59.532 DEBUG: Initializers : 15:16:59.532 INFO: Base dir: /Users/blearner/Documents/Sample/SampleApp 15:16:59.532 INFO: Working dir: /Users/blearner/Documents/Sample/SampleApp/.scannerwork 15:16:59.533 INFO: Source paths: src 15:16:59.533 INFO: Source encoding: UTF-8, default locale: en_US 15:16:59.534 INFO: Index files 15:16:59.547 DEBUG: 'src/app/app.component.css' indexed with language 'null' 15:16:59.548 DEBUG: 'src/environments/environment.ts' indexed with language 'ts' 15:16:59.548 DEBUG: 'src/app/app.component.html' indexed with language 'null' 15:16:59.548 DEBUG: 'src/app/app.component.spec.ts' indexed with language 'ts' 15:16:59.548 DEBUG: 'src/app/app.module.ts' indexed with language 'ts' 15:16:59.548 DEBUG: 'src/main.ts' indexed with language 'ts' 15:16:59.548 DEBUG: 'src/polyfills.ts' indexed with language 'ts' 15:16:59.548 DEBUG: 'src/app/app.component.ts' indexed with language 'ts' 15:16:59.549 DEBUG: 'src/styles.css' indexed with language 'null' 15:16:59.549 DEBUG: 'src/tsconfig.app.json' indexed with language 'null' 15:16:59.549 DEBUG: 'src/tsconfig.spec.json' indexed with language 'null' 15:16:59.549 DEBUG: 'src/environments/environment.prod.ts' indexed with language 'ts' 15:16:59.549 DEBUG: 'src/typings.d.ts' indexed with language 'ts' 15:16:59.549 DEBUG: 'src/test.ts' indexed with language 'ts' 15:16:59.549 DEBUG: 'src/index.html' indexed with language 'null' 15:16:59.549 DEBUG: 'src/favicon.ico' indexed with language 'null' 15:16:59.549 INFO: 16 files indexed 15:16:59.550 INFO: 0 files ignored because of inclusion/exclusion patterns 15:16:59.550 INFO: Quality profile for ts: TsLint 15:17:00.030 DEBUG: 'Generic Coverage Report' skipped because one of the required properties is missing 15:17:00.030 DEBUG: 'Generic Test Executions Report' skipped because one of the required properties is missing 15:17:00.031 DEBUG: 'C#' skipped because there is no related file in current project 15:17:00.031 DEBUG: 'C# Unit Tests Coverage Report Import' skipped because there is no related file in current project 15:17:00.031 DEBUG: 'C# Integration Tests Coverage Report Import' skipped because there is no related file in current project 15:17:00.031 DEBUG: 'C# Unit Test Results Import' skipped because there is no related file in current project 15:17:00.032 DEBUG: 'Python Squid Sensor' skipped because there is no related file in current project 15:17:00.032 DEBUG: 'SurefireSensor' skipped because there is no related file in current project 15:17:00.032 DEBUG: 'JaCoCoSensor' skipped because there is no related file in current project 15:17:00.032 DEBUG: 'JavaSquidSensor' skipped because there is no related file in current project 15:17:00.033 DEBUG: 'Flex' skipped because there is no related file in current project 15:17:00.033 DEBUG: 'Flex Cobertura' skipped because there is no related file in current project 15:17:00.033 DEBUG: 'XML Sensor' skipped because there is no related file in current project 15:17:00.033 DEBUG: 'PHP sensor' skipped because there is no related file in current project 15:17:00.033 DEBUG: 'JavaScript Squid Sensor' skipped because there is no related file in current project 15:17:00.036 DEBUG: 'Generic Coverage Report' skipped because one of the required properties is missing 15:17:00.036 DEBUG: 'Generic Test Executions Report' skipped because one of the required properties is missing 15:17:00.036 DEBUG: 'C#' skipped because there is no related file in current project 15:17:00.036 DEBUG: 'C# Unit Tests Coverage Report Import' skipped because there is no related file in current project 15:17:00.036 DEBUG: 'C# Integration Tests Coverage Report Import' skipped because there is no related file in current project 15:17:00.036 DEBUG: 'C# Unit Test Results Import' skipped because there is no related file in current project 15:17:00.037 DEBUG: 'Python Squid Sensor' skipped because there is no related file in current project 15:17:00.037 DEBUG: 'SurefireSensor' skipped because there is no related file in current project 15:17:00.037 DEBUG: 'JaCoCoSensor' skipped because there is no related file in current project 15:17:00.037 DEBUG: 'JavaSquidSensor' skipped because there is no related file in current project 15:17:00.037 DEBUG: 'Flex' skipped because there is no related file in current project 15:17:00.037 DEBUG: 'Flex Cobertura' skipped because there is no related file in current project 15:17:00.038 DEBUG: 'XML Sensor' skipped because there is no related file in current project 15:17:00.038 DEBUG: 'PHP sensor' skipped because there is no related file in current project 15:17:00.038 DEBUG: 'JavaScript Squid Sensor' skipped because there is no related file in current project 15:17:00.041 DEBUG: Sensors : SonarJavaXmlFileSensor -> Analyzer for "php.ini" files -> Linting sensor for TypeScript files -> Combined LCOV and LOC sensor -> Zero Coverage Sensor -> CPD Block Indexer 15:17:00.042 INFO: Sensor SonarJavaXmlFileSensor [java] 15:17:00.042 INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=1ms 15:17:00.042 INFO: Sensor Analyzer for "php.ini" files [php] 15:17:00.044 INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=2ms 15:17:00.044 INFO: Sensor Linting sensor for TypeScript files [typescript] 15:17:00.045 DEBUG: Found sonar.ts.tslint.path path to be '/usr/local/bin/tslint' 15:17:00.045 DEBUG: Found sonar.ts.tslint.configPath path to be '/Users/blearner/Documents/Sample/SampleApp/tslint.json' 15:17:00.045 DEBUG: Path sonar.ts.tslint.rulesDir not specified, falling back to null 15:17:00.045 DEBUG: Found sonar.ts.tslint.projectPath path to be '/Users/blearner/Documents/Sample/SampleApp/tsconfig.json' 15:17:00.045 DEBUG: Path sonar.ts.tslint.outputPath not specified, falling back to null 15:17:00.045 DEBUG: Found sonar.ts.tslint.nodePath path to be '/usr/local/bin/node' 15:17:00.128 DEBUG: Using a temporary path for TsLint output: /Users/blearner/Documents/Sample/SampleApp/.scannerwork/.sonartmp/3085093627206079050.tmp 15:17:00.128 DEBUG: Running against a single project JSON file 15:17:02.448 INFO: Sensor Linting sensor for TypeScript files [typescript] (done) | time=2404ms 15:17:02.449 INFO: Sensor Combined LCOV and LOC sensor [typescript] 15:17:02.462 WARN: No coverage information will be saved because LCOV file cannot be found. 15:17:02.462 WARN: Provided LCOV file path: /Users/blearner/Documents/Sample/SampleApp/test-results/coverage. Seek file with path: /Users/blearner/Documents/Sample/SampleApp/test-results/coverage 15:17:02.462 WARN: No coverage information will be saved because all LCOV files cannot be found. 15:17:02.462 INFO: Sensor Combined LCOV and LOC sensor [typescript] (done) | time=13ms 15:17:02.462 INFO: Sensor Zero Coverage Sensor 15:17:02.471 INFO: Sensor Zero Coverage Sensor (done) | time=9ms 15:17:02.471 INFO: Sensor CPD Block Indexer 15:17:02.471 DEBUG: org.sonar.scanner.cpd.deprecated.DefaultCpdBlockIndexer is used for ts 15:17:02.471 DEBUG: No CpdMapping for language ts 15:17:02.472 INFO: Sensor CPD Block Indexer (done) | time=0ms 15:17:02.472 INFO: SCM Publisher is disabled 15:17:02.472 INFO: Calculating CPD for 0 files 15:17:02.473 INFO: CPD calculation finished 15:17:02.519 DEBUG: 'src/app/app.component.spec.ts' generated metadata with charset 'UTF-8' 15:17:02.520 DEBUG: 'src/app/app.module.ts' generated metadata with charset 'UTF-8' 15:17:02.521 DEBUG: 'src/app/app.component.ts' generated metadata with charset 'UTF-8' 15:17:02.522 DEBUG: 'src/environments/environment.ts' generated metadata with charset 'UTF-8' 15:17:02.522 DEBUG: 'src/environments/environment.prod.ts' generated metadata with charset 'UTF-8' 15:17:02.523 DEBUG: 'src/main.ts' generated metadata with charset 'UTF-8' 15:17:02.524 DEBUG: 'src/polyfills.ts' generated metadata with charset 'UTF-8' 15:17:02.525 DEBUG: 'src/typings.d.ts' generated metadata with charset 'UTF-8' 15:17:02.526 DEBUG: 'src/test.ts' generated metadata with charset 'UTF-8' 15:17:02.551 INFO: Analysis report generated in 76ms, dir size=35 KB 15:17:02.566 INFO: Analysis reports compressed in 15ms, zip size=15 KB 15:17:02.566 INFO: Analysis report generated in /Users/blearner/Documents/Sample/SampleApp/.scannerwork/batch-report 15:17:02.566 DEBUG: Upload report 15:17:02.584 DEBUG: POST 200 http://localhost:9000/api/ce/submit?projectKey=Sample | time=16ms 15:17:02.585 INFO: Analysis report uploaded in 18ms 15:17:02.586 INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/Sample 15:17:02.586 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report 15:17:02.586 INFO: More about the report processing at http://localhost:9000/api/ce/task?id=AV9LT4F1_g8Daf1iKtdx 15:17:02.586 DEBUG: Report metadata written to /Users/blearner/Documents/Sample/SampleApp/.scannerwork/report-task.txt 15:17:02.588 DEBUG: Post-jobs : 15:17:02.590 INFO: Task total time: 4.526 s 15:17:02.590 INFO: ------------------------------------------------------------------------ 15:17:02.591 INFO: EXECUTION SUCCESS 15:17:02.591 INFO: ------------------------------------------------------------------------ 15:17:02.591 INFO: Total time: 5.362s 15:17:02.662 INFO: Final Memory: 50M/402M 15:17:02.663 INFO: ------------------------------------------------------------------------ 15:17:02.663 DEBUG: Execution getVersion 15:17:02.664 DEBUG: Execution stop

I tried multiple options but nothing worked. I verified my tslint and node are configured correctly

Here are my sonar-project.properties file for refrence sonar.projectKey=SampleApp sonar.ProjectName=SampleApp sonar.sources=/Users/xxxx/Documents/git/Sample/SampleApp/src sonar.ts.tslint.nodePath=/usr/local/bin/node sonar.javascript.lcov.reportPaths=/Users/xxxx/Documents/Sample/SampleApp/test-results/coverage/lcov.info sonar.ts.tslint.enabled=true sonar.ts.tslint.typeCheck=true sonar.ts.tslint.path=/usr/local/bin/tslint sonar.ts.tslint.configPath=/Users/xxxx/Documents/Sample/SampleApp/tslint.json sonar.ts.tslint.projectPath=/Users/xxxx/Documents/Sample/SampleApp/tsconfig.json sonar.ts.coverage.lcovReportPath=/Users/xxxx/Documents/Sample/SampleApp/test-results/coverage

Any help is highly appreciated as stuck with this for 2 days now.

Thanks in advance

glebmachine commented 5 years ago

Got the same:

  "jsonrpc": "2.0",
  "method": "window/logMessage",
  "params": {
    "type": 3,
    "message": "Finished SonarTS Analysis"
  }
}
{
  "jsonrpc": "2.0",
  "method": "window/logMessage",
  "params": {
    "type": 4,
    "message": "\u0027SonarJS\u0027 skipped because there is no related file in current project"
  }
}
{
  "jsonrpc": "2.0",
  "method": "textDocument/publishDiagnostics",
  "params": {
    "uri": "file:///Users/glebmikheev/dokuro/prj/svo/libs/map/src/components/desktop-filters/desktop-filters.component.ts",
    "diagnostics": []
  }
}