aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-05-13 17:59:15 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2015-05-19 20:18:11 +0200
commit1abbd252c8513f92dbb9875288c5d000bb8f8c29 (patch)
treebb2457b69006e1eb49c0cd049da2745864d3e484 /plugins
parent10c3297f7506e314f14bf6512f2db48a3fa1eb1b (diff)
downloadsonarqube-1abbd252c8513f92dbb9875288c5d000bb8f8c29.tar.gz
sonarqube-1abbd252c8513f92dbb9875288c5d000bb8f8c29.zip
SONAR-6555 Drop design related features on batch side
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java19
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/DependencySensor.java106
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/DependencySensorTest.java108
3 files changed, 16 insertions, 217 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java
index 2d77a3d90c4..43f8d25f212 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java
@@ -25,8 +25,22 @@ import org.sonar.xoo.coverage.OverallCoverageSensor;
import org.sonar.xoo.coverage.UtCoverageSensor;
import org.sonar.xoo.extensions.XooPostJob;
import org.sonar.xoo.extensions.XooProjectBuilder;
-import org.sonar.xoo.lang.*;
-import org.sonar.xoo.rule.*;
+import org.sonar.xoo.lang.MeasureSensor;
+import org.sonar.xoo.lang.SymbolReferencesSensor;
+import org.sonar.xoo.lang.SyntaxHighlightingSensor;
+import org.sonar.xoo.lang.XooCpdMapping;
+import org.sonar.xoo.lang.XooTokenizer;
+import org.sonar.xoo.rule.ChecksSensor;
+import org.sonar.xoo.rule.CreateIssueByInternalKeySensor;
+import org.sonar.xoo.rule.DeprecatedResourceApiSensor;
+import org.sonar.xoo.rule.OneIssueOnDirPerFileSensor;
+import org.sonar.xoo.rule.OneIssuePerLineSensor;
+import org.sonar.xoo.rule.RandomAccessSensor;
+import org.sonar.xoo.rule.XooFakeExporter;
+import org.sonar.xoo.rule.XooFakeImporter;
+import org.sonar.xoo.rule.XooFakeImporterWithMessages;
+import org.sonar.xoo.rule.XooQualityProfile;
+import org.sonar.xoo.rule.XooRulesDefinition;
import org.sonar.xoo.scm.XooBlameCommand;
import org.sonar.xoo.scm.XooScmProvider;
import org.sonar.xoo.test.CoveragePerTestSensor;
@@ -66,7 +80,6 @@ public class XooPlugin extends SonarPlugin {
MeasureSensor.class,
SyntaxHighlightingSensor.class,
SymbolReferencesSensor.class,
- DependencySensor.class,
ChecksSensor.class,
RandomAccessSensor.class,
DeprecatedResourceApiSensor.class,
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/DependencySensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/DependencySensor.java
deleted file mode 100644
index 1c558ff24c6..00000000000
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/DependencySensor.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.xoo.lang;
-
-import com.google.common.base.Splitter;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.batch.fs.FilePredicates;
-import org.sonar.api.batch.fs.FileSystem;
-import org.sonar.api.batch.fs.InputFile;
-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;
-import org.sonar.xoo.Xoo;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Parse files *.xoo.deps
- */
-public class DependencySensor implements Sensor {
-
- private static final Logger LOG = Loggers.get(DependencySensor.class);
-
- private static final String DEPS_EXTENSION = ".deps";
-
- private void processDependencies(InputFile inputFile, SensorContext context) {
- File ioFile = inputFile.file();
- File depsFile = new File(ioFile.getParentFile(), ioFile.getName() + DEPS_EXTENSION);
- if (depsFile.exists()) {
- LOG.debug("Processing " + depsFile.getAbsolutePath());
- try {
- List<String> lines = FileUtils.readLines(depsFile, context.fileSystem().encoding().name());
- int lineNumber = 0;
- for (String line : lines) {
- lineNumber++;
- if (StringUtils.isBlank(line) || line.startsWith("#")) {
- continue;
- }
- processLine(depsFile, lineNumber, context, line, inputFile);
- }
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
- }
-
- private void processLine(File coverPerTest, int lineNumber, SensorContext context, String line, InputFile file) {
- try {
- Iterator<String> split = Splitter.on(":").split(line).iterator();
- String otherFileRelativePath = split.next();
- FileSystem fs = context.fileSystem();
- InputFile otherFile = fs.inputFile(fs.predicates().hasRelativePath(otherFileRelativePath));
- if (otherFile == null) {
- throw new IllegalStateException("Unable to find file " + otherFileRelativePath);
- }
- int weight = Integer.parseInt(split.next());
- context.newDependency()
- .from(file)
- .to(otherFile)
- .weight(weight)
- .save();
- } catch (Exception e) {
- throw new IllegalStateException("Error processing line " + lineNumber + " of file " + coverPerTest.getAbsolutePath(), e);
- }
- }
-
- @Override
- public void describe(SensorDescriptor descriptor) {
- descriptor
- .name("Xoo Dependency Sensor")
- .onlyOnLanguages(Xoo.KEY)
- .onlyOnFileType(InputFile.Type.MAIN);
- }
-
- @Override
- public void execute(SensorContext context) {
- FileSystem fs = context.fileSystem();
- FilePredicates p = fs.predicates();
- for (InputFile file : fs.inputFiles(p.and(p.hasLanguages(Xoo.KEY), p.hasType(InputFile.Type.MAIN)))) {
- processDependencies(file, context);
- }
- }
-}
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/DependencySensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/DependencySensorTest.java
deleted file mode 100644
index 73b63909ebc..00000000000
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/DependencySensorTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.xoo.lang;
-
-import org.sonar.api.batch.sensor.internal.SensorStorage;
-
-import org.apache.commons.io.FileUtils;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.sonar.api.batch.fs.InputFile.Type;
-import org.sonar.api.batch.fs.internal.DefaultFileSystem;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.sensor.SensorContext;
-import org.sonar.api.batch.sensor.dependency.Dependency;
-import org.sonar.api.batch.sensor.dependency.internal.DefaultDependency;
-import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
-
-import java.io.File;
-import java.io.IOException;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class DependencySensorTest {
-
- private DependencySensor sensor;
- private SensorContext context = mock(SensorContext.class);
- private DefaultFileSystem fileSystem;
-
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
- private File baseDir;
-
- @Before
- public void prepare() throws IOException {
- baseDir = temp.newFolder();
- sensor = new DependencySensor();
- fileSystem = new DefaultFileSystem(baseDir.toPath());
- when(context.fileSystem()).thenReturn(fileSystem);
- }
-
- @Test
- public void testDescriptor() {
- sensor.describe(new DefaultSensorDescriptor());
- }
-
- @Test
- public void testNoExecutionIfNoDepsFile() {
- DefaultInputFile file = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo")
- .setType(Type.MAIN);
- fileSystem.add(file);
- sensor.execute(context);
- }
-
- @Test
- public void testExecution() throws IOException {
- File deps = new File(baseDir, "src/foo.xoo.deps");
- FileUtils.write(deps, "src/foo2.xoo:2\nsrc2/foo3.xoo:6\n\n#comment");
- DefaultInputFile inputFile1 = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo");
- DefaultInputFile inputFile2 = new DefaultInputFile("foo", "src/foo2.xoo").setLanguage("xoo");
- DefaultInputFile inputFile3 = new DefaultInputFile("foo", "src2/foo3.xoo").setLanguage("xoo");
- fileSystem.add(inputFile1);
- fileSystem.add(inputFile2);
- fileSystem.add(inputFile3);
-
- final SensorStorage sensorStorage = mock(SensorStorage.class);
-
- when(context.newDependency()).thenAnswer(new Answer<Dependency>() {
- @Override
- public Dependency answer(InvocationOnMock invocation) throws Throwable {
- return new DefaultDependency(sensorStorage);
- }
- });
-
- sensor.execute(context);
-
- verify(sensorStorage).store(new DefaultDependency()
- .from(inputFile1)
- .to(inputFile2)
- .weight(2));
- verify(sensorStorage).store(new DefaultDependency()
- .from(inputFile1)
- .to(inputFile3)
- .weight(6));
- }
-}