This repository has been archived by the owner on Apr 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sensor logging message that SonarTS does nothing (#885)
- Loading branch information
1 parent
ea40741
commit 6bc0f09
Showing
4 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...ugin/sonar-typescript-plugin/src/main/java/org/sonar/plugin/typescript/EmptyTsSensor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* SonarTS | ||
* Copyright (C) 2017-2019 SonarSource SA | ||
* mailto:info AT sonarsource DOT com | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.sonar.plugin.typescript; | ||
|
||
import org.sonar.api.batch.sensor.Sensor; | ||
import org.sonar.api.batch.sensor.SensorContext; | ||
import org.sonar.api.batch.sensor.SensorDescriptor; | ||
import org.sonar.api.utils.log.Logger; | ||
import org.sonar.api.utils.log.Loggers; | ||
|
||
public class EmptyTsSensor implements Sensor { | ||
|
||
private static final Logger LOG = Loggers.get(EmptyTsSensor.class); | ||
|
||
@Override | ||
public void describe(SensorDescriptor sensorDescriptor) { | ||
sensorDescriptor | ||
.onlyOnLanguage("ts") | ||
.name("SonarTS"); | ||
} | ||
|
||
@Override | ||
public void execute(SensorContext sensorContext) { | ||
LOG.info("Since SonarTS v2.0, TypeScript analysis is performed by SonarJS analyzer v6.0 or later. No TypeScript analysis is performed by SonarTS."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
.../sonar-typescript-plugin/src/test/java/org/sonar/plugin/typescript/EmptyTsSensorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* SonarTS | ||
* Copyright (C) 2017-2019 SonarSource SA | ||
* mailto:info AT sonarsource DOT com | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.sonar.plugin.typescript; | ||
|
||
import java.io.File; | ||
import org.junit.Test; | ||
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; | ||
import org.sonar.api.batch.sensor.internal.SensorContextTester; | ||
import org.sonar.api.utils.log.LogTester; | ||
import org.sonar.api.utils.log.LoggerLevel; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class EmptyTsSensorTest { | ||
|
||
@org.junit.Rule | ||
public LogTester logTester = new LogTester(); | ||
|
||
@Test | ||
public void descriptor() { | ||
DefaultSensorDescriptor sensorDescriptor = new DefaultSensorDescriptor(); | ||
new EmptyTsSensor().describe(sensorDescriptor); | ||
|
||
assertThat(sensorDescriptor.languages()).containsExactly("ts"); | ||
assertThat(sensorDescriptor.name()).isEqualTo("SonarTS"); | ||
} | ||
|
||
@Test | ||
public void log_message() { | ||
new EmptyTsSensor().execute(SensorContextTester.create(new File(""))); | ||
assertThat(logTester.logs(LoggerLevel.INFO)) | ||
.containsExactly("Since SonarTS v2.0, TypeScript analysis is performed by SonarJS analyzer v6.0 or later. No TypeScript analysis is performed by SonarTS."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters