diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2015-01-15 12:12:53 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2015-01-15 15:12:15 +0100 |
commit | 0132d6677fa9e3d4c9e55ac9ea13a8b700d443bb (patch) | |
tree | abc31143ddce439a6f24f0951454dde32598ec6a /plugins/sonar-core-plugin | |
parent | 19ed354afe89135bec458dd855b99ce606850cdf (diff) | |
download | sonarqube-0132d6677fa9e3d4c9e55ac9ea13a8b700d443bb.tar.gz sonarqube-0132d6677fa9e3d4c9e55ac9ea13a8b700d443bb.zip |
SONAR-5883 Drop snapshot data
Diffstat (limited to 'plugins/sonar-core-plugin')
3 files changed, 0 insertions, 179 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java index fb1eb26c69d..cd9f54ee857 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java @@ -53,7 +53,6 @@ import org.sonar.plugins.core.sensors.BranchCoverageDecorator; import org.sonar.plugins.core.sensors.CommentDensityDecorator; import org.sonar.plugins.core.sensors.CoverageDecorator; import org.sonar.plugins.core.sensors.DirectoriesDecorator; -import org.sonar.plugins.core.sensors.FileHashSensor; import org.sonar.plugins.core.sensors.FilesDecorator; import org.sonar.plugins.core.sensors.ItBranchCoverageDecorator; import org.sonar.plugins.core.sensors.ItCoverageDecorator; @@ -373,7 +372,6 @@ public final class CorePlugin extends SonarPlugin { DirectoriesDecorator.class, FilesDecorator.class, ManualMeasureDecorator.class, - FileHashSensor.class, // time machine TendencyDecorator.class, diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/FileHashSensor.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/FileHashSensor.java deleted file mode 100644 index 5f0bfb3a2dc..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/FileHashSensor.java +++ /dev/null @@ -1,78 +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.plugins.core.sensors; - -import com.google.common.collect.Maps; -import org.sonar.api.batch.Sensor; -import org.sonar.api.batch.SensorContext; -import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile; -import org.sonar.api.resources.Project; -import org.sonar.api.utils.KeyValueFormat; -import org.sonar.batch.index.ComponentDataCache; -import org.sonar.batch.scan.filesystem.InputPathCache; -import org.sonar.core.DryRunIncompatible; -import org.sonar.core.source.SnapshotDataTypes; - -import java.util.Map; - -/** - * This sensor will retrieve hash of each file of the current module and store it in DB - * in order to compare it during next analysis and see if the file was modified. - * This is used by the incremental preview mode. - * - * @since 4.0 - */ -@DryRunIncompatible -public final class FileHashSensor implements Sensor { - - private final InputPathCache fileCache; - private final ComponentDataCache componentDataCache; - - public FileHashSensor(InputPathCache fileCache, ComponentDataCache componentDataCache) { - this.fileCache = fileCache; - this.componentDataCache = componentDataCache; - } - - @Override - public boolean shouldExecuteOnProject(Project project) { - return true; - } - - @Override - public void analyse(Project project, SensorContext context) { - Map<String, String> map = Maps.newHashMap(); - for (InputFile inputFile : fileCache.filesByModule(project.key())) { - String hash = ((DeprecatedDefaultInputFile) inputFile).hash(); - if (hash != null) { - map.put(inputFile.relativePath(), hash); - } - } - if (!map.isEmpty()) { - String data = KeyValueFormat.format(map); - componentDataCache.setStringData(project.key(), SnapshotDataTypes.FILE_HASHES, data); - } - } - - @Override - public String toString() { - return getClass().getSimpleName(); - } -} diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/FileHashSensorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/FileHashSensorTest.java deleted file mode 100644 index f0c32fad7c5..00000000000 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/FileHashSensorTest.java +++ /dev/null @@ -1,99 +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.plugins.core.sensors; - -import com.google.common.collect.Lists; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.rules.TemporaryFolder; -import org.sonar.api.batch.SensorContext; -import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile; -import org.sonar.api.resources.Project; -import org.sonar.batch.index.ComponentDataCache; -import org.sonar.batch.scan.filesystem.InputPathCache; -import org.sonar.core.source.SnapshotDataTypes; - -import java.util.Collections; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; - -public class FileHashSensorTest { - - @Rule - public TemporaryFolder temp = new TemporaryFolder(); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - Project project = new Project("struts"); - InputPathCache fileCache = mock(InputPathCache.class); - ComponentDataCache componentDataCache = mock(ComponentDataCache.class); - FileHashSensor sensor = new FileHashSensor(fileCache, componentDataCache); - - @Test - public void store_file_hashes() throws Exception { - when(fileCache.filesByModule("struts")).thenReturn(Lists.<InputFile>newArrayList( - new DeprecatedDefaultInputFile("foo", "src/Foo.java").setFile(temp.newFile()).setHash("ABC"), - new DeprecatedDefaultInputFile("foo", "src/Bar.java").setFile(temp.newFile()).setHash("DEF"))); - - SensorContext sensorContext = mock(SensorContext.class); - sensor.analyse(project, sensorContext); - - verify(componentDataCache).setStringData("struts", SnapshotDataTypes.FILE_HASHES, "src/Foo.java=ABC;src/Bar.java=DEF"); - verifyZeroInteractions(sensorContext); - } - - @Test - public void store_file_hashes_for_branches() throws Exception { - project = new Project("struts", "branch-2.x", "Struts 2.x"); - when(fileCache.filesByModule("struts:branch-2.x")).thenReturn(Lists.<InputFile>newArrayList( - new DeprecatedDefaultInputFile("foo", "src/Foo.java").setFile(temp.newFile()).setHash("ABC"), - new DeprecatedDefaultInputFile("foo", "src/Bar.java").setFile(temp.newFile()).setHash("DEF"))); - - SensorContext sensorContext = mock(SensorContext.class); - sensor.analyse(project, sensorContext); - - verify(componentDataCache).setStringData("struts:branch-2.x", SnapshotDataTypes.FILE_HASHES, "src/Foo.java=ABC;src/Bar.java=DEF"); - verifyZeroInteractions(sensorContext); - } - - @Test - public void various_tests() throws Exception { - assertThat(sensor.shouldExecuteOnProject(project)).isTrue(); - assertThat(sensor.toString()).isEqualTo("FileHashSensor"); - } - - @Test - public void dont_save_hashes_if_no_files() throws Exception { - when(fileCache.filesByModule("struts")).thenReturn(Collections.<InputFile>emptyList()); - - SensorContext sensorContext = mock(SensorContext.class); - sensor.analyse(project, sensorContext); - - verifyZeroInteractions(componentDataCache); - verifyZeroInteractions(sensorContext); - } -} |