diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-04-17 17:43:59 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-04-20 10:54:26 +0200 |
commit | 5184eb75a04d52848226067b30eda5e652029cdf (patch) | |
tree | 76d4702592f6e46b823454d2dd27ed72ac4e5de7 /server | |
parent | 01f3bef8f77526fb5f5f2dbe94390d42be7fa2bc (diff) | |
download | sonarqube-5184eb75a04d52848226067b30eda5e652029cdf.tar.gz sonarqube-5184eb75a04d52848226067b30eda5e652029cdf.zip |
sanitize batch protocol domains relating to use of singular/plural
Diffstat (limited to 'server')
10 files changed, 49 insertions, 129 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/SourceLinesCache.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/SourceLinesCache.java index b49e8abf5f4..9af0128ce8e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/SourceLinesCache.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/SourceLinesCache.java @@ -21,8 +21,8 @@ package org.sonar.server.computation.issue; import org.apache.commons.lang.StringUtils; import org.sonar.batch.protocol.output.BatchReport; -import org.sonar.batch.protocol.output.BatchReport.Scm.Changeset; -import org.sonar.batch.protocol.output.BatchReport.Scm.Changeset.Builder; +import org.sonar.batch.protocol.output.BatchReport.Changesets.Changeset; +import org.sonar.batch.protocol.output.BatchReport.Changesets.Changeset.Builder; import org.sonar.batch.protocol.output.BatchReportReader; import org.sonar.server.source.index.SourceLineDoc; import org.sonar.server.source.index.SourceLineIndex; @@ -52,7 +52,7 @@ public class SourceLinesCache { private BatchReportReader reportReader; private boolean loaded = false; - private BatchReport.Scm scm; + private BatchReport.Changesets scm; private String currentFileUuid; private Integer currentFileReportRef; @@ -90,7 +90,7 @@ public class SourceLinesCache { } String author = null; if (lineIndex < scm.getChangesetIndexByLineCount()) { - BatchReport.Scm.Changeset changeset = scm.getChangeset(scm.getChangesetIndexByLine(lineIndex)); + BatchReport.Changesets.Changeset changeset = scm.getChangeset(scm.getChangesetIndexByLine(lineIndex)); author = changeset.hasAuthor() ? changeset.getAuthor() : null; } @@ -113,19 +113,19 @@ public class SourceLinesCache { computeLastCommitDateAndAuthor(); } - private BatchReport.Scm loadScmFromReport() { - return reportReader.readComponentScm(currentFileReportRef); + private BatchReport.Changesets loadScmFromReport() { + return reportReader.readChangesets(currentFileReportRef); } - private BatchReport.Scm loadLinesFromIndexAndBuildScm() { + private BatchReport.Changesets loadLinesFromIndexAndBuildScm() { List<SourceLineDoc> lines = index.getLines(currentFileUuid); - Map<String, BatchReport.Scm.Changeset> changesetByRevision = new HashMap<>(); - BatchReport.Scm.Builder scmBuilder = BatchReport.Scm.newBuilder() + Map<String, BatchReport.Changesets.Changeset> changesetByRevision = new HashMap<>(); + BatchReport.Changesets.Builder scmBuilder = BatchReport.Changesets.newBuilder() .setComponentRef(currentFileReportRef); for (SourceLineDoc sourceLine : lines) { String scmRevision = sourceLine.scmRevision(); if (scmRevision == null || changesetByRevision.get(scmRevision) == null) { - Builder changeSetBuilder = BatchReport.Scm.Changeset.newBuilder(); + Builder changeSetBuilder = BatchReport.Changesets.Changeset.newBuilder(); String scmAuthor = sourceLine.scmAuthor(); if (scmAuthor != null) { changeSetBuilder.setAuthor(scmAuthor); @@ -152,7 +152,7 @@ public class SourceLinesCache { } private void computeLastCommitDateAndAuthor() { - for (BatchReport.Scm.Changeset changeset : scm.getChangesetList()) { + for (BatchReport.Changesets.Changeset changeset : scm.getChangesetList()) { if (changeset.hasAuthor() && changeset.hasDate() && changeset.getDate() > lastCommitDate) { lastCommitDate = changeset.getDate(); lastCommitAuthor = changeset.getAuthor(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/source/ScmLineReader.java b/server/sonar-server/src/main/java/org/sonar/server/computation/source/ScmLineReader.java index 4b162ff94b4..e4fadee5e1d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/source/ScmLineReader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/source/ScmLineReader.java @@ -25,15 +25,15 @@ import org.sonar.server.source.db.FileSourceDb; public class ScmLineReader implements LineReader { - private final BatchReport.Scm scmReport; + private final BatchReport.Changesets scmReport; - public ScmLineReader(BatchReport.Scm scmReport) { + public ScmLineReader(BatchReport.Changesets scmReport) { this.scmReport = scmReport; } @Override public void read(FileSourceDb.Line.Builder lineBuilder) { int changeSetIndex = scmReport.getChangesetIndexByLine(lineBuilder.getLine() - 1); - BatchReport.Scm.Changeset changeset = scmReport.getChangeset(changeSetIndex); + BatchReport.Changesets.Changeset changeset = scmReport.getChangeset(changeSetIndex); boolean hasAuthor = changeset.hasAuthor(); if (hasAuthor) { lineBuilder.setScmAuthor(changeset.getAuthor()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java index 7bae33f27d4..77855cdc0c1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java @@ -178,7 +178,7 @@ public class PersistFileSourcesStep implements ComputationStep { LineReaders(BatchReportReader reportReader, int componentRef) { File coverageFile = reportReader.readComponentCoverage(componentRef); - BatchReport.Scm scmReport = reportReader.readComponentScm(componentRef); + BatchReport.Changesets scmReport = reportReader.readChangesets(componentRef); File highlightingFile = reportReader.readComponentSyntaxHighlighting(componentRef); List<BatchReport.Symbols.Symbol> symbols = reportReader.readComponentSymbols(componentRef); List<BatchReport.Duplication> duplications = reportReader.readComponentDuplications(componentRef); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStep.java index 5929138da9d..f9560150120 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStep.java @@ -87,7 +87,7 @@ public class PersistNumberOfDaysSinceLastCommitStep implements ComputationStep { private void recursivelyProcessComponent(ComputationContext context, int componentRef) { BatchReportReader reportReader = context.getReportReader(); BatchReport.Component component = reportReader.readComponent(componentRef); - BatchReport.Scm scm = reportReader.readComponentScm(componentRef); + BatchReport.Changesets scm = reportReader.readChangesets(componentRef); processScm(scm); for (Integer childRef : component.getChildRefList()) { @@ -95,12 +95,12 @@ public class PersistNumberOfDaysSinceLastCommitStep implements ComputationStep { } } - private void processScm(@Nullable BatchReport.Scm scm) { + private void processScm(@Nullable BatchReport.Changesets scm) { if (scm == null) { return; } - for (BatchReport.Scm.Changeset changeset : scm.getChangesetList()) { + for (BatchReport.Changesets.Changeset changeset : scm.getChangesetList()) { if (changeset.hasDate() && changeset.getDate() > lastCommitTimestamp) { lastCommitTimestamp = changeset.getDate(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestResultsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestResultsStep.java deleted file mode 100644 index 8dd727245fa..00000000000 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestResultsStep.java +++ /dev/null @@ -1,79 +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.sonar.api.i18n.I18n; -import org.sonar.api.resources.Qualifiers; -import org.sonar.batch.protocol.output.BatchReport; -import org.sonar.batch.protocol.output.BatchReportReader; -import org.sonar.core.persistence.DbSession; -import org.sonar.core.persistence.MyBatis; -import org.sonar.core.source.db.FileSourceDto; -import org.sonar.server.computation.ComputationContext; -import org.sonar.server.db.DbClient; - -public class PersistTestResultsStep implements ComputationStep { - - private final DbClient dbClient; - - public PersistTestResultsStep(DbClient dbClient, I18n i18n) { - this.dbClient = dbClient; - } - - @Override - public String[] supportedProjectQualifiers() { - return new String[] {Qualifiers.PROJECT}; - } - - @Override - public void execute(ComputationContext context) { - DbSession session = dbClient.openSession(false); - try { - int rootComponentRef = context.getReportMetadata().getRootComponentRef(); - recursivelyProcessComponent(session, context, rootComponentRef); - session.commit(); - } finally { - MyBatis.closeQuietly(session); - } - } - - private void recursivelyProcessComponent(DbSession session, ComputationContext context, int componentRef) { - BatchReportReader reportReader = context.getReportReader(); - BatchReport.Component component = reportReader.readComponent(componentRef); - if (component.getIsTest() && reportReader.readTestResults(componentRef) != null) { - persistTestResults(session, component); - } - - for (Integer childRef : component.getChildRefList()) { - recursivelyProcessComponent(session, context, childRef); - } - } - - private void persistTestResults(DbSession session, BatchReport.Component component) { - dbClient.fileSourceDao().select(component.getUuid()); - dbClient.fileSourceDao().update(session, new FileSourceDto()); - } - - @Override - public String getDescription() { - return "Persist test results"; - } -} diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/SourceLinesCacheTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/SourceLinesCacheTest.java index 290253b4e3b..5a9403fd765 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/SourceLinesCacheTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/SourceLinesCacheTest.java @@ -61,7 +61,7 @@ public class SourceLinesCacheTest { @Test public void line_author_from_report() throws Exception { BatchReportWriter reportWriter = new BatchReportWriter(dir); - reportWriter.writeComponentScm(BatchReport.Scm.newBuilder() + reportWriter.writeComponentChangesets(BatchReport.Changesets.newBuilder() .setComponentRef(123_456_789) .addChangeset(newChangeset("charb", "123-456-789", 123_456_789L)) .addChangeset(newChangeset("wolinski", "987-654-321", 987_654_321L)) @@ -106,8 +106,8 @@ public class SourceLinesCacheTest { sut.lineAuthor(0); } - private BatchReport.Scm.Changeset.Builder newChangeset(String author, String revision, long date) { - return BatchReport.Scm.Changeset.newBuilder() + private BatchReport.Changesets.Changeset.Builder newChangeset(String author, String revision, long date) { + return BatchReport.Changesets.Changeset.newBuilder() .setAuthor(author) .setRevision(revision) .setDate(date); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/source/ReportIteratorTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/source/ReportIteratorTest.java index 86c5e6f405b..9a0a56983f3 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/source/ReportIteratorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/source/ReportIteratorTest.java @@ -55,7 +55,7 @@ public class ReportIteratorTest { .build() )); - file = new FileStructure(dir).fileFor(FileStructure.Domain.COVERAGE, 1); + file = new FileStructure(dir).fileFor(FileStructure.Domain.COVERAGES, 1); } @After diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/source/ScmLineReaderTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/source/ScmLineReaderTest.java index 59c27fe81e1..a8db073973e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/source/ScmLineReaderTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/source/ScmLineReaderTest.java @@ -31,8 +31,8 @@ public class ScmLineReaderTest { @Test public void set_scm() throws Exception { - BatchReport.Scm scmReport = BatchReport.Scm.newBuilder() - .addChangeset(BatchReport.Scm.Changeset.newBuilder() + BatchReport.Changesets scmReport = BatchReport.Changesets.newBuilder() + .addChangeset(BatchReport.Changesets.Changeset.newBuilder() .setAuthor("john") .setDate(123456789L) .setRevision("rev-1") @@ -52,8 +52,8 @@ public class ScmLineReaderTest { @Test public void set_only_author() throws Exception { - BatchReport.Scm scmReport = BatchReport.Scm.newBuilder() - .addChangeset(BatchReport.Scm.Changeset.newBuilder() + BatchReport.Changesets scmReport = BatchReport.Changesets.newBuilder() + .addChangeset(BatchReport.Changesets.Changeset.newBuilder() .setAuthor("john") .build()) .addChangesetIndexByLine(0) @@ -71,8 +71,8 @@ public class ScmLineReaderTest { @Test public void set_only_date() throws Exception { - BatchReport.Scm scmReport = BatchReport.Scm.newBuilder() - .addChangeset(BatchReport.Scm.Changeset.newBuilder() + BatchReport.Changesets scmReport = BatchReport.Changesets.newBuilder() + .addChangeset(BatchReport.Changesets.Changeset.newBuilder() .setDate(123456789L) .build()) .addChangesetIndexByLine(0) @@ -90,8 +90,8 @@ public class ScmLineReaderTest { @Test public void set_only_revision() throws Exception { - BatchReport.Scm scmReport = BatchReport.Scm.newBuilder() - .addChangeset(BatchReport.Scm.Changeset.newBuilder() + BatchReport.Changesets scmReport = BatchReport.Changesets.newBuilder() + .addChangeset(BatchReport.Changesets.Changeset.newBuilder() .setRevision("rev-1") .build()) .addChangesetIndexByLine(0) @@ -109,8 +109,8 @@ public class ScmLineReaderTest { @Test public void fail_when_changeset_is_empty() throws Exception { - BatchReport.Scm scmReport = BatchReport.Scm.newBuilder() - .addChangeset(BatchReport.Scm.Changeset.newBuilder() + BatchReport.Changesets scmReport = BatchReport.Changesets.newBuilder() + .addChangeset(BatchReport.Changesets.Changeset.newBuilder() .build()) .addChangesetIndexByLine(0) .build(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistFileSourcesStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistFileSourcesStepTest.java index e9620343928..5b25f6fb651 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistFileSourcesStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistFileSourcesStepTest.java @@ -20,8 +20,6 @@ package org.sonar.server.computation.step; -import org.sonar.server.source.db.FileSourceDao; - import com.google.common.collect.Lists; import org.apache.commons.io.FileUtils; import org.junit.After; @@ -43,6 +41,7 @@ import org.sonar.core.source.db.FileSourceDto; import org.sonar.server.component.ComponentTesting; import org.sonar.server.computation.ComputationContext; import org.sonar.server.db.DbClient; +import org.sonar.server.source.db.FileSourceDao; import org.sonar.server.source.db.FileSourceDb; import org.sonar.test.DbTests; @@ -146,7 +145,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { .setRef(FILE_REF) .setType(Constants.ComponentType.FILE) .setUuid(FILE_UUID) - // Lines is set to 3 but only 2 lines are read from the file -> the last lines should be added + // Lines is set to 3 but only 2 lines are read from the file -> the last lines should be added .setLines(3) .build()); @@ -209,9 +208,9 @@ public class PersistFileSourcesStepTest extends BaseStepTest { public void persist_scm() throws Exception { BatchReportWriter writer = initBasicReport(1); - writer.writeComponentScm(BatchReport.Scm.newBuilder() + writer.writeComponentChangesets(BatchReport.Changesets.newBuilder() .setComponentRef(FILE_REF) - .addChangeset(BatchReport.Scm.Changeset.newBuilder() + .addChangeset(BatchReport.Changesets.Changeset.newBuilder() .setAuthor("john") .setDate(123456789L) .setRevision("rev-1") @@ -237,13 +236,13 @@ public class PersistFileSourcesStepTest extends BaseStepTest { BatchReportWriter writer = initBasicReport(1); writer.writeComponentSyntaxHighlighting(FILE_REF, newArrayList(BatchReport.SyntaxHighlighting.newBuilder() - .setRange(BatchReport.Range.newBuilder() - .setStartLine(1).setEndLine(1) - .setStartOffset(2).setEndOffset(4) - .build()) - .setType(Constants.HighlightingType.ANNOTATION) - .build() - )); + .setRange(BatchReport.Range.newBuilder() + .setStartLine(1).setEndLine(1) + .setStartOffset(2).setEndOffset(4) + .build()) + .setType(Constants.HighlightingType.ANNOTATION) + .build() + )); sut.execute(new ComputationContext(new BatchReportReader(reportDir), ComponentTesting.newProjectDto(PROJECT_UUID))); @@ -266,10 +265,10 @@ public class PersistFileSourcesStepTest extends BaseStepTest { .setStartLine(1).setEndLine(1).setStartOffset(2).setEndOffset(4) .build()) .addReference(BatchReport.Range.newBuilder() - .setStartLine(3).setEndLine(3).setStartOffset(1).setEndOffset(3) - .build() + .setStartLine(3).setEndLine(3).setStartOffset(1).setEndOffset(3) + .build() ).build() - )); + )); sut.execute(new ComputationContext(new BatchReportReader(reportDir), ComponentTesting.newProjectDto(PROJECT_UUID))); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStepTest.java index 846e9432a4d..b65582c80a9 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStepTest.java @@ -83,11 +83,11 @@ public class PersistNumberOfDaysSinceLastCommitStepTest extends BaseStepTest { public void persist_number_of_days_since_last_commit_from_report() throws Exception { long threeDaysAgo = DateUtils.addDays(new Date(), -3).getTime(); BatchReportWriter reportWriter = initReportWithProjectAndFile(); - reportWriter.writeComponentScm( - BatchReport.Scm.newBuilder() + reportWriter.writeComponentChangesets( + BatchReport.Changesets.newBuilder() .setComponentRef(2) .addChangeset( - BatchReport.Scm.Changeset.newBuilder() + BatchReport.Changesets.Changeset.newBuilder() .setDate(threeDaysAgo) ) .build() |