Giter Site home page Giter Site logo

sonartsplugin's Introduction

SonarTsPlugin

Unofficial and no longer actively supported SonarQube plugin for TypeScript files.

Important - unofficial, and deprecated

For a few years this plugin was essentially the only way to get Typescript analysis, unit test and code coverage information into Sonarqube. However the official SonarTS plugin is much better supported, both in support of SonarQube version upgrades and linting rules.

There will be no further updates to this plugin, and it remains here for reference only. I don't have time to continue to support it, and there's little value in doing so when the official plugin covers off almost all its functionality.

Sample projects

Some sample projects are provided to demonstrate different configuration options in the samples/ folder.

Integrations

Overview

This is plugin for SonarQube 5.6+ for analysing projects with TypeScript content that supports:

  • TsLint for code quality information
  • Importing LCOV files for unit test coverage information
  • NCLOC metric generation

Requirements

  • Java 1.8+
  • SonarQube 5.6 LTS+
  • TsLint 2.4.0+

Building

  • Download the source
  • Build with maven, mvn clean && mvn install

Installation

  • Install Node.js
  • Install TsLint (2.4.0+) with npm install -g tslint, or ensure it is installed locally against your project
    • If you're installing globally, find the path to TsLint and copy it - will be similar to C:\Users\[Username]\AppData\Roaming\npm\node_modules\tslint\bin\tslint on Windows
  • Copy .jar file (from target/ after build, or downloaded from Releases page) to SonarQube extensions/plugins folder
  • Restart SonarQube server
  • Browse to SonarQube web interface, login as Admin, hit up Settings
  • Find the TypeScript tab, paste in the TsLint path
  • Hit the Rules tab, then the TsLint rule set, then apply it to your project - alter rule activation as required
  • Make sure you have a tslint.json file next to sonar-project.properties, or specify its path using the sonar.ts.tslint.configPath setting
  • If LCOV data available, add sonar.ts.coverage.lcovReportPath=lcov.dat to your sonar-project.properties file (replace lcov.dat with your lcov output, will be sought relative to the sonar-project.properties file)
  • Run sonar-runner or sonar-scanner
  • TsLint rule breaches should be shown in the web view

Configuration

Example project configuration

This is an example of what a project configuration file (sonar-project.properties) could look like:

sonar.projectKey=company:my-application
sonar.projectName=My Application
sonar.projectVersion=1.0
sonar.sourceEncoding=UTF-8
sonar.sources=src/app
sonar.exclusions=**/node_modules/**,**/*.spec.ts
sonar.tests=src/app
sonar.test.inclusions=**/*.spec.ts

sonar.ts.tslint.configPath=tslint.json
sonar.ts.coverage.lcovReportPath=test-results/coverage/coverage.lcov
  • See the Analysis Parameters documentation page for general configuration options.
  • See the Narrowing the Focus documentation page for configuration options related to which files to include.
  • See the rest of this README for the SonarTsPlugin specific configuration options.

Global configuration options

KeyDescription
sonar.ts.tslint.ruleConfigsOptionalA list of configurations to map custom TsLint rules to dedicated SonarQube rules & settings - see TsLint Custom Rules section below

Project-level configuration options

KeyDescription
sonar.ts.tslint.pathOptionalPath to the installed copy of `tslint` to use - will be automatically sought in node_modules next to the sonar-project.properties file if not specified
sonar.ts.tslint.configPathOptionalPath to the tslint.json file that configures the rules to be used in linting - will be automatically sought in the same folder as the sonar-project.properties file if not specified
sonar.ts.tslint.outputPathOptionalIf your existing CI process already runs `tslint` you can have the plugin re-use its output using the `outputPath` setting. The output is expected to be in JSON form
sonar.ts.excludeTypeDefinitionFilesOptionalExcludes .d.ts files from analysis, defaults to true
sonar.ts.coverage.forceZeroIfUnspecifiedOptionalForces code coverage percentage to zero for all files when no LCOV report is supplied, defaults to false
sonar.ts.coverage.ignoreNotFoundOptionalControls if a single file should be reported as 0% covered if it doesn't appear in the LCOV report, defaults to false
sonar.ts.tslint.timeoutOptionalMax time to wait for `tslint` to finish processing a single file (in milliseconds), defaults to 60 seconds
sonar.ts.tslint.rulesDirOptionalPath to a folder containing custom `tslint` rules referenced in tslint.json, if any is required
sonar.ts.coverage.lcovReportPathOptionalPath to an LCOV code-coverage report to be used to calculate coverage metrics for your project
sonar.ts.tslint.nodePathOptionalPath to custom node to execute
sonar.ts.tslint.projectPathOptionalPath to tsconfig.json that describes the TypeScript files in your project to analyse, rather than letting SonarQube search for them automatically. Required to allow sonar.ts.tslint.typeCheck to work.
sonar.ts.tslint.typeCheckOptionalIf true, asks tslint to run type-checking, allowing tslint rules that need type information to operate. Requires that you have specified sonar.ts.tslint.projectPath.

TsLint installation and configuration

By default, SonarTsPlugin will look for a version of TsLint installed locally within your project (i.e. in node_modules\tslint\bin), relative to the sonar-project.properties file. This may not be what you want, so you can set this directly via the sonar.ts.tslint.path configuration setting:

  • At project level
  • Globally, for all projects

If analysis is failing, run sonar-scanner with the -X option for more diagnostic information, including a note of where the plugin is searching for tslint. Bear in mind that if running on a build server, the account running the build will need access to the path to tslint.

By default, SonarTsPlugin will look for a tslint configuration file called tslint.json next to the sonar-project.properties file. You can override this using the sonar.ts.tslint.configPath configuration setting if this isn't the case for your project.

TsLint Custom Rules

To present custom tslint rules in SonarQube analysis, you can provide a configuration that maps the rules from your sonar.ts.tslint.rulesDir directory to dedicated Sonar rules for analysis.

The configuration for a tslint Sonar rule consists of a line declaring the TSLint rule id, a boolean switch to enable or disable the rule if needed and some attached properties that are used by Sonar for analysis and reporting.

For example, let's take the export-name rule from the tslint-microsoft-contrib package. A configuration for that rule in SonarTsPlugin could look as follows:

export-name=true
export-name.name=The name of the exported module must match the filename of the source file.
export-name.severity=MAJOR
export-name.description=This is case-sensitive but ignores file extension. Since version 1.0, this rule takes a list of regular expressions as a parameter. Any export name matching that regular expression will be ignored.
export-name.debtFunc=LINEAR_OFFSET
export-name.debtScalar=15min
export-name.debtOffset=1h
export-name.debtType=HARDWARE_RELATED_PORTABILITY

You will need to restart the SonarQube server after configuring custom rules this way before subsequent analyses will pick them up. You will also need to activate the new rules after restart for any quality profile you want them to participate in - by default they will be disabled.

  • For documentation about the technical debt parameters look here and here
  • For possible values for debtType go here

Licence

MIT

Contributors

Thanks to the following for contributions to the plugin:

With thanks

  • The LCOV parser is directly copied from the community JavaScript SonarQube plug-in, which is LGPL'd.

sonartsplugin's People

Contributors

afterbangx avatar alexkrauss avatar cyrilgandon avatar derkoe avatar drywolf avatar j0nathan33 avatar kingatlas avatar mahmoud-samy avatar marklagendijk avatar mucer avatar nikitaegorov avatar oliverbrandt avatar pablissimo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sonartsplugin's Issues

code smell issues are not showing in sonar Qube using tslintplugin for Angular2 project

Line of code alone is coming. code smell issues are not coming for my angular2 project using TSlint plugin in SONAR Qube

sonar.projectKey=test
sonar.projectName=test
sonar.projectVersion=1.0
sonar.language=ts
sonar.sources=src
sonar.sourceEncoding=UTF-8
sonar.ts.excludetypedefinitionfiles=true
#sonar.ts.tslintpath=node_modules/tslint
sonar.ts.tslintconfigpath=/src/tslint.json

Optional

sonar.exclusions=/node_modules//*,//.spec.ts,/*.spec.ts,/*.d.ts

Problem understanding installation guide

The guide tells to "Make sure you have a tslint.json file next to sonar-project.properties, or specify its path using the sonar.ts.tslintconfigpath setting". Where do I find or get that file from? I'm not into TSLint and only installing it for a collegue.

Also the guide doesn't point out whether the config is searched on the build server or on the sonar server. We're only using remote scanners which are reporting to the central server.

Does not work with 6.1

2016.10.17 09:33:10 ERROR web[][o.a.c.c.C.[.[.[/sonar]] Exception sending context initialized event to listener instance of class org.sonar.server.platform.web.PlatformServletContextListener
java.lang.IllegalStateException: Unable to load component class org.sonar.server.rule.RuleDefinitionsLoader
    at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:69) ~[sonar-core-6.1.jar:na]
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.DefaultPicoContainer.instantiateComponentAsIsStartable(DefaultPicoContainer.java:1034) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.DefaultPicoContainer.addAdapterIfStartable(DefaultPicoContainer.java:1026) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1003) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767) ~[picocontainer-2.15.jar:na]
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:141) ~[sonar-core-6.1.jar:na]
    at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:88) ~[sonar-server-6.1.jar:na]
    at org.sonar.server.platform.platformlevel.PlatformLevelStartup.access$001(PlatformLevelStartup.java:43) ~[sonar-server-6.1.jar:na]
    at org.sonar.server.platform.platformlevel.PlatformLevelStartup$1.doPrivileged(PlatformLevelStartup.java:76) ~[sonar-server-6.1.jar:na]
    at org.sonar.server.user.DoPrivileged.execute(DoPrivileged.java:44) ~[sonar-server-6.1.jar:na]
    at org.sonar.server.platform.platformlevel.PlatformLevelStartup.start(PlatformLevelStartup.java:73) ~[sonar-server-6.1.jar:na]
    at org.sonar.server.platform.Platform.executeStartupTasks(Platform.java:201) ~[sonar-server-6.1.jar:na]
    at org.sonar.server.platform.Platform.doStart(Platform.java:114) ~[sonar-server-6.1.jar:na]
    at org.sonar.server.platform.Platform.doStart(Platform.java:99) ~[sonar-server-6.1.jar:na]
    at org.sonar.server.platform.web.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:45) ~[sonar-server-6.1.jar:na]
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812) [tomcat-embed-core-8.0.32.jar:8.0.32]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255) [tomcat-embed-core-8.0.32.jar:8.0.32]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) [tomcat-embed-core-8.0.32.jar:8.0.32]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) [tomcat-embed-core-8.0.32.jar:8.0.32]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) [tomcat-embed-core-8.0.32.jar:8.0.32]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_66]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_66]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_66]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_66]
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.server.rule.RuleDefinitionsLoader
    at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:69) ~[sonar-core-6.1.jar:na]
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:621) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.containers.ImmutablePicoContainer.getComponent(ImmutablePicoContainer.java:40) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:718) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647) ~[picocontainer-2.15.jar:na]
    at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:67) ~[sonar-core-6.1.jar:na]
    ... 34 common frames omitted
Caused by: java.lang.IllegalStateException: Unable to load component class com.pablissimo.sonar.TsRulesDefinition
    at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:69) ~[sonar-core-6.1.jar:na]
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:621) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.parameters.CollectionComponentParameter.getArrayInstance(CollectionComponentParameter.java:334) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.parameters.CollectionComponentParameter.access$100(CollectionComponentParameter.java:49) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.parameters.CollectionComponentParameter$1.resolveInstance(CollectionComponentParameter.java:139) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:141) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647) ~[picocontainer-2.15.jar:na]
    at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:67) ~[sonar-core-6.1.jar:na]
    ... 39 common frames omitted
Caused by: java.lang.IllegalArgumentException: Multiple entries with same key: sonar.forceAuthentication=true and sonar.forceAuthentication=false
    at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:150) ~[guava-18.0.jar:na]
    at com.google.common.collect.RegularImmutableMap.checkNoConflictInBucket(RegularImmutableMap.java:104) ~[guava-18.0.jar:na]
    at com.google.common.collect.RegularImmutableMap.<init>(RegularImmutableMap.java:70) ~[guava-18.0.jar:na]
    at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:254) ~[guava-18.0.jar:na]
    at org.sonar.server.setting.ThreadLocalSettings.getProperties(ThreadLocalSettings.java:154) ~[sonar-server-6.1.jar:na]
    at org.sonar.api.config.Settings.getKeysStartingWith(Settings.java:495) ~[sonar-plugin-api-6.1.jar:na]
    at com.pablissimo.sonar.TsRulesDefinition.loadCustomRules(TsRulesDefinition.java:62) ~[na:na]
    at com.pablissimo.sonar.TsRulesDefinition.<init>(TsRulesDefinition.java:50) ~[na:na]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_66]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_66]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_66]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422) ~[na:1.8.0_66]
    at org.picocontainer.injectors.AbstractInjector.newInstance(AbstractInjector.java:145) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:342) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699) ~[picocontainer-2.15.jar:na]
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647) ~[picocontainer-2.15.jar:na]
    at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:67) ~[sonar-core-6.1.jar:na]
    ... 55 common frames omitted
2016.10.17 09:33:10 ERROR web[][o.a.c.c.StandardContext] One or more listeners failed to start. Full details will be found in the appropriate container log file

Analysis fails when runner not using same working directory as sonar-project.properties

Happens a lot with VSTS build - runner gets executed and the sonar-project.properties is passed as a command-line parameter, which means all subsequent parameters that assume they're relative to the properties file aren't found properly.

Need to instead make all supplied parameters absolute relative to the baseDir (which really should be sonar-project.properties), which then means default values all magically work in that CI environment.

Code scanning not working for TS files.

I have followed given steps as per the redame.md file.However still I am not getting expected result.

Please find below sonar-project.properties file for reference.

sonar.projectKey=my:XXXXX.0
sonar.projectName=XXXXX.0
sonar.projectVersion=2.0

sonar.sources=.
sonar.exclusions=BuildProcessTemplates/, Dependencies/, Design/, Documentation/, Source/, POC/

sonar.ts.tslintpath=../../../Users/user_name/AppData/Roaming/npm/node_modules/tslint/bin/
sonar.ts.tslintconfigpath=tslint.json

Could you please suggest if still I am missing anything?

java.lang.NullPointerException after upgrade to Sonar v5.6 and plugin v0.96

Hi,

I've upgraded to Sonar v5.6 and I'm now using v0.96 of the plugin, this was from v5.1 and v0.90. With the old setup I was able to use the plugin, but now I'm getting the following exception. Nothing has changed in my source code or sonar-project.properties file after the upgrade.

Do you have any ideas as to why this might be happening?

.... .... .... 11:19:12.676 INFO: 136/136 files analyzed 11:19:12.676 INFO: Sensor SCM Sensor (wrapped) (done) | time=2000ms 11:19:12.676 INFO: Sensor Linting sensor for TypeScript files (wrapped) 11:19:12.676 DEBUG: Path sonar.ts.tslintpath not specified, falling back to node_modules/tslint/bin/tslint 11:19:12.676 DEBUG: Found sonar.ts.tslintconfigpath Lint path to be 'tslint.json' 11:19:12.676 DEBUG: Path sonar.ts.tslintrulesdir not specified, falling back to null 11:19:12.676 DEBUG: Using a temporary path for TsLint output: C:\git\XXX\WebComponents\.sonar\.sonartmp\4237565016734021207.tmp 11:19:12.676 DEBUG: Split 134 files into 4 batches for processing 11:19:12.676 DEBUG: Executing TsLint with command: node .... 11:19:16.005 DEBUG: Executing TsLint with command: node .... 11:19:19.363 DEBUG: Executing TsLint with command: node .... 11:19:22.379 DEBUG: Executing TsLint with command: node .... 11:19:23.692 INFO: ------------------------------------------------------------------------ 11:19:23.692 INFO: EXECUTION FAILURE 11:19:23.692 INFO: ------------------------------------------------------------------------ 11:19:23.692 INFO: Total time: 16.313s 11:19:23.739 INFO: Final Memory: 42M/106M 11:19:23.739 INFO: ------------------------------------------------------------------------ 11:19:23.739 ERROR: Error during SonarQube Scanner execution 12:10:50.163 ERROR: Error during SonarQube Scanner execution java.lang.NullPointerException at com.pablissimo.sonar.TsLintParserImpl.parse(TsLintParserImpl.java:26) at com.pablissimo.sonar.TsLintSensor.execute(TsLintSensor.java:104) at org.sonar.batch.sensor.SensorWrapper.analyse(SensorWrapper.java:57) at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58) at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50) at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:83) at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241) at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236) at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47) at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106) at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119) at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60) at com.sun.proxy.$Proxy0.execute(Unknown Source) at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233) at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151) at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:110) at org.sonarsource.scanner.cli.Main.execute(Main.java:74) at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Can't launch runner from distant client due to invalid tslint path

The tslint path is configured on the server, but when I try to launch a runner on a distant machine, it seems that the runner try to find tslint with the path of the server on my local machine.

Maybe one option would be to ship the plugin with tslint wrapped in, and give the option to the user to specify a custom tslint in the global configuration and by projects.

java.lang.NoClassDefFoundError: com/google/common/base/Objects

Hi!

When I try to make a coverage test y receive the following error:

WARN: ----------------------------------------------------------------
WARN: Sonargraph Integration: Skipping projectXXXXXXXXXX [XXXXXXXXXXX], since no Sonargraph rules are activated in current SonarQube quality profile [TsLint].
WARN: ----------------------------------------------------------------
INFO: Sensor Lines Sensor
INFO: Sensor Lines Sensor (done) | time=28ms
INFO: Sensor Sonar-Sonargraph-Plugin [3.5]
INFO: ----------------------------------------------------------------
INFO: Sonargraph: Skipping project [XXXX] XXXXXXXX [XXXXXXX], since no Sonargraph rules are activated in current SonarQube quality profile.
INFO: ----------------------------------------------------------------
INFO: Sensor Sonar-Sonargraph-Plugin 3.5 | time=2ms
INFO: Sensor SCM Sensor
INFO: Sensor SCM Sensor (done) | time=32ms
INFO: Sensor XmlFileSensor
INFO: Sensor XmlFileSensor (done) | time=1ms
INFO: Sensor Linting sensor for TypeScript files
INFO: Sensor Linting sensor for TypeScript files (done) | time=4257ms
INFO: Sensor Combined LCOV and LOC sensor
INFO: Analysing /XXXXX/XXXXXXXXXX/lcov.info
WARN: Problem during processing LCOV report: can't save DA data for line 0 (Line with number 0 doesn't belong to file app/app.ts).
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Objects
at com.pablissimo.sonar.LCOVParserImpl$FileData.addBranch(LCOVParserImpl.java:200)
at com.pablissimo.sonar.LCOVParserImpl.parse(LCOVParserImpl.java:126)
at com.pablissimo.sonar.LCOVParserImpl.(LCOVParserImpl.java:60)
at com.pablissimo.sonar.LCOVParserImpl.create(LCOVParserImpl.java:73)
at com.pablissimo.sonar.TsCoverageSensorImpl.getParser(TsCoverageSensorImpl.java:106)
at com.pablissimo.sonar.TsCoverageSensorImpl.saveMeasureFromLCOVFile(TsCoverageSensorImpl.java:81)
at com.pablissimo.sonar.TsCoverageSensorImpl.execute(TsCoverageSensorImpl.java:141)
at com.pablissimo.sonar.CombinedCoverageSensor.execute(CombinedCoverageSensor.java:34)
at org.sonar.batch.sensor.SensorWrapper.analyse(SensorWrapper.java:57)

I fix this adding the library guava-19.0.jar to your plugin in path: META-INF/lib/ and now the plugin works (I don't know if I did it right but as I say, It works for me)

Inconsistent whitespace in the repos

We have a number of small contributions in the pipeline (fix for linux, update of rule definitions, maybe more...), but producing proper pull requests is a bit cumbersome, since whitespace use is highly inconsistent in the repository. Many editors normalize this automatically, but this produces diffs that are very hard to read.

Would you accept a PR that normalizes all whitespace (use only space, no tab), removes all trailing whitespace and adds an .editorconfig (most editors respect this automatically)? I'm not religious about the exact conventions used, but it is good to have a convention...

Plugin always processes .d.ts files

Since they're TypeScript files, .d.ts files get processed by the plugin automatically - this may not always be desirable and should be configurable via a plugin option.

tslint.json config not found on Windows when in subfolder

The usual pathing syntax in the sonar-project.properties is:

sonar.param = something/in/there

Even in Windows, where there is an initial comment in the file saying Replace "\" by "/" on Windows..

It is not working for the tslnint config path, you have to put instead two backslashes:

sonar.ts.tslintconfigpath=something\\in\\there

The plugin should accept the former too, and throw an exception when not found.

By default, it would be nice if it can search for the tslint.json in the current folder.

Need support for sonar 6.0

Hi,

Just test it with latest sonar 6.0 and found the following error, seems need to upgrade.

Caused by: org.sonar.runner.impl.RunnerException: Unable to execute Sonar at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91) at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75) at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69) at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50) at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102) at org.sonar.runner.api.Runner.execute(Runner.java:100) at org.sonarqube.gradle.SonarQubeTask.run(SonarQubeTask.java:50) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:228) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:621) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:604) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61) ... 68 more Caused by: java.lang.NoSuchMethodError: org.sonar.api.resources.File.fromIOFile(Ljava/io/File;Lorg/sonar/api/resources/Project;)Lorg/sonar/api/resources/File; at com.pablissimo.sonar.TsCoverageSensor.fileFromIoFile(TsCoverageSensor.java:110) at com.pablissimo.sonar.TsCoverageSensor.saveMeasureFromLCOVFile(TsCoverageSensor.java:93) at com.pablissimo.sonar.TsCoverageSensor.analyse(TsCoverageSensor.java:59) at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:57) at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:49) at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:78) at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:184) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241) at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236) at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:234) at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47) at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:115) at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:118) at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:78) at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48) at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)

Custom rules are all put in the 'unknown rule breach' bucket

Since the plugin doesn't know about custom rules (other than passing the parameter to TsLint) it can't translate rule breaches into sensibly named items for the SonarQube analysis and instead a custom rule breach is treated the same as we'd treat any other unknown rule breach - into the 'generic unknown error' bucket.

Would probably have to have this configured via some global configuration file, but should investigate if we can somehow do this dynamically at sonar-runner run-time.

vsts analysis with no msbuild step

Hi,
I'm currently trying to configure SQ TS analysis for a full typescript project. (no .net, working with vs code so no csproj or whatsoever)
The way our CI is configured right now in VSTS is:

  • npm install
  • SQ begin analysis
  • npm run build
  • SQ finish analysis
    ...
    I'm currently getting the following error
    The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
    2016-09-12T18:24:17.9206157Z ##[error]Possible causes:
    2016-09-12T18:24:17.9216152Z ##[error]1. The project has not been built - the project must be built in between the begin and end steps
    2016-09-12T18:24:17.9216152Z ##[error]2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 12.0 upwards are supported
    2016-09-12T18:24:17.9216152Z ##[error]3. The begin, build or end steps have not all been launched from the same folder

From what I understand this is because I don't have a msbuild step in the process. I'm not quite sure what to do though? should I use other tasks for the analysis? Should I create a dummy C# project? add a msbuild step that does nothing?

Path issue related to sonar.ts.tslintpath (Version 9) - work fine in version 8

Hi @Pablissimo.
Thanks for writing this plugins.
I have this issue where whenever I set the sonar.ts.tslintpath, I get this error:

16:40:23 INFO: Sensor com.pablissimo.sonar.TsLintSensor
16:40:23 ERROR: TsLint Err: module.js:327
16:40:23 ERROR: TsLint Err: throw err;
16:40:23 ERROR: TsLint Err: ^
16:40:23 ERROR: TsLint Err:
16:40:23 ERROR: TsLint Err: Error: Cannot find module '/var/jenkins_home/workspace/Test_Customer_Service/"/var/jenkins_home/workspace/Test_Customer_Service/node_modules/tslint/bin/tslint"'
16:40:23 ERROR: TsLint Err: at Function.Module._resolveFilename (module.js:325:15)
16:40:23 ERROR: TsLint Err: at Function.Module._load (module.js:276:25)
16:40:23 ERROR: TsLint Err: at Function.Module.runMain (module.js:441:10)
16:40:23 ERROR: TsLint Err: at startup (node.js:134:18)
16:40:23 ERROR: TsLint Err: at node.js:962:3

It seems like it adds my project path to the path I set in sonar properties while also adding double quote.
I also try no to set the sonar.ts.tslintpath but it gives me this warning:

15:46:55 INFO: Sensor com.pablissimo.sonar.TsLintSensor
15:46:55 WARN: Path to tslint not defined or not found. Skipping tslint analysis.
15:46:55 INFO: Sensor com.pablissimo.sonar.TsLintSensor (done) | time=0ms

It then seems to skip the analysis. (Tested this by introducing linting issue, the analysis result still shows no issue) My tslint path is matching the default In TsLintSensor.java, TSLINT_FALLBACK_PATH. I understand that the plugin has not been tested on Linux, could this be Linux specific?

Rule definitions are very hard to keep consistent with tslint

While trying to update the rule set to newer tslint and applying it for a realistic project, we realized that this is a nightmare in two dimensions:

  • TsLint is a moving target. There are many new rules, many pending suggestions, and options for the rules keep changing. Thus, any version of the Sonar plugin would be tightly coupled to some specific version of tslint. (One could try to bundle tslint with the plugin, but this is not easy as well).
  • Tslint has no consistent model for its rule options. Most options are just flags, others are values, a few are structured objects. The current mapping code from Sonar rules to tslint.json is incomplete in some important ways, but it's pretty much unfixable at the moment, without going into various special cases for some rules. The tslint project is somewhat aware of this issue (palantir/tslint#629), but I'm not sure when this will improve, as it will certainly break existing tslint config files.

IMHO, to make this work reliably, we should avoid trying to understand the complete rule metamodel of tslint, and just pass in a pre-existing tslint file (which all projects will have anyway). Ideally, SonarQube would let us generate dynamic rules based on the issues encountered. But the API does not support this, so I guess we must have at least the set of rules pre-configured, but not all the options.

So, to make this work reliably, I'd propose to simplify it:

  • The plugin no longer knows about all the rules' options, but just the rule keys and user-readable names. So, rule options cannot be configured in Sonar, but only in tslint.json. On the other hand, we have full expressivity there.
  • The plugin takes the path to a tslint.json file as an option. This configuration file will be used for the analysis. It can be passed at analysis time, so this should be flexible enough.
  • Then, all encountered issues are filtered with the set of rules that are activated and then added to sonar. If any issues are encountered for a rule unknown to the plugin, they can be filed with a generic rule "tslint issue".

I think this will make the plugin simpler and much more robust.

What do you think?

Incompatibility with tslint 4.0.0

Via @charpour:

I've tried 0.95 against [email protected], but the run failed with the following error:

01:55:45 INFO: Sensor Linting sensor for TypeScript files
01:55:47 INFO: ------------------------------------------------------------------------
01:55:47 INFO: EXECUTION FAILURE
01:55:47 INFO: ------------------------------------------------------------------------
01:55:47 INFO: Total time: 1:32.425s
01:55:47 INFO: Final Memory: 59M/383M
01:55:47 INFO: ------------------------------------------------------------------------
01:55:47 ERROR: Error during SonarQube Scanner execution
01:55:47 ERROR: 54 is not a valid line for pointer. File [moduleKey=<some_ts_file>, basedir=<some_directory>] has 24 line(s)

custom rules are loaded from the rules-dir but no output is generated

Hi,

This is the issue following up on my comments about custom tslint rules not being reported during analysis in #18.

What I found out is that the rules are being loaded from the rules-dir, but they don't seem to be evaluated by the sonar-runner for some reason.
I added some logging to the plugin and had a look at what the sonar-runner output looked like and there was no occurrance of any of my custom rules.

I even manually added the rule to the plugin and built it from source, but there was still no output for the custom rule that I added.

Is there anything special that I should be careful about when using custom rules to make them work with the plugin ?

EDIT:
tsc-version: Version 1.9.0-dev.20160323
tslint-version: 3.7.1

Thanks

Exclude parameter

I want to be able to exclude directories from being linted. I.E. node_modules

Increase/make configurable the TsLint timeout

5 second timeout waiting for TsLint completion is too low for large or complex files or on overloaded build servers. Update to 60 seconds by default and make configurable in sonar-project.properties.

Exception after Upgrading from SQ 5.5 to 6.1

Today we upgraded from SonarQube 5.5 to 6.1. We also updated the plugin to 0.93-SNAPSHOT.

The runner:

INFO: SonarQube Scanner 2.8
INFO: Java 1.8.0_111 Oracle Corporation (64-bit)

The error:

error   26-Oct-2016 15:17:17    Exception in thread "main" java.lang.NoSuchMethodError: org.sonar.api.resources.File.fromIOFile(Ljava/io/File;Lorg/sonar/api/resources/Project;)Lorg/sonar/api/resources/File;
error   26-Oct-2016 15:17:17        at com.pablissimo.sonar.TsLintSensor.getFileFromIOFile(TsLintSensor.java:177)
error   26-Oct-2016 15:17:17        at com.pablissimo.sonar.TsLintSensor.analyse(TsLintSensor.java:152)
error   26-Oct-2016 15:17:17        at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:57)
error   26-Oct-2016 15:17:17        at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:49)
error   26-Oct-2016 15:17:17        at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:78)
error   26-Oct-2016 15:17:17        at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:182)
error   26-Oct-2016 15:17:17        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
error   26-Oct-2016 15:17:17        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
error   26-Oct-2016 15:17:17        at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:247)
error   26-Oct-2016 15:17:17        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:242)
error   26-Oct-2016 15:17:17        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:232)
error   26-Oct-2016 15:17:17        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
error   26-Oct-2016 15:17:17        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
error   26-Oct-2016 15:17:17        at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
error   26-Oct-2016 15:17:17        at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86)
error   26-Oct-2016 15:17:17        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
error   26-Oct-2016 15:17:17        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
error   26-Oct-2016 15:17:17        at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:115)
error   26-Oct-2016 15:17:17        at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:118)
error   26-Oct-2016 15:17:17        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62)
error   26-Oct-2016 15:17:17        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
error   26-Oct-2016 15:17:17        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
error   26-Oct-2016 15:17:17        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
error   26-Oct-2016 15:17:17        at java.lang.reflect.Method.invoke(Unknown Source)
error   26-Oct-2016 15:17:17        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
error   26-Oct-2016 15:17:17        at com.sun.proxy.$Proxy0.execute(Unknown Source)
error   26-Oct-2016 15:17:17        at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233)
error   26-Oct-2016 15:17:17        at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
error   26-Oct-2016 15:17:17        at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:110)
error   26-Oct-2016 15:17:17        at org.sonarsource.scanner.cli.Main.execute(Main.java:74)
error   26-Oct-2016 15:17:17        at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Let me know if you need some additional informations.
Thank you for providing thins plugin!

No issues are find out

I have installed this plugin on Sona 4.5.1 version. When i run my project by setting the language as ts i am not seeing any issues. Attached screen shot will explain the issue. Please provide the solution for this.
ts_issue

MethodNotFound exception thrown when batching files

I'm having this issue when using the plugin. It seems to be when there are enough files that it causes the plugin to require batching. When I limit the sonar.sources to not require batching then it seems to work. The exception is thrown after the last batch is run.

I've tried versions 0.8 and 0.9.

Running with 0.8 (just happened to be the last version I attempted with) the stack trace is below. When running with 0.9 the exception is the same and is thrown from the same method.

org.sonar.runner.impl.RunnerException: Unable to execute Sonar
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
        at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
        at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
        at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
        at org.sonar.runner.api.Runner.execute(Runner.java:100)
        at org.sonar.runner.Main.executeTask(Main.java:70)
        at org.sonar.runner.Main.execute(Main.java:59)
        at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.NoSuchMethodError: org.sonar.api.resources.File.fromIOFile(Ljava/io/File;Lorg/sonar/api/resources/Project;)Lorg/sonar/api/resources/File;
        at com.pablissimo.sonar.TsLintSensor.getFileFromIOFile(TsLintSensor.java:168)
        at com.pablissimo.sonar.TsLintSensor.analyse(TsLintSensor.java:143)
        at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:57)
        at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:49)
        at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:78)
        at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:184)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
        at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
        at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
        at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
        at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:115)
        at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:118)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:78)
        at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
        ... 9 more

Exception while linting

I'm getting the following exception while sonar is linting TS code:

ERROR: Error during SonarQube Scanner execution
com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated string at line 1 column 118932 path $[0][0].name
at com.google.gson.Gson.fromJson(Gson.java:820)
at com.google.gson.Gson.fromJson(Gson.java:770)
at com.google.gson.Gson.fromJson(Gson.java:719)
at com.google.gson.Gson.fromJson(Gson.java:691)
at com.pablissimo.sonar.TsLintParserImpl.parse(TsLintParserImpl.java:12)
at com.pablissimo.sonar.TsLintSensor.execute(TsLintSensor.java:101)
at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:57)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:49)
at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:78)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:184)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:234)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:234)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:115)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:118)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:244)
at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:154)
at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:110)
at org.sonarsource.scanner.cli.Main.execute(Main.java:72)
at org.sonarsource.scanner.cli.Main.main(Main.java:60)
Caused by: com.google.gson.stream.MalformedJsonException: Unterminated string at line 1 column 118932 path $[0][0].name
at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1572)
at com.google.gson.stream.JsonReader.nextQuotedValue(JsonReader.java:1029)
at com.google.gson.stream.JsonReader.nextString(JsonReader.java:825)
at com.google.gson.internal.bind.TypeAdapters$13.read(TypeAdapters.java:358)
at com.google.gson.internal.bind.TypeAdapters$13.read(TypeAdapters.java:346)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:95)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:183)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72)
at com.google.gson.Gson.fromJson(Gson.java:805)
... 37 more

Any ideas what the problem might be?

I'm using SonarQube 6.0 and the latest released version of the plugin (0.94)

Allow global configuration of tslint.json

It's nice to have a configuration by projects of tslint rules, but it can be useful to have only one set of rules for every projects that are gonna be analyze by one instance of SonarQube.

image

what is the correct path for tslintpath?

I'm trying to get the 0.4-pre to work. But I don't get the plugin to find TSLint. I'm not sure what the tslintpath expects.

i tried a lot of different paths and escaping methods, but nothing seems to work. E.g. an example which i tried. (i'm running this as a build job in TFS)

sonar.ts.tslintpath: C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\npm\node_modules\tslint\bin\tslint

2016-06-02T15:43:44.1737708Z 17:43:44.095 ERROR - TsLint Err: module.js:327
2016-06-02T15:43:44.1737708Z 17:43:44.095 ERROR - TsLint Err: throw err;
2016-06-02T15:43:44.1737708Z 17:43:44.095 ERROR - TsLint Err: ^
2016-06-02T15:43:44.1737708Z 17:43:44.095 ERROR - TsLint Err:
2016-06-02T15:43:44.1737708Z 17:43:44.095 ERROR - TsLint Err: Error: Cannot find module 'C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\npm\node_modules\tslint\bin\tslint'
2016-06-02T15:43:44.1737708Z 17:43:44.095 ERROR - TsLint Err: at Function.Module._resolveFilename (module.js:325:15)
2016-06-02T15:43:44.1737708Z 17:43:44.095 ERROR - TsLint Err: at Function.Module._load (module.js:276:25)
2016-06-02T15:43:44.1737708Z 17:43:44.095 ERROR - TsLint Err: at Function.Module.runMain (module.js:441:10)
2016-06-02T15:43:44.1737708Z 17:43:44.095 ERROR - TsLint Err: at startup (node.js:139:18)
2016-06-02T15:43:44.1737708Z 17:43:44.095 ERROR - TsLint Err: at node.js:968:3

when running manually running "node.exe C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\npm\node_modules\tslint\bin\tslint" it works fine. Any ideas?

Increase performance

Please pass chunk of files to TSLint
or run nodejs once and call tslint in one nodejs process like gulp

Newer rules of tslint are not showing up on webview.

Hi,

Below configurations of sonar:
sonarqube-5.6
sonar-typescript-plugin-0.9-SNAPSHOT.jar
Scanner version 2.6.1, running from command prompt

sonar-project.properties
sonar.ts.tslintpath=../../../Users/user_name/AppData/Roaming/npm/node_modules/tslint/bin/
sonar.ts.tslintconfigpath=tslint.json

Sonar server scanning code as per tslint.json's rule set which is newer than previous one 2.4.x as I was using previously. Newer version of tslint has more rule set but they are not showing up in web view so when user sees the error or code smells as per newer rules he/she gets confused that without rule set how is it showing errors.

Is there any way to showing up rules on web view from tslint.json?

SonarTSPlugin does not show the coverage information in the LCOV file

hello fellow,

I installed the plugin in my SonarQube instance and configure the path to the LCOV file, I generate transpile the code from TS to JS, the I use Karma to generate a LCOV file, it points to JS sources, so after that I use remap-Istanbul to create other file that point the coverage to the TS files.

I placed both files to be used for the plugin regarding the coverage of the tests but I always get 0% coverage.

is there an configuration that I am missing?

Uploading coverage.7zā€¦

Rule names should be imperative, not descriptive

Many rule names are just taken from the TsLint documentation which is descriptive of the check the rule is making ('enforces the rule that...') rather than descriptive of the desired outcome of the rule 'Source code should be consistently indented').

In addition, many of the TsLint rules are direct ports of JsLint rules so their descriptions should, where appropriate, match those of the JsLint rules.

Problem with TSLint and Team Foundation Server Integration

Hi there,

when I run Sonarqube via a Team Foundation Server build it fails with following log message:

2016-12-09T12:51:53.0444407Z 13:51:52.935 INFO: Sensor Linting sensor for TypeScript files
2016-12-09T12:51:53.0444407Z 13:51:52.935 DEBUG: Found sonar.ts.tslintpath Lint path to be 'C:\Users\svctestmediaportal\AppData\Roaming\npm\node_modules\tslint\bin\tslint'
2016-12-09T12:51:53.0444407Z 13:51:52.935 DEBUG: Found sonar.ts.tslintconfigpath Lint path to be 'C:\Sonarqube_tslint\tslint.json'
2016-12-09T12:51:53.0444407Z 13:51:52.935 DEBUG: Path sonar.ts.tslintrulesdir not specified, falling back to null
2016-12-09T12:51:53.0444407Z 13:51:52.935 DEBUG: Using a temporary path for TsLint output: C:\TfsAgent\_work\1\.sonarqube\out\.sonar\.sonartmp\7956119935354822877.tmp
2016-12-09T12:51:53.0444407Z 13:51:52.935 DEBUG: Split 542 files into 17 batches for processing
2016-12-09T12:51:53.1694489Z 13:51:52.951 DEBUG: Executing TsLint with command: node C:\Users\svctestmediaportal\AppData\Roaming\npm\node_modules\tslint\bin\tslint --format json --out C:\TfsAgent\_work\1\.sonarqube\out\.sonar\.sonartmp\7956119935354822877.tmp --config C:\Sonarqube_tslint\tslint.json ...
2016-12-09T12:51:53.3882025Z 13:51:53.185 DEBUG: Executing TsLint with command: node C:\Users\svctestmediaportal\AppData\Roaming\npm\node_modules\tslint\bin\tslint --format json --out C:\TfsAgent\_work\1\.sonarqube\out\.sonar\.sonartmp\7956119935354822877.tmp --config C:\Sonarqube_tslint\tslint.json ...
2016-12-09T12:51:53.6069605Z 13:51:53.419 DEBUG: Executing TsLint with command: node C:\Users\svctestmediaportal\AppData\Roaming\npm\node_modules\tslint\bin\tslint --format json --out C:\TfsAgent\_work\1\.sonarqube\out\.sonar\.sonartmp\7956119935354822877.tmp --config C:\Sonarqube_tslint\tslint.json ...
2016-12-09T12:51:53.8257180Z 13:51:53.622 DEBUG: Executing TsLint with command: node C:\Users\svctestmediaportal\AppData\Roaming\npm\node_modules\tslint\bin\tslint --format json --out C:\TfsAgent\_work\1\.sonarqube\out\.sonar\.sonartmp\7956119935354822877.tmp --config C:\Sonarqube_tslint\tslint.json ...
2016-12-09T12:51:54.0444818Z 13:51:53.841 DEBUG: Executing TsLint with command: node C:\Users\svctestmediaportal\AppData\Roaming\npm\node_modules\tslint\bin\tslint --format json --out C:\TfsAgent\_work\1\.sonarqube\out\.sonar\.sonartmp\7956119935354822877.tmp --config C:\Sonarqube_tslint\tslint.json ...
2016-12-09T12:51:54.2632362Z 13:51:54.044 DEBUG: Executing TsLint with command: node C:\Users\svctestmediaportal\AppData\Roaming\npm\node_modules\tslint\bin\tslint --format json --out C:\TfsAgent\_work\1\.sonarqube\out\.sonar\.sonartmp\7956119935354822877.tmp --config C:\Sonarqube_tslint\tslint.json ...
2016-12-09T12:51:54.4820006Z 13:51:54.278 DEBUG: Executing TsLint with command: node C:\Users\svctestmediaportal\AppData\Roaming\npm\node_modules\tslint\bin\tslint --format json --out C:\TfsAgent\_work\1\.sonarqube\out\.sonar\.sonartmp\7956119935354822877.tmp --config C:\Sonarqube_tslint\tslint.json ...
2016-12-09T12:51:54.7007581Z 13:51:54.513 DEBUG: Executing TsLint with command: node C:\Users\svctestmediaportal\AppData\Roaming\npm\node_modules\tslint\bin\tslint --format json --out C:\TfsAgent\_work\1\.sonarqube\out\.sonar\.sonartmp\7956119935354822877.tmp --config C:\Sonarqube_tslint\tslint.json ...
2016-12-09T12:51:54.9195105Z 13:51:54.732 DEBUG: Executing TsLint with command: node C:\Users\svctestmediaportal\AppData\Roaming\npm\node_modules\tslint\bin\tslint --format json --out C:\TfsAgent\_work\1\.sonarqube\out\.sonar\.sonartmp\7956119935354822877.tmp --config C:\Sonarqube_tslint\tslint.json ...
2016-12-09T12:51:55.1382796Z 13:51:54.935 DEBUG: Executing TsLint with command: node C:\Users\svctestmediaportal\AppData\Roaming\npm\node_modules\tslint\bin\tslint --format json --out C:\TfsAgent\_work\1\.sonarqube\out\.sonar\.sonartmp\7956119935354822877.tmp --config C:\Sonarqube_tslint\tslint.json ...
2016-12-09T12:51:55.3570278Z 13:51:55.169 DEBUG: Executing TsLint with command: node C:\Users\svctestmediaportal\AppData\Roaming\npm\node_modules\tslint\bin\tslint --format json --out C:\TfsAgent\_work\1\.sonarqube\out\.sonar\.sonartmp\7956119935354822877.tmp --config C:\Sonarqube_tslint\tslint.json ...
2016-12-09T12:51:55.5757874Z 13:51:55.388 DEBUG: Executing TsLint with command: node C:\Users\svctestmediaportal\AppData\Roaming\npm\node_modules\tslint\bin\tslint --format json --out C:\TfsAgent\_work\1\.sonarqube\out\.sonar\.sonartmp\7956119935354822877.tmp --config C:\Sonarqube_tslint\tslint.json ...
2016-12-09T12:51:55.7945442Z 13:51:55.607 DEBUG: Executing TsLint with command: node C:\Users\svctestmediaportal\AppData\Roaming\npm\node_modules\tslint\bin\tslint --format json --out C:\TfsAgent\_work\1\.sonarqube\out\.sonar\.sonartmp\7956119935354822877.tmp --config C:\Sonarqube_tslint\tslint.json ...
2016-12-09T12:51:56.0133035Z 13:51:55.810 DEBUG: Executing TsLint with command: node C:\Users\svctestmediaportal\AppData\Roaming\npm\node_modules\tslint\bin\tslint --format json --out C:\TfsAgent\_work\1\.sonarqube\out\.sonar\.sonartmp\7956119935354822877.tmp --config C:\Sonarqube_tslint\tslint.json ...
2016-12-09T12:51:56.2322505Z 13:51:56.029 DEBUG: Executing TsLint with command: node C:\Users\svctestmediaportal\AppData\Roaming\npm\node_modules\tslint\bin\tslint --format json --out C:\TfsAgent\_work\1\.sonarqube\out\.sonar\.sonartmp\7956119935354822877.tmp --config C:\Sonarqube_tslint\tslint.json ...
2016-12-09T12:51:56.4508213Z 13:51:56.232 DEBUG: Executing TsLint with command: node C:\Users\svctestmediaportal\AppData\Roaming\npm\node_modules\tslint\bin\tslint --format json --out C:\TfsAgent\_work\1\.sonarqube\out\.sonar\.sonartmp\7956119935354822877.tmp --config C:\Sonarqube_tslint\tslint.json ...
2016-12-09T12:51:56.6695814Z 13:51:56.450 DEBUG: Executing TsLint with command: node C:\Users\svctestmediaportal\AppData\Roaming\npm\node_modules\tslint\bin\tslint --format json --out C:\TfsAgent\_work\1\.sonarqube\out\.sonar\.sonartmp\7956119935354822877.tmp --config C:\Sonarqube_tslint\tslint.json ...
2016-12-09T12:51:56.8883335Z 13:51:56.763 INFO: ------------------------------------------------------------------------
2016-12-09T12:51:56.8883335Z 13:51:56.763 INFO: EXECUTION FAILURE
2016-12-09T12:51:56.8883335Z 13:51:56.763 INFO: ------------------------------------------------------------------------
2016-12-09T12:51:56.8883335Z 13:51:56.763 INFO: Total time: 29.486s
2016-12-09T12:51:57.1070973Z 13:51:56.966 INFO: Final Memory: 45M/304M
2016-12-09T12:51:57.1070973Z 13:51:56.966 INFO: ------------------------------------------------------------------------
2016-12-09T12:51:57.1070973Z ##[error]13:51:56.966 ERROR: Error during SonarQube Scanner execution
2016-12-09T12:51:57.1070973Z ##[error]java.lang.NullPointerException
2016-12-09T12:51:57.1070973Z ##[error]at com.pablissimo.sonar.TsLintParserImpl.parse(TsLintParserImpl.java:26)
2016-12-09T12:51:57.1070973Z ##[error]at com.pablissimo.sonar.TsLintSensor.execute(TsLintSensor.java:104)
2016-12-09T12:51:57.1070973Z ##[error]at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
2016-12-09T12:51:57.1070973Z ##[error]at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:57)
2016-12-09T12:51:57.1070973Z ##[error]at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:49)
2016-12-09T12:51:57.1070973Z ##[error]at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:78)
2016-12-09T12:51:57.1070973Z ##[error]at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:182)
2016-12-09T12:51:57.1070973Z ##[error]at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
2016-12-09T12:51:57.1070973Z ##[error]at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
2016-12-09T12:51:57.1070973Z ##[error]at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:247)
2016-12-09T12:51:57.1070973Z ##[error]at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:242)
2016-12-09T12:51:57.1070973Z ##[error]at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:240)
2016-12-09T12:51:57.1070973Z ##[error]at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:232)
2016-12-09T12:51:57.1070973Z ##[error]at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
2016-12-09T12:51:57.1070973Z ##[error]at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
2016-12-09T12:51:57.1070973Z ##[error]at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
2016-12-09T12:51:57.1227207Z ##[error]at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86)
2016-12-09T12:51:57.1227207Z ##[error]at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
2016-12-09T12:51:57.1227207Z ##[error]at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
2016-12-09T12:51:57.1227207Z ##[error]at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:115)
2016-12-09T12:51:57.1227207Z ##[error]at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:118)
2016-12-09T12:51:57.1227207Z ##[error]at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62)
2016-12-09T12:51:57.1227207Z ##[error]at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2016-12-09T12:51:57.1227207Z ##[error]at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2016-12-09T12:51:57.1227207Z ##[error]at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2016-12-09T12:51:57.1227207Z ##[error]at java.lang.reflect.Method.invoke(Unknown Source)
2016-12-09T12:51:57.1227207Z ##[error]at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
2016-12-09T12:51:57.1227207Z ##[error]at com.sun.proxy.$Proxy0.execute(Unknown Source)
2016-12-09T12:51:57.1227207Z ##[error]at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233)
2016-12-09T12:51:57.1227207Z ##[error]at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
2016-12-09T12:51:57.1227207Z ##[error]at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:110)
2016-12-09T12:51:57.1227207Z ##[error]at org.sonarsource.scanner.cli.Main.execute(Main.java:74)
2016-12-09T12:51:57.1227207Z ##[error]at org.sonarsource.scanner.cli.Main.main(Main.java:61)
2016-12-09T12:51:57.1227207Z ##[error]13:51:56.966 ERROR:
2016-12-09T12:51:57.1227207Z ##[error]13:51:56.966 ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
2016-12-09T12:51:57.4664813Z Process returned exit code 1
2016-12-09T12:51:57.4664813Z ##[error]The SonarQube Scanner did not complete successfully
2016-12-09T12:51:57.4664813Z 13:51:57.403  Creating a summary markdown file...
2016-12-09T12:51:57.4664813Z ##[error]Post-processing failed. Exit code: 1
2016-12-09T12:51:57.4821073Z ##[error]Unexpected exit code received from batch file: 1
2016-12-09T12:51:57.5133626Z The build was not set to fail if the associated quality gate fails.

Following versions are in use:

  • TFS 2015 Update 3
  • SonarTsPlugin v0.96-pre
  • TSLint 4.0.2
  • SonarQube v6.1

However, one strange observation is, that when running the SonarQube Scanner for MSBuild directly on the TFS build machine, the analysis is completed successfully.

I also tried switching to an older version of TSLint, but the error didn't go away.

SonarQube 6.0

Hi,

we updated our SonarQube-Instance to Version 6.0.
Since this update your great Plugin is not working anymore.

Area you planing to get this work again?

Here the Exception:
10:34:15 Exception in thread "main" java.lang.NoSuchMethodError: org.sonar.api.resources.File.fromIOFile(Ljava/io/File;Lorg/sonar/api/resources/Project;)Lorg/sonar/api/resources/File; 10:34:15 at com.pablissimo.sonar.TsCoverageSensor.fileFromIoFile(TsCoverageSensor.java:110) 10:34:15 at com.pablissimo.sonar.TsCoverageSensor.saveMeasureFromLCOVFile(TsCoverageSensor.java:93) 10:34:15 at com.pablissimo.sonar.TsCoverageSensor.analyse(TsCoverageSensor.java:59) 10:34:15 at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:57) 10:34:15 at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:49) 10:34:15 at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:78) 10:34:15 at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:184) 10:34:15 at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) 10:34:15 at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) 10:34:15 at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241) 10:34:15 at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236) 10:34:15 at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226) 10:34:15 at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) 10:34:15 at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) 10:34:15 at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47) 10:34:15 at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86) 10:34:15 at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) 10:34:15 at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) 10:34:15 at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:115) 10:34:15 at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:118) 10:34:15 at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62) 10:34:15 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 10:34:15 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 10:34:15 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 10:34:15 at java.lang.reflect.Method.invoke(Method.java:498) 10:34:15 at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60) 10:34:15 at com.sun.proxy.$Proxy0.execute(Unknown Source) 10:34:15 at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:240) 10:34:15 at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151) 10:34:15 at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:110) 10:34:15 at org.sonarsource.scanner.cli.Main.execute(Main.java:72) 10:34:15 at org.sonarsource.scanner.cli.Main.main(Main.java:60)

Support custom rules definitions

In attempting to run the TypeScript compiler source (microsoft/TypeScript@8dc3b2e) it seems TsLint fails horribly if it encounters configuration for rules in tslint.json that it doesn't recognise. Need to support the various options that TsLint uses to point it to custom rules.

No HTML documentation specified for any rules

Currently just placeholder text - HTML documentation should be added for rules based on the (admittedly spartan) TsLint documentation with examples of passing and failing code for each rule and each rule option.

Execution failure

Hello,

I'm facing a problem when running this plugin. It fails at the execution phase.
Is there any idea please ?
I've attached the log file.

Regards
13:09:10 13:09:10.515 ERROR - TsLint Err: Error: Cannot find module '/home/jenkins/workspace/Build Front end with Sonar/"/home/jenkins/workspace/Build Front end with Sonar/node_modules/tslint/bin/tslint"' 13:09:10 13:09:10.515 ERROR - TsLint Err: at Function.Module._resolveFilename (module.js:469:15) 13:09:10 13:09:10.516 ERROR - TsLint Err: at Function.Module._load (module.js:417:25) 13:09:10 13:09:10.516 ERROR - TsLint Err: at Module.runMain (module.js:604:10) 13:09:10 13:09:10.516 ERROR - TsLint Err: at run (bootstrap_node.js:394:7) 13:09:10 13:09:10.516 ERROR - TsLint Err: at startup (bootstrap_node.js:149:9) 13:09:10 13:09:10.516 ERROR - TsLint Err: at bootstrap_node.js:509:3

trace.txt

Issue with TsLint path

I have installed the plugin on SonarQube, and the runner works properly on my machine. When I try to analyze my project all the .ts files gets indexed but the TsLint keeps showing this error:

11:15:37.112 DEBUG - Executing TsLint with command: node "/home/guu/myproject/node_modules/tslint/bin/tslint" --format json --config "/home/guu/myproject/tslint.json" "/home/guu/myproject/myapp.ts".
11:15:37.162 ERROR - TsLint Err: module.js:457
11:15:37.162 ERROR - TsLint Err:     throw err;
11:15:37.163 ERROR - TsLint Err:     ^
11:15:37.163 ERROR - TsLint Err:.
11:15:37.163 ERROR - TsLint Err: Error: Cannot find module '/home/guu/myproject/"/home/guu/myproject/node_modules/tslint/bin/tslint"'
11:15:37.163 ERROR - TsLint Err:     at Function.Module._resolveFilename (module.js:455:15)
11:15:37.163 ERROR - TsLint Err:     at Function.Module._load (module.js:403:25)
11:15:37.163 ERROR - TsLint Err:     at Module.runMain (module.js:590:10)
11:15:37.163 ERROR - TsLint Err:     at run (bootstrap_node.js:394:7)
11:15:37.163 ERROR - TsLint Err:     at startup (bootstrap_node.js:149:9)
11:15:37.163 ERROR - TsLint Err:     at bootstrap_node.js:509:3
11:15:37.164 DEBUG - Executing TsLint with command: node "/home/guu/myproject/node_modules/tslint/bin/tslint" --format json --config "/home/guu/myproject/tslint.json" "/home/guu/myproject/test/testUtils.ts"
11:15:37.213 ERROR - TsLint Err: module.js:457
11:15:37.214 ERROR - TsLint Err:     throw err;
11:15:37.214 ERROR - TsLint Err:     ^
11:15:37.214 ERROR - TsLint Err:.
11:15:37.214 ERROR - TsLint Err: Error: Cannot find module '/home/guu/myproject/"/home/guu/myproject/node_modules/tslint/bin/tslint"'
11:15:37.214 ERROR - TsLint Err:     at Function.Module._resolveFilename (module.js:455:15)
11:15:37.214 ERROR - TsLint Err:     at Function.Module._load (module.js:403:25)
11:15:37.214 ERROR - TsLint Err:     at Module.runMain (module.js:590:10)
11:15:37.214 ERROR - TsLint Err:     at run (bootstrap_node.js:394:7)
11:15:37.214 ERROR - TsLint Err:     at startup (bootstrap_node.js:149:9)
11:15:37.214 ERROR - TsLint Err:     at bootstrap_node.js:509:3
11:15:37.252 INFO  - Sensor com.pablissimo.sonar.TsLintSensor (done) | time=215ms

If I copy&paste the command and run it, it works fine.

node "/home/guu/myproject/node_modules/tslint/bin/tslint" --format json --config "/home/guu/myproject/tslint.json" "/home/guu/myproject/myapp.ts".

What may be wrong when executing through sonar-runner? Any ideas?

Coverage problem

ERROR: Problem while calculating coverage for *********TS.Tests\mocks\knockout-binding-context.ts
java.lang.NullPointerException: null
at com.pablissimo.sonar.TsCoverageSensor.saveMeasureFromLCOVFile(TsCoverageSensor.java:99) [sonar-typescript-plugin-0.6-SNAPSHOT.jar:na]
at com.pablissimo.sonar.TsCoverageSensor.saveZeroValueForResource(TsCoverageSensor.java:118) [sonar-typescript-plugin-0.6-SNAPSHOT.jar:na]
at com.pablissimo.sonar.TsCoverageSensor.analyse(TsCoverageSensor.java:59) [sonar-typescript-plugin-0.6-SNAPSHOT.jar:na]
at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58) [sonar-scanner-engine-shaded-5.6.jar:na]
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50) [sonar-scanner-engine-shaded-5.6.jar:na]
at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:83) [sonar-scanner-engine-shaded-5.6.jar:na]
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192) [sonar-scanner-engine-shaded-5.6.jar:na]
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) [sonar-scanner-engine-shaded-5.6.jar:na]
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) [sonar-scanner-engine-shaded-5.6.jar:na]
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241) [sonar-scanner-engine-shaded-5.6.jar:na]
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236) [sonar-scanner-engine-shaded-5.6.jar:na]
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:234) [sonar-scanner-engine-shaded-5.6.jar:na]
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226) [sonar-scanner-engine-shaded-5.6.jar:na]
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) [sonar-scanner-engine-shaded-5.6.jar:na]
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) [sonar-scanner-engine-shaded-5.6.jar:na]
at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47) [sonar-scanner-engine-shaded-5.6.jar:na]
at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86) [sonar-scanner-engine-shaded-5.6.jar:na]
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) [sonar-scanner-engine-shaded-5.6.jar:na]
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) [sonar-scanner-engine-shaded-5.6.jar:na]
at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106) [sonar-scanner-engine-shaded-5.6.jar:na]
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119) [sonar-scanner-engine-shaded-5.6.jar:na]
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62) [sonar-scanner-api-batch1609288521281972918.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_73]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_73]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_73]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_73]
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60) [sonar-scanner-cli-2.6.jar:na]
at com.sun.proxy.$Proxy0.execute(Unknown Source) [na:na]
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:240) [sonar-scanner-cli-2.6.jar:na]
at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151) [sonar-scanner-cli-2.6.jar:na]
at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:110) [sonar-scanner-cli-2.6.jar:na]
at org.sonarsource.scanner.cli.Main.execute(Main.java:72) [sonar-scanner-cli-2.6.jar:na]
at org.sonarsource.scanner.cli.Main.main(Main.java:60) [sonar-scanner-cli-2.6.jar:na]

I fix it like this

  private void saveZeroValueForResource(org.sonar.api.resources.File resource, SensorContext context) {
        PropertiesBuilder<Integer, Integer> lineHitsData = new PropertiesBuilder<>(CoreMetrics.COVERAGE_LINE_HITS_DATA);
        LOG.info("saveZeroValueForResource 1");

        Measure<Integer> measure = context.getMeasure(resource, CoreMetrics.LINES);

        if(measure == null){
            LOG.info("measure == null for {}", resource.getPath());
            return;
        }

Javascript LCOV files

Firstly welldone on a great plugin.

I have a large typescript project, with karma unit tests. And I currently use this plugin to do Linting of my TS files. I'm now trying to add the karma generated LCOV report to the process, but running into issues.

Does your LCOV parser support reading of LCOV files generated off javascript files. The report is generated and read in correctly by Teamcity. But as soon as I pump it into the Sonar it doesn't yeild any results.

Any help with this is appreciated.
Andrew

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.