aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-04-09 17:33:57 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-04-09 17:33:57 +0200
commit183b78861f7b48113686e19765b2d13d31b5cd64 (patch)
treebed1e68ce78a625cddf25b94f07e90bc8cd7e2fe /server/sonar-server
parent7155123011053abae8646c6b8ac79bbe19d1355c (diff)
downloadsonarqube-183b78861f7b48113686e19765b2d13d31b5cd64.tar.gz
sonarqube-183b78861f7b48113686e19765b2d13d31b5cd64.zip
Fix quality flaws
Diffstat (limited to 'server/sonar-server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/source/LineReader.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistSyntaxHighLightingStep.java98
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistSyntaxHighLightingStepTest.java142
3 files changed, 1 insertions, 241 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/source/LineReader.java b/server/sonar-server/src/main/java/org/sonar/server/computation/source/LineReader.java
index ab95c60197a..0ec4d573b2a 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/source/LineReader.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/source/LineReader.java
@@ -24,6 +24,6 @@ import org.sonar.server.source.db.FileSourceDb;
public interface LineReader {
- void read(FileSourceDb.Line.Builder lineBuilder);
+ void read(FileSourceDb.Line.Builder lineBuilder);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistSyntaxHighLightingStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistSyntaxHighLightingStep.java
deleted file mode 100644
index e3f0e458862..00000000000
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistSyntaxHighLightingStep.java
+++ /dev/null
@@ -1,98 +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.server.computation.step;
-
-import com.google.common.annotations.VisibleForTesting;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.server.computation.ComputationContext;
-
-import java.util.Map;
-
-/**
- * Nothing is persist for the moment. Only Syntax Highlighting are read and not persist for the moment
- */
-public class PersistSyntaxHighLightingStep implements ComputationStep {
-
- private static final String OFFSET_SEPARATOR = ",";
-
- // Temporary variable in order to be able to test that syntax highlighting are well computed. Will only contains data from last processed
- // file
- private Map<Integer, StringBuilder> syntaxHighlightingByLineForLastProcessedFile;
-
- @Override
- public String[] supportedProjectQualifiers() {
- return new String[] {Qualifiers.PROJECT};
- }
-
- @Override
- public void execute(ComputationContext context) {
- int rootComponentRef = context.getReportMetadata().getRootComponentRef();
-// recursivelyProcessComponent(context, rootComponentRef);
- }
-//
-// private void recursivelyProcessComponent(ComputationContext context, int componentRef) {
-// BatchReportReader reportReader = context.getReportReader();
-// BatchReport.Component component = reportReader.readComponent(componentRef);
-// List<BatchReport.SyntaxHighlighting.HighlightingRule> highlightingRules = reportReader.readComponentSyntaxHighlighting(componentRef);
-// processSyntaxHightlighting(component, highlightingRules);
-//
-// for (Integer childRef : component.getChildRefList()) {
-// recursivelyProcessComponent(context, childRef);
-// }
-// }
-//
-// private void processSyntaxHightlighting(BatchReport.Component component, List<BatchReport.SyntaxHighlighting.HighlightingRule> highlightingRules) {
-// syntaxHighlightingByLineForLastProcessedFile = newHashMap();
-// if (!highlightingRules.isEmpty()) {
-// for (BatchReport.SyntaxHighlighting.HighlightingRule highlightingRule : highlightingRules) {
-// processHighlightingRule(highlightingRule);
-// }
-// }
-// }
-//
-// private void processHighlightingRule(BatchReport.SyntaxHighlighting.HighlightingRule highlightingRule) {
-// BatchReport.Range range = highlightingRule.getRange();
-// int startLine = range.getStartLine();
-// int endLine = range.getEndLine();
-// if (startLine != endLine) {
-// // TODO support syntax highlighting on multiple lines when source will be in compute, in order to be able to know the end line in this case
-// throw new IllegalStateException("To be implemented : Syntax Highlighting on multiple lines are not supported for the moment");
-// }
-// StringBuilder symbolLine = syntaxHighlightingByLineForLastProcessedFile.get(startLine);
-// if (symbolLine == null) {
-// symbolLine = new StringBuilder();
-// syntaxHighlightingByLineForLastProcessedFile.put(startLine, symbolLine);
-// }
-// symbolLine.append(range.getStartOffset()).append(OFFSET_SEPARATOR);
-// symbolLine.append(range.getEndOffset()).append(OFFSET_SEPARATOR);
-// symbolLine.append(highlightingRule.getType().toString());
-// }
-
- @VisibleForTesting
- Map<Integer, StringBuilder> getSyntaxHighlightingByLine() {
- return syntaxHighlightingByLineForLastProcessedFile;
- }
-
- @Override
- public String getDescription() {
- return "Read Syntax Highlighting";
- }
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistSyntaxHighLightingStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistSyntaxHighLightingStepTest.java
deleted file mode 100644
index e38b5dd75e0..00000000000
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistSyntaxHighLightingStepTest.java
+++ /dev/null
@@ -1,142 +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.server.computation.step;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.TemporaryFolder;
-import org.sonar.batch.protocol.Constants;
-import org.sonar.batch.protocol.output.BatchReport;
-import org.sonar.batch.protocol.output.BatchReportWriter;
-
-import java.io.File;
-import java.io.IOException;
-
-public class PersistSyntaxHighLightingStepTest extends BaseStepTest {
-
- private static final Integer FILE_REF = 3;
-
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
- File reportDir;
-
- PersistSyntaxHighLightingStep step;
-
- @Before
- public void setup() throws Exception {
- reportDir = temp.newFolder();
- step = new PersistSyntaxHighLightingStep();
- }
-
- @Override
- protected ComputationStep step() throws IOException {
- return step;
- }
-
-// @Test
-// public void compute_no_symbol() throws Exception {
-// initReport();
-//
-// step.execute(new ComputationContext(new BatchReportReader(reportDir),
-// ComponentTesting.newProjectDto("PROJECT_A")));
-//
-// assertThat(step.getSyntaxHighlightingByLine()).isEmpty();
-// }
-//
-// @Test
-// public void compute_syntax_highlighting() throws Exception {
-// BatchReportWriter writer = initReport();
-//
-// writer.writeComponentSyntaxHighlighting(FILE_REF, newArrayList(
-// BatchReport.SyntaxHighlighting.HighlightingRule.newBuilder()
-// .setRange(BatchReport.Range.newBuilder()
-// .setStartLine(1)
-// .setStartOffset(3)
-// .setEndLine(1)
-// .setEndOffset(5)
-// .build())
-// .setType(Constants.HighlightingType.ANNOTATION)
-// .build(),
-// BatchReport.SyntaxHighlighting.HighlightingRule.newBuilder()
-// .setRange(BatchReport.Range.newBuilder()
-// .setStartLine(3)
-// .setStartOffset(6)
-// .setEndLine(3)
-// .setEndOffset(7)
-// .build())
-// .setType(Constants.HighlightingType.COMMENT)
-// .build())
-// );
-//
-// step.execute(new ComputationContext(new BatchReportReader(reportDir), mock(ComponentDto.class)));
-//
-// assertThat(step.getSyntaxHighlightingByLine()).hasSize(2);
-// assertThat(step.getSyntaxHighlightingByLine().get(1).toString()).isEqualTo("3,5,ANNOTATION");
-// assertThat(step.getSyntaxHighlightingByLine().get(3).toString()).isEqualTo("6,7,COMMENT");
-// }
-//
-// @Test(expected = IllegalStateException.class)
-// public void fail_when_range_is_defined_on_different_line() throws Exception {
-// BatchReportWriter writer = initReport();
-//
-// writer.writeComponentSyntaxHighlighting(FILE_REF, newArrayList(
-// BatchReport.SyntaxHighlighting.HighlightingRule.newBuilder()
-// .setRange(BatchReport.Range.newBuilder()
-// .setStartLine(1)
-// .setStartOffset(3)
-// .setEndLine(2)
-// .setEndOffset(2)
-// .build())
-// .setType(Constants.HighlightingType.ANNOTATION)
-// .build()));
-//
-// step.execute(new ComputationContext(new BatchReportReader(reportDir), mock(ComponentDto.class)));
-// }
-
- private BatchReportWriter initReport() {
- BatchReportWriter writer = new BatchReportWriter(reportDir);
- writer.writeMetadata(BatchReport.Metadata.newBuilder()
- .setRootComponentRef(1)
- .setProjectKey("PROJECT_KEY")
- .setAnalysisDate(150000000L)
- .build());
-
- writer.writeComponent(BatchReport.Component.newBuilder()
- .setRef(1)
- .setType(Constants.ComponentType.PROJECT)
- .setUuid("PROJECT_A")
- .addChildRef(2)
- .build());
- writer.writeComponent(BatchReport.Component.newBuilder()
- .setRef(2)
- .setType(Constants.ComponentType.MODULE)
- .setUuid("BCDE")
- .addChildRef(FILE_REF)
- .build());
- writer.writeComponent(BatchReport.Component.newBuilder()
- .setRef(FILE_REF)
- .setType(Constants.ComponentType.FILE)
- .setUuid("FILE_A")
- .build());
- return writer;
- }
-
-}