aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-07-20 00:22:54 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-07-20 22:30:42 +0200
commit399f6c100092eff8eef6f99b7bfb8051af2d4f68 (patch)
tree208532e628886a7207d450a3eb1d90f115333ada
parent548a1ccb48cd1d403602670d923bf73b7bd70c0e (diff)
downloadsonarqube-399f6c100092eff8eef6f99b7bfb8051af2d4f68.tar.gz
sonarqube-399f6c100092eff8eef6f99b7bfb8051af2d4f68.zip
SONAR-6703 load common rule parameters from batch report
-rw-r--r--server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/PersistFileSourcesStepTest.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/batch/BatchReportReader.java13
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/batch/BatchReportReaderImpl.java15
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/issue/BaseIssuesLoader.java21
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/issue/Rule.java5
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleCacheLoader.java11
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleImpl.java10
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java14
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/AbstractCoverageRule.java29
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/BranchCoverageRule.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/CommentDensityRule.java42
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/CommonRule.java13
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/LineCoverageRule.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/measure/MeasureRepositoryImpl.java16
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/qualityprofile/ActiveRule.java10
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/qualityprofile/ActiveRulesHolderImpl.java5
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/source/DuplicationLineReader.java8
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/source/ReportIterator.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/source/SymbolsLineReader.java34
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputationSteps.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/FeedActiveRulesStep.java35
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDuplicationsStep.java21
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java43
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistIssuesStep.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/SendIssueNotificationsStep.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/CommonRuleDefinitionsImpl.java6
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/CommonRuleKeys.java6
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/util/ObjectInputStreamIterator.java1
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/util/cache/DiskCache.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/batch/BatchReportReaderImplTest.java33
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/batch/BatchReportReaderRule.java43
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/issue/DumbRule.java11
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/issue/RuleCacheLoaderTest.java18
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/BranchCoverageRuleTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CommentDensityRuleTest.java55
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CommonRuleTest.java71
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CoverageRuleTest.java10
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/DuplicatedBlockRuleTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/LineCoverageRuleTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/SkippedTestRuleTest.java7
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/TestErrorRuleTest.java7
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/qualityprofile/ActiveRulesHolderImplTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/source/DuplicationLineReaderTest.java18
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/source/SymbolsLineReaderTest.java78
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/FeedActiveRulesStepTest.java73
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistFileSourcesStepTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistIssuesStepTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/util/cache/DiskCacheTest.java2
-rw-r--r--sonar-batch-protocol/pom.xml4
-rw-r--r--sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java5902
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/ProtobufUtil.java69
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java69
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportWriter.java35
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/FileStructure.java4
-rw-r--r--sonar-batch-protocol/src/main/protobuf/batch_report.proto44
-rw-r--r--sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/ProtobufUtilTest.java37
-rw-r--r--sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java71
-rw-r--r--sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportWriterTest.java43
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java44
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/report/ActiveRulesPublisher.java62
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/report/MetadataPublisher.java20
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/report/ActiveRulesPublisherTest.java70
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/report/DuplicationsPublisherTest.java54
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java10
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/report/MetadataPublisherTest.java9
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java10
-rw-r--r--sonar-core/src/main/java/org/sonar/core/util/CloseableIterator.java (renamed from server/sonar-server/src/main/java/org/sonar/server/util/CloseableIterator.java)2
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/CloseableIteratorTest.java (renamed from server/sonar-server/src/test/java/org/sonar/server/util/CloseableIteratorTest.java)2
71 files changed, 3057 insertions, 4347 deletions
diff --git a/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/PersistFileSourcesStepTest.java b/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/PersistFileSourcesStepTest.java
index 435ec58a559..914521f3d6f 100644
--- a/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/PersistFileSourcesStepTest.java
+++ b/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/PersistFileSourcesStepTest.java
@@ -147,7 +147,7 @@ public class PersistFileSourcesStepTest {
BatchReport.Changesets.Builder changesetsBuilder = BatchReport.Changesets.newBuilder();
List<BatchReport.Coverage> coverages = new ArrayList<>();
List<BatchReport.SyntaxHighlighting> highlightings = new ArrayList<>();
- List<BatchReport.Symbols.Symbol> symbols = new ArrayList<>();
+ List<BatchReport.Symbol> symbols = new ArrayList<>();
List<BatchReport.Duplication> duplications = new ArrayList<>();
void generateLineData(int line) {
@@ -178,7 +178,7 @@ public class PersistFileSourcesStepTest {
.setType(Constants.HighlightingType.ANNOTATION)
.build());
- symbols.add(BatchReport.Symbols.Symbol.newBuilder()
+ symbols.add(BatchReport.Symbol.newBuilder()
.setDeclaration(BatchReport.Range.newBuilder()
.setStartLine(line).setEndLine(line).setStartOffset(2).setEndOffset(4)
.build())
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/batch/BatchReportReader.java b/server/sonar-server/src/main/java/org/sonar/server/computation/batch/BatchReportReader.java
index 2568cb4ed9a..301821d186b 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/batch/BatchReportReader.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/batch/BatchReportReader.java
@@ -19,26 +19,27 @@
*/
package org.sonar.server.computation.batch;
-import java.util.List;
import javax.annotation.CheckForNull;
import org.sonar.batch.protocol.output.BatchReport;
-import org.sonar.server.util.CloseableIterator;
+import org.sonar.core.util.CloseableIterator;
public interface BatchReportReader {
BatchReport.Metadata readMetadata();
- List<BatchReport.Measure> readComponentMeasures(int componentRef);
+ CloseableIterator<BatchReport.ActiveRule> readActiveRules();
+
+ CloseableIterator<BatchReport.Measure> readComponentMeasures(int componentRef);
@CheckForNull
BatchReport.Changesets readChangesets(int componentRef);
BatchReport.Component readComponent(int componentRef);
- List<BatchReport.Issue> readComponentIssues(int componentRef);
+ CloseableIterator<BatchReport.Issue> readComponentIssues(int componentRef);
- List<BatchReport.Duplication> readComponentDuplications(int componentRef);
+ CloseableIterator<BatchReport.Duplication> readComponentDuplications(int componentRef);
- List<BatchReport.Symbols.Symbol> readComponentSymbols(int componentRef);
+ CloseableIterator<BatchReport.Symbol> readComponentSymbols(int componentRef);
CloseableIterator<BatchReport.SyntaxHighlighting> readComponentSyntaxHighlighting(int fileRef);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/batch/BatchReportReaderImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/batch/BatchReportReaderImpl.java
index 8f1f476e2ec..775d500d595 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/batch/BatchReportReaderImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/batch/BatchReportReaderImpl.java
@@ -33,7 +33,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.LineIterator;
import org.sonar.batch.protocol.output.BatchReport;
-import org.sonar.server.util.CloseableIterator;
+import org.sonar.core.util.CloseableIterator;
public class BatchReportReaderImpl implements BatchReportReader {
private final org.sonar.batch.protocol.output.BatchReportReader delegate;
@@ -53,7 +53,12 @@ public class BatchReportReaderImpl implements BatchReportReader {
}
@Override
- public List<BatchReport.Measure> readComponentMeasures(int componentRef) {
+ public CloseableIterator<BatchReport.ActiveRule> readActiveRules() {
+ return delegate.readActiveRules();
+ }
+
+ @Override
+ public CloseableIterator<BatchReport.Measure> readComponentMeasures(int componentRef) {
return delegate.readComponentMeasures(componentRef);
}
@@ -69,17 +74,17 @@ public class BatchReportReaderImpl implements BatchReportReader {
}
@Override
- public List<BatchReport.Issue> readComponentIssues(int componentRef) {
+ public CloseableIterator<BatchReport.Issue> readComponentIssues(int componentRef) {
return delegate.readComponentIssues(componentRef);
}
@Override
- public List<BatchReport.Duplication> readComponentDuplications(int componentRef) {
+ public CloseableIterator<BatchReport.Duplication> readComponentDuplications(int componentRef) {
return delegate.readComponentDuplications(componentRef);
}
@Override
- public List<BatchReport.Symbols.Symbol> readComponentSymbols(int componentRef) {
+ public CloseableIterator<BatchReport.Symbol> readComponentSymbols(int componentRef) {
return delegate.readComponentSymbols(componentRef);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/BaseIssuesLoader.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/BaseIssuesLoader.java
index a16f57b2813..e04a79434d1 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/BaseIssuesLoader.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/BaseIssuesLoader.java
@@ -29,16 +29,13 @@ import org.apache.ibatis.session.ResultHandler;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
import org.sonar.core.issue.DefaultIssue;
-import org.sonar.db.issue.IssueDto;
-import org.sonar.db.issue.IssueMapper;
+import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.MyBatis;
-import org.sonar.server.computation.batch.BatchReportReader;
+import org.sonar.db.issue.IssueDto;
+import org.sonar.db.issue.IssueMapper;
import org.sonar.server.computation.component.TreeRootHolder;
-import org.sonar.db.DbClient;
-
-import static com.google.common.collect.FluentIterable.from;
-import static org.sonar.core.rule.RuleKeyFunctions.stringToRuleKey;
+import org.sonar.server.computation.qualityprofile.ActiveRulesHolder;
/**
* Loads all the project open issues from database, including manual issues.
@@ -46,14 +43,14 @@ import static org.sonar.core.rule.RuleKeyFunctions.stringToRuleKey;
*/
public class BaseIssuesLoader {
- private final Set<RuleKey> activeRuleKeys;
private final TreeRootHolder treeRootHolder;
private final DbClient dbClient;
private final RuleRepository ruleRepository;
+ private final ActiveRulesHolder activeRulesHolder;
- public BaseIssuesLoader(BatchReportReader reportReader, TreeRootHolder treeRootHolder,
- DbClient dbClient, RuleRepository ruleRepository) {
- this.activeRuleKeys = from(reportReader.readMetadata().getActiveRuleKeyList()).transform(stringToRuleKey()).toSet();
+ public BaseIssuesLoader(TreeRootHolder treeRootHolder,
+ DbClient dbClient, RuleRepository ruleRepository, ActiveRulesHolder activeRulesHolder) {
+ this.activeRulesHolder = activeRulesHolder;
this.treeRootHolder = treeRootHolder;
this.dbClient = dbClient;
this.ruleRepository = ruleRepository;
@@ -87,7 +84,7 @@ public class BaseIssuesLoader {
}
private boolean isActive(RuleKey ruleKey) {
- return ruleKey.isManual() || activeRuleKeys.contains(ruleKey);
+ return ruleKey.isManual() || activeRulesHolder.get(ruleKey).isPresent();
}
/**
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/Rule.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/Rule.java
index acf8bd333a5..31df7e063e5 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/Rule.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/Rule.java
@@ -36,11 +36,6 @@ public interface Rule {
RuleStatus getStatus();
/**
- * Is activated in a Quality Profile associated to the project
- */
- boolean isActivated();
-
- /**
* Get all tags, whatever system or user tags.
*/
Set<String> getTags();
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleCacheLoader.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleCacheLoader.java
index 2bdf37e462b..2a3ac48b822 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleCacheLoader.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleCacheLoader.java
@@ -21,26 +21,19 @@ package org.sonar.server.computation.issue;
import java.util.Collection;
import java.util.Map;
-import java.util.Set;
import org.sonar.api.rule.RuleKey;
import org.sonar.db.DbSession;
import org.sonar.db.MyBatis;
import org.sonar.db.rule.RuleDto;
-import org.sonar.server.computation.batch.BatchReportReader;
import org.sonar.server.db.DbClient;
import org.sonar.server.util.cache.CacheLoader;
-import static com.google.common.collect.FluentIterable.from;
-import static org.sonar.core.rule.RuleKeyFunctions.stringToRuleKey;
-
public class RuleCacheLoader implements CacheLoader<RuleKey, Rule> {
private final DbClient dbClient;
- private final Set<RuleKey> activatedKeys;
- public RuleCacheLoader(DbClient dbClient, BatchReportReader batchReportReader) {
+ public RuleCacheLoader(DbClient dbClient) {
this.dbClient = dbClient;
- this.activatedKeys = from(batchReportReader.readMetadata().getActiveRuleKeyList()).transform(stringToRuleKey()).toSet();
}
@Override
@@ -49,7 +42,7 @@ public class RuleCacheLoader implements CacheLoader<RuleKey, Rule> {
try {
RuleDto dto = dbClient.ruleDao().getNullableByKey(session, key);
if (dto != null) {
- return new RuleImpl(dto, activatedKeys.contains(key));
+ return new RuleImpl(dto);
}
return null;
} finally {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleImpl.java
index a0f230ad7db..a30d9cd9d72 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleImpl.java
@@ -39,12 +39,11 @@ public class RuleImpl implements Rule {
private final RuleKey key;
private final String name;
private final RuleStatus status;
- private final boolean isActivated;
private final Integer subCharacteristicId;
private final Set<String> tags;
private final DebtRemediationFunction remediationFunction;
- public RuleImpl(RuleDto dto, boolean isActivated) {
+ public RuleImpl(RuleDto dto) {
this.id = dto.getId();
this.key = dto.getKey();
this.name = dto.getName();
@@ -52,7 +51,6 @@ public class RuleImpl implements Rule {
this.subCharacteristicId = effectiveCharacteristicId(dto);
this.tags = union(dto.getSystemTags(), dto.getTags());
this.remediationFunction = effectiveRemediationFunction(dto);
- this.isActivated = isActivated;
}
@Override
@@ -76,11 +74,6 @@ public class RuleImpl implements Rule {
}
@Override
- public boolean isActivated() {
- return isActivated;
- }
-
- @Override
public Set<String> getTags() {
return tags;
}
@@ -119,7 +112,6 @@ public class RuleImpl implements Rule {
.add("key", key)
.add("name", name)
.add("status", status)
- .add("isActivated", isActivated)
.add("subCharacteristicId", subCharacteristicId)
.add("tags", tags)
.toString();
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java
index 357d1df8694..3add0e12515 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java
@@ -33,6 +33,7 @@ import org.sonar.core.issue.DefaultIssue;
import org.sonar.core.issue.tracking.Input;
import org.sonar.core.issue.tracking.LazyInput;
import org.sonar.core.issue.tracking.LineHashSequence;
+import org.sonar.core.util.CloseableIterator;
import org.sonar.server.computation.batch.BatchReportReader;
import org.sonar.server.computation.component.Component;
import org.sonar.server.computation.component.TreeRootHolder;
@@ -76,24 +77,25 @@ public class TrackerRawInputFactory {
@Override
protected List<DefaultIssue> loadIssues() {
- List<BatchReport.Issue> reportIssues = reportReader.readComponentIssues(component.getRef());
List<DefaultIssue> result = new ArrayList<>();
for (DefaultIssue commonRuleIssue : commonRuleEngine.process(component)) {
result.add(init(commonRuleIssue));
}
- if (!reportIssues.isEmpty()) {
- // optimization - do not load line hashes if there are no issues
- LineHashSequence lineHashSeq = getLineHashSequence();
- for (BatchReport.Issue reportIssue : reportIssues) {
+ try (CloseableIterator<BatchReport.Issue> reportIssues = reportReader.readComponentIssues(component.getRef())) {
+ // optimization - do not load line hashes if there are no issues -> getLineHashSequence() is executed
+ // as late as possible
+ while (reportIssues.hasNext()) {
+ BatchReport.Issue reportIssue = reportIssues.next();
if (isIssueOnUnsupportedCommonRule(reportIssue)) {
- DefaultIssue issue = toIssue(lineHashSeq, reportIssue);
+ DefaultIssue issue = toIssue(getLineHashSequence(), reportIssue);
result.add(issue);
} else {
Loggers.get(getClass()).debug("Ignored issue from analysis report on rule {}:{}", reportIssue.getRuleRepository(), reportIssue.getRuleKey());
}
}
}
+
return result;
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/AbstractCoverageRule.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/AbstractCoverageRule.java
index 4439ed52502..01063ebd3c3 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/AbstractCoverageRule.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/AbstractCoverageRule.java
@@ -33,11 +33,13 @@ public abstract class AbstractCoverageRule extends CommonRule {
private final Metric coverageMetric;
private final Metric uncoveredMetric;
private final Metric toCoverMetric;
+ private final String minPropertyKey;
- public AbstractCoverageRule(ActiveRulesHolder activeRulesHolder, String ruleKey,
+ public AbstractCoverageRule(ActiveRulesHolder activeRulesHolder, String ruleKey, String minPropertyKey,
MeasureRepository measureRepository,
Metric coverageMetric, Metric uncoveredMetric, Metric toCoverMetric) {
super(activeRulesHolder, ruleKey);
+ this.minPropertyKey = minPropertyKey;
this.measureRepository = measureRepository;
this.coverageMetric = coverageMetric;
this.uncoveredMetric = uncoveredMetric;
@@ -49,22 +51,25 @@ public abstract class AbstractCoverageRule extends CommonRule {
Optional<Measure> coverageMeasure = measureRepository.getRawMeasure(file, coverageMetric);
if (!file.getFileAttributes().isUnitTest() && coverageMeasure.isPresent()) {
double coverage = coverageMeasure.get().getDoubleValue();
- // FIXME load threshold from activeRule
- double minimumCoverage = 65.0;
+ double minimumCoverage = getMinDensityParam(activeRule, minPropertyKey);
if (coverage < minimumCoverage) {
- Optional<Measure> uncoveredMeasure = measureRepository.getRawMeasure(file, uncoveredMetric);
- Optional<Measure> toCoverMeasure = measureRepository.getRawMeasure(file, toCoverMetric);
- double uncovered = uncoveredMeasure.isPresent() ? uncoveredMeasure.get().getDoubleValue() : 0.0;
- double toCover = toCoverMeasure.isPresent() ? toCoverMeasure.get().getDoubleValue() : 0.0;
-
- // effort to fix is the number of lines/conditions to cover for reaching threshold
- int effortToFix = (int) Math.ceil((toCover * minimumCoverage / 100) - (toCover - uncovered));
-
- return new CommonRuleIssue(effortToFix, formatMessage(effortToFix, minimumCoverage));
+ return generateIssue(file, minimumCoverage);
}
}
return null;
}
+ private CommonRuleIssue generateIssue(Component file, double minimumCoverage) {
+ Optional<Measure> uncoveredMeasure = measureRepository.getRawMeasure(file, uncoveredMetric);
+ Optional<Measure> toCoverMeasure = measureRepository.getRawMeasure(file, toCoverMetric);
+ double uncovered = uncoveredMeasure.isPresent() ? uncoveredMeasure.get().getDoubleValue() : 0.0;
+ double toCover = toCoverMeasure.isPresent() ? toCoverMeasure.get().getDoubleValue() : 0.0;
+
+ // effort to fix is the number of lines/conditions to cover for reaching threshold
+ int effortToFix = (int) Math.ceil((toCover * minimumCoverage / 100) - (toCover - uncovered));
+
+ return new CommonRuleIssue(effortToFix, formatMessage(effortToFix, minimumCoverage));
+ }
+
protected abstract String formatMessage(int effortToFix, double minCoverage);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/BranchCoverageRule.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/BranchCoverageRule.java
index 7b4df10ef02..d8bbe062be9 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/BranchCoverageRule.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/BranchCoverageRule.java
@@ -30,7 +30,8 @@ import static java.lang.String.format;
public class BranchCoverageRule extends AbstractCoverageRule {
public BranchCoverageRule(ActiveRulesHolder activeRulesHolder, MetricRepository metricRepository, MeasureRepository measureRepository) {
- super(activeRulesHolder, CommonRuleKeys.INSUFFICIENT_BRANCH_COVERAGE, measureRepository,
+ super(activeRulesHolder, CommonRuleKeys.INSUFFICIENT_BRANCH_COVERAGE, CommonRuleKeys.INSUFFICIENT_BRANCH_COVERAGE_PROPERTY,
+ measureRepository,
metricRepository.getByKey(CoreMetrics.BRANCH_COVERAGE_KEY),
metricRepository.getByKey(CoreMetrics.UNCOVERED_CONDITIONS_KEY),
metricRepository.getByKey(CoreMetrics.CONDITIONS_TO_COVER_KEY));
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/CommentDensityRule.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/CommentDensityRule.java
index 0346a6567ce..f06897757b1 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/CommentDensityRule.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/CommentDensityRule.java
@@ -52,23 +52,37 @@ public class CommentDensityRule extends CommonRule {
Optional<Measure> commentDensityMeasure = measureRepository.getRawMeasure(file, commentDensityMetric);
Optional<Measure> commentLinesMeasure = measureRepository.getRawMeasure(file, commentLinesMetric);
Optional<Measure> nclocMeasure = measureRepository.getRawMeasure(file, nclocMetric);
- // FIXME
- double minCommentDensity = 25.0;
- if (commentDensityMeasure.isPresent() && nclocMeasure.isPresent() && nclocMeasure.get().getIntValue() > 0 && commentDensityMeasure.get().getDoubleValue() < minCommentDensity) {
- int commentLines = commentLinesMeasure.isPresent() ? commentLinesMeasure.get().getIntValue() : 0;
- int ncloc = nclocMeasure.get().getIntValue();
- int minExpectedCommentLines = (int) Math.ceil(minCommentDensity * ncloc / (100 - minCommentDensity));
- int missingCommentLines = minExpectedCommentLines - commentLines;
- if (missingCommentLines <= 0) {
- throw new IllegalStateException(format("Bug in measures of comment lines - density=%s, comment_lines= %d, ncloc=%d, threshold=%s%%", commentDensityMeasure.get()
- .getDoubleValue(), commentLines, nclocMeasure.get().getIntValue(), minCommentDensity));
+
+ if (commentDensityMeasure.isPresent() && nclocMeasure.isPresent() && nclocMeasure.get().getIntValue() > 0) {
+ // this is a small optimization to not load the minimum value when the measures are not present
+ double minCommentDensity = getMinDensity(activeRule);
+ if (commentDensityMeasure.get().getDoubleValue() < minCommentDensity) {
+ return generateIssue(commentDensityMeasure, commentLinesMeasure, nclocMeasure, minCommentDensity);
}
+ }
+ return null;
+ }
- // TODO declare min threshold as int but not float ?
- String message = format("%d more comment lines need to be written to reach the minimum threshold of %s%% comment density.", missingCommentLines, minCommentDensity);
- return new CommonRuleIssue(missingCommentLines, message);
+ private double getMinDensity(ActiveRule activeRule) {
+ double min = getMinDensityParam(activeRule, CommonRuleKeys.INSUFFICIENT_COMMENT_DENSITY_PROPERTY);
+ if (min >= 100.0) {
+ throw new IllegalStateException("Minimum density of rule [" + activeRule.getRuleKey() + "] is incorrect. Got [100] but must be strictly less than 100.");
}
+ return min;
+ }
- return null;
+ private CommonRuleIssue generateIssue(Optional<Measure> commentDensityMeasure, Optional<Measure> commentLinesMeasure, Optional<Measure> nclocMeasure, double minCommentDensity) {
+ int commentLines = commentLinesMeasure.isPresent() ? commentLinesMeasure.get().getIntValue() : 0;
+ int ncloc = nclocMeasure.get().getIntValue();
+ int minExpectedCommentLines = (int) Math.ceil(minCommentDensity * ncloc / (100 - minCommentDensity));
+ int missingCommentLines = minExpectedCommentLines - commentLines;
+ if (missingCommentLines <= 0) {
+ throw new IllegalStateException(format("Bug in measures of comment lines - density=%s, comment_lines= %d, ncloc=%d, threshold=%s%%", commentDensityMeasure.get()
+ .getDoubleValue(), commentLines, nclocMeasure.get().getIntValue(), minCommentDensity));
+ }
+
+ // TODO declare min threshold as int but not float ?
+ String message = format("%d more comment lines need to be written to reach the minimum threshold of %s%% comment density.", missingCommentLines, minCommentDensity);
+ return new CommonRuleIssue(missingCommentLines, message);
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/CommonRule.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/CommonRule.java
index 4fdea207acb..2dcce69c577 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/CommonRule.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/CommonRule.java
@@ -21,6 +21,7 @@ package org.sonar.server.computation.issue.commonrule;
import com.google.common.base.Optional;
import javax.annotation.CheckForNull;
+import org.elasticsearch.common.lang3.StringUtils;
import org.sonar.api.rule.RuleKey;
import org.sonar.core.issue.DefaultIssue;
import org.sonar.server.computation.component.Component;
@@ -76,4 +77,16 @@ public abstract class CommonRule {
this.message = message;
}
}
+
+ protected static double getMinDensityParam(ActiveRule activeRule, String paramKey) {
+ String s = activeRule.getParams().get(paramKey);
+ if (StringUtils.isNoneBlank(s)) {
+ double d = Double.parseDouble(s);
+ if (d < 0.0 || d > 100.0) {
+ throw new IllegalStateException(String.format("Minimum density of rule [%s] is incorrect. Got [%s] but must be between 0 and 100.", activeRule.getRuleKey(), s));
+ }
+ return d;
+ }
+ throw new IllegalStateException(String.format("Required parameter [%s] is missing on rule [%s]", paramKey, activeRule.getRuleKey()));
+ }
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/LineCoverageRule.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/LineCoverageRule.java
index e860f6d0c55..885a6704a2e 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/LineCoverageRule.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/LineCoverageRule.java
@@ -30,7 +30,8 @@ import static java.lang.String.format;
public class LineCoverageRule extends AbstractCoverageRule {
public LineCoverageRule(ActiveRulesHolder activeRulesHolder, MetricRepository metricRepository, MeasureRepository measureRepository) {
- super(activeRulesHolder, CommonRuleKeys.INSUFFICIENT_LINE_COVERAGE, measureRepository,
+ super(activeRulesHolder, CommonRuleKeys.INSUFFICIENT_LINE_COVERAGE, CommonRuleKeys.INSUFFICIENT_LINE_COVERAGE_PROPERTY,
+ measureRepository,
metricRepository.getByKey(CoreMetrics.LINE_COVERAGE_KEY),
metricRepository.getByKey(CoreMetrics.UNCOVERED_LINES_KEY),
metricRepository.getByKey(CoreMetrics.LINES_TO_COVER_KEY));
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/measure/MeasureRepositoryImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/measure/MeasureRepositoryImpl.java
index 04b5fa46cb2..c62981597aa 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/measure/MeasureRepositoryImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/measure/MeasureRepositoryImpl.java
@@ -28,6 +28,7 @@ import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import org.sonar.batch.protocol.output.BatchReport;
+import org.sonar.core.util.CloseableIterator;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.measure.MeasureDto;
@@ -184,18 +185,21 @@ public class MeasureRepositoryImpl implements MeasureRepository {
return;
}
- for (BatchReport.Measure batchMeasure : reportReader.readComponentMeasures(component.getRef())) {
- String metricKey = batchMeasure.getMetricKey();
- if (reportMetricValidator.validate(metricKey)) {
- Metric metric = metricRepository.getByKey(metricKey);
- addLocal(component, metric, batchMeasureToMeasure.toMeasure(batchMeasure, metric).get(), OverridePolicy.DO_NOT_OVERRIDE);
+ try (CloseableIterator<BatchReport.Measure> readIt = reportReader.readComponentMeasures(component.getRef())) {
+ while (readIt.hasNext()) {
+ BatchReport.Measure batchMeasure = readIt.next();
+ String metricKey = batchMeasure.getMetricKey();
+ if (reportMetricValidator.validate(metricKey)) {
+ Metric metric = metricRepository.getByKey(metricKey);
+ addLocal(component, metric, batchMeasureToMeasure.toMeasure(batchMeasure, metric).get(), OverridePolicy.DO_NOT_OVERRIDE);
+ }
}
}
loadedComponents.add(component.getRef());
}
private Optional<Measure> findLocal(Component component, Metric metric,
- @Nullable RuleDto rule, @Nullable Characteristic characteristic) {
+ @Nullable RuleDto rule, @Nullable Characteristic characteristic) {
Map<MeasureKey, Measure> measuresPerMetric = measures.get(component.getRef());
if (measuresPerMetric == null) {
return Optional.absent();
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/qualityprofile/ActiveRule.java b/server/sonar-server/src/main/java/org/sonar/server/computation/qualityprofile/ActiveRule.java
index 669641f1063..ec8b643b3af 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/qualityprofile/ActiveRule.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/qualityprofile/ActiveRule.java
@@ -19,6 +19,8 @@
*/
package org.sonar.server.computation.qualityprofile;
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
import javax.annotation.concurrent.Immutable;
import org.sonar.api.rule.RuleKey;
@@ -26,10 +28,12 @@ import org.sonar.api.rule.RuleKey;
public class ActiveRule {
private final RuleKey ruleKey;
private final String severity;
+ private final Map<String, String> params;
- public ActiveRule(RuleKey ruleKey, String severity) {
+ public ActiveRule(RuleKey ruleKey, String severity, Map<String, String> params) {
this.ruleKey = ruleKey;
this.severity = severity;
+ this.params = ImmutableMap.copyOf(params);
}
public RuleKey getRuleKey() {
@@ -39,4 +43,8 @@ public class ActiveRule {
public String getSeverity() {
return severity;
}
+
+ public Map<String, String> getParams() {
+ return params;
+ }
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/qualityprofile/ActiveRulesHolderImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/qualityprofile/ActiveRulesHolderImpl.java
index 2bad41cfecb..44a02ba5f57 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/qualityprofile/ActiveRulesHolderImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/qualityprofile/ActiveRulesHolderImpl.java
@@ -39,6 +39,11 @@ public class ActiveRulesHolderImpl implements ActiveRulesHolder {
return Optional.fromNullable(activeRulesByKey.get(ruleKey));
}
+ public Collection<ActiveRule> getAll() {
+ checkState(activeRulesByKey != null, "Active rules have not been initialized yet");
+ return activeRulesByKey.values();
+ }
+
public void set(Collection<ActiveRule> activeRules) {
requireNonNull(activeRules, "Active rules cannot be null");
checkState(activeRulesByKey == null, "Active rules have already been initialized");
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/source/DuplicationLineReader.java b/server/sonar-server/src/main/java/org/sonar/server/computation/source/DuplicationLineReader.java
index 275f431da01..1c7623aacde 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/source/DuplicationLineReader.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/source/DuplicationLineReader.java
@@ -20,14 +20,14 @@
package org.sonar.server.computation.source;
-import org.sonar.batch.protocol.output.BatchReport;
-import org.sonar.server.source.db.FileSourceDb;
-
import java.io.Serializable;
import java.util.Collections;
import java.util.Comparator;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.sonar.batch.protocol.output.BatchReport;
+import org.sonar.server.source.db.FileSourceDb;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Maps.newHashMap;
@@ -37,7 +37,7 @@ public class DuplicationLineReader implements LineReader {
private final List<BatchReport.Duplication> duplications;
private final Map<BatchReport.Range, Integer> duplicationIdsByRange;
- public DuplicationLineReader(List<BatchReport.Duplication> duplications) {
+ public DuplicationLineReader(Iterator<BatchReport.Duplication> duplications) {
this.duplications = newArrayList(duplications);
// Sort duplication to have deterministic results and avoid false variation that would lead to an unnecessary update of the source files
// data
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/source/ReportIterator.java b/server/sonar-server/src/main/java/org/sonar/server/computation/source/ReportIterator.java
index 4f54808e9bf..59e14dec2b6 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/source/ReportIterator.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/source/ReportIterator.java
@@ -25,7 +25,7 @@ import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Parser;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
-import org.sonar.server.util.CloseableIterator;
+import org.sonar.core.util.CloseableIterator;
import java.io.File;
import java.io.IOException;
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/source/SymbolsLineReader.java b/server/sonar-server/src/main/java/org/sonar/server/computation/source/SymbolsLineReader.java
index ce8bdf2c609..4e4de493367 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/source/SymbolsLineReader.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/source/SymbolsLineReader.java
@@ -20,27 +20,27 @@
package org.sonar.server.computation.source;
+import com.google.common.collect.Lists;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.sonar.batch.protocol.output.BatchReport;
import org.sonar.server.source.db.FileSourceDb;
-import static com.google.common.collect.Lists.newArrayList;
-
public class SymbolsLineReader implements LineReader {
- private final List<BatchReport.Symbols.Symbol> symbols;
- private final Map<BatchReport.Symbols.Symbol, Integer> idsBySymbol;
+ private final List<BatchReport.Symbol> symbols;
+ private final Map<BatchReport.Symbol, Integer> idsBySymbol;
- public SymbolsLineReader(List<BatchReport.Symbols.Symbol> symbols) {
- this.symbols = newArrayList(symbols);
+ public SymbolsLineReader(Iterator<BatchReport.Symbol> symbols) {
+ this.symbols = Lists.newArrayList(symbols);
// Sort symbols to have deterministic results and avoid false variation that would lead to an unnecessary update of the source files
// data
Collections.sort(this.symbols, new SymbolsComparator());
@@ -51,8 +51,8 @@ public class SymbolsLineReader implements LineReader {
@Override
public void read(FileSourceDb.Line.Builder lineBuilder) {
int line = lineBuilder.getLine();
- List<BatchReport.Symbols.Symbol> lineSymbols = findSymbolsMatchingLine(line);
- for (BatchReport.Symbols.Symbol lineSymbol : lineSymbols) {
+ List<BatchReport.Symbol> lineSymbols = findSymbolsMatchingLine(line);
+ for (BatchReport.Symbol lineSymbol : lineSymbols) {
int symbolId = idsBySymbol.get(lineSymbol);
StringBuilder symbolString = new StringBuilder(lineBuilder.getSymbols());
@@ -81,10 +81,10 @@ public class SymbolsLineReader implements LineReader {
}
}
- private List<BatchReport.Symbols.Symbol> findSymbolsMatchingLine(int line) {
- List<BatchReport.Symbols.Symbol> lineSymbols = new ArrayList<>();
- Set<BatchReport.Symbols.Symbol> symbolsIndex = new HashSet<>();
- for (BatchReport.Symbols.Symbol symbol : symbols) {
+ private List<BatchReport.Symbol> findSymbolsMatchingLine(int line) {
+ List<BatchReport.Symbol> lineSymbols = new ArrayList<>();
+ Set<BatchReport.Symbol> symbolsIndex = new HashSet<>();
+ for (BatchReport.Symbol symbol : symbols) {
if (matchLine(symbol.getDeclaration(), line) && !symbolsIndex.contains(symbol)) {
lineSymbols.add(symbol);
symbolsIndex.add(symbol);
@@ -104,19 +104,19 @@ public class SymbolsLineReader implements LineReader {
return range.getStartLine() <= line && range.getEndLine() >= line;
}
- private static Map<BatchReport.Symbols.Symbol, Integer> createIdsBySymbolMap(List<BatchReport.Symbols.Symbol> symbols) {
- Map<BatchReport.Symbols.Symbol, Integer> map = new HashMap<>();
+ private static Map<BatchReport.Symbol, Integer> createIdsBySymbolMap(List<BatchReport.Symbol> symbols) {
+ Map<BatchReport.Symbol, Integer> map = new HashMap<>();
int symbolId = 1;
- for (BatchReport.Symbols.Symbol symbol : symbols) {
+ for (BatchReport.Symbol symbol : symbols) {
map.put(symbol, symbolId);
symbolId++;
}
return map;
}
- private static class SymbolsComparator implements Comparator<BatchReport.Symbols.Symbol>, Serializable {
+ private static class SymbolsComparator implements Comparator<BatchReport.Symbol>, Serializable {
@Override
- public int compare(BatchReport.Symbols.Symbol o1, BatchReport.Symbols.Symbol o2) {
+ public int compare(BatchReport.Symbol o1, BatchReport.Symbol o2) {
if (o1.getDeclaration().getStartLine() == o2.getDeclaration().getStartLine()) {
return Integer.compare(o1.getDeclaration().getStartOffset(), o2.getDeclaration().getStartOffset());
} else {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputationSteps.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputationSteps.java
index 1c7f45b74c6..1b3209c6c2e 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputationSteps.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputationSteps.java
@@ -54,11 +54,9 @@ public class ComputationSteps {
// data computation
CoverageMeasuresStep.class,
CommentMeasuresStep.class,
-
- // must be executed after the measures required for common rules (coverage, comment density, duplications)
CustomMeasuresCopyStep.class,
- CommentMeasuresStep.class,
DuplicationMeasuresStep.class,
+ // must be executed after the measures required for common rules (coverage, comment density, duplications)
IntegrateIssuesStep.class,
CoreMetricFormulaExecutorStep.class,
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/FeedActiveRulesStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/FeedActiveRulesStep.java
index 38a1ac7fe55..ce577489ae1 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/FeedActiveRulesStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/FeedActiveRulesStep.java
@@ -19,18 +19,17 @@
*/
package org.sonar.server.computation.step;
-import com.google.common.base.Function;
-import java.util.Collection;
-import javax.annotation.Nonnull;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.sonar.api.rule.RuleKey;
-import org.sonar.api.rule.Severity;
+import org.sonar.batch.protocol.output.BatchReport;
+import org.sonar.core.util.CloseableIterator;
import org.sonar.server.computation.batch.BatchReportReader;
import org.sonar.server.computation.qualityprofile.ActiveRule;
import org.sonar.server.computation.qualityprofile.ActiveRulesHolderImpl;
-import static com.google.common.collect.FluentIterable.from;
-import static org.sonar.core.rule.RuleKeyFunctions.stringToRuleKey;
-
public class FeedActiveRulesStep implements ComputationStep {
private final BatchReportReader batchReportReader;
@@ -43,8 +42,14 @@ public class FeedActiveRulesStep implements ComputationStep {
@Override
public void execute() {
- Collection<String> keys = batchReportReader.readMetadata().getActiveRuleKeyList();
- activeRulesHolder.set(from(keys).transform(stringToRuleKey()).transform(ToActiveRule.INSTANCE).toList());
+ List<ActiveRule> activeRules = new ArrayList<>();
+ try (CloseableIterator<BatchReport.ActiveRule> batchActiveRules = batchReportReader.readActiveRules()) {
+ while (batchActiveRules.hasNext()) {
+ BatchReport.ActiveRule batchActiveRule = batchActiveRules.next();
+ activeRules.add(convert(batchActiveRule));
+ }
+ }
+ activeRulesHolder.set(activeRules);
}
@Override
@@ -52,12 +57,12 @@ public class FeedActiveRulesStep implements ComputationStep {
return getClass().getSimpleName();
}
- private enum ToActiveRule implements Function<RuleKey, ActiveRule> {
- INSTANCE;
- @Override
- public ActiveRule apply(@Nonnull RuleKey ruleKey) {
- // FIXME load severity
- return new ActiveRule(ruleKey, Severity.MAJOR);
+ private ActiveRule convert(BatchReport.ActiveRule input) {
+ RuleKey key = RuleKey.of(input.getRuleRepository(), input.getRuleKey());
+ Map<String, String> params = new HashMap<>();
+ for (BatchReport.ActiveRule.ActiveRuleParam inputParam : input.getParamList()) {
+ params.put(inputParam.getKey(), inputParam.getValue());
}
+ return new ActiveRule(key, input.getSeverity().name(), params);
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDuplicationsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDuplicationsStep.java
index 67e2a0b39e7..9696abfc4e0 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDuplicationsStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDuplicationsStep.java
@@ -20,15 +20,16 @@
package org.sonar.server.computation.step;
-import java.util.List;
+import java.util.Iterator;
import org.apache.commons.lang.StringEscapeUtils;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.batch.protocol.output.BatchReport;
import org.sonar.batch.protocol.output.BatchReport.Range;
-import org.sonar.db.measure.MeasureDto;
-import org.sonar.db.metric.MetricDto;
+import org.sonar.core.util.CloseableIterator;
import org.sonar.db.DbSession;
import org.sonar.db.MyBatis;
+import org.sonar.db.measure.MeasureDto;
+import org.sonar.db.metric.MetricDto;
import org.sonar.server.computation.batch.BatchReportReader;
import org.sonar.server.computation.component.Component;
import org.sonar.server.computation.component.DbIdsRepository;
@@ -84,13 +85,14 @@ public class PersistDuplicationsStep implements ComputationStep {
}
private void visitComponent(Component component) {
- List<BatchReport.Duplication> duplications = reportReader.readComponentDuplications(component.getRef());
- if (!duplications.isEmpty()) {
- saveDuplications( component, duplications);
+ try (CloseableIterator<BatchReport.Duplication> duplications = reportReader.readComponentDuplications(component.getRef())) {
+ if (duplications.hasNext()) {
+ saveDuplications(component, duplications);
+ }
}
}
- private void saveDuplications(Component component, List<BatchReport.Duplication> duplications) {
+ private void saveDuplications(Component component, Iterator<BatchReport.Duplication> duplications) {
String duplicationXml = createXmlDuplications(component.getKey(), duplications);
MeasureDto measureDto = new MeasureDto()
.setMetricId(duplicationMetric.getId())
@@ -100,10 +102,11 @@ public class PersistDuplicationsStep implements ComputationStep {
dbClient.measureDao().insert(session, measureDto);
}
- private String createXmlDuplications(String componentKey, Iterable<BatchReport.Duplication> duplications) {
+ private String createXmlDuplications(String componentKey, Iterator<BatchReport.Duplication> duplications) {
StringBuilder xml = new StringBuilder();
xml.append("<duplications>");
- for (BatchReport.Duplication duplication : duplications) {
+ while (duplications.hasNext()) {
+ BatchReport.Duplication duplication = duplications.next();
xml.append("<g>");
appendDuplication(xml, componentKey, duplication.getOriginPosition());
for (BatchReport.Duplicate duplicationBlock : duplication.getDuplicateList()) {
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 8ad3021e97f..21839fe6d24 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
@@ -30,6 +30,8 @@ import org.apache.ibatis.session.ResultContext;
import org.apache.ibatis.session.ResultHandler;
import org.sonar.api.utils.System2;
import org.sonar.batch.protocol.output.BatchReport;
+import org.sonar.core.util.CloseableIterator;
+import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.MyBatis;
import org.sonar.db.source.FileSourceDto;
@@ -45,9 +47,7 @@ import org.sonar.server.computation.source.HighlightingLineReader;
import org.sonar.server.computation.source.LineReader;
import org.sonar.server.computation.source.ScmLineReader;
import org.sonar.server.computation.source.SymbolsLineReader;
-import org.sonar.db.DbClient;
import org.sonar.server.source.db.FileSourceDb;
-import org.sonar.server.util.CloseableIterator;
import static org.sonar.server.computation.component.ComponentVisitor.Order.PRE_ORDER;
@@ -164,32 +164,29 @@ public class PersistFileSourcesStep implements ComputationStep {
private static class LineReaders {
private final List<LineReader> readers = new ArrayList<>();
- private final List<CloseableIterator<?>> iterators = new ArrayList<>();
+ private final List<CloseableIterator<?>> closeables = new ArrayList<>();
LineReaders(BatchReportReader reportReader, int componentRef) {
- CloseableIterator<BatchReport.Coverage> coverageReportIterator = reportReader.readComponentCoverage(componentRef);
- BatchReport.Changesets scmReport = reportReader.readChangesets(componentRef);
- CloseableIterator<BatchReport.SyntaxHighlighting> highlightingIterator = reportReader.readComponentSyntaxHighlighting(componentRef);
- List<BatchReport.Symbols.Symbol> symbols = reportReader.readComponentSymbols(componentRef);
- List<BatchReport.Duplication> duplications = reportReader.readComponentDuplications(componentRef);
+ CloseableIterator<BatchReport.Coverage> coverageIt = reportReader.readComponentCoverage(componentRef);
+ closeables.add(coverageIt);
+ readers.add(new CoverageLineReader(coverageIt));
- if (coverageReportIterator != null) {
- iterators.add(coverageReportIterator);
- readers.add(new CoverageLineReader(coverageReportIterator));
- }
+ BatchReport.Changesets scmReport = reportReader.readChangesets(componentRef);
if (scmReport != null) {
readers.add(new ScmLineReader(scmReport));
}
- if (highlightingIterator != null) {
- iterators.add(highlightingIterator);
- readers.add(new HighlightingLineReader(highlightingIterator));
- }
- if (!duplications.isEmpty()) {
- readers.add(new DuplicationLineReader(duplications));
- }
- if (!symbols.isEmpty()) {
- readers.add(new SymbolsLineReader(symbols));
- }
+
+ CloseableIterator<BatchReport.SyntaxHighlighting> highlightingIt = reportReader.readComponentSyntaxHighlighting(componentRef);
+ closeables.add(highlightingIt);
+ readers.add(new HighlightingLineReader(highlightingIt));
+
+ CloseableIterator<BatchReport.Symbol> symbolsIt = reportReader.readComponentSymbols(componentRef);
+ closeables.add(symbolsIt);
+ readers.add(new SymbolsLineReader(symbolsIt));
+
+ CloseableIterator<BatchReport.Duplication> duplicationsIt = reportReader.readComponentDuplications(componentRef);
+ closeables.add(duplicationsIt);
+ readers.add(new DuplicationLineReader(duplicationsIt));
}
List<LineReader> readers() {
@@ -197,7 +194,7 @@ public class PersistFileSourcesStep implements ComputationStep {
}
void close() {
- for (CloseableIterator<?> reportIterator : iterators) {
+ for (CloseableIterator<?> reportIterator : closeables) {
reportIterator.close();
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistIssuesStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistIssuesStep.java
index b9de241635f..93ef3ad2b38 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistIssuesStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistIssuesStep.java
@@ -34,7 +34,7 @@ import org.sonar.db.MyBatis;
import org.sonar.server.computation.issue.IssueCache;
import org.sonar.server.computation.issue.RuleRepository;
import org.sonar.db.DbClient;
-import org.sonar.server.util.CloseableIterator;
+import org.sonar.core.util.CloseableIterator;
public class PersistIssuesStep implements ComputationStep {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java
index 62119d32ad6..7433a21bc57 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java
@@ -51,7 +51,7 @@ import org.sonar.server.computation.component.TreeRootHolder;
import org.sonar.db.DbClient;
import org.sonar.server.source.db.FileSourceDb;
import org.sonar.server.source.db.FileSourceDb.Test.TestStatus;
-import org.sonar.server.util.CloseableIterator;
+import org.sonar.core.util.CloseableIterator;
public class PersistTestsStep implements ComputationStep {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/SendIssueNotificationsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/SendIssueNotificationsStep.java
index f55a33ac0ad..84b0a1d117f 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/SendIssueNotificationsStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/SendIssueNotificationsStep.java
@@ -35,7 +35,7 @@ import org.sonar.server.issue.notification.NewIssuesNotification;
import org.sonar.server.issue.notification.NewIssuesNotificationFactory;
import org.sonar.server.issue.notification.NewIssuesStatistics;
import org.sonar.server.notification.NotificationService;
-import org.sonar.server.util.CloseableIterator;
+import org.sonar.core.util.CloseableIterator;
/**
* Reads issues from disk cache and send related notifications. For performance reasons,
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/CommonRuleDefinitionsImpl.java b/server/sonar-server/src/main/java/org/sonar/server/rule/CommonRuleDefinitionsImpl.java
index d5365ab2956..cf9b12e57cc 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/CommonRuleDefinitionsImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/CommonRuleDefinitionsImpl.java
@@ -66,7 +66,7 @@ public class CommonRuleDefinitionsImpl implements CommonRuleDefinitions {
.setDebtRemediationFunction(rule.debtRemediationFunctions().linear("5min"))
.setEffortToFixDescription("number of uncovered conditions")
.setSeverity(Severity.MAJOR);
- rule.createParam("minimumBranchCoverageRatio")
+ rule.createParam(CommonRuleKeys.INSUFFICIENT_BRANCH_COVERAGE_PROPERTY)
.setName("The minimum required branch coverage ratio")
.setDefaultValue("65")
.setType(RuleParamType.FLOAT);
@@ -82,7 +82,7 @@ public class CommonRuleDefinitionsImpl implements CommonRuleDefinitions {
.setDebtRemediationFunction(rule.debtRemediationFunctions().linear("2min"))
.setEffortToFixDescription("number of lines under the coverage threshold")
.setSeverity(Severity.MAJOR);
- rule.createParam("minimumLineCoverageRatio")
+ rule.createParam(CommonRuleKeys.INSUFFICIENT_LINE_COVERAGE_PROPERTY)
.setName("The minimum required line coverage ratio")
.setDefaultValue("65")
.setType(RuleParamType.FLOAT);
@@ -98,7 +98,7 @@ public class CommonRuleDefinitionsImpl implements CommonRuleDefinitions {
.setDebtRemediationFunction(rule.debtRemediationFunctions().linear("2min"))
.setEffortToFixDescription("number of lines required to meet minimum density")
.setSeverity(Severity.MAJOR);
- rule.createParam("minimumCommentDensity")
+ rule.createParam(CommonRuleKeys.INSUFFICIENT_COMMENT_DENSITY_PROPERTY)
.setName("The minimum required comment density")
.setDefaultValue("25")
.setType(RuleParamType.FLOAT);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/CommonRuleKeys.java b/server/sonar-server/src/main/java/org/sonar/server/rule/CommonRuleKeys.java
index 97d91a2a01a..74163672745 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/CommonRuleKeys.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/CommonRuleKeys.java
@@ -24,8 +24,14 @@ public class CommonRuleKeys {
public static final String REPOSITORY_PREFIX = "common-";
public static final String INSUFFICIENT_BRANCH_COVERAGE = "InsufficientBranchCoverage";
+ public static final String INSUFFICIENT_BRANCH_COVERAGE_PROPERTY = "minimumBranchCoverageRatio";
+
public static final String INSUFFICIENT_LINE_COVERAGE = "InsufficientLineCoverage";
+ public static final String INSUFFICIENT_LINE_COVERAGE_PROPERTY = "minimumLineCoverageRatio";
+
public static final String INSUFFICIENT_COMMENT_DENSITY = "InsufficientCommentDensity";
+ public static final String INSUFFICIENT_COMMENT_DENSITY_PROPERTY = "minimumCommentDensity";
+
public static final String DUPLICATED_BLOCKS = "DuplicatedBlocks";
public static final String FAILED_UNIT_TESTS = "FailedUnitTests";
public static final String SKIPPED_UNIT_TESTS = "SkippedUnitTests";
diff --git a/server/sonar-server/src/main/java/org/sonar/server/util/ObjectInputStreamIterator.java b/server/sonar-server/src/main/java/org/sonar/server/util/ObjectInputStreamIterator.java
index f84b0f17c49..79ad0b80b0d 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/util/ObjectInputStreamIterator.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/util/ObjectInputStreamIterator.java
@@ -26,6 +26,7 @@ import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
+import org.sonar.core.util.CloseableIterator;
public class ObjectInputStreamIterator<E> extends CloseableIterator<E> {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/util/cache/DiskCache.java b/server/sonar-server/src/main/java/org/sonar/server/util/cache/DiskCache.java
index b3310954c7d..a5fa64205cf 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/util/cache/DiskCache.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/util/cache/DiskCache.java
@@ -28,7 +28,7 @@ import java.io.Serializable;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.sonar.api.utils.System2;
-import org.sonar.server.util.CloseableIterator;
+import org.sonar.core.util.CloseableIterator;
import org.sonar.server.util.ObjectInputStreamIterator;
/**
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/batch/BatchReportReaderImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/batch/BatchReportReaderImplTest.java
index ebcf74bcb35..a652c597e1b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/batch/BatchReportReaderImplTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/batch/BatchReportReaderImplTest.java
@@ -30,7 +30,7 @@ import org.sonar.api.utils.internal.JUnitTempFolder;
import org.sonar.batch.protocol.output.BatchReport;
import org.sonar.batch.protocol.output.BatchReportWriter;
import org.sonar.batch.protocol.output.FileStructure;
-import org.sonar.server.util.CloseableIterator;
+import org.sonar.core.util.CloseableIterator;
import static com.google.common.collect.ImmutableList.of;
import static org.assertj.core.api.Assertions.assertThat;
@@ -42,9 +42,8 @@ public class BatchReportReaderImplTest {
private static final BatchReport.Measure MEASURE = BatchReport.Measure.newBuilder().build();
private static final BatchReport.Component COMPONENT = BatchReport.Component.newBuilder().setRef(COMPONENT_REF).build();
private static final BatchReport.Issue ISSUE = BatchReport.Issue.newBuilder().build();
- private static final BatchReport.Issues ISSUES = BatchReport.Issues.newBuilder().setComponentRef(COMPONENT_REF).addIssue(ISSUE).build();
private static final BatchReport.Duplication DUPLICATION = BatchReport.Duplication.newBuilder().build();
- private static final BatchReport.Symbols.Symbol SYMBOL = BatchReport.Symbols.Symbol.newBuilder().build();
+ private static final BatchReport.Symbol SYMBOL = BatchReport.Symbol.newBuilder().build();
private static final BatchReport.SyntaxHighlighting SYNTAX_HIGHLIGHTING_1 = BatchReport.SyntaxHighlighting.newBuilder().build();
private static final BatchReport.SyntaxHighlighting SYNTAX_HIGHLIGHTING_2 = BatchReport.SyntaxHighlighting.newBuilder().build();
private static final BatchReport.Coverage COVERAGE_1 = BatchReport.Coverage.newBuilder().build();
@@ -94,9 +93,10 @@ public class BatchReportReaderImplTest {
public void verify_readComponentMeasures_returns_measures() {
writer.writeComponentMeasures(COMPONENT_REF, of(MEASURE));
- List<BatchReport.Measure> measures = underTest.readComponentMeasures(COMPONENT_REF);
- assertThat(measures).hasSize(1);
- assertThat(measures.get(0)).isEqualTo(MEASURE);
+ try (CloseableIterator<BatchReport.Measure> measures = underTest.readComponentMeasures(COMPONENT_REF)) {
+ assertThat(measures.next()).isEqualTo(MEASURE);
+ assertThat(measures.hasNext()).isFalse();
+ }
}
@Test
@@ -154,9 +154,10 @@ public class BatchReportReaderImplTest {
public void verify_readComponentIssues_returns_Issues() {
writer.writeComponentIssues(COMPONENT_REF, of(ISSUE));
- List<BatchReport.Issue> res = underTest.readComponentIssues(COMPONENT_REF);
- assertThat(res).hasSize(1);
- assertThat(res.get(0)).isEqualTo(ISSUE);
+ try (CloseableIterator<BatchReport.Issue> res = underTest.readComponentIssues(COMPONENT_REF)) {
+ assertThat(res.next()).isEqualTo(ISSUE);
+ assertThat(res.hasNext()).isFalse();
+ }
}
@Test
@@ -175,9 +176,10 @@ public class BatchReportReaderImplTest {
public void verify_readComponentDuplications_returns_Issues() {
writer.writeComponentDuplications(COMPONENT_REF, of(DUPLICATION));
- List<BatchReport.Duplication> res = underTest.readComponentDuplications(COMPONENT_REF);
- assertThat(res).hasSize(1);
- assertThat(res.get(0)).isEqualTo(DUPLICATION);
+ try (CloseableIterator<BatchReport.Duplication> res = underTest.readComponentDuplications(COMPONENT_REF)) {
+ assertThat(res.next()).isEqualTo(DUPLICATION);
+ assertThat(res.hasNext()).isFalse();
+ }
}
@Test
@@ -196,9 +198,10 @@ public class BatchReportReaderImplTest {
public void verify_readComponentSymbols_returns_Issues() {
writer.writeComponentSymbols(COMPONENT_REF, of(SYMBOL));
- List<BatchReport.Symbols.Symbol> res = underTest.readComponentSymbols(COMPONENT_REF);
- assertThat(res).hasSize(1);
- assertThat(res.get(0)).isEqualTo(SYMBOL);
+ try (CloseableIterator<BatchReport.Symbol> res = underTest.readComponentSymbols(COMPONENT_REF)) {
+ assertThat(res.next()).isEqualTo(SYMBOL);
+ assertThat(res.hasNext()).isFalse();
+ }
}
@Test
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/batch/BatchReportReaderRule.java b/server/sonar-server/src/test/java/org/sonar/server/computation/batch/BatchReportReaderRule.java
index 77a62c5610f..04adf2322af 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/batch/BatchReportReaderRule.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/batch/BatchReportReaderRule.java
@@ -20,8 +20,8 @@
package org.sonar.server.computation.batch;
import com.google.common.base.Preconditions;
+import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -31,16 +31,17 @@ import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.sonar.batch.protocol.output.BatchReport;
-import org.sonar.server.util.CloseableIterator;
+import org.sonar.core.util.CloseableIterator;
public class BatchReportReaderRule implements TestRule, BatchReportReader {
private BatchReport.Metadata metadata;
+ private List<BatchReport.ActiveRule> activeRules = new ArrayList<>();
private Map<Integer, List<BatchReport.Measure>> measures = new HashMap<>();
private Map<Integer, BatchReport.Changesets> changesets = new HashMap<>();
private Map<Integer, BatchReport.Component> components = new HashMap<>();
private Map<Integer, List<BatchReport.Issue>> issues = new HashMap<>();
private Map<Integer, List<BatchReport.Duplication>> duplications = new HashMap<>();
- private Map<Integer, List<BatchReport.Symbols.Symbol>> symbols = new HashMap<>();
+ private Map<Integer, List<BatchReport.Symbol>> symbols = new HashMap<>();
private Map<Integer, List<BatchReport.SyntaxHighlighting>> syntaxHighlightings = new HashMap<>();
private Map<Integer, List<BatchReport.Coverage>> coverages = new HashMap<>();
private Map<Integer, List<String>> fileSources = new HashMap<>();
@@ -89,12 +90,24 @@ public class BatchReportReaderRule implements TestRule, BatchReportReader {
}
@Override
- public List<BatchReport.Measure> readComponentMeasures(int componentRef) {
+ public CloseableIterator<BatchReport.ActiveRule> readActiveRules() {
+ if (activeRules == null) {
+ throw new IllegalStateException("Active rules are not set");
+ }
+ return CloseableIterator.from(activeRules.iterator());
+ }
+
+ public void putActiveRules(List<BatchReport.ActiveRule> activeRules) {
+ this.activeRules = activeRules;
+ }
+
+ @Override
+ public CloseableIterator<BatchReport.Measure> readComponentMeasures(int componentRef) {
List<BatchReport.Measure> res = this.measures.get(componentRef);
if (res == null) {
- return Collections.emptyList();
+ return CloseableIterator.emptyCloseableIterator();
}
- return res;
+ return CloseableIterator.from(res.iterator());
}
public void putMeasures(int componentRef, List<BatchReport.Measure> measures) {
@@ -121,8 +134,8 @@ public class BatchReportReaderRule implements TestRule, BatchReportReader {
}
@Override
- public List<BatchReport.Issue> readComponentIssues(int componentRef) {
- return nonNull(issues.get(componentRef));
+ public CloseableIterator<BatchReport.Issue> readComponentIssues(int componentRef) {
+ return closeableIterator(issues.get(componentRef));
}
public void putIssues(int componentRef, List<BatchReport.Issue> issue) {
@@ -130,8 +143,8 @@ public class BatchReportReaderRule implements TestRule, BatchReportReader {
}
@Override
- public List<BatchReport.Duplication> readComponentDuplications(int componentRef) {
- return nonNull(this.duplications.get(componentRef));
+ public CloseableIterator<BatchReport.Duplication> readComponentDuplications(int componentRef) {
+ return closeableIterator(this.duplications.get(componentRef));
}
public void putDuplications(int componentRef, List<BatchReport.Duplication> duplications) {
@@ -139,15 +152,15 @@ public class BatchReportReaderRule implements TestRule, BatchReportReader {
}
@Override
- public List<BatchReport.Symbols.Symbol> readComponentSymbols(int componentRef) {
- return nonNull(this.symbols.get(componentRef));
+ public CloseableIterator<BatchReport.Symbol> readComponentSymbols(int componentRef) {
+ return closeableIterator(this.symbols.get(componentRef));
}
- private static <T> List<T> nonNull(@Nullable List<T> symbols) {
- return symbols == null ? Collections.<T>emptyList() : symbols;
+ private static <T> CloseableIterator<T> closeableIterator(@Nullable List<T> list) {
+ return list == null ? CloseableIterator.<T>emptyCloseableIterator() : CloseableIterator.from(list.iterator());
}
- public void putSymbols(int componentRef, List<BatchReport.Symbols.Symbol> symbols) {
+ public void putSymbols(int componentRef, List<BatchReport.Symbol> symbols) {
this.symbols.put(componentRef, symbols);
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/DumbRule.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/DumbRule.java
index 79be4f1dafa..72e780b2298 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/DumbRule.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/DumbRule.java
@@ -33,7 +33,6 @@ public class DumbRule implements Rule {
private RuleKey key;
private String name;
private RuleStatus status = RuleStatus.READY;
- private boolean isActivated = false;
private Set<String> tags = new HashSet<>();
private Integer subCharacteristicId;
private DebtRemediationFunction function;
@@ -63,11 +62,6 @@ public class DumbRule implements Rule {
}
@Override
- public boolean isActivated() {
- return isActivated;
- }
-
- @Override
public Set<String> getTags() {
return requireNonNull(tags);
}
@@ -97,11 +91,6 @@ public class DumbRule implements Rule {
return this;
}
- public DumbRule setIsActivated(boolean isActivated) {
- this.isActivated = isActivated;
- return this;
- }
-
public DumbRule setSubCharacteristicId(@Nullable Integer subCharacteristicId) {
this.subCharacteristicId = subCharacteristicId;
return this;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/RuleCacheLoaderTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/RuleCacheLoaderTest.java
index 4f59b661d83..6157c0e634d 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/RuleCacheLoaderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/RuleCacheLoaderTest.java
@@ -25,14 +25,11 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.utils.System2;
-import org.sonar.batch.protocol.output.BatchReport;
import org.sonar.db.DbTester;
-import org.sonar.server.computation.batch.BatchReportReaderRule;
import org.sonar.server.db.DbClient;
import org.sonar.server.rule.db.RuleDao;
import org.sonar.test.DbTests;
-import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
@@ -43,9 +40,6 @@ public class RuleCacheLoaderTest {
@org.junit.Rule
public DbTester dbTester = DbTester.create(System2.INSTANCE);
- @org.junit.Rule
- public BatchReportReaderRule reportReader = new BatchReportReaderRule();
-
@Before
public void setUp() {
dbTester.truncateTables();
@@ -53,31 +47,23 @@ public class RuleCacheLoaderTest {
@Test
public void load_by_key() {
- BatchReport.Metadata metadata = BatchReport.Metadata.newBuilder()
- .addAllActiveRuleKey(asList("java:JAV01")).build();
- reportReader.setMetadata(metadata);
-
dbTester.prepareDbUnit(getClass(), "shared.xml");
DbClient dbClient = new DbClient(dbTester.database(), dbTester.myBatis(), new RuleDao(mock(System2.class)));
- RuleCacheLoader loader = new RuleCacheLoader(dbClient, reportReader);
+ RuleCacheLoader loader = new RuleCacheLoader(dbClient);
Rule javaRule = loader.load(RuleKey.of("java", "JAV01"));
assertThat(javaRule.getName()).isEqualTo("Java One");
- assertThat(javaRule.isActivated()).isTrue();
Rule jsRule = loader.load(RuleKey.of("js", "JS01"));
assertThat(jsRule.getName()).isEqualTo("JS One");
- assertThat(jsRule.isActivated()).isFalse();
assertThat(loader.load(RuleKey.of("java", "MISSING"))).isNull();
}
@Test
public void load_by_keys_is_not_supported() {
- reportReader.setMetadata(BatchReport.Metadata.newBuilder().build());
-
DbClient dbClient = new DbClient(dbTester.database(), dbTester.myBatis(), new RuleDao(mock(System2.class)));
- RuleCacheLoader loader = new RuleCacheLoader(dbClient, reportReader);
+ RuleCacheLoader loader = new RuleCacheLoader(dbClient);
try {
loader.loadAll(Collections.<RuleKey>emptyList());
fail();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/BranchCoverageRuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/BranchCoverageRuleTest.java
index 71b82064e31..117896f9332 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/BranchCoverageRuleTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/BranchCoverageRuleTest.java
@@ -36,6 +36,11 @@ public class BranchCoverageRuleTest extends CoverageRuleTest {
}
@Override
+ protected String getMinPropertyKey() {
+ return CommonRuleKeys.INSUFFICIENT_BRANCH_COVERAGE_PROPERTY;
+ }
+
+ @Override
protected String getCoverageMetricKey() {
return CoreMetrics.BRANCH_COVERAGE_KEY;
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CommentDensityRuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CommentDensityRuleTest.java
index 1c43abfe951..051b9a1bdda 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CommentDensityRuleTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CommentDensityRuleTest.java
@@ -19,8 +19,10 @@
*/
package org.sonar.server.computation.issue.commonrule;
+import com.google.common.collect.ImmutableMap;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.Severity;
@@ -48,6 +50,9 @@ public class CommentDensityRuleTest {
.build();
@Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Rule
public ActiveRulesHolderRule activeRuleHolder = new ActiveRulesHolderRule();
@Rule
@@ -66,7 +71,7 @@ public class CommentDensityRuleTest {
@Test
public void no_issues_if_enough_comments() {
- activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL));
+ activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, ImmutableMap.of(CommonRuleKeys.INSUFFICIENT_COMMENT_DENSITY_PROPERTY, "25")));
measureRepository.addRawMeasure(FILE.getRef(), CoreMetrics.COMMENT_LINES_DENSITY_KEY, Measure.newMeasureBuilder().create(90.0));
DefaultIssue issue = underTest.processFile(FILE, "java");
@@ -76,7 +81,7 @@ public class CommentDensityRuleTest {
@Test
public void issue_if_not_enough_comments() {
- activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL));
+ activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, ImmutableMap.of(CommonRuleKeys.INSUFFICIENT_COMMENT_DENSITY_PROPERTY, "25")));
measureRepository.addRawMeasure(FILE.getRef(), CoreMetrics.COMMENT_LINES_DENSITY_KEY, Measure.newMeasureBuilder().create(10.0));
measureRepository.addRawMeasure(FILE.getRef(), CoreMetrics.COMMENT_LINES_KEY, Measure.newMeasureBuilder().create(40));
measureRepository.addRawMeasure(FILE.getRef(), CoreMetrics.NCLOC_KEY, Measure.newMeasureBuilder().create(360));
@@ -93,7 +98,7 @@ public class CommentDensityRuleTest {
@Test
public void issue_if_not_enough_comments__test_ceil() {
- activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL));
+ activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, ImmutableMap.of(CommonRuleKeys.INSUFFICIENT_COMMENT_DENSITY_PROPERTY, "25")));
measureRepository.addRawMeasure(FILE.getRef(), CoreMetrics.COMMENT_LINES_DENSITY_KEY, Measure.newMeasureBuilder().create(0.0));
measureRepository.addRawMeasure(FILE.getRef(), CoreMetrics.COMMENT_LINES_KEY, Measure.newMeasureBuilder().create(0));
measureRepository.addRawMeasure(FILE.getRef(), CoreMetrics.NCLOC_KEY, Measure.newMeasureBuilder().create(1));
@@ -107,33 +112,19 @@ public class CommentDensityRuleTest {
assertThat(issue.message()).isEqualTo("1 more comment lines need to be written to reach the minimum threshold of 25.0% comment density.");
}
- // /**
- // * SQALE-110
- // */
- // @Test
- // public void shouldFailIfMinimumCommentDensitySetTo100() {
- // check.setMinimumCommentDensity(100);
- //
- // thrown.expect(IllegalArgumentException.class);
- // thrown.expectMessage("100.0 is not a valid value for minimum required comment density for rule 'CommentDensityCheck' (must be >= 0 and < 100).");
- //
- // check.checkResource(resource, context, null, perspectives);
- //
- // verify(perspectives, times(0)).as(Issuable.class, resource);
- // }
- //
- // /**
- // * SQALE-110
- // */
- // @Test
- // public void shouldFailIfMinimumCommentDensitySetToNegative() {
- // check.setMinimumCommentDensity(-5);
- //
- // thrown.expect(IllegalArgumentException.class);
- // thrown.expectMessage("-5.0 is not a valid value for minimum required comment density for rule 'CommentDensityCheck' (must be >= 0 and < 100).");
- //
- // check.checkResource(resource, context, null, mock(ResourcePerspectives.class));
- //
- // verify(perspectives, times(0)).as(Issuable.class, resource);
- // }
+ /**
+ * SQALE-110
+ */
+ @Test
+ public void fail_if_min_density_is_100() {
+ thrown.expect(IllegalStateException.class);
+ thrown.expectMessage("Minimum density of rule [common-java:InsufficientCommentDensity] is incorrect. Got [100] but must be strictly less than 100.");
+
+ activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, ImmutableMap.of(CommonRuleKeys.INSUFFICIENT_COMMENT_DENSITY_PROPERTY, "100")));
+ measureRepository.addRawMeasure(FILE.getRef(), CoreMetrics.COMMENT_LINES_DENSITY_KEY, Measure.newMeasureBuilder().create(0.0));
+ measureRepository.addRawMeasure(FILE.getRef(), CoreMetrics.COMMENT_LINES_KEY, Measure.newMeasureBuilder().create(0));
+ measureRepository.addRawMeasure(FILE.getRef(), CoreMetrics.NCLOC_KEY, Measure.newMeasureBuilder().create(1));
+
+ underTest.processFile(FILE, "java");
+ }
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CommonRuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CommonRuleTest.java
new file mode 100644
index 00000000000..22f0fdfe380
--- /dev/null
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CommonRuleTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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.issue.commonrule;
+
+import com.google.common.collect.ImmutableMap;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.api.rule.Severity;
+import org.sonar.db.rule.RuleTesting;
+import org.sonar.server.computation.qualityprofile.ActiveRule;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class CommonRuleTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void test_getMinDensityParam() throws Exception {
+ ActiveRule activeRule = new ActiveRule(RuleTesting.XOO_X1, Severity.MAJOR, ImmutableMap.of("minDensity", "30.5"));
+ double minDensity = CommonRule.getMinDensityParam(activeRule, "minDensity");
+
+ assertThat(minDensity).isEqualTo(30.5);
+ }
+
+ @Test
+ public void getMinDensityParam_fails_if_param_value_is_absent() throws Exception {
+ thrown.expect(IllegalStateException.class);
+ thrown.expectMessage("Required parameter [minDensity] is missing on rule [xoo:x1]");
+
+ ActiveRule activeRule = new ActiveRule(RuleTesting.XOO_X1, Severity.MAJOR, ImmutableMap.<String, String>of());
+ CommonRule.getMinDensityParam(activeRule, "minDensity");
+ }
+
+ @Test
+ public void getMinDensityParam_fails_if_param_value_is_negative() throws Exception {
+ thrown.expect(IllegalStateException.class);
+ thrown.expectMessage("Minimum density of rule [xoo:x1] is incorrect. Got [-30.5] but must be between 0 and 100.");
+
+ ActiveRule activeRule = new ActiveRule(RuleTesting.XOO_X1, Severity.MAJOR, ImmutableMap.of("minDensity", "-30.5"));
+ CommonRule.getMinDensityParam(activeRule, "minDensity");
+ }
+
+ @Test
+ public void getMinDensityParam_fails_if_param_value_is_greater_than_100() throws Exception {
+ thrown.expect(IllegalStateException.class);
+ thrown.expectMessage("Minimum density of rule [xoo:x1] is incorrect. Got [305] but must be between 0 and 100.");
+
+ ActiveRule activeRule = new ActiveRule(RuleTesting.XOO_X1, Severity.MAJOR, ImmutableMap.of("minDensity", "305"));
+ CommonRule.getMinDensityParam(activeRule, "minDensity");
+ }
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CoverageRuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CoverageRuleTest.java
index fa33b25a88d..0323cdf5393 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CoverageRuleTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/CoverageRuleTest.java
@@ -19,6 +19,8 @@
*/
package org.sonar.server.computation.issue.commonrule;
+import com.google.common.collect.ImmutableMap;
+import java.util.Collections;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -74,6 +76,8 @@ public abstract class CoverageRuleTest {
protected abstract RuleKey getRuleKey();
+ protected abstract String getMinPropertyKey();
+
protected abstract String getCoverageMetricKey();
protected abstract String getToCoverMetricKey();
@@ -82,7 +86,7 @@ public abstract class CoverageRuleTest {
@Test
public void no_issue_if_enough_coverage() {
- activeRuleHolder.put(new ActiveRule(getRuleKey(), Severity.CRITICAL));
+ activeRuleHolder.put(new ActiveRule(getRuleKey(), Severity.CRITICAL, ImmutableMap.of(getMinPropertyKey(), "65")));
measureRepository.addRawMeasure(FILE.getRef(), getCoverageMetricKey(), Measure.newMeasureBuilder().create(90.0));
DefaultIssue issue = underTest.processFile(FILE, "java");
@@ -92,7 +96,7 @@ public abstract class CoverageRuleTest {
@Test
public void issue_if_coverage_is_too_low() {
- activeRuleHolder.put(new ActiveRule(getRuleKey(), Severity.CRITICAL));
+ activeRuleHolder.put(new ActiveRule(getRuleKey(), Severity.CRITICAL, ImmutableMap.of(getMinPropertyKey(), "65")));
measureRepository.addRawMeasure(FILE.getRef(), getCoverageMetricKey(), Measure.newMeasureBuilder().create(20.0));
measureRepository.addRawMeasure(FILE.getRef(), getUncoveredMetricKey(), Measure.newMeasureBuilder().create(40.0));
measureRepository.addRawMeasure(FILE.getRef(), getToCoverMetricKey(), Measure.newMeasureBuilder().create(50.0));
@@ -110,7 +114,7 @@ public abstract class CoverageRuleTest {
@Test
public void no_issue_if_coverage_is_not_set() {
- activeRuleHolder.put(new ActiveRule(getRuleKey(), Severity.CRITICAL));
+ activeRuleHolder.put(new ActiveRule(getRuleKey(), Severity.CRITICAL, ImmutableMap.of(getMinPropertyKey(), "65")));
DefaultIssue issue = underTest.processFile(FILE, "java");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/DuplicatedBlockRuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/DuplicatedBlockRuleTest.java
index 8eff15bedaa..7e3e40d7bf4 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/DuplicatedBlockRuleTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/DuplicatedBlockRuleTest.java
@@ -19,6 +19,7 @@
*/
package org.sonar.server.computation.issue.commonrule;
+import java.util.Collections;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.measures.CoreMetrics;
@@ -64,7 +65,7 @@ public class DuplicatedBlockRuleTest {
@Test
public void no_issue_if_no_duplicated_blocks() throws Exception {
- activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL));
+ activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, Collections.<String, String>emptyMap()));
measureRepository.addRawMeasure(FILE.getRef(), CoreMetrics.DUPLICATED_BLOCKS_KEY, Measure.newMeasureBuilder().create(0));
DefaultIssue issue = underTest.processFile(FILE, "java");
@@ -74,7 +75,7 @@ public class DuplicatedBlockRuleTest {
@Test
public void issue_if_duplicated_blocks() throws Exception {
- activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL));
+ activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, Collections.<String, String>emptyMap()));
measureRepository.addRawMeasure(FILE.getRef(), CoreMetrics.DUPLICATED_BLOCKS_KEY, Measure.newMeasureBuilder().create(3));
DefaultIssue issue = underTest.processFile(FILE, "java");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/LineCoverageRuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/LineCoverageRuleTest.java
index 202b9a529bc..1f5623f67f1 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/LineCoverageRuleTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/LineCoverageRuleTest.java
@@ -36,6 +36,11 @@ public class LineCoverageRuleTest extends CoverageRuleTest {
}
@Override
+ protected String getMinPropertyKey() {
+ return CommonRuleKeys.INSUFFICIENT_LINE_COVERAGE_PROPERTY;
+ }
+
+ @Override
protected String getCoverageMetricKey() {
return CoreMetrics.LINE_COVERAGE_KEY;
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/SkippedTestRuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/SkippedTestRuleTest.java
index eaa9b121b19..1c5882f0a8d 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/SkippedTestRuleTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/SkippedTestRuleTest.java
@@ -19,6 +19,7 @@
*/
package org.sonar.server.computation.issue.commonrule;
+import java.util.Collections;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.measures.CoreMetrics;
@@ -65,7 +66,7 @@ public class SkippedTestRuleTest {
@Test
public void issue_if_skipped_tests() throws Exception {
- activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL));
+ activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, Collections.<String, String>emptyMap()));
measureRepository.addRawMeasure(FILE.getRef(), CoreMetrics.SKIPPED_TESTS_KEY, Measure.newMeasureBuilder().create(2));
DefaultIssue issue = underTest.processFile(FILE, "java");
@@ -78,7 +79,7 @@ public class SkippedTestRuleTest {
@Test
public void no_issues_if_zero_skipped_tests() throws Exception {
- activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL));
+ activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, Collections.<String, String>emptyMap()));
measureRepository.addRawMeasure(FILE.getRef(), CoreMetrics.SKIPPED_TESTS_KEY, Measure.newMeasureBuilder().create(0));
DefaultIssue issue = underTest.processFile(FILE, "java");
@@ -88,7 +89,7 @@ public class SkippedTestRuleTest {
@Test
public void no_issues_if_measure_is_absent() throws Exception {
- activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL));
+ activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, Collections.<String, String>emptyMap()));
DefaultIssue issue = underTest.processFile(FILE, "java");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/TestErrorRuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/TestErrorRuleTest.java
index 3d8594d9744..35bdd49c704 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/TestErrorRuleTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/commonrule/TestErrorRuleTest.java
@@ -19,6 +19,7 @@
*/
package org.sonar.server.computation.issue.commonrule;
+import java.util.Collections;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.measures.CoreMetrics;
@@ -66,7 +67,7 @@ public class TestErrorRuleTest {
@Test
public void issue_if_errors_or_failures() throws Exception {
- activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL));
+ activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, Collections.<String, String>emptyMap()));
measureRepository.addRawMeasure(FILE.getRef(), CoreMetrics.TEST_ERRORS_KEY, Measure.newMeasureBuilder().create(2));
measureRepository.addRawMeasure(FILE.getRef(), CoreMetrics.TEST_FAILURES_KEY, Measure.newMeasureBuilder().create(1));
@@ -80,7 +81,7 @@ public class TestErrorRuleTest {
@Test
public void no_issues_if_zero_errors_and_failures() throws Exception {
- activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL));
+ activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, Collections.<String, String>emptyMap()));
measureRepository.addRawMeasure(FILE.getRef(), CoreMetrics.TEST_ERRORS_KEY, Measure.newMeasureBuilder().create(0));
measureRepository.addRawMeasure(FILE.getRef(), CoreMetrics.TEST_FAILURES_KEY, Measure.newMeasureBuilder().create(0));
@@ -91,7 +92,7 @@ public class TestErrorRuleTest {
@Test
public void no_issues_if_test_measures_are_absent() throws Exception {
- activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL));
+ activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, Collections.<String, String>emptyMap()));
DefaultIssue issue = underTest.processFile(FILE, "java");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/qualityprofile/ActiveRulesHolderImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/qualityprofile/ActiveRulesHolderImplTest.java
index 4497c8071de..5b5f531a3dc 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/qualityprofile/ActiveRulesHolderImplTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/qualityprofile/ActiveRulesHolderImplTest.java
@@ -48,7 +48,7 @@ public class ActiveRulesHolderImplTest {
@Test
public void get_active_rule() throws Exception {
- underTest.set(asList(new ActiveRule(RULE_KEY, Severity.BLOCKER)));
+ underTest.set(asList(new ActiveRule(RULE_KEY, Severity.BLOCKER, Collections.<String, String>emptyMap())));
Optional<ActiveRule> activeRule = underTest.get(RULE_KEY);
assertThat(activeRule.isPresent()).isTrue();
@@ -61,7 +61,7 @@ public class ActiveRulesHolderImplTest {
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Active rules have already been initialized");
- underTest.set(asList(new ActiveRule(RULE_KEY, Severity.BLOCKER)));
+ underTest.set(asList(new ActiveRule(RULE_KEY, Severity.BLOCKER, Collections.<String, String>emptyMap())));
underTest.set(Collections.<ActiveRule>emptyList());
}
@@ -80,8 +80,8 @@ public class ActiveRulesHolderImplTest {
thrown.expectMessage("Active rule must not be declared multiple times: java:S001");
underTest.set(asList(
- new ActiveRule(RULE_KEY, Severity.BLOCKER),
- new ActiveRule(RULE_KEY, Severity.MAJOR)
+ new ActiveRule(RULE_KEY, Severity.BLOCKER, Collections.<String, String>emptyMap()),
+ new ActiveRule(RULE_KEY, Severity.MAJOR, Collections.<String, String>emptyMap())
));
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/source/DuplicationLineReaderTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/source/DuplicationLineReaderTest.java
index 8f64ab62772..259ef3dc080 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/source/DuplicationLineReaderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/source/DuplicationLineReaderTest.java
@@ -20,8 +20,10 @@
package org.sonar.server.computation.source;
+import com.google.common.collect.Iterators;
import org.junit.Test;
import org.sonar.batch.protocol.output.BatchReport;
+import org.sonar.core.util.CloseableIterator;
import org.sonar.server.source.db.FileSourceDb;
import java.util.Collections;
@@ -39,7 +41,7 @@ public class DuplicationLineReaderTest {
@Test
public void read_nothing() {
- DuplicationLineReader reader = new DuplicationLineReader(Collections.<BatchReport.Duplication>emptyList());
+ DuplicationLineReader reader = new DuplicationLineReader(CloseableIterator.<BatchReport.Duplication>emptyCloseableIterator());
reader.read(line1);
@@ -48,7 +50,7 @@ public class DuplicationLineReaderTest {
@Test
public void read_duplication_with_duplicates_on_same_file() {
- DuplicationLineReader reader = new DuplicationLineReader(newArrayList(
+ DuplicationLineReader reader = new DuplicationLineReader(Iterators.forArray(
BatchReport.Duplication.newBuilder()
.setOriginPosition(BatchReport.Range.newBuilder()
.setStartLine(1)
@@ -61,7 +63,7 @@ public class DuplicationLineReaderTest {
.build())
.build())
.build()
- ));
+ ));
reader.read(line1);
reader.read(line2);
@@ -76,7 +78,7 @@ public class DuplicationLineReaderTest {
@Test
public void read_duplication_with_duplicates_on_other_file() {
- DuplicationLineReader reader = new DuplicationLineReader(newArrayList(
+ DuplicationLineReader reader = new DuplicationLineReader(Iterators.forArray(
BatchReport.Duplication.newBuilder()
.setOriginPosition(BatchReport.Range.newBuilder()
.setStartLine(1)
@@ -105,7 +107,7 @@ public class DuplicationLineReaderTest {
@Test
public void read_duplication_with_duplicates_on_other_file_from_other_project() {
- DuplicationLineReader reader = new DuplicationLineReader(newArrayList(
+ DuplicationLineReader reader = new DuplicationLineReader(Iterators.forArray(
BatchReport.Duplication.newBuilder()
.setOriginPosition(BatchReport.Range.newBuilder()
.setStartLine(1)
@@ -134,7 +136,7 @@ public class DuplicationLineReaderTest {
@Test
public void read_many_duplications() {
- DuplicationLineReader reader = new DuplicationLineReader(newArrayList(
+ DuplicationLineReader reader = new DuplicationLineReader(Iterators.forArray(
BatchReport.Duplication.newBuilder()
.setOriginPosition(BatchReport.Range.newBuilder()
.setStartLine(1)
@@ -174,7 +176,7 @@ public class DuplicationLineReaderTest {
@Test
public void should_be_sorted_by_line_block() {
- DuplicationLineReader reader = new DuplicationLineReader(newArrayList(
+ DuplicationLineReader reader = new DuplicationLineReader(Iterators.forArray(
BatchReport.Duplication.newBuilder()
.setOriginPosition(BatchReport.Range.newBuilder()
.setStartLine(2)
@@ -214,7 +216,7 @@ public class DuplicationLineReaderTest {
@Test
public void should_be_sorted_by_line_length() {
- DuplicationLineReader reader = new DuplicationLineReader(newArrayList(
+ DuplicationLineReader reader = new DuplicationLineReader(Iterators.forArray(
BatchReport.Duplication.newBuilder()
.setOriginPosition(BatchReport.Range.newBuilder()
.setStartLine(1)
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/source/SymbolsLineReaderTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/source/SymbolsLineReaderTest.java
index dac7d1347c3..90947a46ae7 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/source/SymbolsLineReaderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/source/SymbolsLineReaderTest.java
@@ -20,13 +20,13 @@
package org.sonar.server.computation.source;
+import java.util.Collections;
+import java.util.List;
import org.junit.Test;
import org.sonar.batch.protocol.output.BatchReport;
+import org.sonar.core.util.CloseableIterator;
import org.sonar.server.source.db.FileSourceDb;
-import java.util.Collections;
-import java.util.List;
-
import static com.google.common.collect.Lists.newArrayList;
import static org.assertj.core.api.Assertions.assertThat;
@@ -40,7 +40,7 @@ public class SymbolsLineReaderTest {
@Test
public void read_nothing() {
- SymbolsLineReader symbolsLineReader = new SymbolsLineReader(Collections.<BatchReport.Symbols.Symbol>emptyList());
+ SymbolsLineReader symbolsLineReader = new SymbolsLineReader(CloseableIterator.<BatchReport.Symbol>emptyCloseableIterator());
symbolsLineReader.read(line1);
@@ -49,8 +49,8 @@ public class SymbolsLineReaderTest {
@Test
public void read_symbols() {
- List<BatchReport.Symbols.Symbol> symbols = newArrayList(
- BatchReport.Symbols.Symbol.newBuilder()
+ List<BatchReport.Symbol> symbols = newArrayList(
+ BatchReport.Symbol.newBuilder()
.setDeclaration(BatchReport.Range.newBuilder()
.setStartLine(1).setEndLine(1).setStartOffset(2).setEndOffset(4)
.build())
@@ -60,7 +60,7 @@ public class SymbolsLineReaderTest {
.build()
);
- SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols);
+ SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols.iterator());
symbolsLineReader.read(line1);
symbolsLineReader.read(line2);
symbolsLineReader.read(line3);
@@ -72,8 +72,8 @@ public class SymbolsLineReaderTest {
@Test
public void read_symbols_with_reference_on_same_line() {
- List<BatchReport.Symbols.Symbol> symbols = newArrayList(
- BatchReport.Symbols.Symbol.newBuilder()
+ List<BatchReport.Symbol> symbols = newArrayList(
+ BatchReport.Symbol.newBuilder()
.setDeclaration(BatchReport.Range.newBuilder()
.setStartLine(1).setEndLine(1).setStartOffset(0).setEndOffset(1)
.build())
@@ -83,7 +83,7 @@ public class SymbolsLineReaderTest {
.build()
);
- SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols);
+ SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols.iterator());
symbolsLineReader.read(line1);
assertThat(line1.getSymbols()).isEqualTo("0,1,1;2,3,1");
@@ -91,8 +91,8 @@ public class SymbolsLineReaderTest {
@Test
public void read_symbols_with_two_references() {
- List<BatchReport.Symbols.Symbol> symbols = newArrayList(
- BatchReport.Symbols.Symbol.newBuilder()
+ List<BatchReport.Symbol> symbols = newArrayList(
+ BatchReport.Symbol.newBuilder()
.setDeclaration(BatchReport.Range.newBuilder()
.setStartLine(1).setEndLine(1).setStartOffset(2).setEndOffset(4)
.build())
@@ -105,7 +105,7 @@ public class SymbolsLineReaderTest {
.build()
);
- SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols);
+ SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols.iterator());
symbolsLineReader.read(line1);
symbolsLineReader.read(line2);
symbolsLineReader.read(line3);
@@ -117,8 +117,8 @@ public class SymbolsLineReaderTest {
@Test
public void read_symbols_with_two_references_on_the_same_line() {
- List<BatchReport.Symbols.Symbol> symbols = newArrayList(
- BatchReport.Symbols.Symbol.newBuilder()
+ List<BatchReport.Symbol> symbols = newArrayList(
+ BatchReport.Symbol.newBuilder()
.setDeclaration(BatchReport.Range.newBuilder()
.setStartLine(1).setEndLine(1).setStartOffset(2).setEndOffset(3)
.build())
@@ -129,9 +129,9 @@ public class SymbolsLineReaderTest {
.setStartLine(2).setEndLine(2).setStartOffset(2).setEndOffset(3)
.build())
.build()
- );
+ );
- SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols);
+ SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols.iterator());
symbolsLineReader.read(line1);
symbolsLineReader.read(line2);
@@ -141,8 +141,8 @@ public class SymbolsLineReaderTest {
@Test
public void read_symbols_when_reference_line_is_before_declaration_line() {
- List<BatchReport.Symbols.Symbol> symbols = newArrayList(
- BatchReport.Symbols.Symbol.newBuilder()
+ List<BatchReport.Symbol> symbols = newArrayList(
+ BatchReport.Symbol.newBuilder()
.setDeclaration(BatchReport.Range.newBuilder()
.setStartLine(2).setEndLine(2).setStartOffset(3).setEndOffset(4)
.build())
@@ -152,7 +152,7 @@ public class SymbolsLineReaderTest {
.build()
);
- SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols);
+ SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols.iterator());
symbolsLineReader.read(line1);
symbolsLineReader.read(line2);
@@ -162,8 +162,8 @@ public class SymbolsLineReaderTest {
@Test
public void read_many_symbols_on_lines() {
- List<BatchReport.Symbols.Symbol> symbols = newArrayList(
- BatchReport.Symbols.Symbol.newBuilder()
+ List<BatchReport.Symbol> symbols = newArrayList(
+ BatchReport.Symbol.newBuilder()
.setDeclaration(BatchReport.Range.newBuilder()
.setStartLine(1).setEndLine(1).setStartOffset(1).setEndOffset(2)
.build())
@@ -171,7 +171,7 @@ public class SymbolsLineReaderTest {
.setStartLine(3).setEndLine(3).setStartOffset(2).setEndOffset(3)
.build())
.build(),
- BatchReport.Symbols.Symbol.newBuilder()
+ BatchReport.Symbol.newBuilder()
.setDeclaration(BatchReport.Range.newBuilder()
.setStartLine(1).setEndLine(1).setStartOffset(3).setEndOffset(4)
.build())
@@ -181,7 +181,7 @@ public class SymbolsLineReaderTest {
.build()
);
- SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols);
+ SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols.iterator());
symbolsLineReader.read(line1);
symbolsLineReader.read(line2);
symbolsLineReader.read(line3);
@@ -193,8 +193,8 @@ public class SymbolsLineReaderTest {
@Test
public void symbol_declaration_should_be_sorted_by_offset() {
- List<BatchReport.Symbols.Symbol> symbols = newArrayList(
- BatchReport.Symbols.Symbol.newBuilder()
+ List<BatchReport.Symbol> symbols = newArrayList(
+ BatchReport.Symbol.newBuilder()
.setDeclaration(BatchReport.Range.newBuilder()
// This symbol begins after the second symbol, it should appear in second place
.setStartLine(1).setEndLine(1).setStartOffset(2).setEndOffset(3)
@@ -203,7 +203,7 @@ public class SymbolsLineReaderTest {
.setStartLine(3).setEndLine(3).setStartOffset(2).setEndOffset(3)
.build())
.build(),
- BatchReport.Symbols.Symbol.newBuilder()
+ BatchReport.Symbol.newBuilder()
.setDeclaration(BatchReport.Range.newBuilder()
.setStartLine(1).setEndLine(1).setStartOffset(0).setEndOffset(1)
.build())
@@ -212,7 +212,7 @@ public class SymbolsLineReaderTest {
.build())
.build());
- SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols);
+ SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols.iterator());
symbolsLineReader.read(line1);
symbolsLineReader.read(line2);
symbolsLineReader.read(line3);
@@ -224,8 +224,8 @@ public class SymbolsLineReaderTest {
@Test
public void symbol_declaration_should_be_sorted_by_line() {
- List<BatchReport.Symbols.Symbol> symbols = newArrayList(
- BatchReport.Symbols.Symbol.newBuilder()
+ List<BatchReport.Symbol> symbols = newArrayList(
+ BatchReport.Symbol.newBuilder()
.setDeclaration(BatchReport.Range.newBuilder()
// This symbol begins after the second symbol, it should appear in second place
.setStartLine(2).setEndLine(2).setStartOffset(0).setEndOffset(1)
@@ -234,7 +234,7 @@ public class SymbolsLineReaderTest {
.setStartLine(3).setEndLine(3).setStartOffset(2).setEndOffset(3)
.build())
.build(),
- BatchReport.Symbols.Symbol.newBuilder()
+ BatchReport.Symbol.newBuilder()
.setDeclaration(BatchReport.Range.newBuilder()
.setStartLine(1).setEndLine(1).setStartOffset(0).setEndOffset(1)
.build())
@@ -243,7 +243,7 @@ public class SymbolsLineReaderTest {
.build())
.build());
- SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols);
+ SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols.iterator());
symbolsLineReader.read(line1);
symbolsLineReader.read(line2);
symbolsLineReader.read(line3);
@@ -255,8 +255,8 @@ public class SymbolsLineReaderTest {
@Test
public void read_symbols_defined_on_many_lines() {
- List<BatchReport.Symbols.Symbol> symbols = newArrayList(
- BatchReport.Symbols.Symbol.newBuilder()
+ List<BatchReport.Symbol> symbols = newArrayList(
+ BatchReport.Symbol.newBuilder()
.setDeclaration(BatchReport.Range.newBuilder()
.setStartLine(1).setEndLine(2).setStartOffset(1).setEndOffset(3)
.build())
@@ -265,7 +265,7 @@ public class SymbolsLineReaderTest {
.build())
.build());
- SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols);
+ SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols.iterator());
symbolsLineReader.read(line1);
symbolsLineReader.read(line2);
symbolsLineReader.read(line3);
@@ -279,8 +279,8 @@ public class SymbolsLineReaderTest {
@Test
public void read_symbols_declared_on_a_whole_line() {
- List<BatchReport.Symbols.Symbol> symbols = newArrayList(
- BatchReport.Symbols.Symbol.newBuilder()
+ List<BatchReport.Symbol> symbols = newArrayList(
+ BatchReport.Symbol.newBuilder()
.setDeclaration(BatchReport.Range.newBuilder()
.setStartLine(1).setEndLine(2).setStartOffset(0).setEndOffset(0)
.build())
@@ -288,9 +288,9 @@ public class SymbolsLineReaderTest {
.setStartLine(3).setEndLine(3).setStartOffset(1).setEndOffset(3)
.build())
.build()
- );
+ );
- SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols);
+ SymbolsLineReader symbolsLineReader = new SymbolsLineReader(symbols.iterator());
symbolsLineReader.read(line1);
symbolsLineReader.read(line2);
symbolsLineReader.read(line3);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/FeedActiveRulesStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/FeedActiveRulesStepTest.java
new file mode 100644
index 00000000000..6b4180d8af6
--- /dev/null
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/FeedActiveRulesStepTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.base.Optional;
+import java.util.Arrays;
+import org.assertj.core.data.MapEntry;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.sonar.api.rule.RuleKey;
+import org.sonar.api.rule.Severity;
+import org.sonar.batch.protocol.Constants;
+import org.sonar.batch.protocol.output.BatchReport;
+import org.sonar.server.computation.batch.BatchReportReaderRule;
+import org.sonar.server.computation.qualityprofile.ActiveRule;
+import org.sonar.server.computation.qualityprofile.ActiveRulesHolderImpl;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class FeedActiveRulesStepTest {
+
+ @Rule
+ public TemporaryFolder temp = new TemporaryFolder();
+
+ @Rule
+ public BatchReportReaderRule batchReportReader = new BatchReportReaderRule();
+
+ ActiveRulesHolderImpl activeRulesHolder = new ActiveRulesHolderImpl();
+ FeedActiveRulesStep underTest = new FeedActiveRulesStep(batchReportReader, activeRulesHolder);
+
+ @Test
+ public void write() throws Exception {
+ BatchReport.ActiveRule.Builder batch1 = BatchReport.ActiveRule.newBuilder()
+ .setRuleRepository("java").setRuleKey("S001")
+ .setSeverity(Constants.Severity.BLOCKER);
+ batch1.addParamBuilder().setKey("p1").setValue("v1").build();
+
+ BatchReport.ActiveRule.Builder batch2 = BatchReport.ActiveRule.newBuilder()
+ .setRuleRepository("java").setRuleKey("S002").setSeverity(Constants.Severity.MAJOR);
+ batchReportReader.putActiveRules(Arrays.asList(batch1.build(), batch2.build()));
+
+ underTest.execute();
+
+ assertThat(activeRulesHolder.getAll()).hasSize(2);
+
+ Optional<ActiveRule> ar1 = activeRulesHolder.get(RuleKey.of("java", "S001"));
+ assertThat(ar1.get().getSeverity()).isEqualTo(Severity.BLOCKER);
+ assertThat(ar1.get().getParams()).containsExactly(MapEntry.entry("p1", "v1"));
+
+ Optional<ActiveRule> ar2 = activeRulesHolder.get(RuleKey.of("java", "S002"));
+ assertThat(ar2.get().getSeverity()).isEqualTo(Severity.MAJOR);
+ assertThat(ar2.get().getParams()).isEmpty();
+
+ }
+}
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 dc2652a850b..4974256fe20 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
@@ -243,7 +243,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
initBasicReport(3);
reportReader.putSymbols(FILE_REF, newArrayList(
- BatchReport.Symbols.Symbol.newBuilder()
+ BatchReport.Symbol.newBuilder()
.setDeclaration(BatchReport.Range.newBuilder()
.setStartLine(1).setEndLine(1).setStartOffset(2).setEndOffset(4)
.build())
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistIssuesStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistIssuesStepTest.java
index 29ce9923955..af3435c22d4 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistIssuesStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistIssuesStepTest.java
@@ -85,7 +85,7 @@ public class PersistIssuesStepTest extends BaseStepTest {
when(system2.now()).thenReturn(NOW);
reportReader.setMetadata(BatchReport.Metadata.getDefaultInstance());
- step = new PersistIssuesStep(dbClient, system2, new UpdateConflictResolver(), new RuleRepositoryImpl(new RuleCacheLoader(dbClient, reportReader)), issueCache);
+ step = new PersistIssuesStep(dbClient, system2, new UpdateConflictResolver(), new RuleRepositoryImpl(new RuleCacheLoader(dbClient)), issueCache);
}
@After
diff --git a/server/sonar-server/src/test/java/org/sonar/server/util/cache/DiskCacheTest.java b/server/sonar-server/src/test/java/org/sonar/server/util/cache/DiskCacheTest.java
index ff36bca82a3..2f2a1ff1792 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/util/cache/DiskCacheTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/util/cache/DiskCacheTest.java
@@ -23,7 +23,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.utils.System2;
-import org.sonar.server.util.CloseableIterator;
+import org.sonar.core.util.CloseableIterator;
import java.io.ObjectOutputStream;
import java.io.Serializable;
diff --git a/sonar-batch-protocol/pom.xml b/sonar-batch-protocol/pom.xml
index 9cba80bc7d9..4766df2a574 100644
--- a/sonar-batch-protocol/pom.xml
+++ b/sonar-batch-protocol/pom.xml
@@ -34,6 +34,10 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-core</artifactId>
+ </dependency>
<!-- unit tests -->
<dependency>
diff --git a/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java b/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java
index 93549a0163f..f3ffae7e8fe 100644
--- a/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java
+++ b/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java
@@ -69,49 +69,6 @@ public final class BatchReport {
* <code>optional int32 root_component_ref = 4;</code>
*/
int getRootComponentRef();
-
- /**
- * <code>repeated string active_rule_key = 5;</code>
- *
- * <pre>
- *Keys of the rules that were enabled in Quality profiles.
- *A key is a string composed of the repository and the subKey, specific to the repository. Format is
- *"{repository}:{subKey}", for instance "java:NullDereference".
- * </pre>
- */
- com.google.protobuf.ProtocolStringList
- getActiveRuleKeyList();
- /**
- * <code>repeated string active_rule_key = 5;</code>
- *
- * <pre>
- *Keys of the rules that were enabled in Quality profiles.
- *A key is a string composed of the repository and the subKey, specific to the repository. Format is
- *"{repository}:{subKey}", for instance "java:NullDereference".
- * </pre>
- */
- int getActiveRuleKeyCount();
- /**
- * <code>repeated string active_rule_key = 5;</code>
- *
- * <pre>
- *Keys of the rules that were enabled in Quality profiles.
- *A key is a string composed of the repository and the subKey, specific to the repository. Format is
- *"{repository}:{subKey}", for instance "java:NullDereference".
- * </pre>
- */
- java.lang.String getActiveRuleKey(int index);
- /**
- * <code>repeated string active_rule_key = 5;</code>
- *
- * <pre>
- *Keys of the rules that were enabled in Quality profiles.
- *A key is a string composed of the repository and the subKey, specific to the repository. Format is
- *"{repository}:{subKey}", for instance "java:NullDereference".
- * </pre>
- */
- com.google.protobuf.ByteString
- getActiveRuleKeyBytes(int index);
}
/**
* Protobuf type {@code Metadata}
@@ -187,15 +144,6 @@ public final class BatchReport {
rootComponentRef_ = input.readInt32();
break;
}
- case 42: {
- com.google.protobuf.ByteString bs = input.readBytes();
- if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) {
- activeRuleKey_ = new com.google.protobuf.LazyStringArrayList();
- mutable_bitField0_ |= 0x00000010;
- }
- activeRuleKey_.add(bs);
- break;
- }
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
@@ -204,9 +152,6 @@ public final class BatchReport {
throw new com.google.protobuf.InvalidProtocolBufferException(
e.getMessage()).setUnfinishedMessage(this);
} finally {
- if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) {
- activeRuleKey_ = activeRuleKey_.getUnmodifiableView();
- }
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
@@ -365,65 +310,11 @@ public final class BatchReport {
return rootComponentRef_;
}
- public static final int ACTIVE_RULE_KEY_FIELD_NUMBER = 5;
- private com.google.protobuf.LazyStringList activeRuleKey_;
- /**
- * <code>repeated string active_rule_key = 5;</code>
- *
- * <pre>
- *Keys of the rules that were enabled in Quality profiles.
- *A key is a string composed of the repository and the subKey, specific to the repository. Format is
- *"{repository}:{subKey}", for instance "java:NullDereference".
- * </pre>
- */
- public com.google.protobuf.ProtocolStringList
- getActiveRuleKeyList() {
- return activeRuleKey_;
- }
- /**
- * <code>repeated string active_rule_key = 5;</code>
- *
- * <pre>
- *Keys of the rules that were enabled in Quality profiles.
- *A key is a string composed of the repository and the subKey, specific to the repository. Format is
- *"{repository}:{subKey}", for instance "java:NullDereference".
- * </pre>
- */
- public int getActiveRuleKeyCount() {
- return activeRuleKey_.size();
- }
- /**
- * <code>repeated string active_rule_key = 5;</code>
- *
- * <pre>
- *Keys of the rules that were enabled in Quality profiles.
- *A key is a string composed of the repository and the subKey, specific to the repository. Format is
- *"{repository}:{subKey}", for instance "java:NullDereference".
- * </pre>
- */
- public java.lang.String getActiveRuleKey(int index) {
- return activeRuleKey_.get(index);
- }
- /**
- * <code>repeated string active_rule_key = 5;</code>
- *
- * <pre>
- *Keys of the rules that were enabled in Quality profiles.
- *A key is a string composed of the repository and the subKey, specific to the repository. Format is
- *"{repository}:{subKey}", for instance "java:NullDereference".
- * </pre>
- */
- public com.google.protobuf.ByteString
- getActiveRuleKeyBytes(int index) {
- return activeRuleKey_.getByteString(index);
- }
-
private void initFields() {
analysisDate_ = 0L;
projectKey_ = "";
branch_ = "";
rootComponentRef_ = 0;
- activeRuleKey_ = com.google.protobuf.LazyStringArrayList.EMPTY;
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
@@ -450,9 +341,6 @@ public final class BatchReport {
if (((bitField0_ & 0x00000008) == 0x00000008)) {
output.writeInt32(4, rootComponentRef_);
}
- for (int i = 0; i < activeRuleKey_.size(); i++) {
- output.writeBytes(5, activeRuleKey_.getByteString(i));
- }
getUnknownFields().writeTo(output);
}
@@ -478,15 +366,6 @@ public final class BatchReport {
size += com.google.protobuf.CodedOutputStream
.computeInt32Size(4, rootComponentRef_);
}
- {
- int dataSize = 0;
- for (int i = 0; i < activeRuleKey_.size(); i++) {
- dataSize += com.google.protobuf.CodedOutputStream
- .computeBytesSizeNoTag(activeRuleKey_.getByteString(i));
- }
- size += dataSize;
- size += 1 * getActiveRuleKeyList().size();
- }
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
return size;
@@ -612,8 +491,6 @@ public final class BatchReport {
bitField0_ = (bitField0_ & ~0x00000004);
rootComponentRef_ = 0;
bitField0_ = (bitField0_ & ~0x00000008);
- activeRuleKey_ = com.google.protobuf.LazyStringArrayList.EMPTY;
- bitField0_ = (bitField0_ & ~0x00000010);
return this;
}
@@ -658,11 +535,6 @@ public final class BatchReport {
to_bitField0_ |= 0x00000008;
}
result.rootComponentRef_ = rootComponentRef_;
- if (((bitField0_ & 0x00000010) == 0x00000010)) {
- activeRuleKey_ = activeRuleKey_.getUnmodifiableView();
- bitField0_ = (bitField0_ & ~0x00000010);
- }
- result.activeRuleKey_ = activeRuleKey_;
result.bitField0_ = to_bitField0_;
onBuilt();
return result;
@@ -695,16 +567,6 @@ public final class BatchReport {
if (other.hasRootComponentRef()) {
setRootComponentRef(other.getRootComponentRef());
}
- if (!other.activeRuleKey_.isEmpty()) {
- if (activeRuleKey_.isEmpty()) {
- activeRuleKey_ = other.activeRuleKey_;
- bitField0_ = (bitField0_ & ~0x00000010);
- } else {
- ensureActiveRuleKeyIsMutable();
- activeRuleKey_.addAll(other.activeRuleKey_);
- }
- onChanged();
- }
this.mergeUnknownFields(other.getUnknownFields());
return this;
}
@@ -972,162 +834,1736 @@ public final class BatchReport {
return this;
}
- private com.google.protobuf.LazyStringList activeRuleKey_ = com.google.protobuf.LazyStringArrayList.EMPTY;
- private void ensureActiveRuleKeyIsMutable() {
- if (!((bitField0_ & 0x00000010) == 0x00000010)) {
- activeRuleKey_ = new com.google.protobuf.LazyStringArrayList(activeRuleKey_);
- bitField0_ |= 0x00000010;
- }
+ // @@protoc_insertion_point(builder_scope:Metadata)
+ }
+
+ static {
+ defaultInstance = new Metadata(true);
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:Metadata)
+ }
+
+ public interface ActiveRuleOrBuilder extends
+ // @@protoc_insertion_point(interface_extends:ActiveRule)
+ com.google.protobuf.MessageOrBuilder {
+
+ /**
+ * <code>optional string rule_repository = 1;</code>
+ */
+ boolean hasRuleRepository();
+ /**
+ * <code>optional string rule_repository = 1;</code>
+ */
+ java.lang.String getRuleRepository();
+ /**
+ * <code>optional string rule_repository = 1;</code>
+ */
+ com.google.protobuf.ByteString
+ getRuleRepositoryBytes();
+
+ /**
+ * <code>optional string rule_key = 2;</code>
+ */
+ boolean hasRuleKey();
+ /**
+ * <code>optional string rule_key = 2;</code>
+ */
+ java.lang.String getRuleKey();
+ /**
+ * <code>optional string rule_key = 2;</code>
+ */
+ com.google.protobuf.ByteString
+ getRuleKeyBytes();
+
+ /**
+ * <code>optional .Severity severity = 3;</code>
+ */
+ boolean hasSeverity();
+ /**
+ * <code>optional .Severity severity = 3;</code>
+ */
+ org.sonar.batch.protocol.Constants.Severity getSeverity();
+
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ java.util.List<org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam>
+ getParamList();
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam getParam(int index);
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ int getParamCount();
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParamOrBuilder>
+ getParamOrBuilderList();
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParamOrBuilder getParamOrBuilder(
+ int index);
+ }
+ /**
+ * Protobuf type {@code ActiveRule}
+ */
+ public static final class ActiveRule extends
+ com.google.protobuf.GeneratedMessage implements
+ // @@protoc_insertion_point(message_implements:ActiveRule)
+ ActiveRuleOrBuilder {
+ // Use ActiveRule.newBuilder() to construct.
+ private ActiveRule(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
+ super(builder);
+ this.unknownFields = builder.getUnknownFields();
+ }
+ private ActiveRule(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
+
+ private static final ActiveRule defaultInstance;
+ public static ActiveRule getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public ActiveRule getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ private final com.google.protobuf.UnknownFieldSet unknownFields;
+ @java.lang.Override
+ public final com.google.protobuf.UnknownFieldSet
+ getUnknownFields() {
+ return this.unknownFields;
+ }
+ private ActiveRule(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ initFields();
+ int mutable_bitField0_ = 0;
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder();
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ default: {
+ if (!parseUnknownField(input, unknownFields,
+ extensionRegistry, tag)) {
+ done = true;
+ }
+ break;
+ }
+ case 10: {
+ com.google.protobuf.ByteString bs = input.readBytes();
+ bitField0_ |= 0x00000001;
+ ruleRepository_ = bs;
+ break;
+ }
+ case 18: {
+ com.google.protobuf.ByteString bs = input.readBytes();
+ bitField0_ |= 0x00000002;
+ ruleKey_ = bs;
+ break;
+ }
+ case 24: {
+ int rawValue = input.readEnum();
+ org.sonar.batch.protocol.Constants.Severity value = org.sonar.batch.protocol.Constants.Severity.valueOf(rawValue);
+ if (value == null) {
+ unknownFields.mergeVarintField(3, rawValue);
+ } else {
+ bitField0_ |= 0x00000004;
+ severity_ = value;
+ }
+ break;
+ }
+ case 34: {
+ if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) {
+ param_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam>();
+ mutable_bitField0_ |= 0x00000008;
+ }
+ param_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.PARSER, extensionRegistry));
+ break;
+ }
+ }
+ }
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(this);
+ } catch (java.io.IOException e) {
+ throw new com.google.protobuf.InvalidProtocolBufferException(
+ e.getMessage()).setUnfinishedMessage(this);
+ } finally {
+ if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) {
+ param_ = java.util.Collections.unmodifiableList(param_);
+ }
+ this.unknownFields = unknownFields.build();
+ makeExtensionsImmutable();
}
+ }
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return org.sonar.batch.protocol.output.BatchReport.internal_static_ActiveRule_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return org.sonar.batch.protocol.output.BatchReport.internal_static_ActiveRule_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ org.sonar.batch.protocol.output.BatchReport.ActiveRule.class, org.sonar.batch.protocol.output.BatchReport.ActiveRule.Builder.class);
+ }
+
+ public static com.google.protobuf.Parser<ActiveRule> PARSER =
+ new com.google.protobuf.AbstractParser<ActiveRule>() {
+ public ActiveRule parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return new ActiveRule(input, extensionRegistry);
+ }
+ };
+
+ @java.lang.Override
+ public com.google.protobuf.Parser<ActiveRule> getParserForType() {
+ return PARSER;
+ }
+
+ public interface ActiveRuleParamOrBuilder extends
+ // @@protoc_insertion_point(interface_extends:ActiveRule.ActiveRuleParam)
+ com.google.protobuf.MessageOrBuilder {
+
/**
- * <code>repeated string active_rule_key = 5;</code>
- *
- * <pre>
- *Keys of the rules that were enabled in Quality profiles.
- *A key is a string composed of the repository and the subKey, specific to the repository. Format is
- *"{repository}:{subKey}", for instance "java:NullDereference".
- * </pre>
+ * <code>optional string key = 1;</code>
*/
- public com.google.protobuf.ProtocolStringList
- getActiveRuleKeyList() {
- return activeRuleKey_.getUnmodifiableView();
+ boolean hasKey();
+ /**
+ * <code>optional string key = 1;</code>
+ */
+ java.lang.String getKey();
+ /**
+ * <code>optional string key = 1;</code>
+ */
+ com.google.protobuf.ByteString
+ getKeyBytes();
+
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ boolean hasValue();
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ java.lang.String getValue();
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ com.google.protobuf.ByteString
+ getValueBytes();
+ }
+ /**
+ * Protobuf type {@code ActiveRule.ActiveRuleParam}
+ *
+ * <pre>
+ * TODO replace by map
+ * </pre>
+ */
+ public static final class ActiveRuleParam extends
+ com.google.protobuf.GeneratedMessage implements
+ // @@protoc_insertion_point(message_implements:ActiveRule.ActiveRuleParam)
+ ActiveRuleParamOrBuilder {
+ // Use ActiveRuleParam.newBuilder() to construct.
+ private ActiveRuleParam(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
+ super(builder);
+ this.unknownFields = builder.getUnknownFields();
+ }
+ private ActiveRuleParam(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
+
+ private static final ActiveRuleParam defaultInstance;
+ public static ActiveRuleParam getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public ActiveRuleParam getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ private final com.google.protobuf.UnknownFieldSet unknownFields;
+ @java.lang.Override
+ public final com.google.protobuf.UnknownFieldSet
+ getUnknownFields() {
+ return this.unknownFields;
+ }
+ private ActiveRuleParam(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ initFields();
+ int mutable_bitField0_ = 0;
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder();
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ default: {
+ if (!parseUnknownField(input, unknownFields,
+ extensionRegistry, tag)) {
+ done = true;
+ }
+ break;
+ }
+ case 10: {
+ com.google.protobuf.ByteString bs = input.readBytes();
+ bitField0_ |= 0x00000001;
+ key_ = bs;
+ break;
+ }
+ case 18: {
+ com.google.protobuf.ByteString bs = input.readBytes();
+ bitField0_ |= 0x00000002;
+ value_ = bs;
+ break;
+ }
+ }
+ }
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(this);
+ } catch (java.io.IOException e) {
+ throw new com.google.protobuf.InvalidProtocolBufferException(
+ e.getMessage()).setUnfinishedMessage(this);
+ } finally {
+ this.unknownFields = unknownFields.build();
+ makeExtensionsImmutable();
+ }
+ }
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return org.sonar.batch.protocol.output.BatchReport.internal_static_ActiveRule_ActiveRuleParam_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return org.sonar.batch.protocol.output.BatchReport.internal_static_ActiveRule_ActiveRuleParam_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.class, org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.Builder.class);
}
+
+ public static com.google.protobuf.Parser<ActiveRuleParam> PARSER =
+ new com.google.protobuf.AbstractParser<ActiveRuleParam>() {
+ public ActiveRuleParam parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return new ActiveRuleParam(input, extensionRegistry);
+ }
+ };
+
+ @java.lang.Override
+ public com.google.protobuf.Parser<ActiveRuleParam> getParserForType() {
+ return PARSER;
+ }
+
+ private int bitField0_;
+ public static final int KEY_FIELD_NUMBER = 1;
+ private java.lang.Object key_;
/**
- * <code>repeated string active_rule_key = 5;</code>
- *
- * <pre>
- *Keys of the rules that were enabled in Quality profiles.
- *A key is a string composed of the repository and the subKey, specific to the repository. Format is
- *"{repository}:{subKey}", for instance "java:NullDereference".
- * </pre>
+ * <code>optional string key = 1;</code>
*/
- public int getActiveRuleKeyCount() {
- return activeRuleKey_.size();
+ public boolean hasKey() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
- * <code>repeated string active_rule_key = 5;</code>
- *
- * <pre>
- *Keys of the rules that were enabled in Quality profiles.
- *A key is a string composed of the repository and the subKey, specific to the repository. Format is
- *"{repository}:{subKey}", for instance "java:NullDereference".
- * </pre>
+ * <code>optional string key = 1;</code>
*/
- public java.lang.String getActiveRuleKey(int index) {
- return activeRuleKey_.get(index);
+ public java.lang.String getKey() {
+ java.lang.Object ref = key_;
+ if (ref instanceof java.lang.String) {
+ return (java.lang.String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ if (bs.isValidUtf8()) {
+ key_ = s;
+ }
+ return s;
+ }
}
/**
- * <code>repeated string active_rule_key = 5;</code>
- *
- * <pre>
- *Keys of the rules that were enabled in Quality profiles.
- *A key is a string composed of the repository and the subKey, specific to the repository. Format is
- *"{repository}:{subKey}", for instance "java:NullDereference".
- * </pre>
+ * <code>optional string key = 1;</code>
+ */
+ public com.google.protobuf.ByteString
+ getKeyBytes() {
+ java.lang.Object ref = key_;
+ if (ref instanceof java.lang.String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ key_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int VALUE_FIELD_NUMBER = 2;
+ private java.lang.Object value_;
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ public boolean hasValue() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ public java.lang.String getValue() {
+ java.lang.Object ref = value_;
+ if (ref instanceof java.lang.String) {
+ return (java.lang.String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ if (bs.isValidUtf8()) {
+ value_ = s;
+ }
+ return s;
+ }
+ }
+ /**
+ * <code>optional string value = 2;</code>
*/
public com.google.protobuf.ByteString
- getActiveRuleKeyBytes(int index) {
- return activeRuleKey_.getByteString(index);
+ getValueBytes() {
+ java.lang.Object ref = value_;
+ if (ref instanceof java.lang.String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ value_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ private void initFields() {
+ key_ = "";
+ value_ = "";
+ }
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ getSerializedSize();
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ output.writeBytes(1, getKeyBytes());
+ }
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ output.writeBytes(2, getValueBytes());
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(1, getKeyBytes());
+ }
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(2, getValueBytes());
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ private static final long serialVersionUID = 0L;
+ @java.lang.Override
+ protected java.lang.Object writeReplace()
+ throws java.io.ObjectStreamException {
+ return super.writeReplace();
+ }
+
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input);
+ }
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input, extensionRegistry);
+ }
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return PARSER.parseDelimitedFrom(input);
+ }
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseDelimitedFrom(input, extensionRegistry);
+ }
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input);
+ }
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input, extensionRegistry);
+ }
+
+ public static Builder newBuilder() { return Builder.create(); }
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder(org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() { return newBuilder(this); }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
}
/**
- * <code>repeated string active_rule_key = 5;</code>
+ * Protobuf type {@code ActiveRule.ActiveRuleParam}
*
* <pre>
- *Keys of the rules that were enabled in Quality profiles.
- *A key is a string composed of the repository and the subKey, specific to the repository. Format is
- *"{repository}:{subKey}", for instance "java:NullDereference".
+ * TODO replace by map
* </pre>
*/
- public Builder setActiveRuleKey(
- int index, java.lang.String value) {
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessage.Builder<Builder> implements
+ // @@protoc_insertion_point(builder_implements:ActiveRule.ActiveRuleParam)
+ org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParamOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return org.sonar.batch.protocol.output.BatchReport.internal_static_ActiveRule_ActiveRuleParam_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return org.sonar.batch.protocol.output.BatchReport.internal_static_ActiveRule_ActiveRuleParam_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.class, org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.Builder.class);
+ }
+
+ // Construct using org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ }
+ }
+ private static Builder create() {
+ return new Builder();
+ }
+
+ public Builder clear() {
+ super.clear();
+ key_ = "";
+ bitField0_ = (bitField0_ & ~0x00000001);
+ value_ = "";
+ bitField0_ = (bitField0_ & ~0x00000002);
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(buildPartial());
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return org.sonar.batch.protocol.output.BatchReport.internal_static_ActiveRule_ActiveRuleParam_descriptor;
+ }
+
+ public org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam getDefaultInstanceForType() {
+ return org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.getDefaultInstance();
+ }
+
+ public org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam build() {
+ org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ public org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam buildPartial() {
+ org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam result = new org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam(this);
+ int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
+ if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+ to_bitField0_ |= 0x00000001;
+ }
+ result.key_ = key_;
+ if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
+ to_bitField0_ |= 0x00000002;
+ }
+ result.value_ = value_;
+ result.bitField0_ = to_bitField0_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam) {
+ return mergeFrom((org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam other) {
+ if (other == org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.getDefaultInstance()) return this;
+ if (other.hasKey()) {
+ bitField0_ |= 0x00000001;
+ key_ = other.key_;
+ onChanged();
+ }
+ if (other.hasValue()) {
+ bitField0_ |= 0x00000002;
+ value_ = other.value_;
+ onChanged();
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam parsedMessage = null;
+ try {
+ parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ parsedMessage = (org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam) e.getUnfinishedMessage();
+ throw e;
+ } finally {
+ if (parsedMessage != null) {
+ mergeFrom(parsedMessage);
+ }
+ }
+ return this;
+ }
+ private int bitField0_;
+
+ private java.lang.Object key_ = "";
+ /**
+ * <code>optional string key = 1;</code>
+ */
+ public boolean hasKey() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ /**
+ * <code>optional string key = 1;</code>
+ */
+ public java.lang.String getKey() {
+ java.lang.Object ref = key_;
+ if (!(ref instanceof java.lang.String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ if (bs.isValidUtf8()) {
+ key_ = s;
+ }
+ return s;
+ } else {
+ return (java.lang.String) ref;
+ }
+ }
+ /**
+ * <code>optional string key = 1;</code>
+ */
+ public com.google.protobuf.ByteString
+ getKeyBytes() {
+ java.lang.Object ref = key_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ key_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * <code>optional string key = 1;</code>
+ */
+ public Builder setKey(
+ java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000001;
+ key_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional string key = 1;</code>
+ */
+ public Builder clearKey() {
+ bitField0_ = (bitField0_ & ~0x00000001);
+ key_ = getDefaultInstance().getKey();
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional string key = 1;</code>
+ */
+ public Builder setKeyBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000001;
+ key_ = value;
+ onChanged();
+ return this;
+ }
+
+ private java.lang.Object value_ = "";
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ public boolean hasValue() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ public java.lang.String getValue() {
+ java.lang.Object ref = value_;
+ if (!(ref instanceof java.lang.String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ if (bs.isValidUtf8()) {
+ value_ = s;
+ }
+ return s;
+ } else {
+ return (java.lang.String) ref;
+ }
+ }
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ public com.google.protobuf.ByteString
+ getValueBytes() {
+ java.lang.Object ref = value_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ value_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ public Builder setValue(
+ java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000002;
+ value_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ public Builder clearValue() {
+ bitField0_ = (bitField0_ & ~0x00000002);
+ value_ = getDefaultInstance().getValue();
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ public Builder setValueBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000002;
+ value_ = value;
+ onChanged();
+ return this;
+ }
+
+ // @@protoc_insertion_point(builder_scope:ActiveRule.ActiveRuleParam)
+ }
+
+ static {
+ defaultInstance = new ActiveRuleParam(true);
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:ActiveRule.ActiveRuleParam)
+ }
+
+ private int bitField0_;
+ public static final int RULE_REPOSITORY_FIELD_NUMBER = 1;
+ private java.lang.Object ruleRepository_;
+ /**
+ * <code>optional string rule_repository = 1;</code>
+ */
+ public boolean hasRuleRepository() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ /**
+ * <code>optional string rule_repository = 1;</code>
+ */
+ public java.lang.String getRuleRepository() {
+ java.lang.Object ref = ruleRepository_;
+ if (ref instanceof java.lang.String) {
+ return (java.lang.String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ if (bs.isValidUtf8()) {
+ ruleRepository_ = s;
+ }
+ return s;
+ }
+ }
+ /**
+ * <code>optional string rule_repository = 1;</code>
+ */
+ public com.google.protobuf.ByteString
+ getRuleRepositoryBytes() {
+ java.lang.Object ref = ruleRepository_;
+ if (ref instanceof java.lang.String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ ruleRepository_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int RULE_KEY_FIELD_NUMBER = 2;
+ private java.lang.Object ruleKey_;
+ /**
+ * <code>optional string rule_key = 2;</code>
+ */
+ public boolean hasRuleKey() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ /**
+ * <code>optional string rule_key = 2;</code>
+ */
+ public java.lang.String getRuleKey() {
+ java.lang.Object ref = ruleKey_;
+ if (ref instanceof java.lang.String) {
+ return (java.lang.String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ if (bs.isValidUtf8()) {
+ ruleKey_ = s;
+ }
+ return s;
+ }
+ }
+ /**
+ * <code>optional string rule_key = 2;</code>
+ */
+ public com.google.protobuf.ByteString
+ getRuleKeyBytes() {
+ java.lang.Object ref = ruleKey_;
+ if (ref instanceof java.lang.String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ ruleKey_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int SEVERITY_FIELD_NUMBER = 3;
+ private org.sonar.batch.protocol.Constants.Severity severity_;
+ /**
+ * <code>optional .Severity severity = 3;</code>
+ */
+ public boolean hasSeverity() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ /**
+ * <code>optional .Severity severity = 3;</code>
+ */
+ public org.sonar.batch.protocol.Constants.Severity getSeverity() {
+ return severity_;
+ }
+
+ public static final int PARAM_FIELD_NUMBER = 4;
+ private java.util.List<org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam> param_;
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public java.util.List<org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam> getParamList() {
+ return param_;
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParamOrBuilder>
+ getParamOrBuilderList() {
+ return param_;
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public int getParamCount() {
+ return param_.size();
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam getParam(int index) {
+ return param_.get(index);
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParamOrBuilder getParamOrBuilder(
+ int index) {
+ return param_.get(index);
+ }
+
+ private void initFields() {
+ ruleRepository_ = "";
+ ruleKey_ = "";
+ severity_ = org.sonar.batch.protocol.Constants.Severity.INFO;
+ param_ = java.util.Collections.emptyList();
+ }
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ getSerializedSize();
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ output.writeBytes(1, getRuleRepositoryBytes());
+ }
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ output.writeBytes(2, getRuleKeyBytes());
+ }
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ output.writeEnum(3, severity_.getNumber());
+ }
+ for (int i = 0; i < param_.size(); i++) {
+ output.writeMessage(4, param_.get(i));
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(1, getRuleRepositoryBytes());
+ }
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(2, getRuleKeyBytes());
+ }
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeEnumSize(3, severity_.getNumber());
+ }
+ for (int i = 0; i < param_.size(); i++) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeMessageSize(4, param_.get(i));
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ private static final long serialVersionUID = 0L;
+ @java.lang.Override
+ protected java.lang.Object writeReplace()
+ throws java.io.ObjectStreamException {
+ return super.writeReplace();
+ }
+
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input);
+ }
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input, extensionRegistry);
+ }
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return PARSER.parseDelimitedFrom(input);
+ }
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseDelimitedFrom(input, extensionRegistry);
+ }
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input);
+ }
+ public static org.sonar.batch.protocol.output.BatchReport.ActiveRule parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input, extensionRegistry);
+ }
+
+ public static Builder newBuilder() { return Builder.create(); }
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder(org.sonar.batch.protocol.output.BatchReport.ActiveRule prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() { return newBuilder(this); }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code ActiveRule}
+ */
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessage.Builder<Builder> implements
+ // @@protoc_insertion_point(builder_implements:ActiveRule)
+ org.sonar.batch.protocol.output.BatchReport.ActiveRuleOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return org.sonar.batch.protocol.output.BatchReport.internal_static_ActiveRule_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return org.sonar.batch.protocol.output.BatchReport.internal_static_ActiveRule_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ org.sonar.batch.protocol.output.BatchReport.ActiveRule.class, org.sonar.batch.protocol.output.BatchReport.ActiveRule.Builder.class);
+ }
+
+ // Construct using org.sonar.batch.protocol.output.BatchReport.ActiveRule.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ getParamFieldBuilder();
+ }
+ }
+ private static Builder create() {
+ return new Builder();
+ }
+
+ public Builder clear() {
+ super.clear();
+ ruleRepository_ = "";
+ bitField0_ = (bitField0_ & ~0x00000001);
+ ruleKey_ = "";
+ bitField0_ = (bitField0_ & ~0x00000002);
+ severity_ = org.sonar.batch.protocol.Constants.Severity.INFO;
+ bitField0_ = (bitField0_ & ~0x00000004);
+ if (paramBuilder_ == null) {
+ param_ = java.util.Collections.emptyList();
+ bitField0_ = (bitField0_ & ~0x00000008);
+ } else {
+ paramBuilder_.clear();
+ }
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(buildPartial());
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return org.sonar.batch.protocol.output.BatchReport.internal_static_ActiveRule_descriptor;
+ }
+
+ public org.sonar.batch.protocol.output.BatchReport.ActiveRule getDefaultInstanceForType() {
+ return org.sonar.batch.protocol.output.BatchReport.ActiveRule.getDefaultInstance();
+ }
+
+ public org.sonar.batch.protocol.output.BatchReport.ActiveRule build() {
+ org.sonar.batch.protocol.output.BatchReport.ActiveRule result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ public org.sonar.batch.protocol.output.BatchReport.ActiveRule buildPartial() {
+ org.sonar.batch.protocol.output.BatchReport.ActiveRule result = new org.sonar.batch.protocol.output.BatchReport.ActiveRule(this);
+ int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
+ if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+ to_bitField0_ |= 0x00000001;
+ }
+ result.ruleRepository_ = ruleRepository_;
+ if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
+ to_bitField0_ |= 0x00000002;
+ }
+ result.ruleKey_ = ruleKey_;
+ if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
+ to_bitField0_ |= 0x00000004;
+ }
+ result.severity_ = severity_;
+ if (paramBuilder_ == null) {
+ if (((bitField0_ & 0x00000008) == 0x00000008)) {
+ param_ = java.util.Collections.unmodifiableList(param_);
+ bitField0_ = (bitField0_ & ~0x00000008);
+ }
+ result.param_ = param_;
+ } else {
+ result.param_ = paramBuilder_.build();
+ }
+ result.bitField0_ = to_bitField0_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof org.sonar.batch.protocol.output.BatchReport.ActiveRule) {
+ return mergeFrom((org.sonar.batch.protocol.output.BatchReport.ActiveRule)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(org.sonar.batch.protocol.output.BatchReport.ActiveRule other) {
+ if (other == org.sonar.batch.protocol.output.BatchReport.ActiveRule.getDefaultInstance()) return this;
+ if (other.hasRuleRepository()) {
+ bitField0_ |= 0x00000001;
+ ruleRepository_ = other.ruleRepository_;
+ onChanged();
+ }
+ if (other.hasRuleKey()) {
+ bitField0_ |= 0x00000002;
+ ruleKey_ = other.ruleKey_;
+ onChanged();
+ }
+ if (other.hasSeverity()) {
+ setSeverity(other.getSeverity());
+ }
+ if (paramBuilder_ == null) {
+ if (!other.param_.isEmpty()) {
+ if (param_.isEmpty()) {
+ param_ = other.param_;
+ bitField0_ = (bitField0_ & ~0x00000008);
+ } else {
+ ensureParamIsMutable();
+ param_.addAll(other.param_);
+ }
+ onChanged();
+ }
+ } else {
+ if (!other.param_.isEmpty()) {
+ if (paramBuilder_.isEmpty()) {
+ paramBuilder_.dispose();
+ paramBuilder_ = null;
+ param_ = other.param_;
+ bitField0_ = (bitField0_ & ~0x00000008);
+ paramBuilder_ =
+ com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
+ getParamFieldBuilder() : null;
+ } else {
+ paramBuilder_.addAllMessages(other.param_);
+ }
+ }
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ org.sonar.batch.protocol.output.BatchReport.ActiveRule parsedMessage = null;
+ try {
+ parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ parsedMessage = (org.sonar.batch.protocol.output.BatchReport.ActiveRule) e.getUnfinishedMessage();
+ throw e;
+ } finally {
+ if (parsedMessage != null) {
+ mergeFrom(parsedMessage);
+ }
+ }
+ return this;
+ }
+ private int bitField0_;
+
+ private java.lang.Object ruleRepository_ = "";
+ /**
+ * <code>optional string rule_repository = 1;</code>
+ */
+ public boolean hasRuleRepository() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ /**
+ * <code>optional string rule_repository = 1;</code>
+ */
+ public java.lang.String getRuleRepository() {
+ java.lang.Object ref = ruleRepository_;
+ if (!(ref instanceof java.lang.String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ if (bs.isValidUtf8()) {
+ ruleRepository_ = s;
+ }
+ return s;
+ } else {
+ return (java.lang.String) ref;
+ }
+ }
+ /**
+ * <code>optional string rule_repository = 1;</code>
+ */
+ public com.google.protobuf.ByteString
+ getRuleRepositoryBytes() {
+ java.lang.Object ref = ruleRepository_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ ruleRepository_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * <code>optional string rule_repository = 1;</code>
+ */
+ public Builder setRuleRepository(
+ java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
- ensureActiveRuleKeyIsMutable();
- activeRuleKey_.set(index, value);
+ bitField0_ |= 0x00000001;
+ ruleRepository_ = value;
onChanged();
return this;
}
/**
- * <code>repeated string active_rule_key = 5;</code>
- *
- * <pre>
- *Keys of the rules that were enabled in Quality profiles.
- *A key is a string composed of the repository and the subKey, specific to the repository. Format is
- *"{repository}:{subKey}", for instance "java:NullDereference".
- * </pre>
+ * <code>optional string rule_repository = 1;</code>
*/
- public Builder addActiveRuleKey(
- java.lang.String value) {
+ public Builder clearRuleRepository() {
+ bitField0_ = (bitField0_ & ~0x00000001);
+ ruleRepository_ = getDefaultInstance().getRuleRepository();
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional string rule_repository = 1;</code>
+ */
+ public Builder setRuleRepositoryBytes(
+ com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
- ensureActiveRuleKeyIsMutable();
- activeRuleKey_.add(value);
+ bitField0_ |= 0x00000001;
+ ruleRepository_ = value;
onChanged();
return this;
}
+
+ private java.lang.Object ruleKey_ = "";
/**
- * <code>repeated string active_rule_key = 5;</code>
- *
- * <pre>
- *Keys of the rules that were enabled in Quality profiles.
- *A key is a string composed of the repository and the subKey, specific to the repository. Format is
- *"{repository}:{subKey}", for instance "java:NullDereference".
- * </pre>
+ * <code>optional string rule_key = 2;</code>
*/
- public Builder addAllActiveRuleKey(
- java.lang.Iterable<java.lang.String> values) {
- ensureActiveRuleKeyIsMutable();
- com.google.protobuf.AbstractMessageLite.Builder.addAll(
- values, activeRuleKey_);
+ public boolean hasRuleKey() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ /**
+ * <code>optional string rule_key = 2;</code>
+ */
+ public java.lang.String getRuleKey() {
+ java.lang.Object ref = ruleKey_;
+ if (!(ref instanceof java.lang.String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ if (bs.isValidUtf8()) {
+ ruleKey_ = s;
+ }
+ return s;
+ } else {
+ return (java.lang.String) ref;
+ }
+ }
+ /**
+ * <code>optional string rule_key = 2;</code>
+ */
+ public com.google.protobuf.ByteString
+ getRuleKeyBytes() {
+ java.lang.Object ref = ruleKey_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ ruleKey_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * <code>optional string rule_key = 2;</code>
+ */
+ public Builder setRuleKey(
+ java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000002;
+ ruleKey_ = value;
onChanged();
return this;
}
/**
- * <code>repeated string active_rule_key = 5;</code>
- *
- * <pre>
- *Keys of the rules that were enabled in Quality profiles.
- *A key is a string composed of the repository and the subKey, specific to the repository. Format is
- *"{repository}:{subKey}", for instance "java:NullDereference".
- * </pre>
+ * <code>optional string rule_key = 2;</code>
*/
- public Builder clearActiveRuleKey() {
- activeRuleKey_ = com.google.protobuf.LazyStringArrayList.EMPTY;
- bitField0_ = (bitField0_ & ~0x00000010);
+ public Builder clearRuleKey() {
+ bitField0_ = (bitField0_ & ~0x00000002);
+ ruleKey_ = getDefaultInstance().getRuleKey();
onChanged();
return this;
}
/**
- * <code>repeated string active_rule_key = 5;</code>
- *
- * <pre>
- *Keys of the rules that were enabled in Quality profiles.
- *A key is a string composed of the repository and the subKey, specific to the repository. Format is
- *"{repository}:{subKey}", for instance "java:NullDereference".
- * </pre>
+ * <code>optional string rule_key = 2;</code>
*/
- public Builder addActiveRuleKeyBytes(
+ public Builder setRuleKeyBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
- ensureActiveRuleKeyIsMutable();
- activeRuleKey_.add(value);
+ bitField0_ |= 0x00000002;
+ ruleKey_ = value;
onChanged();
return this;
}
- // @@protoc_insertion_point(builder_scope:Metadata)
+ private org.sonar.batch.protocol.Constants.Severity severity_ = org.sonar.batch.protocol.Constants.Severity.INFO;
+ /**
+ * <code>optional .Severity severity = 3;</code>
+ */
+ public boolean hasSeverity() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ /**
+ * <code>optional .Severity severity = 3;</code>
+ */
+ public org.sonar.batch.protocol.Constants.Severity getSeverity() {
+ return severity_;
+ }
+ /**
+ * <code>optional .Severity severity = 3;</code>
+ */
+ public Builder setSeverity(org.sonar.batch.protocol.Constants.Severity value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000004;
+ severity_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional .Severity severity = 3;</code>
+ */
+ public Builder clearSeverity() {
+ bitField0_ = (bitField0_ & ~0x00000004);
+ severity_ = org.sonar.batch.protocol.Constants.Severity.INFO;
+ onChanged();
+ return this;
+ }
+
+ private java.util.List<org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam> param_ =
+ java.util.Collections.emptyList();
+ private void ensureParamIsMutable() {
+ if (!((bitField0_ & 0x00000008) == 0x00000008)) {
+ param_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam>(param_);
+ bitField0_ |= 0x00000008;
+ }
+ }
+
+ private com.google.protobuf.RepeatedFieldBuilder<
+ org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam, org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.Builder, org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParamOrBuilder> paramBuilder_;
+
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public java.util.List<org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam> getParamList() {
+ if (paramBuilder_ == null) {
+ return java.util.Collections.unmodifiableList(param_);
+ } else {
+ return paramBuilder_.getMessageList();
+ }
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public int getParamCount() {
+ if (paramBuilder_ == null) {
+ return param_.size();
+ } else {
+ return paramBuilder_.getCount();
+ }
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam getParam(int index) {
+ if (paramBuilder_ == null) {
+ return param_.get(index);
+ } else {
+ return paramBuilder_.getMessage(index);
+ }
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public Builder setParam(
+ int index, org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam value) {
+ if (paramBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureParamIsMutable();
+ param_.set(index, value);
+ onChanged();
+ } else {
+ paramBuilder_.setMessage(index, value);
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public Builder setParam(
+ int index, org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.Builder builderForValue) {
+ if (paramBuilder_ == null) {
+ ensureParamIsMutable();
+ param_.set(index, builderForValue.build());
+ onChanged();
+ } else {
+ paramBuilder_.setMessage(index, builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public Builder addParam(org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam value) {
+ if (paramBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureParamIsMutable();
+ param_.add(value);
+ onChanged();
+ } else {
+ paramBuilder_.addMessage(value);
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public Builder addParam(
+ int index, org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam value) {
+ if (paramBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureParamIsMutable();
+ param_.add(index, value);
+ onChanged();
+ } else {
+ paramBuilder_.addMessage(index, value);
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public Builder addParam(
+ org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.Builder builderForValue) {
+ if (paramBuilder_ == null) {
+ ensureParamIsMutable();
+ param_.add(builderForValue.build());
+ onChanged();
+ } else {
+ paramBuilder_.addMessage(builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public Builder addParam(
+ int index, org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.Builder builderForValue) {
+ if (paramBuilder_ == null) {
+ ensureParamIsMutable();
+ param_.add(index, builderForValue.build());
+ onChanged();
+ } else {
+ paramBuilder_.addMessage(index, builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public Builder addAllParam(
+ java.lang.Iterable<? extends org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam> values) {
+ if (paramBuilder_ == null) {
+ ensureParamIsMutable();
+ com.google.protobuf.AbstractMessageLite.Builder.addAll(
+ values, param_);
+ onChanged();
+ } else {
+ paramBuilder_.addAllMessages(values);
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public Builder clearParam() {
+ if (paramBuilder_ == null) {
+ param_ = java.util.Collections.emptyList();
+ bitField0_ = (bitField0_ & ~0x00000008);
+ onChanged();
+ } else {
+ paramBuilder_.clear();
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public Builder removeParam(int index) {
+ if (paramBuilder_ == null) {
+ ensureParamIsMutable();
+ param_.remove(index);
+ onChanged();
+ } else {
+ paramBuilder_.remove(index);
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.Builder getParamBuilder(
+ int index) {
+ return getParamFieldBuilder().getBuilder(index);
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParamOrBuilder getParamOrBuilder(
+ int index) {
+ if (paramBuilder_ == null) {
+ return param_.get(index); } else {
+ return paramBuilder_.getMessageOrBuilder(index);
+ }
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParamOrBuilder>
+ getParamOrBuilderList() {
+ if (paramBuilder_ != null) {
+ return paramBuilder_.getMessageOrBuilderList();
+ } else {
+ return java.util.Collections.unmodifiableList(param_);
+ }
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.Builder addParamBuilder() {
+ return getParamFieldBuilder().addBuilder(
+ org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.getDefaultInstance());
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.Builder addParamBuilder(
+ int index) {
+ return getParamFieldBuilder().addBuilder(
+ index, org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.getDefaultInstance());
+ }
+ /**
+ * <code>repeated .ActiveRule.ActiveRuleParam param = 4;</code>
+ */
+ public java.util.List<org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.Builder>
+ getParamBuilderList() {
+ return getParamFieldBuilder().getBuilderList();
+ }
+ private com.google.protobuf.RepeatedFieldBuilder<
+ org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam, org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.Builder, org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParamOrBuilder>
+ getParamFieldBuilder() {
+ if (paramBuilder_ == null) {
+ paramBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
+ org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam, org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParam.Builder, org.sonar.batch.protocol.output.BatchReport.ActiveRule.ActiveRuleParamOrBuilder>(
+ param_,
+ ((bitField0_ & 0x00000008) == 0x00000008),
+ getParentForChildren(),
+ isClean());
+ param_ = null;
+ }
+ return paramBuilder_;
+ }
+
+ // @@protoc_insertion_point(builder_scope:ActiveRule)
}
static {
- defaultInstance = new Metadata(true);
+ defaultInstance = new ActiveRule(true);
defaultInstance.initFields();
}
- // @@protoc_insertion_point(class_scope:Metadata)
+ // @@protoc_insertion_point(class_scope:ActiveRule)
}
public interface ComponentLinkOrBuilder extends
@@ -5725,771 +7161,6 @@ public final class BatchReport {
// @@protoc_insertion_point(class_scope:Measure)
}
- public interface MeasuresOrBuilder extends
- // @@protoc_insertion_point(interface_extends:Measures)
- com.google.protobuf.MessageOrBuilder {
-
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- boolean hasComponentRef();
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- int getComponentRef();
-
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- java.util.List<org.sonar.batch.protocol.output.BatchReport.Measure>
- getMeasureList();
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- org.sonar.batch.protocol.output.BatchReport.Measure getMeasure(int index);
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- int getMeasureCount();
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.MeasureOrBuilder>
- getMeasureOrBuilderList();
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- org.sonar.batch.protocol.output.BatchReport.MeasureOrBuilder getMeasureOrBuilder(
- int index);
- }
- /**
- * Protobuf type {@code Measures}
- *
- * <pre>
- * TODO to be removed. It prevents streaming
- * </pre>
- */
- public static final class Measures extends
- com.google.protobuf.GeneratedMessage implements
- // @@protoc_insertion_point(message_implements:Measures)
- MeasuresOrBuilder {
- // Use Measures.newBuilder() to construct.
- private Measures(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
- super(builder);
- this.unknownFields = builder.getUnknownFields();
- }
- private Measures(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
-
- private static final Measures defaultInstance;
- public static Measures getDefaultInstance() {
- return defaultInstance;
- }
-
- public Measures getDefaultInstanceForType() {
- return defaultInstance;
- }
-
- private final com.google.protobuf.UnknownFieldSet unknownFields;
- @java.lang.Override
- public final com.google.protobuf.UnknownFieldSet
- getUnknownFields() {
- return this.unknownFields;
- }
- private Measures(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- initFields();
- int mutable_bitField0_ = 0;
- com.google.protobuf.UnknownFieldSet.Builder unknownFields =
- com.google.protobuf.UnknownFieldSet.newBuilder();
- try {
- boolean done = false;
- while (!done) {
- int tag = input.readTag();
- switch (tag) {
- case 0:
- done = true;
- break;
- default: {
- if (!parseUnknownField(input, unknownFields,
- extensionRegistry, tag)) {
- done = true;
- }
- break;
- }
- case 8: {
- bitField0_ |= 0x00000001;
- componentRef_ = input.readInt32();
- break;
- }
- case 18: {
- if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
- measure_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Measure>();
- mutable_bitField0_ |= 0x00000002;
- }
- measure_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.Measure.PARSER, extensionRegistry));
- break;
- }
- }
- }
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- throw e.setUnfinishedMessage(this);
- } catch (java.io.IOException e) {
- throw new com.google.protobuf.InvalidProtocolBufferException(
- e.getMessage()).setUnfinishedMessage(this);
- } finally {
- if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
- measure_ = java.util.Collections.unmodifiableList(measure_);
- }
- this.unknownFields = unknownFields.build();
- makeExtensionsImmutable();
- }
- }
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Measures_descriptor;
- }
-
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Measures_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.sonar.batch.protocol.output.BatchReport.Measures.class, org.sonar.batch.protocol.output.BatchReport.Measures.Builder.class);
- }
-
- public static com.google.protobuf.Parser<Measures> PARSER =
- new com.google.protobuf.AbstractParser<Measures>() {
- public Measures parsePartialFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return new Measures(input, extensionRegistry);
- }
- };
-
- @java.lang.Override
- public com.google.protobuf.Parser<Measures> getParserForType() {
- return PARSER;
- }
-
- private int bitField0_;
- public static final int COMPONENT_REF_FIELD_NUMBER = 1;
- private int componentRef_;
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- public boolean hasComponentRef() {
- return ((bitField0_ & 0x00000001) == 0x00000001);
- }
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- public int getComponentRef() {
- return componentRef_;
- }
-
- public static final int MEASURE_FIELD_NUMBER = 2;
- private java.util.List<org.sonar.batch.protocol.output.BatchReport.Measure> measure_;
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public java.util.List<org.sonar.batch.protocol.output.BatchReport.Measure> getMeasureList() {
- return measure_;
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.MeasureOrBuilder>
- getMeasureOrBuilderList() {
- return measure_;
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public int getMeasureCount() {
- return measure_.size();
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Measure getMeasure(int index) {
- return measure_.get(index);
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.MeasureOrBuilder getMeasureOrBuilder(
- int index) {
- return measure_.get(index);
- }
-
- private void initFields() {
- componentRef_ = 0;
- measure_ = java.util.Collections.emptyList();
- }
- private byte memoizedIsInitialized = -1;
- public final boolean isInitialized() {
- byte isInitialized = memoizedIsInitialized;
- if (isInitialized == 1) return true;
- if (isInitialized == 0) return false;
-
- memoizedIsInitialized = 1;
- return true;
- }
-
- public void writeTo(com.google.protobuf.CodedOutputStream output)
- throws java.io.IOException {
- getSerializedSize();
- if (((bitField0_ & 0x00000001) == 0x00000001)) {
- output.writeInt32(1, componentRef_);
- }
- for (int i = 0; i < measure_.size(); i++) {
- output.writeMessage(2, measure_.get(i));
- }
- getUnknownFields().writeTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public int getSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (((bitField0_ & 0x00000001) == 0x00000001)) {
- size += com.google.protobuf.CodedOutputStream
- .computeInt32Size(1, componentRef_);
- }
- for (int i = 0; i < measure_.size(); i++) {
- size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(2, measure_.get(i));
- }
- size += getUnknownFields().getSerializedSize();
- memoizedSerializedSize = size;
- return size;
- }
-
- private static final long serialVersionUID = 0L;
- @java.lang.Override
- protected java.lang.Object writeReplace()
- throws java.io.ObjectStreamException {
- return super.writeReplace();
- }
-
- public static org.sonar.batch.protocol.output.BatchReport.Measures parseFrom(
- com.google.protobuf.ByteString data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Measures parseFrom(
- com.google.protobuf.ByteString data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Measures parseFrom(byte[] data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Measures parseFrom(
- byte[] data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Measures parseFrom(java.io.InputStream input)
- throws java.io.IOException {
- return PARSER.parseFrom(input);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Measures parseFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseFrom(input, extensionRegistry);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Measures parseDelimitedFrom(java.io.InputStream input)
- throws java.io.IOException {
- return PARSER.parseDelimitedFrom(input);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Measures parseDelimitedFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseDelimitedFrom(input, extensionRegistry);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Measures parseFrom(
- com.google.protobuf.CodedInputStream input)
- throws java.io.IOException {
- return PARSER.parseFrom(input);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Measures parseFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseFrom(input, extensionRegistry);
- }
-
- public static Builder newBuilder() { return Builder.create(); }
- public Builder newBuilderForType() { return newBuilder(); }
- public static Builder newBuilder(org.sonar.batch.protocol.output.BatchReport.Measures prototype) {
- return newBuilder().mergeFrom(prototype);
- }
- public Builder toBuilder() { return newBuilder(this); }
-
- @java.lang.Override
- protected Builder newBuilderForType(
- com.google.protobuf.GeneratedMessage.BuilderParent parent) {
- Builder builder = new Builder(parent);
- return builder;
- }
- /**
- * Protobuf type {@code Measures}
- *
- * <pre>
- * TODO to be removed. It prevents streaming
- * </pre>
- */
- public static final class Builder extends
- com.google.protobuf.GeneratedMessage.Builder<Builder> implements
- // @@protoc_insertion_point(builder_implements:Measures)
- org.sonar.batch.protocol.output.BatchReport.MeasuresOrBuilder {
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Measures_descriptor;
- }
-
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Measures_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.sonar.batch.protocol.output.BatchReport.Measures.class, org.sonar.batch.protocol.output.BatchReport.Measures.Builder.class);
- }
-
- // Construct using org.sonar.batch.protocol.output.BatchReport.Measures.newBuilder()
- private Builder() {
- maybeForceBuilderInitialization();
- }
-
- private Builder(
- com.google.protobuf.GeneratedMessage.BuilderParent parent) {
- super(parent);
- maybeForceBuilderInitialization();
- }
- private void maybeForceBuilderInitialization() {
- if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
- getMeasureFieldBuilder();
- }
- }
- private static Builder create() {
- return new Builder();
- }
-
- public Builder clear() {
- super.clear();
- componentRef_ = 0;
- bitField0_ = (bitField0_ & ~0x00000001);
- if (measureBuilder_ == null) {
- measure_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000002);
- } else {
- measureBuilder_.clear();
- }
- return this;
- }
-
- public Builder clone() {
- return create().mergeFrom(buildPartial());
- }
-
- public com.google.protobuf.Descriptors.Descriptor
- getDescriptorForType() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Measures_descriptor;
- }
-
- public org.sonar.batch.protocol.output.BatchReport.Measures getDefaultInstanceForType() {
- return org.sonar.batch.protocol.output.BatchReport.Measures.getDefaultInstance();
- }
-
- public org.sonar.batch.protocol.output.BatchReport.Measures build() {
- org.sonar.batch.protocol.output.BatchReport.Measures result = buildPartial();
- if (!result.isInitialized()) {
- throw newUninitializedMessageException(result);
- }
- return result;
- }
-
- public org.sonar.batch.protocol.output.BatchReport.Measures buildPartial() {
- org.sonar.batch.protocol.output.BatchReport.Measures result = new org.sonar.batch.protocol.output.BatchReport.Measures(this);
- int from_bitField0_ = bitField0_;
- int to_bitField0_ = 0;
- if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
- to_bitField0_ |= 0x00000001;
- }
- result.componentRef_ = componentRef_;
- if (measureBuilder_ == null) {
- if (((bitField0_ & 0x00000002) == 0x00000002)) {
- measure_ = java.util.Collections.unmodifiableList(measure_);
- bitField0_ = (bitField0_ & ~0x00000002);
- }
- result.measure_ = measure_;
- } else {
- result.measure_ = measureBuilder_.build();
- }
- result.bitField0_ = to_bitField0_;
- onBuilt();
- return result;
- }
-
- public Builder mergeFrom(com.google.protobuf.Message other) {
- if (other instanceof org.sonar.batch.protocol.output.BatchReport.Measures) {
- return mergeFrom((org.sonar.batch.protocol.output.BatchReport.Measures)other);
- } else {
- super.mergeFrom(other);
- return this;
- }
- }
-
- public Builder mergeFrom(org.sonar.batch.protocol.output.BatchReport.Measures other) {
- if (other == org.sonar.batch.protocol.output.BatchReport.Measures.getDefaultInstance()) return this;
- if (other.hasComponentRef()) {
- setComponentRef(other.getComponentRef());
- }
- if (measureBuilder_ == null) {
- if (!other.measure_.isEmpty()) {
- if (measure_.isEmpty()) {
- measure_ = other.measure_;
- bitField0_ = (bitField0_ & ~0x00000002);
- } else {
- ensureMeasureIsMutable();
- measure_.addAll(other.measure_);
- }
- onChanged();
- }
- } else {
- if (!other.measure_.isEmpty()) {
- if (measureBuilder_.isEmpty()) {
- measureBuilder_.dispose();
- measureBuilder_ = null;
- measure_ = other.measure_;
- bitField0_ = (bitField0_ & ~0x00000002);
- measureBuilder_ =
- com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
- getMeasureFieldBuilder() : null;
- } else {
- measureBuilder_.addAllMessages(other.measure_);
- }
- }
- }
- this.mergeUnknownFields(other.getUnknownFields());
- return this;
- }
-
- public final boolean isInitialized() {
- return true;
- }
-
- public Builder mergeFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- org.sonar.batch.protocol.output.BatchReport.Measures parsedMessage = null;
- try {
- parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- parsedMessage = (org.sonar.batch.protocol.output.BatchReport.Measures) e.getUnfinishedMessage();
- throw e;
- } finally {
- if (parsedMessage != null) {
- mergeFrom(parsedMessage);
- }
- }
- return this;
- }
- private int bitField0_;
-
- private int componentRef_ ;
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- public boolean hasComponentRef() {
- return ((bitField0_ & 0x00000001) == 0x00000001);
- }
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- public int getComponentRef() {
- return componentRef_;
- }
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- public Builder setComponentRef(int value) {
- bitField0_ |= 0x00000001;
- componentRef_ = value;
- onChanged();
- return this;
- }
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- public Builder clearComponentRef() {
- bitField0_ = (bitField0_ & ~0x00000001);
- componentRef_ = 0;
- onChanged();
- return this;
- }
-
- private java.util.List<org.sonar.batch.protocol.output.BatchReport.Measure> measure_ =
- java.util.Collections.emptyList();
- private void ensureMeasureIsMutable() {
- if (!((bitField0_ & 0x00000002) == 0x00000002)) {
- measure_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Measure>(measure_);
- bitField0_ |= 0x00000002;
- }
- }
-
- private com.google.protobuf.RepeatedFieldBuilder<
- org.sonar.batch.protocol.output.BatchReport.Measure, org.sonar.batch.protocol.output.BatchReport.Measure.Builder, org.sonar.batch.protocol.output.BatchReport.MeasureOrBuilder> measureBuilder_;
-
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public java.util.List<org.sonar.batch.protocol.output.BatchReport.Measure> getMeasureList() {
- if (measureBuilder_ == null) {
- return java.util.Collections.unmodifiableList(measure_);
- } else {
- return measureBuilder_.getMessageList();
- }
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public int getMeasureCount() {
- if (measureBuilder_ == null) {
- return measure_.size();
- } else {
- return measureBuilder_.getCount();
- }
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Measure getMeasure(int index) {
- if (measureBuilder_ == null) {
- return measure_.get(index);
- } else {
- return measureBuilder_.getMessage(index);
- }
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public Builder setMeasure(
- int index, org.sonar.batch.protocol.output.BatchReport.Measure value) {
- if (measureBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensureMeasureIsMutable();
- measure_.set(index, value);
- onChanged();
- } else {
- measureBuilder_.setMessage(index, value);
- }
- return this;
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public Builder setMeasure(
- int index, org.sonar.batch.protocol.output.BatchReport.Measure.Builder builderForValue) {
- if (measureBuilder_ == null) {
- ensureMeasureIsMutable();
- measure_.set(index, builderForValue.build());
- onChanged();
- } else {
- measureBuilder_.setMessage(index, builderForValue.build());
- }
- return this;
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public Builder addMeasure(org.sonar.batch.protocol.output.BatchReport.Measure value) {
- if (measureBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensureMeasureIsMutable();
- measure_.add(value);
- onChanged();
- } else {
- measureBuilder_.addMessage(value);
- }
- return this;
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public Builder addMeasure(
- int index, org.sonar.batch.protocol.output.BatchReport.Measure value) {
- if (measureBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensureMeasureIsMutable();
- measure_.add(index, value);
- onChanged();
- } else {
- measureBuilder_.addMessage(index, value);
- }
- return this;
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public Builder addMeasure(
- org.sonar.batch.protocol.output.BatchReport.Measure.Builder builderForValue) {
- if (measureBuilder_ == null) {
- ensureMeasureIsMutable();
- measure_.add(builderForValue.build());
- onChanged();
- } else {
- measureBuilder_.addMessage(builderForValue.build());
- }
- return this;
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public Builder addMeasure(
- int index, org.sonar.batch.protocol.output.BatchReport.Measure.Builder builderForValue) {
- if (measureBuilder_ == null) {
- ensureMeasureIsMutable();
- measure_.add(index, builderForValue.build());
- onChanged();
- } else {
- measureBuilder_.addMessage(index, builderForValue.build());
- }
- return this;
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public Builder addAllMeasure(
- java.lang.Iterable<? extends org.sonar.batch.protocol.output.BatchReport.Measure> values) {
- if (measureBuilder_ == null) {
- ensureMeasureIsMutable();
- com.google.protobuf.AbstractMessageLite.Builder.addAll(
- values, measure_);
- onChanged();
- } else {
- measureBuilder_.addAllMessages(values);
- }
- return this;
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public Builder clearMeasure() {
- if (measureBuilder_ == null) {
- measure_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000002);
- onChanged();
- } else {
- measureBuilder_.clear();
- }
- return this;
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public Builder removeMeasure(int index) {
- if (measureBuilder_ == null) {
- ensureMeasureIsMutable();
- measure_.remove(index);
- onChanged();
- } else {
- measureBuilder_.remove(index);
- }
- return this;
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Measure.Builder getMeasureBuilder(
- int index) {
- return getMeasureFieldBuilder().getBuilder(index);
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.MeasureOrBuilder getMeasureOrBuilder(
- int index) {
- if (measureBuilder_ == null) {
- return measure_.get(index); } else {
- return measureBuilder_.getMessageOrBuilder(index);
- }
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.MeasureOrBuilder>
- getMeasureOrBuilderList() {
- if (measureBuilder_ != null) {
- return measureBuilder_.getMessageOrBuilderList();
- } else {
- return java.util.Collections.unmodifiableList(measure_);
- }
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Measure.Builder addMeasureBuilder() {
- return getMeasureFieldBuilder().addBuilder(
- org.sonar.batch.protocol.output.BatchReport.Measure.getDefaultInstance());
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Measure.Builder addMeasureBuilder(
- int index) {
- return getMeasureFieldBuilder().addBuilder(
- index, org.sonar.batch.protocol.output.BatchReport.Measure.getDefaultInstance());
- }
- /**
- * <code>repeated .Measure measure = 2;</code>
- */
- public java.util.List<org.sonar.batch.protocol.output.BatchReport.Measure.Builder>
- getMeasureBuilderList() {
- return getMeasureFieldBuilder().getBuilderList();
- }
- private com.google.protobuf.RepeatedFieldBuilder<
- org.sonar.batch.protocol.output.BatchReport.Measure, org.sonar.batch.protocol.output.BatchReport.Measure.Builder, org.sonar.batch.protocol.output.BatchReport.MeasureOrBuilder>
- getMeasureFieldBuilder() {
- if (measureBuilder_ == null) {
- measureBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
- org.sonar.batch.protocol.output.BatchReport.Measure, org.sonar.batch.protocol.output.BatchReport.Measure.Builder, org.sonar.batch.protocol.output.BatchReport.MeasureOrBuilder>(
- measure_,
- ((bitField0_ & 0x00000002) == 0x00000002),
- getParentForChildren(),
- isClean());
- measure_ = null;
- }
- return measureBuilder_;
- }
-
- // @@protoc_insertion_point(builder_scope:Measures)
- }
-
- static {
- defaultInstance = new Measures(true);
- defaultInstance.initFields();
- }
-
- // @@protoc_insertion_point(class_scope:Measures)
- }
-
public interface IssueOrBuilder extends
// @@protoc_insertion_point(interface_extends:Issue)
com.google.protobuf.MessageOrBuilder {
@@ -7863,771 +8534,6 @@ public final class BatchReport {
// @@protoc_insertion_point(class_scope:Issue)
}
- public interface IssuesOrBuilder extends
- // @@protoc_insertion_point(interface_extends:Issues)
- com.google.protobuf.MessageOrBuilder {
-
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- boolean hasComponentRef();
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- int getComponentRef();
-
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- java.util.List<org.sonar.batch.protocol.output.BatchReport.Issue>
- getIssueList();
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- org.sonar.batch.protocol.output.BatchReport.Issue getIssue(int index);
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- int getIssueCount();
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.IssueOrBuilder>
- getIssueOrBuilderList();
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- org.sonar.batch.protocol.output.BatchReport.IssueOrBuilder getIssueOrBuilder(
- int index);
- }
- /**
- * Protobuf type {@code Issues}
- *
- * <pre>
- * TODO to be removed. It prevents streaming
- * </pre>
- */
- public static final class Issues extends
- com.google.protobuf.GeneratedMessage implements
- // @@protoc_insertion_point(message_implements:Issues)
- IssuesOrBuilder {
- // Use Issues.newBuilder() to construct.
- private Issues(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
- super(builder);
- this.unknownFields = builder.getUnknownFields();
- }
- private Issues(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
-
- private static final Issues defaultInstance;
- public static Issues getDefaultInstance() {
- return defaultInstance;
- }
-
- public Issues getDefaultInstanceForType() {
- return defaultInstance;
- }
-
- private final com.google.protobuf.UnknownFieldSet unknownFields;
- @java.lang.Override
- public final com.google.protobuf.UnknownFieldSet
- getUnknownFields() {
- return this.unknownFields;
- }
- private Issues(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- initFields();
- int mutable_bitField0_ = 0;
- com.google.protobuf.UnknownFieldSet.Builder unknownFields =
- com.google.protobuf.UnknownFieldSet.newBuilder();
- try {
- boolean done = false;
- while (!done) {
- int tag = input.readTag();
- switch (tag) {
- case 0:
- done = true;
- break;
- default: {
- if (!parseUnknownField(input, unknownFields,
- extensionRegistry, tag)) {
- done = true;
- }
- break;
- }
- case 8: {
- bitField0_ |= 0x00000001;
- componentRef_ = input.readInt32();
- break;
- }
- case 18: {
- if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
- issue_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Issue>();
- mutable_bitField0_ |= 0x00000002;
- }
- issue_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.Issue.PARSER, extensionRegistry));
- break;
- }
- }
- }
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- throw e.setUnfinishedMessage(this);
- } catch (java.io.IOException e) {
- throw new com.google.protobuf.InvalidProtocolBufferException(
- e.getMessage()).setUnfinishedMessage(this);
- } finally {
- if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
- issue_ = java.util.Collections.unmodifiableList(issue_);
- }
- this.unknownFields = unknownFields.build();
- makeExtensionsImmutable();
- }
- }
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Issues_descriptor;
- }
-
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Issues_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.sonar.batch.protocol.output.BatchReport.Issues.class, org.sonar.batch.protocol.output.BatchReport.Issues.Builder.class);
- }
-
- public static com.google.protobuf.Parser<Issues> PARSER =
- new com.google.protobuf.AbstractParser<Issues>() {
- public Issues parsePartialFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return new Issues(input, extensionRegistry);
- }
- };
-
- @java.lang.Override
- public com.google.protobuf.Parser<Issues> getParserForType() {
- return PARSER;
- }
-
- private int bitField0_;
- public static final int COMPONENT_REF_FIELD_NUMBER = 1;
- private int componentRef_;
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- public boolean hasComponentRef() {
- return ((bitField0_ & 0x00000001) == 0x00000001);
- }
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- public int getComponentRef() {
- return componentRef_;
- }
-
- public static final int ISSUE_FIELD_NUMBER = 2;
- private java.util.List<org.sonar.batch.protocol.output.BatchReport.Issue> issue_;
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public java.util.List<org.sonar.batch.protocol.output.BatchReport.Issue> getIssueList() {
- return issue_;
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.IssueOrBuilder>
- getIssueOrBuilderList() {
- return issue_;
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public int getIssueCount() {
- return issue_.size();
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Issue getIssue(int index) {
- return issue_.get(index);
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.IssueOrBuilder getIssueOrBuilder(
- int index) {
- return issue_.get(index);
- }
-
- private void initFields() {
- componentRef_ = 0;
- issue_ = java.util.Collections.emptyList();
- }
- private byte memoizedIsInitialized = -1;
- public final boolean isInitialized() {
- byte isInitialized = memoizedIsInitialized;
- if (isInitialized == 1) return true;
- if (isInitialized == 0) return false;
-
- memoizedIsInitialized = 1;
- return true;
- }
-
- public void writeTo(com.google.protobuf.CodedOutputStream output)
- throws java.io.IOException {
- getSerializedSize();
- if (((bitField0_ & 0x00000001) == 0x00000001)) {
- output.writeInt32(1, componentRef_);
- }
- for (int i = 0; i < issue_.size(); i++) {
- output.writeMessage(2, issue_.get(i));
- }
- getUnknownFields().writeTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public int getSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (((bitField0_ & 0x00000001) == 0x00000001)) {
- size += com.google.protobuf.CodedOutputStream
- .computeInt32Size(1, componentRef_);
- }
- for (int i = 0; i < issue_.size(); i++) {
- size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(2, issue_.get(i));
- }
- size += getUnknownFields().getSerializedSize();
- memoizedSerializedSize = size;
- return size;
- }
-
- private static final long serialVersionUID = 0L;
- @java.lang.Override
- protected java.lang.Object writeReplace()
- throws java.io.ObjectStreamException {
- return super.writeReplace();
- }
-
- public static org.sonar.batch.protocol.output.BatchReport.Issues parseFrom(
- com.google.protobuf.ByteString data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Issues parseFrom(
- com.google.protobuf.ByteString data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Issues parseFrom(byte[] data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Issues parseFrom(
- byte[] data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Issues parseFrom(java.io.InputStream input)
- throws java.io.IOException {
- return PARSER.parseFrom(input);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Issues parseFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseFrom(input, extensionRegistry);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Issues parseDelimitedFrom(java.io.InputStream input)
- throws java.io.IOException {
- return PARSER.parseDelimitedFrom(input);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Issues parseDelimitedFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseDelimitedFrom(input, extensionRegistry);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Issues parseFrom(
- com.google.protobuf.CodedInputStream input)
- throws java.io.IOException {
- return PARSER.parseFrom(input);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Issues parseFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseFrom(input, extensionRegistry);
- }
-
- public static Builder newBuilder() { return Builder.create(); }
- public Builder newBuilderForType() { return newBuilder(); }
- public static Builder newBuilder(org.sonar.batch.protocol.output.BatchReport.Issues prototype) {
- return newBuilder().mergeFrom(prototype);
- }
- public Builder toBuilder() { return newBuilder(this); }
-
- @java.lang.Override
- protected Builder newBuilderForType(
- com.google.protobuf.GeneratedMessage.BuilderParent parent) {
- Builder builder = new Builder(parent);
- return builder;
- }
- /**
- * Protobuf type {@code Issues}
- *
- * <pre>
- * TODO to be removed. It prevents streaming
- * </pre>
- */
- public static final class Builder extends
- com.google.protobuf.GeneratedMessage.Builder<Builder> implements
- // @@protoc_insertion_point(builder_implements:Issues)
- org.sonar.batch.protocol.output.BatchReport.IssuesOrBuilder {
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Issues_descriptor;
- }
-
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Issues_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.sonar.batch.protocol.output.BatchReport.Issues.class, org.sonar.batch.protocol.output.BatchReport.Issues.Builder.class);
- }
-
- // Construct using org.sonar.batch.protocol.output.BatchReport.Issues.newBuilder()
- private Builder() {
- maybeForceBuilderInitialization();
- }
-
- private Builder(
- com.google.protobuf.GeneratedMessage.BuilderParent parent) {
- super(parent);
- maybeForceBuilderInitialization();
- }
- private void maybeForceBuilderInitialization() {
- if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
- getIssueFieldBuilder();
- }
- }
- private static Builder create() {
- return new Builder();
- }
-
- public Builder clear() {
- super.clear();
- componentRef_ = 0;
- bitField0_ = (bitField0_ & ~0x00000001);
- if (issueBuilder_ == null) {
- issue_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000002);
- } else {
- issueBuilder_.clear();
- }
- return this;
- }
-
- public Builder clone() {
- return create().mergeFrom(buildPartial());
- }
-
- public com.google.protobuf.Descriptors.Descriptor
- getDescriptorForType() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Issues_descriptor;
- }
-
- public org.sonar.batch.protocol.output.BatchReport.Issues getDefaultInstanceForType() {
- return org.sonar.batch.protocol.output.BatchReport.Issues.getDefaultInstance();
- }
-
- public org.sonar.batch.protocol.output.BatchReport.Issues build() {
- org.sonar.batch.protocol.output.BatchReport.Issues result = buildPartial();
- if (!result.isInitialized()) {
- throw newUninitializedMessageException(result);
- }
- return result;
- }
-
- public org.sonar.batch.protocol.output.BatchReport.Issues buildPartial() {
- org.sonar.batch.protocol.output.BatchReport.Issues result = new org.sonar.batch.protocol.output.BatchReport.Issues(this);
- int from_bitField0_ = bitField0_;
- int to_bitField0_ = 0;
- if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
- to_bitField0_ |= 0x00000001;
- }
- result.componentRef_ = componentRef_;
- if (issueBuilder_ == null) {
- if (((bitField0_ & 0x00000002) == 0x00000002)) {
- issue_ = java.util.Collections.unmodifiableList(issue_);
- bitField0_ = (bitField0_ & ~0x00000002);
- }
- result.issue_ = issue_;
- } else {
- result.issue_ = issueBuilder_.build();
- }
- result.bitField0_ = to_bitField0_;
- onBuilt();
- return result;
- }
-
- public Builder mergeFrom(com.google.protobuf.Message other) {
- if (other instanceof org.sonar.batch.protocol.output.BatchReport.Issues) {
- return mergeFrom((org.sonar.batch.protocol.output.BatchReport.Issues)other);
- } else {
- super.mergeFrom(other);
- return this;
- }
- }
-
- public Builder mergeFrom(org.sonar.batch.protocol.output.BatchReport.Issues other) {
- if (other == org.sonar.batch.protocol.output.BatchReport.Issues.getDefaultInstance()) return this;
- if (other.hasComponentRef()) {
- setComponentRef(other.getComponentRef());
- }
- if (issueBuilder_ == null) {
- if (!other.issue_.isEmpty()) {
- if (issue_.isEmpty()) {
- issue_ = other.issue_;
- bitField0_ = (bitField0_ & ~0x00000002);
- } else {
- ensureIssueIsMutable();
- issue_.addAll(other.issue_);
- }
- onChanged();
- }
- } else {
- if (!other.issue_.isEmpty()) {
- if (issueBuilder_.isEmpty()) {
- issueBuilder_.dispose();
- issueBuilder_ = null;
- issue_ = other.issue_;
- bitField0_ = (bitField0_ & ~0x00000002);
- issueBuilder_ =
- com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
- getIssueFieldBuilder() : null;
- } else {
- issueBuilder_.addAllMessages(other.issue_);
- }
- }
- }
- this.mergeUnknownFields(other.getUnknownFields());
- return this;
- }
-
- public final boolean isInitialized() {
- return true;
- }
-
- public Builder mergeFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- org.sonar.batch.protocol.output.BatchReport.Issues parsedMessage = null;
- try {
- parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- parsedMessage = (org.sonar.batch.protocol.output.BatchReport.Issues) e.getUnfinishedMessage();
- throw e;
- } finally {
- if (parsedMessage != null) {
- mergeFrom(parsedMessage);
- }
- }
- return this;
- }
- private int bitField0_;
-
- private int componentRef_ ;
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- public boolean hasComponentRef() {
- return ((bitField0_ & 0x00000001) == 0x00000001);
- }
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- public int getComponentRef() {
- return componentRef_;
- }
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- public Builder setComponentRef(int value) {
- bitField0_ |= 0x00000001;
- componentRef_ = value;
- onChanged();
- return this;
- }
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- public Builder clearComponentRef() {
- bitField0_ = (bitField0_ & ~0x00000001);
- componentRef_ = 0;
- onChanged();
- return this;
- }
-
- private java.util.List<org.sonar.batch.protocol.output.BatchReport.Issue> issue_ =
- java.util.Collections.emptyList();
- private void ensureIssueIsMutable() {
- if (!((bitField0_ & 0x00000002) == 0x00000002)) {
- issue_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Issue>(issue_);
- bitField0_ |= 0x00000002;
- }
- }
-
- private com.google.protobuf.RepeatedFieldBuilder<
- org.sonar.batch.protocol.output.BatchReport.Issue, org.sonar.batch.protocol.output.BatchReport.Issue.Builder, org.sonar.batch.protocol.output.BatchReport.IssueOrBuilder> issueBuilder_;
-
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public java.util.List<org.sonar.batch.protocol.output.BatchReport.Issue> getIssueList() {
- if (issueBuilder_ == null) {
- return java.util.Collections.unmodifiableList(issue_);
- } else {
- return issueBuilder_.getMessageList();
- }
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public int getIssueCount() {
- if (issueBuilder_ == null) {
- return issue_.size();
- } else {
- return issueBuilder_.getCount();
- }
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Issue getIssue(int index) {
- if (issueBuilder_ == null) {
- return issue_.get(index);
- } else {
- return issueBuilder_.getMessage(index);
- }
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public Builder setIssue(
- int index, org.sonar.batch.protocol.output.BatchReport.Issue value) {
- if (issueBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensureIssueIsMutable();
- issue_.set(index, value);
- onChanged();
- } else {
- issueBuilder_.setMessage(index, value);
- }
- return this;
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public Builder setIssue(
- int index, org.sonar.batch.protocol.output.BatchReport.Issue.Builder builderForValue) {
- if (issueBuilder_ == null) {
- ensureIssueIsMutable();
- issue_.set(index, builderForValue.build());
- onChanged();
- } else {
- issueBuilder_.setMessage(index, builderForValue.build());
- }
- return this;
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public Builder addIssue(org.sonar.batch.protocol.output.BatchReport.Issue value) {
- if (issueBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensureIssueIsMutable();
- issue_.add(value);
- onChanged();
- } else {
- issueBuilder_.addMessage(value);
- }
- return this;
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public Builder addIssue(
- int index, org.sonar.batch.protocol.output.BatchReport.Issue value) {
- if (issueBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensureIssueIsMutable();
- issue_.add(index, value);
- onChanged();
- } else {
- issueBuilder_.addMessage(index, value);
- }
- return this;
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public Builder addIssue(
- org.sonar.batch.protocol.output.BatchReport.Issue.Builder builderForValue) {
- if (issueBuilder_ == null) {
- ensureIssueIsMutable();
- issue_.add(builderForValue.build());
- onChanged();
- } else {
- issueBuilder_.addMessage(builderForValue.build());
- }
- return this;
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public Builder addIssue(
- int index, org.sonar.batch.protocol.output.BatchReport.Issue.Builder builderForValue) {
- if (issueBuilder_ == null) {
- ensureIssueIsMutable();
- issue_.add(index, builderForValue.build());
- onChanged();
- } else {
- issueBuilder_.addMessage(index, builderForValue.build());
- }
- return this;
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public Builder addAllIssue(
- java.lang.Iterable<? extends org.sonar.batch.protocol.output.BatchReport.Issue> values) {
- if (issueBuilder_ == null) {
- ensureIssueIsMutable();
- com.google.protobuf.AbstractMessageLite.Builder.addAll(
- values, issue_);
- onChanged();
- } else {
- issueBuilder_.addAllMessages(values);
- }
- return this;
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public Builder clearIssue() {
- if (issueBuilder_ == null) {
- issue_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000002);
- onChanged();
- } else {
- issueBuilder_.clear();
- }
- return this;
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public Builder removeIssue(int index) {
- if (issueBuilder_ == null) {
- ensureIssueIsMutable();
- issue_.remove(index);
- onChanged();
- } else {
- issueBuilder_.remove(index);
- }
- return this;
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Issue.Builder getIssueBuilder(
- int index) {
- return getIssueFieldBuilder().getBuilder(index);
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.IssueOrBuilder getIssueOrBuilder(
- int index) {
- if (issueBuilder_ == null) {
- return issue_.get(index); } else {
- return issueBuilder_.getMessageOrBuilder(index);
- }
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.IssueOrBuilder>
- getIssueOrBuilderList() {
- if (issueBuilder_ != null) {
- return issueBuilder_.getMessageOrBuilderList();
- } else {
- return java.util.Collections.unmodifiableList(issue_);
- }
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Issue.Builder addIssueBuilder() {
- return getIssueFieldBuilder().addBuilder(
- org.sonar.batch.protocol.output.BatchReport.Issue.getDefaultInstance());
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Issue.Builder addIssueBuilder(
- int index) {
- return getIssueFieldBuilder().addBuilder(
- index, org.sonar.batch.protocol.output.BatchReport.Issue.getDefaultInstance());
- }
- /**
- * <code>repeated .Issue issue = 2;</code>
- */
- public java.util.List<org.sonar.batch.protocol.output.BatchReport.Issue.Builder>
- getIssueBuilderList() {
- return getIssueFieldBuilder().getBuilderList();
- }
- private com.google.protobuf.RepeatedFieldBuilder<
- org.sonar.batch.protocol.output.BatchReport.Issue, org.sonar.batch.protocol.output.BatchReport.Issue.Builder, org.sonar.batch.protocol.output.BatchReport.IssueOrBuilder>
- getIssueFieldBuilder() {
- if (issueBuilder_ == null) {
- issueBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
- org.sonar.batch.protocol.output.BatchReport.Issue, org.sonar.batch.protocol.output.BatchReport.Issue.Builder, org.sonar.batch.protocol.output.BatchReport.IssueOrBuilder>(
- issue_,
- ((bitField0_ & 0x00000002) == 0x00000002),
- getParentForChildren(),
- isClean());
- issue_ = null;
- }
- return issueBuilder_;
- }
-
- // @@protoc_insertion_point(builder_scope:Issues)
- }
-
- static {
- defaultInstance = new Issues(true);
- defaultInstance.initFields();
- }
-
- // @@protoc_insertion_point(class_scope:Issues)
- }
-
public interface ChangesetsOrBuilder extends
// @@protoc_insertion_point(interface_extends:Changesets)
com.google.protobuf.MessageOrBuilder {
@@ -12064,763 +11970,6 @@ public final class BatchReport {
// @@protoc_insertion_point(class_scope:Duplication)
}
- public interface DuplicationsOrBuilder extends
- // @@protoc_insertion_point(interface_extends:Duplications)
- com.google.protobuf.MessageOrBuilder {
-
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- boolean hasComponentRef();
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- int getComponentRef();
-
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- java.util.List<org.sonar.batch.protocol.output.BatchReport.Duplication>
- getDuplicationList();
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- org.sonar.batch.protocol.output.BatchReport.Duplication getDuplication(int index);
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- int getDuplicationCount();
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.DuplicationOrBuilder>
- getDuplicationOrBuilderList();
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- org.sonar.batch.protocol.output.BatchReport.DuplicationOrBuilder getDuplicationOrBuilder(
- int index);
- }
- /**
- * Protobuf type {@code Duplications}
- */
- public static final class Duplications extends
- com.google.protobuf.GeneratedMessage implements
- // @@protoc_insertion_point(message_implements:Duplications)
- DuplicationsOrBuilder {
- // Use Duplications.newBuilder() to construct.
- private Duplications(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
- super(builder);
- this.unknownFields = builder.getUnknownFields();
- }
- private Duplications(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
-
- private static final Duplications defaultInstance;
- public static Duplications getDefaultInstance() {
- return defaultInstance;
- }
-
- public Duplications getDefaultInstanceForType() {
- return defaultInstance;
- }
-
- private final com.google.protobuf.UnknownFieldSet unknownFields;
- @java.lang.Override
- public final com.google.protobuf.UnknownFieldSet
- getUnknownFields() {
- return this.unknownFields;
- }
- private Duplications(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- initFields();
- int mutable_bitField0_ = 0;
- com.google.protobuf.UnknownFieldSet.Builder unknownFields =
- com.google.protobuf.UnknownFieldSet.newBuilder();
- try {
- boolean done = false;
- while (!done) {
- int tag = input.readTag();
- switch (tag) {
- case 0:
- done = true;
- break;
- default: {
- if (!parseUnknownField(input, unknownFields,
- extensionRegistry, tag)) {
- done = true;
- }
- break;
- }
- case 8: {
- bitField0_ |= 0x00000001;
- componentRef_ = input.readInt32();
- break;
- }
- case 18: {
- if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
- duplication_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Duplication>();
- mutable_bitField0_ |= 0x00000002;
- }
- duplication_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.Duplication.PARSER, extensionRegistry));
- break;
- }
- }
- }
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- throw e.setUnfinishedMessage(this);
- } catch (java.io.IOException e) {
- throw new com.google.protobuf.InvalidProtocolBufferException(
- e.getMessage()).setUnfinishedMessage(this);
- } finally {
- if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
- duplication_ = java.util.Collections.unmodifiableList(duplication_);
- }
- this.unknownFields = unknownFields.build();
- makeExtensionsImmutable();
- }
- }
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Duplications_descriptor;
- }
-
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Duplications_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.sonar.batch.protocol.output.BatchReport.Duplications.class, org.sonar.batch.protocol.output.BatchReport.Duplications.Builder.class);
- }
-
- public static com.google.protobuf.Parser<Duplications> PARSER =
- new com.google.protobuf.AbstractParser<Duplications>() {
- public Duplications parsePartialFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return new Duplications(input, extensionRegistry);
- }
- };
-
- @java.lang.Override
- public com.google.protobuf.Parser<Duplications> getParserForType() {
- return PARSER;
- }
-
- private int bitField0_;
- public static final int COMPONENT_REF_FIELD_NUMBER = 1;
- private int componentRef_;
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- public boolean hasComponentRef() {
- return ((bitField0_ & 0x00000001) == 0x00000001);
- }
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- public int getComponentRef() {
- return componentRef_;
- }
-
- public static final int DUPLICATION_FIELD_NUMBER = 2;
- private java.util.List<org.sonar.batch.protocol.output.BatchReport.Duplication> duplication_;
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public java.util.List<org.sonar.batch.protocol.output.BatchReport.Duplication> getDuplicationList() {
- return duplication_;
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.DuplicationOrBuilder>
- getDuplicationOrBuilderList() {
- return duplication_;
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public int getDuplicationCount() {
- return duplication_.size();
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Duplication getDuplication(int index) {
- return duplication_.get(index);
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.DuplicationOrBuilder getDuplicationOrBuilder(
- int index) {
- return duplication_.get(index);
- }
-
- private void initFields() {
- componentRef_ = 0;
- duplication_ = java.util.Collections.emptyList();
- }
- private byte memoizedIsInitialized = -1;
- public final boolean isInitialized() {
- byte isInitialized = memoizedIsInitialized;
- if (isInitialized == 1) return true;
- if (isInitialized == 0) return false;
-
- memoizedIsInitialized = 1;
- return true;
- }
-
- public void writeTo(com.google.protobuf.CodedOutputStream output)
- throws java.io.IOException {
- getSerializedSize();
- if (((bitField0_ & 0x00000001) == 0x00000001)) {
- output.writeInt32(1, componentRef_);
- }
- for (int i = 0; i < duplication_.size(); i++) {
- output.writeMessage(2, duplication_.get(i));
- }
- getUnknownFields().writeTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public int getSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (((bitField0_ & 0x00000001) == 0x00000001)) {
- size += com.google.protobuf.CodedOutputStream
- .computeInt32Size(1, componentRef_);
- }
- for (int i = 0; i < duplication_.size(); i++) {
- size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(2, duplication_.get(i));
- }
- size += getUnknownFields().getSerializedSize();
- memoizedSerializedSize = size;
- return size;
- }
-
- private static final long serialVersionUID = 0L;
- @java.lang.Override
- protected java.lang.Object writeReplace()
- throws java.io.ObjectStreamException {
- return super.writeReplace();
- }
-
- public static org.sonar.batch.protocol.output.BatchReport.Duplications parseFrom(
- com.google.protobuf.ByteString data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Duplications parseFrom(
- com.google.protobuf.ByteString data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Duplications parseFrom(byte[] data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Duplications parseFrom(
- byte[] data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Duplications parseFrom(java.io.InputStream input)
- throws java.io.IOException {
- return PARSER.parseFrom(input);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Duplications parseFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseFrom(input, extensionRegistry);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Duplications parseDelimitedFrom(java.io.InputStream input)
- throws java.io.IOException {
- return PARSER.parseDelimitedFrom(input);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Duplications parseDelimitedFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseDelimitedFrom(input, extensionRegistry);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Duplications parseFrom(
- com.google.protobuf.CodedInputStream input)
- throws java.io.IOException {
- return PARSER.parseFrom(input);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Duplications parseFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseFrom(input, extensionRegistry);
- }
-
- public static Builder newBuilder() { return Builder.create(); }
- public Builder newBuilderForType() { return newBuilder(); }
- public static Builder newBuilder(org.sonar.batch.protocol.output.BatchReport.Duplications prototype) {
- return newBuilder().mergeFrom(prototype);
- }
- public Builder toBuilder() { return newBuilder(this); }
-
- @java.lang.Override
- protected Builder newBuilderForType(
- com.google.protobuf.GeneratedMessage.BuilderParent parent) {
- Builder builder = new Builder(parent);
- return builder;
- }
- /**
- * Protobuf type {@code Duplications}
- */
- public static final class Builder extends
- com.google.protobuf.GeneratedMessage.Builder<Builder> implements
- // @@protoc_insertion_point(builder_implements:Duplications)
- org.sonar.batch.protocol.output.BatchReport.DuplicationsOrBuilder {
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Duplications_descriptor;
- }
-
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Duplications_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.sonar.batch.protocol.output.BatchReport.Duplications.class, org.sonar.batch.protocol.output.BatchReport.Duplications.Builder.class);
- }
-
- // Construct using org.sonar.batch.protocol.output.BatchReport.Duplications.newBuilder()
- private Builder() {
- maybeForceBuilderInitialization();
- }
-
- private Builder(
- com.google.protobuf.GeneratedMessage.BuilderParent parent) {
- super(parent);
- maybeForceBuilderInitialization();
- }
- private void maybeForceBuilderInitialization() {
- if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
- getDuplicationFieldBuilder();
- }
- }
- private static Builder create() {
- return new Builder();
- }
-
- public Builder clear() {
- super.clear();
- componentRef_ = 0;
- bitField0_ = (bitField0_ & ~0x00000001);
- if (duplicationBuilder_ == null) {
- duplication_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000002);
- } else {
- duplicationBuilder_.clear();
- }
- return this;
- }
-
- public Builder clone() {
- return create().mergeFrom(buildPartial());
- }
-
- public com.google.protobuf.Descriptors.Descriptor
- getDescriptorForType() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Duplications_descriptor;
- }
-
- public org.sonar.batch.protocol.output.BatchReport.Duplications getDefaultInstanceForType() {
- return org.sonar.batch.protocol.output.BatchReport.Duplications.getDefaultInstance();
- }
-
- public org.sonar.batch.protocol.output.BatchReport.Duplications build() {
- org.sonar.batch.protocol.output.BatchReport.Duplications result = buildPartial();
- if (!result.isInitialized()) {
- throw newUninitializedMessageException(result);
- }
- return result;
- }
-
- public org.sonar.batch.protocol.output.BatchReport.Duplications buildPartial() {
- org.sonar.batch.protocol.output.BatchReport.Duplications result = new org.sonar.batch.protocol.output.BatchReport.Duplications(this);
- int from_bitField0_ = bitField0_;
- int to_bitField0_ = 0;
- if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
- to_bitField0_ |= 0x00000001;
- }
- result.componentRef_ = componentRef_;
- if (duplicationBuilder_ == null) {
- if (((bitField0_ & 0x00000002) == 0x00000002)) {
- duplication_ = java.util.Collections.unmodifiableList(duplication_);
- bitField0_ = (bitField0_ & ~0x00000002);
- }
- result.duplication_ = duplication_;
- } else {
- result.duplication_ = duplicationBuilder_.build();
- }
- result.bitField0_ = to_bitField0_;
- onBuilt();
- return result;
- }
-
- public Builder mergeFrom(com.google.protobuf.Message other) {
- if (other instanceof org.sonar.batch.protocol.output.BatchReport.Duplications) {
- return mergeFrom((org.sonar.batch.protocol.output.BatchReport.Duplications)other);
- } else {
- super.mergeFrom(other);
- return this;
- }
- }
-
- public Builder mergeFrom(org.sonar.batch.protocol.output.BatchReport.Duplications other) {
- if (other == org.sonar.batch.protocol.output.BatchReport.Duplications.getDefaultInstance()) return this;
- if (other.hasComponentRef()) {
- setComponentRef(other.getComponentRef());
- }
- if (duplicationBuilder_ == null) {
- if (!other.duplication_.isEmpty()) {
- if (duplication_.isEmpty()) {
- duplication_ = other.duplication_;
- bitField0_ = (bitField0_ & ~0x00000002);
- } else {
- ensureDuplicationIsMutable();
- duplication_.addAll(other.duplication_);
- }
- onChanged();
- }
- } else {
- if (!other.duplication_.isEmpty()) {
- if (duplicationBuilder_.isEmpty()) {
- duplicationBuilder_.dispose();
- duplicationBuilder_ = null;
- duplication_ = other.duplication_;
- bitField0_ = (bitField0_ & ~0x00000002);
- duplicationBuilder_ =
- com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
- getDuplicationFieldBuilder() : null;
- } else {
- duplicationBuilder_.addAllMessages(other.duplication_);
- }
- }
- }
- this.mergeUnknownFields(other.getUnknownFields());
- return this;
- }
-
- public final boolean isInitialized() {
- return true;
- }
-
- public Builder mergeFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- org.sonar.batch.protocol.output.BatchReport.Duplications parsedMessage = null;
- try {
- parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- parsedMessage = (org.sonar.batch.protocol.output.BatchReport.Duplications) e.getUnfinishedMessage();
- throw e;
- } finally {
- if (parsedMessage != null) {
- mergeFrom(parsedMessage);
- }
- }
- return this;
- }
- private int bitField0_;
-
- private int componentRef_ ;
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- public boolean hasComponentRef() {
- return ((bitField0_ & 0x00000001) == 0x00000001);
- }
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- public int getComponentRef() {
- return componentRef_;
- }
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- public Builder setComponentRef(int value) {
- bitField0_ |= 0x00000001;
- componentRef_ = value;
- onChanged();
- return this;
- }
- /**
- * <code>optional int32 component_ref = 1;</code>
- */
- public Builder clearComponentRef() {
- bitField0_ = (bitField0_ & ~0x00000001);
- componentRef_ = 0;
- onChanged();
- return this;
- }
-
- private java.util.List<org.sonar.batch.protocol.output.BatchReport.Duplication> duplication_ =
- java.util.Collections.emptyList();
- private void ensureDuplicationIsMutable() {
- if (!((bitField0_ & 0x00000002) == 0x00000002)) {
- duplication_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Duplication>(duplication_);
- bitField0_ |= 0x00000002;
- }
- }
-
- private com.google.protobuf.RepeatedFieldBuilder<
- org.sonar.batch.protocol.output.BatchReport.Duplication, org.sonar.batch.protocol.output.BatchReport.Duplication.Builder, org.sonar.batch.protocol.output.BatchReport.DuplicationOrBuilder> duplicationBuilder_;
-
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public java.util.List<org.sonar.batch.protocol.output.BatchReport.Duplication> getDuplicationList() {
- if (duplicationBuilder_ == null) {
- return java.util.Collections.unmodifiableList(duplication_);
- } else {
- return duplicationBuilder_.getMessageList();
- }
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public int getDuplicationCount() {
- if (duplicationBuilder_ == null) {
- return duplication_.size();
- } else {
- return duplicationBuilder_.getCount();
- }
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Duplication getDuplication(int index) {
- if (duplicationBuilder_ == null) {
- return duplication_.get(index);
- } else {
- return duplicationBuilder_.getMessage(index);
- }
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public Builder setDuplication(
- int index, org.sonar.batch.protocol.output.BatchReport.Duplication value) {
- if (duplicationBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensureDuplicationIsMutable();
- duplication_.set(index, value);
- onChanged();
- } else {
- duplicationBuilder_.setMessage(index, value);
- }
- return this;
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public Builder setDuplication(
- int index, org.sonar.batch.protocol.output.BatchReport.Duplication.Builder builderForValue) {
- if (duplicationBuilder_ == null) {
- ensureDuplicationIsMutable();
- duplication_.set(index, builderForValue.build());
- onChanged();
- } else {
- duplicationBuilder_.setMessage(index, builderForValue.build());
- }
- return this;
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public Builder addDuplication(org.sonar.batch.protocol.output.BatchReport.Duplication value) {
- if (duplicationBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensureDuplicationIsMutable();
- duplication_.add(value);
- onChanged();
- } else {
- duplicationBuilder_.addMessage(value);
- }
- return this;
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public Builder addDuplication(
- int index, org.sonar.batch.protocol.output.BatchReport.Duplication value) {
- if (duplicationBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensureDuplicationIsMutable();
- duplication_.add(index, value);
- onChanged();
- } else {
- duplicationBuilder_.addMessage(index, value);
- }
- return this;
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public Builder addDuplication(
- org.sonar.batch.protocol.output.BatchReport.Duplication.Builder builderForValue) {
- if (duplicationBuilder_ == null) {
- ensureDuplicationIsMutable();
- duplication_.add(builderForValue.build());
- onChanged();
- } else {
- duplicationBuilder_.addMessage(builderForValue.build());
- }
- return this;
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public Builder addDuplication(
- int index, org.sonar.batch.protocol.output.BatchReport.Duplication.Builder builderForValue) {
- if (duplicationBuilder_ == null) {
- ensureDuplicationIsMutable();
- duplication_.add(index, builderForValue.build());
- onChanged();
- } else {
- duplicationBuilder_.addMessage(index, builderForValue.build());
- }
- return this;
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public Builder addAllDuplication(
- java.lang.Iterable<? extends org.sonar.batch.protocol.output.BatchReport.Duplication> values) {
- if (duplicationBuilder_ == null) {
- ensureDuplicationIsMutable();
- com.google.protobuf.AbstractMessageLite.Builder.addAll(
- values, duplication_);
- onChanged();
- } else {
- duplicationBuilder_.addAllMessages(values);
- }
- return this;
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public Builder clearDuplication() {
- if (duplicationBuilder_ == null) {
- duplication_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000002);
- onChanged();
- } else {
- duplicationBuilder_.clear();
- }
- return this;
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public Builder removeDuplication(int index) {
- if (duplicationBuilder_ == null) {
- ensureDuplicationIsMutable();
- duplication_.remove(index);
- onChanged();
- } else {
- duplicationBuilder_.remove(index);
- }
- return this;
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Duplication.Builder getDuplicationBuilder(
- int index) {
- return getDuplicationFieldBuilder().getBuilder(index);
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.DuplicationOrBuilder getDuplicationOrBuilder(
- int index) {
- if (duplicationBuilder_ == null) {
- return duplication_.get(index); } else {
- return duplicationBuilder_.getMessageOrBuilder(index);
- }
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.DuplicationOrBuilder>
- getDuplicationOrBuilderList() {
- if (duplicationBuilder_ != null) {
- return duplicationBuilder_.getMessageOrBuilderList();
- } else {
- return java.util.Collections.unmodifiableList(duplication_);
- }
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Duplication.Builder addDuplicationBuilder() {
- return getDuplicationFieldBuilder().addBuilder(
- org.sonar.batch.protocol.output.BatchReport.Duplication.getDefaultInstance());
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Duplication.Builder addDuplicationBuilder(
- int index) {
- return getDuplicationFieldBuilder().addBuilder(
- index, org.sonar.batch.protocol.output.BatchReport.Duplication.getDefaultInstance());
- }
- /**
- * <code>repeated .Duplication duplication = 2;</code>
- */
- public java.util.List<org.sonar.batch.protocol.output.BatchReport.Duplication.Builder>
- getDuplicationBuilderList() {
- return getDuplicationFieldBuilder().getBuilderList();
- }
- private com.google.protobuf.RepeatedFieldBuilder<
- org.sonar.batch.protocol.output.BatchReport.Duplication, org.sonar.batch.protocol.output.BatchReport.Duplication.Builder, org.sonar.batch.protocol.output.BatchReport.DuplicationOrBuilder>
- getDuplicationFieldBuilder() {
- if (duplicationBuilder_ == null) {
- duplicationBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
- org.sonar.batch.protocol.output.BatchReport.Duplication, org.sonar.batch.protocol.output.BatchReport.Duplication.Builder, org.sonar.batch.protocol.output.BatchReport.DuplicationOrBuilder>(
- duplication_,
- ((bitField0_ & 0x00000002) == 0x00000002),
- getParentForChildren(),
- isClean());
- duplication_ = null;
- }
- return duplicationBuilder_;
- }
-
- // @@protoc_insertion_point(builder_scope:Duplications)
- }
-
- static {
- defaultInstance = new Duplications(true);
- defaultInstance.initFields();
- }
-
- // @@protoc_insertion_point(class_scope:Duplications)
- }
-
public interface RangeOrBuilder extends
// @@protoc_insertion_point(interface_extends:Range)
com.google.protobuf.MessageOrBuilder {
@@ -13588,63 +12737,67 @@ public final class BatchReport {
// @@protoc_insertion_point(class_scope:Range)
}
- public interface SymbolsOrBuilder extends
- // @@protoc_insertion_point(interface_extends:Symbols)
+ public interface SymbolOrBuilder extends
+ // @@protoc_insertion_point(interface_extends:Symbol)
com.google.protobuf.MessageOrBuilder {
/**
- * <code>optional int32 file_ref = 1;</code>
+ * <code>optional .Range declaration = 1;</code>
+ */
+ boolean hasDeclaration();
+ /**
+ * <code>optional .Range declaration = 1;</code>
*/
- boolean hasFileRef();
+ org.sonar.batch.protocol.output.BatchReport.Range getDeclaration();
/**
- * <code>optional int32 file_ref = 1;</code>
+ * <code>optional .Range declaration = 1;</code>
*/
- int getFileRef();
+ org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder getDeclarationOrBuilder();
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- java.util.List<org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol>
- getSymbolList();
+ java.util.List<org.sonar.batch.protocol.output.BatchReport.Range>
+ getReferenceList();
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol getSymbol(int index);
+ org.sonar.batch.protocol.output.BatchReport.Range getReference(int index);
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- int getSymbolCount();
+ int getReferenceCount();
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.Symbols.SymbolOrBuilder>
- getSymbolOrBuilderList();
+ java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>
+ getReferenceOrBuilderList();
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- org.sonar.batch.protocol.output.BatchReport.Symbols.SymbolOrBuilder getSymbolOrBuilder(
+ org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder getReferenceOrBuilder(
int index);
}
/**
- * Protobuf type {@code Symbols}
+ * Protobuf type {@code Symbol}
*/
- public static final class Symbols extends
+ public static final class Symbol extends
com.google.protobuf.GeneratedMessage implements
- // @@protoc_insertion_point(message_implements:Symbols)
- SymbolsOrBuilder {
- // Use Symbols.newBuilder() to construct.
- private Symbols(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
+ // @@protoc_insertion_point(message_implements:Symbol)
+ SymbolOrBuilder {
+ // Use Symbol.newBuilder() to construct.
+ private Symbol(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
super(builder);
this.unknownFields = builder.getUnknownFields();
}
- private Symbols(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
+ private Symbol(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
- private static final Symbols defaultInstance;
- public static Symbols getDefaultInstance() {
+ private static final Symbol defaultInstance;
+ public static Symbol getDefaultInstance() {
return defaultInstance;
}
- public Symbols getDefaultInstanceForType() {
+ public Symbol getDefaultInstanceForType() {
return defaultInstance;
}
@@ -13654,7 +12807,7 @@ public final class BatchReport {
getUnknownFields() {
return this.unknownFields;
}
- private Symbols(
+ private Symbol(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
@@ -13677,17 +12830,25 @@ public final class BatchReport {
}
break;
}
- case 8: {
+ case 10: {
+ org.sonar.batch.protocol.output.BatchReport.Range.Builder subBuilder = null;
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ subBuilder = declaration_.toBuilder();
+ }
+ declaration_ = input.readMessage(org.sonar.batch.protocol.output.BatchReport.Range.PARSER, extensionRegistry);
+ if (subBuilder != null) {
+ subBuilder.mergeFrom(declaration_);
+ declaration_ = subBuilder.buildPartial();
+ }
bitField0_ |= 0x00000001;
- fileRef_ = input.readInt32();
break;
}
case 18: {
if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
- symbol_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol>();
+ reference_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Range>();
mutable_bitField0_ |= 0x00000002;
}
- symbol_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.PARSER, extensionRegistry));
+ reference_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.Range.PARSER, extensionRegistry));
break;
}
}
@@ -13699,7 +12860,7 @@ public final class BatchReport {
e.getMessage()).setUnfinishedMessage(this);
} finally {
if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
- symbol_ = java.util.Collections.unmodifiableList(symbol_);
+ reference_ = java.util.Collections.unmodifiableList(reference_);
}
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
@@ -13707,953 +12868,91 @@ public final class BatchReport {
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Symbols_descriptor;
+ return org.sonar.batch.protocol.output.BatchReport.internal_static_Symbol_descriptor;
}
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Symbols_fieldAccessorTable
+ return org.sonar.batch.protocol.output.BatchReport.internal_static_Symbol_fieldAccessorTable
.ensureFieldAccessorsInitialized(
- org.sonar.batch.protocol.output.BatchReport.Symbols.class, org.sonar.batch.protocol.output.BatchReport.Symbols.Builder.class);
+ org.sonar.batch.protocol.output.BatchReport.Symbol.class, org.sonar.batch.protocol.output.BatchReport.Symbol.Builder.class);
}
- public static com.google.protobuf.Parser<Symbols> PARSER =
- new com.google.protobuf.AbstractParser<Symbols>() {
- public Symbols parsePartialFrom(
+ public static com.google.protobuf.Parser<Symbol> PARSER =
+ new com.google.protobuf.AbstractParser<Symbol>() {
+ public Symbol parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
- return new Symbols(input, extensionRegistry);
+ return new Symbol(input, extensionRegistry);
}
};
@java.lang.Override
- public com.google.protobuf.Parser<Symbols> getParserForType() {
+ public com.google.protobuf.Parser<Symbol> getParserForType() {
return PARSER;
}
- public interface SymbolOrBuilder extends
- // @@protoc_insertion_point(interface_extends:Symbols.Symbol)
- com.google.protobuf.MessageOrBuilder {
-
- /**
- * <code>optional .Range declaration = 1;</code>
- */
- boolean hasDeclaration();
- /**
- * <code>optional .Range declaration = 1;</code>
- */
- org.sonar.batch.protocol.output.BatchReport.Range getDeclaration();
- /**
- * <code>optional .Range declaration = 1;</code>
- */
- org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder getDeclarationOrBuilder();
-
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- java.util.List<org.sonar.batch.protocol.output.BatchReport.Range>
- getReferenceList();
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- org.sonar.batch.protocol.output.BatchReport.Range getReference(int index);
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- int getReferenceCount();
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>
- getReferenceOrBuilderList();
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder getReferenceOrBuilder(
- int index);
- }
+ private int bitField0_;
+ public static final int DECLARATION_FIELD_NUMBER = 1;
+ private org.sonar.batch.protocol.output.BatchReport.Range declaration_;
/**
- * Protobuf type {@code Symbols.Symbol}
+ * <code>optional .Range declaration = 1;</code>
*/
- public static final class Symbol extends
- com.google.protobuf.GeneratedMessage implements
- // @@protoc_insertion_point(message_implements:Symbols.Symbol)
- SymbolOrBuilder {
- // Use Symbol.newBuilder() to construct.
- private Symbol(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
- super(builder);
- this.unknownFields = builder.getUnknownFields();
- }
- private Symbol(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
-
- private static final Symbol defaultInstance;
- public static Symbol getDefaultInstance() {
- return defaultInstance;
- }
-
- public Symbol getDefaultInstanceForType() {
- return defaultInstance;
- }
-
- private final com.google.protobuf.UnknownFieldSet unknownFields;
- @java.lang.Override
- public final com.google.protobuf.UnknownFieldSet
- getUnknownFields() {
- return this.unknownFields;
- }
- private Symbol(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- initFields();
- int mutable_bitField0_ = 0;
- com.google.protobuf.UnknownFieldSet.Builder unknownFields =
- com.google.protobuf.UnknownFieldSet.newBuilder();
- try {
- boolean done = false;
- while (!done) {
- int tag = input.readTag();
- switch (tag) {
- case 0:
- done = true;
- break;
- default: {
- if (!parseUnknownField(input, unknownFields,
- extensionRegistry, tag)) {
- done = true;
- }
- break;
- }
- case 10: {
- org.sonar.batch.protocol.output.BatchReport.Range.Builder subBuilder = null;
- if (((bitField0_ & 0x00000001) == 0x00000001)) {
- subBuilder = declaration_.toBuilder();
- }
- declaration_ = input.readMessage(org.sonar.batch.protocol.output.BatchReport.Range.PARSER, extensionRegistry);
- if (subBuilder != null) {
- subBuilder.mergeFrom(declaration_);
- declaration_ = subBuilder.buildPartial();
- }
- bitField0_ |= 0x00000001;
- break;
- }
- case 18: {
- if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
- reference_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Range>();
- mutable_bitField0_ |= 0x00000002;
- }
- reference_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.Range.PARSER, extensionRegistry));
- break;
- }
- }
- }
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- throw e.setUnfinishedMessage(this);
- } catch (java.io.IOException e) {
- throw new com.google.protobuf.InvalidProtocolBufferException(
- e.getMessage()).setUnfinishedMessage(this);
- } finally {
- if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
- reference_ = java.util.Collections.unmodifiableList(reference_);
- }
- this.unknownFields = unknownFields.build();
- makeExtensionsImmutable();
- }
- }
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Symbols_Symbol_descriptor;
- }
-
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Symbols_Symbol_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.class, org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.Builder.class);
- }
-
- public static com.google.protobuf.Parser<Symbol> PARSER =
- new com.google.protobuf.AbstractParser<Symbol>() {
- public Symbol parsePartialFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return new Symbol(input, extensionRegistry);
- }
- };
-
- @java.lang.Override
- public com.google.protobuf.Parser<Symbol> getParserForType() {
- return PARSER;
- }
-
- private int bitField0_;
- public static final int DECLARATION_FIELD_NUMBER = 1;
- private org.sonar.batch.protocol.output.BatchReport.Range declaration_;
- /**
- * <code>optional .Range declaration = 1;</code>
- */
- public boolean hasDeclaration() {
- return ((bitField0_ & 0x00000001) == 0x00000001);
- }
- /**
- * <code>optional .Range declaration = 1;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Range getDeclaration() {
- return declaration_;
- }
- /**
- * <code>optional .Range declaration = 1;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder getDeclarationOrBuilder() {
- return declaration_;
- }
-
- public static final int REFERENCE_FIELD_NUMBER = 2;
- private java.util.List<org.sonar.batch.protocol.output.BatchReport.Range> reference_;
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public java.util.List<org.sonar.batch.protocol.output.BatchReport.Range> getReferenceList() {
- return reference_;
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>
- getReferenceOrBuilderList() {
- return reference_;
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public int getReferenceCount() {
- return reference_.size();
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Range getReference(int index) {
- return reference_.get(index);
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder getReferenceOrBuilder(
- int index) {
- return reference_.get(index);
- }
-
- private void initFields() {
- declaration_ = org.sonar.batch.protocol.output.BatchReport.Range.getDefaultInstance();
- reference_ = java.util.Collections.emptyList();
- }
- private byte memoizedIsInitialized = -1;
- public final boolean isInitialized() {
- byte isInitialized = memoizedIsInitialized;
- if (isInitialized == 1) return true;
- if (isInitialized == 0) return false;
-
- memoizedIsInitialized = 1;
- return true;
- }
-
- public void writeTo(com.google.protobuf.CodedOutputStream output)
- throws java.io.IOException {
- getSerializedSize();
- if (((bitField0_ & 0x00000001) == 0x00000001)) {
- output.writeMessage(1, declaration_);
- }
- for (int i = 0; i < reference_.size(); i++) {
- output.writeMessage(2, reference_.get(i));
- }
- getUnknownFields().writeTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public int getSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (((bitField0_ & 0x00000001) == 0x00000001)) {
- size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(1, declaration_);
- }
- for (int i = 0; i < reference_.size(); i++) {
- size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(2, reference_.get(i));
- }
- size += getUnknownFields().getSerializedSize();
- memoizedSerializedSize = size;
- return size;
- }
-
- private static final long serialVersionUID = 0L;
- @java.lang.Override
- protected java.lang.Object writeReplace()
- throws java.io.ObjectStreamException {
- return super.writeReplace();
- }
-
- public static org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol parseFrom(
- com.google.protobuf.ByteString data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol parseFrom(
- com.google.protobuf.ByteString data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol parseFrom(byte[] data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol parseFrom(
- byte[] data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol parseFrom(java.io.InputStream input)
- throws java.io.IOException {
- return PARSER.parseFrom(input);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol parseFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseFrom(input, extensionRegistry);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol parseDelimitedFrom(java.io.InputStream input)
- throws java.io.IOException {
- return PARSER.parseDelimitedFrom(input);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol parseDelimitedFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseDelimitedFrom(input, extensionRegistry);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol parseFrom(
- com.google.protobuf.CodedInputStream input)
- throws java.io.IOException {
- return PARSER.parseFrom(input);
- }
- public static org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol parseFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseFrom(input, extensionRegistry);
- }
-
- public static Builder newBuilder() { return Builder.create(); }
- public Builder newBuilderForType() { return newBuilder(); }
- public static Builder newBuilder(org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol prototype) {
- return newBuilder().mergeFrom(prototype);
- }
- public Builder toBuilder() { return newBuilder(this); }
-
- @java.lang.Override
- protected Builder newBuilderForType(
- com.google.protobuf.GeneratedMessage.BuilderParent parent) {
- Builder builder = new Builder(parent);
- return builder;
- }
- /**
- * Protobuf type {@code Symbols.Symbol}
- */
- public static final class Builder extends
- com.google.protobuf.GeneratedMessage.Builder<Builder> implements
- // @@protoc_insertion_point(builder_implements:Symbols.Symbol)
- org.sonar.batch.protocol.output.BatchReport.Symbols.SymbolOrBuilder {
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Symbols_Symbol_descriptor;
- }
-
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Symbols_Symbol_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.class, org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.Builder.class);
- }
-
- // Construct using org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.newBuilder()
- private Builder() {
- maybeForceBuilderInitialization();
- }
-
- private Builder(
- com.google.protobuf.GeneratedMessage.BuilderParent parent) {
- super(parent);
- maybeForceBuilderInitialization();
- }
- private void maybeForceBuilderInitialization() {
- if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
- getDeclarationFieldBuilder();
- getReferenceFieldBuilder();
- }
- }
- private static Builder create() {
- return new Builder();
- }
-
- public Builder clear() {
- super.clear();
- if (declarationBuilder_ == null) {
- declaration_ = org.sonar.batch.protocol.output.BatchReport.Range.getDefaultInstance();
- } else {
- declarationBuilder_.clear();
- }
- bitField0_ = (bitField0_ & ~0x00000001);
- if (referenceBuilder_ == null) {
- reference_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000002);
- } else {
- referenceBuilder_.clear();
- }
- return this;
- }
-
- public Builder clone() {
- return create().mergeFrom(buildPartial());
- }
-
- public com.google.protobuf.Descriptors.Descriptor
- getDescriptorForType() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Symbols_Symbol_descriptor;
- }
-
- public org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol getDefaultInstanceForType() {
- return org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.getDefaultInstance();
- }
-
- public org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol build() {
- org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol result = buildPartial();
- if (!result.isInitialized()) {
- throw newUninitializedMessageException(result);
- }
- return result;
- }
-
- public org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol buildPartial() {
- org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol result = new org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol(this);
- int from_bitField0_ = bitField0_;
- int to_bitField0_ = 0;
- if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
- to_bitField0_ |= 0x00000001;
- }
- if (declarationBuilder_ == null) {
- result.declaration_ = declaration_;
- } else {
- result.declaration_ = declarationBuilder_.build();
- }
- if (referenceBuilder_ == null) {
- if (((bitField0_ & 0x00000002) == 0x00000002)) {
- reference_ = java.util.Collections.unmodifiableList(reference_);
- bitField0_ = (bitField0_ & ~0x00000002);
- }
- result.reference_ = reference_;
- } else {
- result.reference_ = referenceBuilder_.build();
- }
- result.bitField0_ = to_bitField0_;
- onBuilt();
- return result;
- }
-
- public Builder mergeFrom(com.google.protobuf.Message other) {
- if (other instanceof org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol) {
- return mergeFrom((org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol)other);
- } else {
- super.mergeFrom(other);
- return this;
- }
- }
-
- public Builder mergeFrom(org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol other) {
- if (other == org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.getDefaultInstance()) return this;
- if (other.hasDeclaration()) {
- mergeDeclaration(other.getDeclaration());
- }
- if (referenceBuilder_ == null) {
- if (!other.reference_.isEmpty()) {
- if (reference_.isEmpty()) {
- reference_ = other.reference_;
- bitField0_ = (bitField0_ & ~0x00000002);
- } else {
- ensureReferenceIsMutable();
- reference_.addAll(other.reference_);
- }
- onChanged();
- }
- } else {
- if (!other.reference_.isEmpty()) {
- if (referenceBuilder_.isEmpty()) {
- referenceBuilder_.dispose();
- referenceBuilder_ = null;
- reference_ = other.reference_;
- bitField0_ = (bitField0_ & ~0x00000002);
- referenceBuilder_ =
- com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
- getReferenceFieldBuilder() : null;
- } else {
- referenceBuilder_.addAllMessages(other.reference_);
- }
- }
- }
- this.mergeUnknownFields(other.getUnknownFields());
- return this;
- }
-
- public final boolean isInitialized() {
- return true;
- }
-
- public Builder mergeFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol parsedMessage = null;
- try {
- parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- parsedMessage = (org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol) e.getUnfinishedMessage();
- throw e;
- } finally {
- if (parsedMessage != null) {
- mergeFrom(parsedMessage);
- }
- }
- return this;
- }
- private int bitField0_;
-
- private org.sonar.batch.protocol.output.BatchReport.Range declaration_ = org.sonar.batch.protocol.output.BatchReport.Range.getDefaultInstance();
- private com.google.protobuf.SingleFieldBuilder<
- org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder> declarationBuilder_;
- /**
- * <code>optional .Range declaration = 1;</code>
- */
- public boolean hasDeclaration() {
- return ((bitField0_ & 0x00000001) == 0x00000001);
- }
- /**
- * <code>optional .Range declaration = 1;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Range getDeclaration() {
- if (declarationBuilder_ == null) {
- return declaration_;
- } else {
- return declarationBuilder_.getMessage();
- }
- }
- /**
- * <code>optional .Range declaration = 1;</code>
- */
- public Builder setDeclaration(org.sonar.batch.protocol.output.BatchReport.Range value) {
- if (declarationBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- declaration_ = value;
- onChanged();
- } else {
- declarationBuilder_.setMessage(value);
- }
- bitField0_ |= 0x00000001;
- return this;
- }
- /**
- * <code>optional .Range declaration = 1;</code>
- */
- public Builder setDeclaration(
- org.sonar.batch.protocol.output.BatchReport.Range.Builder builderForValue) {
- if (declarationBuilder_ == null) {
- declaration_ = builderForValue.build();
- onChanged();
- } else {
- declarationBuilder_.setMessage(builderForValue.build());
- }
- bitField0_ |= 0x00000001;
- return this;
- }
- /**
- * <code>optional .Range declaration = 1;</code>
- */
- public Builder mergeDeclaration(org.sonar.batch.protocol.output.BatchReport.Range value) {
- if (declarationBuilder_ == null) {
- if (((bitField0_ & 0x00000001) == 0x00000001) &&
- declaration_ != org.sonar.batch.protocol.output.BatchReport.Range.getDefaultInstance()) {
- declaration_ =
- org.sonar.batch.protocol.output.BatchReport.Range.newBuilder(declaration_).mergeFrom(value).buildPartial();
- } else {
- declaration_ = value;
- }
- onChanged();
- } else {
- declarationBuilder_.mergeFrom(value);
- }
- bitField0_ |= 0x00000001;
- return this;
- }
- /**
- * <code>optional .Range declaration = 1;</code>
- */
- public Builder clearDeclaration() {
- if (declarationBuilder_ == null) {
- declaration_ = org.sonar.batch.protocol.output.BatchReport.Range.getDefaultInstance();
- onChanged();
- } else {
- declarationBuilder_.clear();
- }
- bitField0_ = (bitField0_ & ~0x00000001);
- return this;
- }
- /**
- * <code>optional .Range declaration = 1;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Range.Builder getDeclarationBuilder() {
- bitField0_ |= 0x00000001;
- onChanged();
- return getDeclarationFieldBuilder().getBuilder();
- }
- /**
- * <code>optional .Range declaration = 1;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder getDeclarationOrBuilder() {
- if (declarationBuilder_ != null) {
- return declarationBuilder_.getMessageOrBuilder();
- } else {
- return declaration_;
- }
- }
- /**
- * <code>optional .Range declaration = 1;</code>
- */
- private com.google.protobuf.SingleFieldBuilder<
- org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>
- getDeclarationFieldBuilder() {
- if (declarationBuilder_ == null) {
- declarationBuilder_ = new com.google.protobuf.SingleFieldBuilder<
- org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>(
- getDeclaration(),
- getParentForChildren(),
- isClean());
- declaration_ = null;
- }
- return declarationBuilder_;
- }
-
- private java.util.List<org.sonar.batch.protocol.output.BatchReport.Range> reference_ =
- java.util.Collections.emptyList();
- private void ensureReferenceIsMutable() {
- if (!((bitField0_ & 0x00000002) == 0x00000002)) {
- reference_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Range>(reference_);
- bitField0_ |= 0x00000002;
- }
- }
-
- private com.google.protobuf.RepeatedFieldBuilder<
- org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder> referenceBuilder_;
-
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public java.util.List<org.sonar.batch.protocol.output.BatchReport.Range> getReferenceList() {
- if (referenceBuilder_ == null) {
- return java.util.Collections.unmodifiableList(reference_);
- } else {
- return referenceBuilder_.getMessageList();
- }
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public int getReferenceCount() {
- if (referenceBuilder_ == null) {
- return reference_.size();
- } else {
- return referenceBuilder_.getCount();
- }
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Range getReference(int index) {
- if (referenceBuilder_ == null) {
- return reference_.get(index);
- } else {
- return referenceBuilder_.getMessage(index);
- }
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public Builder setReference(
- int index, org.sonar.batch.protocol.output.BatchReport.Range value) {
- if (referenceBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensureReferenceIsMutable();
- reference_.set(index, value);
- onChanged();
- } else {
- referenceBuilder_.setMessage(index, value);
- }
- return this;
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public Builder setReference(
- int index, org.sonar.batch.protocol.output.BatchReport.Range.Builder builderForValue) {
- if (referenceBuilder_ == null) {
- ensureReferenceIsMutable();
- reference_.set(index, builderForValue.build());
- onChanged();
- } else {
- referenceBuilder_.setMessage(index, builderForValue.build());
- }
- return this;
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public Builder addReference(org.sonar.batch.protocol.output.BatchReport.Range value) {
- if (referenceBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensureReferenceIsMutable();
- reference_.add(value);
- onChanged();
- } else {
- referenceBuilder_.addMessage(value);
- }
- return this;
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public Builder addReference(
- int index, org.sonar.batch.protocol.output.BatchReport.Range value) {
- if (referenceBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensureReferenceIsMutable();
- reference_.add(index, value);
- onChanged();
- } else {
- referenceBuilder_.addMessage(index, value);
- }
- return this;
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public Builder addReference(
- org.sonar.batch.protocol.output.BatchReport.Range.Builder builderForValue) {
- if (referenceBuilder_ == null) {
- ensureReferenceIsMutable();
- reference_.add(builderForValue.build());
- onChanged();
- } else {
- referenceBuilder_.addMessage(builderForValue.build());
- }
- return this;
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public Builder addReference(
- int index, org.sonar.batch.protocol.output.BatchReport.Range.Builder builderForValue) {
- if (referenceBuilder_ == null) {
- ensureReferenceIsMutable();
- reference_.add(index, builderForValue.build());
- onChanged();
- } else {
- referenceBuilder_.addMessage(index, builderForValue.build());
- }
- return this;
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public Builder addAllReference(
- java.lang.Iterable<? extends org.sonar.batch.protocol.output.BatchReport.Range> values) {
- if (referenceBuilder_ == null) {
- ensureReferenceIsMutable();
- com.google.protobuf.AbstractMessageLite.Builder.addAll(
- values, reference_);
- onChanged();
- } else {
- referenceBuilder_.addAllMessages(values);
- }
- return this;
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public Builder clearReference() {
- if (referenceBuilder_ == null) {
- reference_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000002);
- onChanged();
- } else {
- referenceBuilder_.clear();
- }
- return this;
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public Builder removeReference(int index) {
- if (referenceBuilder_ == null) {
- ensureReferenceIsMutable();
- reference_.remove(index);
- onChanged();
- } else {
- referenceBuilder_.remove(index);
- }
- return this;
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Range.Builder getReferenceBuilder(
- int index) {
- return getReferenceFieldBuilder().getBuilder(index);
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder getReferenceOrBuilder(
- int index) {
- if (referenceBuilder_ == null) {
- return reference_.get(index); } else {
- return referenceBuilder_.getMessageOrBuilder(index);
- }
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>
- getReferenceOrBuilderList() {
- if (referenceBuilder_ != null) {
- return referenceBuilder_.getMessageOrBuilderList();
- } else {
- return java.util.Collections.unmodifiableList(reference_);
- }
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Range.Builder addReferenceBuilder() {
- return getReferenceFieldBuilder().addBuilder(
- org.sonar.batch.protocol.output.BatchReport.Range.getDefaultInstance());
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public org.sonar.batch.protocol.output.BatchReport.Range.Builder addReferenceBuilder(
- int index) {
- return getReferenceFieldBuilder().addBuilder(
- index, org.sonar.batch.protocol.output.BatchReport.Range.getDefaultInstance());
- }
- /**
- * <code>repeated .Range reference = 2;</code>
- */
- public java.util.List<org.sonar.batch.protocol.output.BatchReport.Range.Builder>
- getReferenceBuilderList() {
- return getReferenceFieldBuilder().getBuilderList();
- }
- private com.google.protobuf.RepeatedFieldBuilder<
- org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>
- getReferenceFieldBuilder() {
- if (referenceBuilder_ == null) {
- referenceBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
- org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>(
- reference_,
- ((bitField0_ & 0x00000002) == 0x00000002),
- getParentForChildren(),
- isClean());
- reference_ = null;
- }
- return referenceBuilder_;
- }
-
- // @@protoc_insertion_point(builder_scope:Symbols.Symbol)
- }
-
- static {
- defaultInstance = new Symbol(true);
- defaultInstance.initFields();
- }
-
- // @@protoc_insertion_point(class_scope:Symbols.Symbol)
+ public boolean hasDeclaration() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
}
-
- private int bitField0_;
- public static final int FILE_REF_FIELD_NUMBER = 1;
- private int fileRef_;
/**
- * <code>optional int32 file_ref = 1;</code>
+ * <code>optional .Range declaration = 1;</code>
*/
- public boolean hasFileRef() {
- return ((bitField0_ & 0x00000001) == 0x00000001);
+ public org.sonar.batch.protocol.output.BatchReport.Range getDeclaration() {
+ return declaration_;
}
/**
- * <code>optional int32 file_ref = 1;</code>
+ * <code>optional .Range declaration = 1;</code>
*/
- public int getFileRef() {
- return fileRef_;
+ public org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder getDeclarationOrBuilder() {
+ return declaration_;
}
- public static final int SYMBOL_FIELD_NUMBER = 2;
- private java.util.List<org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol> symbol_;
+ public static final int REFERENCE_FIELD_NUMBER = 2;
+ private java.util.List<org.sonar.batch.protocol.output.BatchReport.Range> reference_;
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public java.util.List<org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol> getSymbolList() {
- return symbol_;
+ public java.util.List<org.sonar.batch.protocol.output.BatchReport.Range> getReferenceList() {
+ return reference_;
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.Symbols.SymbolOrBuilder>
- getSymbolOrBuilderList() {
- return symbol_;
+ public java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>
+ getReferenceOrBuilderList() {
+ return reference_;
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public int getSymbolCount() {
- return symbol_.size();
+ public int getReferenceCount() {
+ return reference_.size();
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol getSymbol(int index) {
- return symbol_.get(index);
+ public org.sonar.batch.protocol.output.BatchReport.Range getReference(int index) {
+ return reference_.get(index);
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public org.sonar.batch.protocol.output.BatchReport.Symbols.SymbolOrBuilder getSymbolOrBuilder(
+ public org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder getReferenceOrBuilder(
int index) {
- return symbol_.get(index);
+ return reference_.get(index);
}
private void initFields() {
- fileRef_ = 0;
- symbol_ = java.util.Collections.emptyList();
+ declaration_ = org.sonar.batch.protocol.output.BatchReport.Range.getDefaultInstance();
+ reference_ = java.util.Collections.emptyList();
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
@@ -14669,10 +12968,10 @@ public final class BatchReport {
throws java.io.IOException {
getSerializedSize();
if (((bitField0_ & 0x00000001) == 0x00000001)) {
- output.writeInt32(1, fileRef_);
+ output.writeMessage(1, declaration_);
}
- for (int i = 0; i < symbol_.size(); i++) {
- output.writeMessage(2, symbol_.get(i));
+ for (int i = 0; i < reference_.size(); i++) {
+ output.writeMessage(2, reference_.get(i));
}
getUnknownFields().writeTo(output);
}
@@ -14685,11 +12984,11 @@ public final class BatchReport {
size = 0;
if (((bitField0_ & 0x00000001) == 0x00000001)) {
size += com.google.protobuf.CodedOutputStream
- .computeInt32Size(1, fileRef_);
+ .computeMessageSize(1, declaration_);
}
- for (int i = 0; i < symbol_.size(); i++) {
+ for (int i = 0; i < reference_.size(); i++) {
size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(2, symbol_.get(i));
+ .computeMessageSize(2, reference_.get(i));
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
@@ -14703,53 +13002,53 @@ public final class BatchReport {
return super.writeReplace();
}
- public static org.sonar.batch.protocol.output.BatchReport.Symbols parseFrom(
+ public static org.sonar.batch.protocol.output.BatchReport.Symbol parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
- public static org.sonar.batch.protocol.output.BatchReport.Symbols parseFrom(
+ public static org.sonar.batch.protocol.output.BatchReport.Symbol parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
- public static org.sonar.batch.protocol.output.BatchReport.Symbols parseFrom(byte[] data)
+ public static org.sonar.batch.protocol.output.BatchReport.Symbol parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
- public static org.sonar.batch.protocol.output.BatchReport.Symbols parseFrom(
+ public static org.sonar.batch.protocol.output.BatchReport.Symbol parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
- public static org.sonar.batch.protocol.output.BatchReport.Symbols parseFrom(java.io.InputStream input)
+ public static org.sonar.batch.protocol.output.BatchReport.Symbol parseFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
- public static org.sonar.batch.protocol.output.BatchReport.Symbols parseFrom(
+ public static org.sonar.batch.protocol.output.BatchReport.Symbol parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseFrom(input, extensionRegistry);
}
- public static org.sonar.batch.protocol.output.BatchReport.Symbols parseDelimitedFrom(java.io.InputStream input)
+ public static org.sonar.batch.protocol.output.BatchReport.Symbol parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input);
}
- public static org.sonar.batch.protocol.output.BatchReport.Symbols parseDelimitedFrom(
+ public static org.sonar.batch.protocol.output.BatchReport.Symbol parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input, extensionRegistry);
}
- public static org.sonar.batch.protocol.output.BatchReport.Symbols parseFrom(
+ public static org.sonar.batch.protocol.output.BatchReport.Symbol parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
- public static org.sonar.batch.protocol.output.BatchReport.Symbols parseFrom(
+ public static org.sonar.batch.protocol.output.BatchReport.Symbol parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
@@ -14758,7 +13057,7 @@ public final class BatchReport {
public static Builder newBuilder() { return Builder.create(); }
public Builder newBuilderForType() { return newBuilder(); }
- public static Builder newBuilder(org.sonar.batch.protocol.output.BatchReport.Symbols prototype) {
+ public static Builder newBuilder(org.sonar.batch.protocol.output.BatchReport.Symbol prototype) {
return newBuilder().mergeFrom(prototype);
}
public Builder toBuilder() { return newBuilder(this); }
@@ -14770,25 +13069,25 @@ public final class BatchReport {
return builder;
}
/**
- * Protobuf type {@code Symbols}
+ * Protobuf type {@code Symbol}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessage.Builder<Builder> implements
- // @@protoc_insertion_point(builder_implements:Symbols)
- org.sonar.batch.protocol.output.BatchReport.SymbolsOrBuilder {
+ // @@protoc_insertion_point(builder_implements:Symbol)
+ org.sonar.batch.protocol.output.BatchReport.SymbolOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Symbols_descriptor;
+ return org.sonar.batch.protocol.output.BatchReport.internal_static_Symbol_descriptor;
}
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Symbols_fieldAccessorTable
+ return org.sonar.batch.protocol.output.BatchReport.internal_static_Symbol_fieldAccessorTable
.ensureFieldAccessorsInitialized(
- org.sonar.batch.protocol.output.BatchReport.Symbols.class, org.sonar.batch.protocol.output.BatchReport.Symbols.Builder.class);
+ org.sonar.batch.protocol.output.BatchReport.Symbol.class, org.sonar.batch.protocol.output.BatchReport.Symbol.Builder.class);
}
- // Construct using org.sonar.batch.protocol.output.BatchReport.Symbols.newBuilder()
+ // Construct using org.sonar.batch.protocol.output.BatchReport.Symbol.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
@@ -14800,7 +13099,8 @@ public final class BatchReport {
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
- getSymbolFieldBuilder();
+ getDeclarationFieldBuilder();
+ getReferenceFieldBuilder();
}
}
private static Builder create() {
@@ -14809,13 +13109,17 @@ public final class BatchReport {
public Builder clear() {
super.clear();
- fileRef_ = 0;
+ if (declarationBuilder_ == null) {
+ declaration_ = org.sonar.batch.protocol.output.BatchReport.Range.getDefaultInstance();
+ } else {
+ declarationBuilder_.clear();
+ }
bitField0_ = (bitField0_ & ~0x00000001);
- if (symbolBuilder_ == null) {
- symbol_ = java.util.Collections.emptyList();
+ if (referenceBuilder_ == null) {
+ reference_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000002);
} else {
- symbolBuilder_.clear();
+ referenceBuilder_.clear();
}
return this;
}
@@ -14826,37 +13130,41 @@ public final class BatchReport {
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
- return org.sonar.batch.protocol.output.BatchReport.internal_static_Symbols_descriptor;
+ return org.sonar.batch.protocol.output.BatchReport.internal_static_Symbol_descriptor;
}
- public org.sonar.batch.protocol.output.BatchReport.Symbols getDefaultInstanceForType() {
- return org.sonar.batch.protocol.output.BatchReport.Symbols.getDefaultInstance();
+ public org.sonar.batch.protocol.output.BatchReport.Symbol getDefaultInstanceForType() {
+ return org.sonar.batch.protocol.output.BatchReport.Symbol.getDefaultInstance();
}
- public org.sonar.batch.protocol.output.BatchReport.Symbols build() {
- org.sonar.batch.protocol.output.BatchReport.Symbols result = buildPartial();
+ public org.sonar.batch.protocol.output.BatchReport.Symbol build() {
+ org.sonar.batch.protocol.output.BatchReport.Symbol result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
- public org.sonar.batch.protocol.output.BatchReport.Symbols buildPartial() {
- org.sonar.batch.protocol.output.BatchReport.Symbols result = new org.sonar.batch.protocol.output.BatchReport.Symbols(this);
+ public org.sonar.batch.protocol.output.BatchReport.Symbol buildPartial() {
+ org.sonar.batch.protocol.output.BatchReport.Symbol result = new org.sonar.batch.protocol.output.BatchReport.Symbol(this);
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
to_bitField0_ |= 0x00000001;
}
- result.fileRef_ = fileRef_;
- if (symbolBuilder_ == null) {
+ if (declarationBuilder_ == null) {
+ result.declaration_ = declaration_;
+ } else {
+ result.declaration_ = declarationBuilder_.build();
+ }
+ if (referenceBuilder_ == null) {
if (((bitField0_ & 0x00000002) == 0x00000002)) {
- symbol_ = java.util.Collections.unmodifiableList(symbol_);
+ reference_ = java.util.Collections.unmodifiableList(reference_);
bitField0_ = (bitField0_ & ~0x00000002);
}
- result.symbol_ = symbol_;
+ result.reference_ = reference_;
} else {
- result.symbol_ = symbolBuilder_.build();
+ result.reference_ = referenceBuilder_.build();
}
result.bitField0_ = to_bitField0_;
onBuilt();
@@ -14864,42 +13172,42 @@ public final class BatchReport {
}
public Builder mergeFrom(com.google.protobuf.Message other) {
- if (other instanceof org.sonar.batch.protocol.output.BatchReport.Symbols) {
- return mergeFrom((org.sonar.batch.protocol.output.BatchReport.Symbols)other);
+ if (other instanceof org.sonar.batch.protocol.output.BatchReport.Symbol) {
+ return mergeFrom((org.sonar.batch.protocol.output.BatchReport.Symbol)other);
} else {
super.mergeFrom(other);
return this;
}
}
- public Builder mergeFrom(org.sonar.batch.protocol.output.BatchReport.Symbols other) {
- if (other == org.sonar.batch.protocol.output.BatchReport.Symbols.getDefaultInstance()) return this;
- if (other.hasFileRef()) {
- setFileRef(other.getFileRef());
+ public Builder mergeFrom(org.sonar.batch.protocol.output.BatchReport.Symbol other) {
+ if (other == org.sonar.batch.protocol.output.BatchReport.Symbol.getDefaultInstance()) return this;
+ if (other.hasDeclaration()) {
+ mergeDeclaration(other.getDeclaration());
}
- if (symbolBuilder_ == null) {
- if (!other.symbol_.isEmpty()) {
- if (symbol_.isEmpty()) {
- symbol_ = other.symbol_;
+ if (referenceBuilder_ == null) {
+ if (!other.reference_.isEmpty()) {
+ if (reference_.isEmpty()) {
+ reference_ = other.reference_;
bitField0_ = (bitField0_ & ~0x00000002);
} else {
- ensureSymbolIsMutable();
- symbol_.addAll(other.symbol_);
+ ensureReferenceIsMutable();
+ reference_.addAll(other.reference_);
}
onChanged();
}
} else {
- if (!other.symbol_.isEmpty()) {
- if (symbolBuilder_.isEmpty()) {
- symbolBuilder_.dispose();
- symbolBuilder_ = null;
- symbol_ = other.symbol_;
+ if (!other.reference_.isEmpty()) {
+ if (referenceBuilder_.isEmpty()) {
+ referenceBuilder_.dispose();
+ referenceBuilder_ = null;
+ reference_ = other.reference_;
bitField0_ = (bitField0_ & ~0x00000002);
- symbolBuilder_ =
+ referenceBuilder_ =
com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
- getSymbolFieldBuilder() : null;
+ getReferenceFieldBuilder() : null;
} else {
- symbolBuilder_.addAllMessages(other.symbol_);
+ referenceBuilder_.addAllMessages(other.reference_);
}
}
}
@@ -14915,11 +13223,11 @@ public final class BatchReport {
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
- org.sonar.batch.protocol.output.BatchReport.Symbols parsedMessage = null;
+ org.sonar.batch.protocol.output.BatchReport.Symbol parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
- parsedMessage = (org.sonar.batch.protocol.output.BatchReport.Symbols) e.getUnfinishedMessage();
+ parsedMessage = (org.sonar.batch.protocol.output.BatchReport.Symbol) e.getUnfinishedMessage();
throw e;
} finally {
if (parsedMessage != null) {
@@ -14930,287 +13238,371 @@ public final class BatchReport {
}
private int bitField0_;
- private int fileRef_ ;
+ private org.sonar.batch.protocol.output.BatchReport.Range declaration_ = org.sonar.batch.protocol.output.BatchReport.Range.getDefaultInstance();
+ private com.google.protobuf.SingleFieldBuilder<
+ org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder> declarationBuilder_;
/**
- * <code>optional int32 file_ref = 1;</code>
+ * <code>optional .Range declaration = 1;</code>
*/
- public boolean hasFileRef() {
+ public boolean hasDeclaration() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
- * <code>optional int32 file_ref = 1;</code>
+ * <code>optional .Range declaration = 1;</code>
*/
- public int getFileRef() {
- return fileRef_;
+ public org.sonar.batch.protocol.output.BatchReport.Range getDeclaration() {
+ if (declarationBuilder_ == null) {
+ return declaration_;
+ } else {
+ return declarationBuilder_.getMessage();
+ }
}
/**
- * <code>optional int32 file_ref = 1;</code>
+ * <code>optional .Range declaration = 1;</code>
*/
- public Builder setFileRef(int value) {
+ public Builder setDeclaration(org.sonar.batch.protocol.output.BatchReport.Range value) {
+ if (declarationBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ declaration_ = value;
+ onChanged();
+ } else {
+ declarationBuilder_.setMessage(value);
+ }
bitField0_ |= 0x00000001;
- fileRef_ = value;
- onChanged();
return this;
}
/**
- * <code>optional int32 file_ref = 1;</code>
+ * <code>optional .Range declaration = 1;</code>
+ */
+ public Builder setDeclaration(
+ org.sonar.batch.protocol.output.BatchReport.Range.Builder builderForValue) {
+ if (declarationBuilder_ == null) {
+ declaration_ = builderForValue.build();
+ onChanged();
+ } else {
+ declarationBuilder_.setMessage(builderForValue.build());
+ }
+ bitField0_ |= 0x00000001;
+ return this;
+ }
+ /**
+ * <code>optional .Range declaration = 1;</code>
*/
- public Builder clearFileRef() {
+ public Builder mergeDeclaration(org.sonar.batch.protocol.output.BatchReport.Range value) {
+ if (declarationBuilder_ == null) {
+ if (((bitField0_ & 0x00000001) == 0x00000001) &&
+ declaration_ != org.sonar.batch.protocol.output.BatchReport.Range.getDefaultInstance()) {
+ declaration_ =
+ org.sonar.batch.protocol.output.BatchReport.Range.newBuilder(declaration_).mergeFrom(value).buildPartial();
+ } else {
+ declaration_ = value;
+ }
+ onChanged();
+ } else {
+ declarationBuilder_.mergeFrom(value);
+ }
+ bitField0_ |= 0x00000001;
+ return this;
+ }
+ /**
+ * <code>optional .Range declaration = 1;</code>
+ */
+ public Builder clearDeclaration() {
+ if (declarationBuilder_ == null) {
+ declaration_ = org.sonar.batch.protocol.output.BatchReport.Range.getDefaultInstance();
+ onChanged();
+ } else {
+ declarationBuilder_.clear();
+ }
bitField0_ = (bitField0_ & ~0x00000001);
- fileRef_ = 0;
- onChanged();
return this;
}
+ /**
+ * <code>optional .Range declaration = 1;</code>
+ */
+ public org.sonar.batch.protocol.output.BatchReport.Range.Builder getDeclarationBuilder() {
+ bitField0_ |= 0x00000001;
+ onChanged();
+ return getDeclarationFieldBuilder().getBuilder();
+ }
+ /**
+ * <code>optional .Range declaration = 1;</code>
+ */
+ public org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder getDeclarationOrBuilder() {
+ if (declarationBuilder_ != null) {
+ return declarationBuilder_.getMessageOrBuilder();
+ } else {
+ return declaration_;
+ }
+ }
+ /**
+ * <code>optional .Range declaration = 1;</code>
+ */
+ private com.google.protobuf.SingleFieldBuilder<
+ org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>
+ getDeclarationFieldBuilder() {
+ if (declarationBuilder_ == null) {
+ declarationBuilder_ = new com.google.protobuf.SingleFieldBuilder<
+ org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>(
+ getDeclaration(),
+ getParentForChildren(),
+ isClean());
+ declaration_ = null;
+ }
+ return declarationBuilder_;
+ }
- private java.util.List<org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol> symbol_ =
+ private java.util.List<org.sonar.batch.protocol.output.BatchReport.Range> reference_ =
java.util.Collections.emptyList();
- private void ensureSymbolIsMutable() {
+ private void ensureReferenceIsMutable() {
if (!((bitField0_ & 0x00000002) == 0x00000002)) {
- symbol_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol>(symbol_);
+ reference_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Range>(reference_);
bitField0_ |= 0x00000002;
}
}
private com.google.protobuf.RepeatedFieldBuilder<
- org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol, org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.Builder, org.sonar.batch.protocol.output.BatchReport.Symbols.SymbolOrBuilder> symbolBuilder_;
+ org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder> referenceBuilder_;
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public java.util.List<org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol> getSymbolList() {
- if (symbolBuilder_ == null) {
- return java.util.Collections.unmodifiableList(symbol_);
+ public java.util.List<org.sonar.batch.protocol.output.BatchReport.Range> getReferenceList() {
+ if (referenceBuilder_ == null) {
+ return java.util.Collections.unmodifiableList(reference_);
} else {
- return symbolBuilder_.getMessageList();
+ return referenceBuilder_.getMessageList();
}
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public int getSymbolCount() {
- if (symbolBuilder_ == null) {
- return symbol_.size();
+ public int getReferenceCount() {
+ if (referenceBuilder_ == null) {
+ return reference_.size();
} else {
- return symbolBuilder_.getCount();
+ return referenceBuilder_.getCount();
}
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol getSymbol(int index) {
- if (symbolBuilder_ == null) {
- return symbol_.get(index);
+ public org.sonar.batch.protocol.output.BatchReport.Range getReference(int index) {
+ if (referenceBuilder_ == null) {
+ return reference_.get(index);
} else {
- return symbolBuilder_.getMessage(index);
+ return referenceBuilder_.getMessage(index);
}
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public Builder setSymbol(
- int index, org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol value) {
- if (symbolBuilder_ == null) {
+ public Builder setReference(
+ int index, org.sonar.batch.protocol.output.BatchReport.Range value) {
+ if (referenceBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
- ensureSymbolIsMutable();
- symbol_.set(index, value);
+ ensureReferenceIsMutable();
+ reference_.set(index, value);
onChanged();
} else {
- symbolBuilder_.setMessage(index, value);
+ referenceBuilder_.setMessage(index, value);
}
return this;
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public Builder setSymbol(
- int index, org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.Builder builderForValue) {
- if (symbolBuilder_ == null) {
- ensureSymbolIsMutable();
- symbol_.set(index, builderForValue.build());
+ public Builder setReference(
+ int index, org.sonar.batch.protocol.output.BatchReport.Range.Builder builderForValue) {
+ if (referenceBuilder_ == null) {
+ ensureReferenceIsMutable();
+ reference_.set(index, builderForValue.build());
onChanged();
} else {
- symbolBuilder_.setMessage(index, builderForValue.build());
+ referenceBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public Builder addSymbol(org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol value) {
- if (symbolBuilder_ == null) {
+ public Builder addReference(org.sonar.batch.protocol.output.BatchReport.Range value) {
+ if (referenceBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
- ensureSymbolIsMutable();
- symbol_.add(value);
+ ensureReferenceIsMutable();
+ reference_.add(value);
onChanged();
} else {
- symbolBuilder_.addMessage(value);
+ referenceBuilder_.addMessage(value);
}
return this;
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public Builder addSymbol(
- int index, org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol value) {
- if (symbolBuilder_ == null) {
+ public Builder addReference(
+ int index, org.sonar.batch.protocol.output.BatchReport.Range value) {
+ if (referenceBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
- ensureSymbolIsMutable();
- symbol_.add(index, value);
+ ensureReferenceIsMutable();
+ reference_.add(index, value);
onChanged();
} else {
- symbolBuilder_.addMessage(index, value);
+ referenceBuilder_.addMessage(index, value);
}
return this;
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public Builder addSymbol(
- org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.Builder builderForValue) {
- if (symbolBuilder_ == null) {
- ensureSymbolIsMutable();
- symbol_.add(builderForValue.build());
+ public Builder addReference(
+ org.sonar.batch.protocol.output.BatchReport.Range.Builder builderForValue) {
+ if (referenceBuilder_ == null) {
+ ensureReferenceIsMutable();
+ reference_.add(builderForValue.build());
onChanged();
} else {
- symbolBuilder_.addMessage(builderForValue.build());
+ referenceBuilder_.addMessage(builderForValue.build());
}
return this;
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public Builder addSymbol(
- int index, org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.Builder builderForValue) {
- if (symbolBuilder_ == null) {
- ensureSymbolIsMutable();
- symbol_.add(index, builderForValue.build());
+ public Builder addReference(
+ int index, org.sonar.batch.protocol.output.BatchReport.Range.Builder builderForValue) {
+ if (referenceBuilder_ == null) {
+ ensureReferenceIsMutable();
+ reference_.add(index, builderForValue.build());
onChanged();
} else {
- symbolBuilder_.addMessage(index, builderForValue.build());
+ referenceBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public Builder addAllSymbol(
- java.lang.Iterable<? extends org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol> values) {
- if (symbolBuilder_ == null) {
- ensureSymbolIsMutable();
+ public Builder addAllReference(
+ java.lang.Iterable<? extends org.sonar.batch.protocol.output.BatchReport.Range> values) {
+ if (referenceBuilder_ == null) {
+ ensureReferenceIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(
- values, symbol_);
+ values, reference_);
onChanged();
} else {
- symbolBuilder_.addAllMessages(values);
+ referenceBuilder_.addAllMessages(values);
}
return this;
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public Builder clearSymbol() {
- if (symbolBuilder_ == null) {
- symbol_ = java.util.Collections.emptyList();
+ public Builder clearReference() {
+ if (referenceBuilder_ == null) {
+ reference_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
} else {
- symbolBuilder_.clear();
+ referenceBuilder_.clear();
}
return this;
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public Builder removeSymbol(int index) {
- if (symbolBuilder_ == null) {
- ensureSymbolIsMutable();
- symbol_.remove(index);
+ public Builder removeReference(int index) {
+ if (referenceBuilder_ == null) {
+ ensureReferenceIsMutable();
+ reference_.remove(index);
onChanged();
} else {
- symbolBuilder_.remove(index);
+ referenceBuilder_.remove(index);
}
return this;
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.Builder getSymbolBuilder(
+ public org.sonar.batch.protocol.output.BatchReport.Range.Builder getReferenceBuilder(
int index) {
- return getSymbolFieldBuilder().getBuilder(index);
+ return getReferenceFieldBuilder().getBuilder(index);
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public org.sonar.batch.protocol.output.BatchReport.Symbols.SymbolOrBuilder getSymbolOrBuilder(
+ public org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder getReferenceOrBuilder(
int index) {
- if (symbolBuilder_ == null) {
- return symbol_.get(index); } else {
- return symbolBuilder_.getMessageOrBuilder(index);
+ if (referenceBuilder_ == null) {
+ return reference_.get(index); } else {
+ return referenceBuilder_.getMessageOrBuilder(index);
}
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.Symbols.SymbolOrBuilder>
- getSymbolOrBuilderList() {
- if (symbolBuilder_ != null) {
- return symbolBuilder_.getMessageOrBuilderList();
+ public java.util.List<? extends org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>
+ getReferenceOrBuilderList() {
+ if (referenceBuilder_ != null) {
+ return referenceBuilder_.getMessageOrBuilderList();
} else {
- return java.util.Collections.unmodifiableList(symbol_);
+ return java.util.Collections.unmodifiableList(reference_);
}
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.Builder addSymbolBuilder() {
- return getSymbolFieldBuilder().addBuilder(
- org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.getDefaultInstance());
+ public org.sonar.batch.protocol.output.BatchReport.Range.Builder addReferenceBuilder() {
+ return getReferenceFieldBuilder().addBuilder(
+ org.sonar.batch.protocol.output.BatchReport.Range.getDefaultInstance());
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.Builder addSymbolBuilder(
+ public org.sonar.batch.protocol.output.BatchReport.Range.Builder addReferenceBuilder(
int index) {
- return getSymbolFieldBuilder().addBuilder(
- index, org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.getDefaultInstance());
+ return getReferenceFieldBuilder().addBuilder(
+ index, org.sonar.batch.protocol.output.BatchReport.Range.getDefaultInstance());
}
/**
- * <code>repeated .Symbols.Symbol symbol = 2;</code>
+ * <code>repeated .Range reference = 2;</code>
*/
- public java.util.List<org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.Builder>
- getSymbolBuilderList() {
- return getSymbolFieldBuilder().getBuilderList();
+ public java.util.List<org.sonar.batch.protocol.output.BatchReport.Range.Builder>
+ getReferenceBuilderList() {
+ return getReferenceFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilder<
- org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol, org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.Builder, org.sonar.batch.protocol.output.BatchReport.Symbols.SymbolOrBuilder>
- getSymbolFieldBuilder() {
- if (symbolBuilder_ == null) {
- symbolBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
- org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol, org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.Builder, org.sonar.batch.protocol.output.BatchReport.Symbols.SymbolOrBuilder>(
- symbol_,
+ org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>
+ getReferenceFieldBuilder() {
+ if (referenceBuilder_ == null) {
+ referenceBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
+ org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>(
+ reference_,
((bitField0_ & 0x00000002) == 0x00000002),
getParentForChildren(),
isClean());
- symbol_ = null;
+ reference_ = null;
}
- return symbolBuilder_;
+ return referenceBuilder_;
}
- // @@protoc_insertion_point(builder_scope:Symbols)
+ // @@protoc_insertion_point(builder_scope:Symbol)
}
static {
- defaultInstance = new Symbols(true);
+ defaultInstance = new Symbol(true);
defaultInstance.initFields();
}
- // @@protoc_insertion_point(class_scope:Symbols)
+ // @@protoc_insertion_point(class_scope:Symbol)
}
public interface CoverageOrBuilder extends
@@ -19244,6 +17636,16 @@ public final class BatchReport {
com.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_Metadata_fieldAccessorTable;
private static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_ActiveRule_descriptor;
+ private static
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_ActiveRule_fieldAccessorTable;
+ private static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_ActiveRule_ActiveRuleParam_descriptor;
+ private static
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_ActiveRule_ActiveRuleParam_fieldAccessorTable;
+ private static final com.google.protobuf.Descriptors.Descriptor
internal_static_ComponentLink_descriptor;
private static
com.google.protobuf.GeneratedMessage.FieldAccessorTable
@@ -19259,21 +17661,11 @@ public final class BatchReport {
com.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_Measure_fieldAccessorTable;
private static final com.google.protobuf.Descriptors.Descriptor
- internal_static_Measures_descriptor;
- private static
- com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internal_static_Measures_fieldAccessorTable;
- private static final com.google.protobuf.Descriptors.Descriptor
internal_static_Issue_descriptor;
private static
com.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_Issue_fieldAccessorTable;
private static final com.google.protobuf.Descriptors.Descriptor
- internal_static_Issues_descriptor;
- private static
- com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internal_static_Issues_fieldAccessorTable;
- private static final com.google.protobuf.Descriptors.Descriptor
internal_static_Changesets_descriptor;
private static
com.google.protobuf.GeneratedMessage.FieldAccessorTable
@@ -19294,25 +17686,15 @@ public final class BatchReport {
com.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_Duplication_fieldAccessorTable;
private static final com.google.protobuf.Descriptors.Descriptor
- internal_static_Duplications_descriptor;
- private static
- com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internal_static_Duplications_fieldAccessorTable;
- private static final com.google.protobuf.Descriptors.Descriptor
internal_static_Range_descriptor;
private static
com.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_Range_fieldAccessorTable;
private static final com.google.protobuf.Descriptors.Descriptor
- internal_static_Symbols_descriptor;
+ internal_static_Symbol_descriptor;
private static
com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internal_static_Symbols_fieldAccessorTable;
- private static final com.google.protobuf.Descriptors.Descriptor
- internal_static_Symbols_Symbol_descriptor;
- private static
- com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internal_static_Symbols_Symbol_fieldAccessorTable;
+ internal_static_Symbol_fieldAccessorTable;
private static final com.google.protobuf.Descriptors.Descriptor
internal_static_Coverage_descriptor;
private static
@@ -19347,63 +17729,61 @@ public final class BatchReport {
descriptor;
static {
java.lang.String[] descriptorData = {
- "\n\022batch_report.proto\032\017constants.proto\"{\n" +
+ "\n\022batch_report.proto\032\017constants.proto\"b\n" +
"\010Metadata\022\025\n\ranalysis_date\030\001 \001(\003\022\023\n\013proj" +
"ect_key\030\002 \001(\t\022\016\n\006branch\030\003 \001(\t\022\032\n\022root_co" +
- "mponent_ref\030\004 \001(\005\022\027\n\017active_rule_key\030\005 \003" +
- "(\t\"?\n\rComponentLink\022 \n\004type\030\001 \001(\0162\022.Comp" +
- "onentLinkType\022\014\n\004href\030\002 \001(\t\"\354\001\n\tComponen" +
- "t\022\013\n\003ref\030\001 \001(\005\022\014\n\004path\030\002 \001(\t\022\014\n\004name\030\003 \001" +
- "(\t\022\034\n\004type\030\004 \001(\0162\016.ComponentType\022\017\n\007is_t" +
- "est\030\005 \001(\010\022\020\n\010language\030\006 \001(\t\022\025\n\tchild_ref" +
- "\030\007 \003(\005B\002\020\001\022\034\n\004link\030\010 \003(\0132\016.ComponentLink",
- "\022\017\n\007version\030\t \001(\t\022\013\n\003key\030\n \001(\t\022\r\n\005lines\030" +
- "\013 \001(\005\022\023\n\013description\030\014 \001(\t\"\335\002\n\007Measure\022%" +
- "\n\nvalue_type\030\001 \001(\0162\021.MeasureValueType\022\025\n" +
- "\rboolean_value\030\002 \001(\010\022\021\n\tint_value\030\003 \001(\005\022" +
- "\022\n\nlong_value\030\004 \001(\003\022\024\n\014double_value\030\005 \001(" +
- "\001\022\024\n\014string_value\030\006 \001(\t\022\022\n\nmetric_key\030\007 " +
- "\001(\t\022\023\n\013description\030\t \001(\t\022\031\n\021variation_va" +
- "lue_1\030\016 \001(\001\022\031\n\021variation_value_2\030\017 \001(\001\022\031" +
- "\n\021variation_value_3\030\020 \001(\001\022\031\n\021variation_v" +
- "alue_4\030\021 \001(\001\022\031\n\021variation_value_5\030\022 \001(\001\022",
- "\021\n\tperson_id\030\024 \001(\005\"<\n\010Measures\022\025\n\rcompon" +
- "ent_ref\030\001 \001(\005\022\031\n\007measure\030\002 \003(\0132\010.Measure" +
- "\"\242\001\n\005Issue\022\027\n\017rule_repository\030\001 \001(\t\022\020\n\010r" +
- "ule_key\030\002 \001(\t\022\014\n\004line\030\003 \001(\005\022\013\n\003msg\030\004 \001(\t" +
- "\022\033\n\010severity\030\005 \001(\0162\t.Severity\022\013\n\003tag\030\006 \003" +
- "(\t\022\025\n\reffort_to_fix\030\007 \001(\001\022\022\n\nattributes\030" +
- "\010 \001(\t\"6\n\006Issues\022\025\n\rcomponent_ref\030\001 \001(\005\022\025" +
- "\n\005issue\030\002 \003(\0132\006.Issue\"\254\001\n\nChangesets\022\025\n\r" +
- "component_ref\030\001 \001(\005\022(\n\tchangeset\030\002 \003(\0132\025" +
- ".Changesets.Changeset\022 \n\024changesetIndexB",
- "yLine\030\003 \003(\005B\002\020\001\032;\n\tChangeset\022\020\n\010revision" +
- "\030\001 \001(\t\022\016\n\006author\030\002 \001(\t\022\014\n\004date\030\003 \001(\003\"R\n\t" +
- "Duplicate\022\026\n\016other_file_ref\030\001 \001(\005\022\025\n\005ran" +
- "ge\030\002 \001(\0132\006.Range\022\026\n\016other_file_key\030\003 \001(\t" +
- "\"M\n\013Duplication\022\037\n\017origin_position\030\001 \001(\013" +
- "2\006.Range\022\035\n\tduplicate\030\002 \003(\0132\n.Duplicate\"" +
- "H\n\014Duplications\022\025\n\rcomponent_ref\030\001 \001(\005\022!" +
- "\n\013duplication\030\002 \003(\0132\014.Duplication\"W\n\005Ran" +
- "ge\022\022\n\nstart_line\030\001 \001(\005\022\020\n\010end_line\030\002 \001(\005" +
- "\022\024\n\014start_offset\030\003 \001(\005\022\022\n\nend_offset\030\004 \001",
- "(\005\"~\n\007Symbols\022\020\n\010file_ref\030\001 \001(\005\022\037\n\006symbo" +
- "l\030\002 \003(\0132\017.Symbols.Symbol\032@\n\006Symbol\022\033\n\013de" +
- "claration\030\001 \001(\0132\006.Range\022\031\n\treference\030\002 \003" +
- "(\0132\006.Range\"\260\001\n\010Coverage\022\014\n\004line\030\001 \001(\005\022\022\n" +
- "\nconditions\030\002 \001(\005\022\017\n\007ut_hits\030\003 \001(\010\022\017\n\007it" +
- "_hits\030\004 \001(\010\022\035\n\025ut_covered_conditions\030\005 \001" +
- "(\005\022\035\n\025it_covered_conditions\030\006 \001(\005\022\"\n\032ove" +
- "rall_covered_conditions\030\007 \001(\005\"L\n\022SyntaxH" +
- "ighlighting\022\025\n\005range\030\001 \001(\0132\006.Range\022\037\n\004ty" +
- "pe\030\002 \001(\0162\021.HighlightingType\"j\n\004Test\022\014\n\004n",
- "ame\030\001 \001(\t\022\033\n\006status\030\002 \001(\0162\013.TestStatus\022\026" +
- "\n\016duration_in_ms\030\003 \001(\003\022\022\n\nstacktrace\030\004 \001" +
- "(\t\022\013\n\003msg\030\005 \001(\t\"\221\001\n\016CoverageDetail\022\021\n\tte" +
- "st_name\030\001 \001(\t\0221\n\014covered_file\030\002 \003(\0132\033.Co" +
- "verageDetail.CoveredFile\0329\n\013CoveredFile\022" +
- "\020\n\010file_ref\030\001 \001(\005\022\030\n\014covered_line\030\002 \003(\005B" +
- "\002\020\001B#\n\037org.sonar.batch.protocol.outputH\001"
+ "mponent_ref\030\004 \001(\005\"\257\001\n\nActiveRule\022\027\n\017rule" +
+ "_repository\030\001 \001(\t\022\020\n\010rule_key\030\002 \001(\t\022\033\n\010s" +
+ "everity\030\003 \001(\0162\t.Severity\022*\n\005param\030\004 \003(\0132" +
+ "\033.ActiveRule.ActiveRuleParam\032-\n\017ActiveRu" +
+ "leParam\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t\"?\n\rC" +
+ "omponentLink\022 \n\004type\030\001 \001(\0162\022.ComponentLi" +
+ "nkType\022\014\n\004href\030\002 \001(\t\"\354\001\n\tComponent\022\013\n\003re",
+ "f\030\001 \001(\005\022\014\n\004path\030\002 \001(\t\022\014\n\004name\030\003 \001(\t\022\034\n\004t" +
+ "ype\030\004 \001(\0162\016.ComponentType\022\017\n\007is_test\030\005 \001" +
+ "(\010\022\020\n\010language\030\006 \001(\t\022\025\n\tchild_ref\030\007 \003(\005B" +
+ "\002\020\001\022\034\n\004link\030\010 \003(\0132\016.ComponentLink\022\017\n\007ver" +
+ "sion\030\t \001(\t\022\013\n\003key\030\n \001(\t\022\r\n\005lines\030\013 \001(\005\022\023" +
+ "\n\013description\030\014 \001(\t\"\335\002\n\007Measure\022%\n\nvalue" +
+ "_type\030\001 \001(\0162\021.MeasureValueType\022\025\n\rboolea" +
+ "n_value\030\002 \001(\010\022\021\n\tint_value\030\003 \001(\005\022\022\n\nlong" +
+ "_value\030\004 \001(\003\022\024\n\014double_value\030\005 \001(\001\022\024\n\014st" +
+ "ring_value\030\006 \001(\t\022\022\n\nmetric_key\030\007 \001(\t\022\023\n\013",
+ "description\030\t \001(\t\022\031\n\021variation_value_1\030\016" +
+ " \001(\001\022\031\n\021variation_value_2\030\017 \001(\001\022\031\n\021varia" +
+ "tion_value_3\030\020 \001(\001\022\031\n\021variation_value_4\030" +
+ "\021 \001(\001\022\031\n\021variation_value_5\030\022 \001(\001\022\021\n\tpers" +
+ "on_id\030\024 \001(\005\"\242\001\n\005Issue\022\027\n\017rule_repository" +
+ "\030\001 \001(\t\022\020\n\010rule_key\030\002 \001(\t\022\014\n\004line\030\003 \001(\005\022\013" +
+ "\n\003msg\030\004 \001(\t\022\033\n\010severity\030\005 \001(\0162\t.Severity" +
+ "\022\013\n\003tag\030\006 \003(\t\022\025\n\reffort_to_fix\030\007 \001(\001\022\022\n\n" +
+ "attributes\030\010 \001(\t\"\254\001\n\nChangesets\022\025\n\rcompo" +
+ "nent_ref\030\001 \001(\005\022(\n\tchangeset\030\002 \003(\0132\025.Chan",
+ "gesets.Changeset\022 \n\024changesetIndexByLine" +
+ "\030\003 \003(\005B\002\020\001\032;\n\tChangeset\022\020\n\010revision\030\001 \001(" +
+ "\t\022\016\n\006author\030\002 \001(\t\022\014\n\004date\030\003 \001(\003\"R\n\tDupli" +
+ "cate\022\026\n\016other_file_ref\030\001 \001(\005\022\025\n\005range\030\002 " +
+ "\001(\0132\006.Range\022\026\n\016other_file_key\030\003 \001(\t\"M\n\013D" +
+ "uplication\022\037\n\017origin_position\030\001 \001(\0132\006.Ra" +
+ "nge\022\035\n\tduplicate\030\002 \003(\0132\n.Duplicate\"W\n\005Ra" +
+ "nge\022\022\n\nstart_line\030\001 \001(\005\022\020\n\010end_line\030\002 \001(" +
+ "\005\022\024\n\014start_offset\030\003 \001(\005\022\022\n\nend_offset\030\004 " +
+ "\001(\005\"@\n\006Symbol\022\033\n\013declaration\030\001 \001(\0132\006.Ran",
+ "ge\022\031\n\treference\030\002 \003(\0132\006.Range\"\260\001\n\010Covera" +
+ "ge\022\014\n\004line\030\001 \001(\005\022\022\n\nconditions\030\002 \001(\005\022\017\n\007" +
+ "ut_hits\030\003 \001(\010\022\017\n\007it_hits\030\004 \001(\010\022\035\n\025ut_cov" +
+ "ered_conditions\030\005 \001(\005\022\035\n\025it_covered_cond" +
+ "itions\030\006 \001(\005\022\"\n\032overall_covered_conditio" +
+ "ns\030\007 \001(\005\"L\n\022SyntaxHighlighting\022\025\n\005range\030" +
+ "\001 \001(\0132\006.Range\022\037\n\004type\030\002 \001(\0162\021.Highlighti" +
+ "ngType\"j\n\004Test\022\014\n\004name\030\001 \001(\t\022\033\n\006status\030\002" +
+ " \001(\0162\013.TestStatus\022\026\n\016duration_in_ms\030\003 \001(" +
+ "\003\022\022\n\nstacktrace\030\004 \001(\t\022\013\n\003msg\030\005 \001(\t\"\221\001\n\016C",
+ "overageDetail\022\021\n\ttest_name\030\001 \001(\t\0221\n\014cove" +
+ "red_file\030\002 \003(\0132\033.CoverageDetail.CoveredF" +
+ "ile\0329\n\013CoveredFile\022\020\n\010file_ref\030\001 \001(\005\022\030\n\014" +
+ "covered_line\030\002 \003(\005B\002\020\001B#\n\037org.sonar.batc" +
+ "h.protocol.outputH\001"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
@@ -19423,45 +17803,45 @@ public final class BatchReport {
internal_static_Metadata_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_Metadata_descriptor,
- new java.lang.String[] { "AnalysisDate", "ProjectKey", "Branch", "RootComponentRef", "ActiveRuleKey", });
- internal_static_ComponentLink_descriptor =
+ new java.lang.String[] { "AnalysisDate", "ProjectKey", "Branch", "RootComponentRef", });
+ internal_static_ActiveRule_descriptor =
getDescriptor().getMessageTypes().get(1);
+ internal_static_ActiveRule_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_ActiveRule_descriptor,
+ new java.lang.String[] { "RuleRepository", "RuleKey", "Severity", "Param", });
+ internal_static_ActiveRule_ActiveRuleParam_descriptor =
+ internal_static_ActiveRule_descriptor.getNestedTypes().get(0);
+ internal_static_ActiveRule_ActiveRuleParam_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_ActiveRule_ActiveRuleParam_descriptor,
+ new java.lang.String[] { "Key", "Value", });
+ internal_static_ComponentLink_descriptor =
+ getDescriptor().getMessageTypes().get(2);
internal_static_ComponentLink_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_ComponentLink_descriptor,
new java.lang.String[] { "Type", "Href", });
internal_static_Component_descriptor =
- getDescriptor().getMessageTypes().get(2);
+ getDescriptor().getMessageTypes().get(3);
internal_static_Component_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_Component_descriptor,
new java.lang.String[] { "Ref", "Path", "Name", "Type", "IsTest", "Language", "ChildRef", "Link", "Version", "Key", "Lines", "Description", });
internal_static_Measure_descriptor =
- getDescriptor().getMessageTypes().get(3);
+ getDescriptor().getMessageTypes().get(4);
internal_static_Measure_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_Measure_descriptor,
new java.lang.String[] { "ValueType", "BooleanValue", "IntValue", "LongValue", "DoubleValue", "StringValue", "MetricKey", "Description", "VariationValue1", "VariationValue2", "VariationValue3", "VariationValue4", "VariationValue5", "PersonId", });
- internal_static_Measures_descriptor =
- getDescriptor().getMessageTypes().get(4);
- internal_static_Measures_fieldAccessorTable = new
- com.google.protobuf.GeneratedMessage.FieldAccessorTable(
- internal_static_Measures_descriptor,
- new java.lang.String[] { "ComponentRef", "Measure", });
internal_static_Issue_descriptor =
getDescriptor().getMessageTypes().get(5);
internal_static_Issue_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_Issue_descriptor,
new java.lang.String[] { "RuleRepository", "RuleKey", "Line", "Msg", "Severity", "Tag", "EffortToFix", "Attributes", });
- internal_static_Issues_descriptor =
- getDescriptor().getMessageTypes().get(6);
- internal_static_Issues_fieldAccessorTable = new
- com.google.protobuf.GeneratedMessage.FieldAccessorTable(
- internal_static_Issues_descriptor,
- new java.lang.String[] { "ComponentRef", "Issue", });
internal_static_Changesets_descriptor =
- getDescriptor().getMessageTypes().get(7);
+ getDescriptor().getMessageTypes().get(6);
internal_static_Changesets_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_Changesets_descriptor,
@@ -19473,61 +17853,49 @@ public final class BatchReport {
internal_static_Changesets_Changeset_descriptor,
new java.lang.String[] { "Revision", "Author", "Date", });
internal_static_Duplicate_descriptor =
- getDescriptor().getMessageTypes().get(8);
+ getDescriptor().getMessageTypes().get(7);
internal_static_Duplicate_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_Duplicate_descriptor,
new java.lang.String[] { "OtherFileRef", "Range", "OtherFileKey", });
internal_static_Duplication_descriptor =
- getDescriptor().getMessageTypes().get(9);
+ getDescriptor().getMessageTypes().get(8);
internal_static_Duplication_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_Duplication_descriptor,
new java.lang.String[] { "OriginPosition", "Duplicate", });
- internal_static_Duplications_descriptor =
- getDescriptor().getMessageTypes().get(10);
- internal_static_Duplications_fieldAccessorTable = new
- com.google.protobuf.GeneratedMessage.FieldAccessorTable(
- internal_static_Duplications_descriptor,
- new java.lang.String[] { "ComponentRef", "Duplication", });
internal_static_Range_descriptor =
- getDescriptor().getMessageTypes().get(11);
+ getDescriptor().getMessageTypes().get(9);
internal_static_Range_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_Range_descriptor,
new java.lang.String[] { "StartLine", "EndLine", "StartOffset", "EndOffset", });
- internal_static_Symbols_descriptor =
- getDescriptor().getMessageTypes().get(12);
- internal_static_Symbols_fieldAccessorTable = new
- com.google.protobuf.GeneratedMessage.FieldAccessorTable(
- internal_static_Symbols_descriptor,
- new java.lang.String[] { "FileRef", "Symbol", });
- internal_static_Symbols_Symbol_descriptor =
- internal_static_Symbols_descriptor.getNestedTypes().get(0);
- internal_static_Symbols_Symbol_fieldAccessorTable = new
+ internal_static_Symbol_descriptor =
+ getDescriptor().getMessageTypes().get(10);
+ internal_static_Symbol_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
- internal_static_Symbols_Symbol_descriptor,
+ internal_static_Symbol_descriptor,
new java.lang.String[] { "Declaration", "Reference", });
internal_static_Coverage_descriptor =
- getDescriptor().getMessageTypes().get(13);
+ getDescriptor().getMessageTypes().get(11);
internal_static_Coverage_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_Coverage_descriptor,
new java.lang.String[] { "Line", "Conditions", "UtHits", "ItHits", "UtCoveredConditions", "ItCoveredConditions", "OverallCoveredConditions", });
internal_static_SyntaxHighlighting_descriptor =
- getDescriptor().getMessageTypes().get(14);
+ getDescriptor().getMessageTypes().get(12);
internal_static_SyntaxHighlighting_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_SyntaxHighlighting_descriptor,
new java.lang.String[] { "Range", "Type", });
internal_static_Test_descriptor =
- getDescriptor().getMessageTypes().get(15);
+ getDescriptor().getMessageTypes().get(13);
internal_static_Test_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_Test_descriptor,
new java.lang.String[] { "Name", "Status", "DurationInMs", "Stacktrace", "Msg", });
internal_static_CoverageDetail_descriptor =
- getDescriptor().getMessageTypes().get(16);
+ getDescriptor().getMessageTypes().get(14);
internal_static_CoverageDetail_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_CoverageDetail_descriptor,
diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/ProtobufUtil.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/ProtobufUtil.java
index 3962cfd4ed1..43d8af6bfbf 100644
--- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/ProtobufUtil.java
+++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/ProtobufUtil.java
@@ -19,72 +19,103 @@
*/
package org.sonar.batch.protocol;
+import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Message;
import com.google.protobuf.Parser;
-import org.apache.commons.io.IOUtils;
-
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import org.apache.commons.io.IOUtils;
+import org.sonar.core.util.CloseableIterator;
+
+import static java.lang.String.format;
public class ProtobufUtil {
private ProtobufUtil() {
// only static stuff
}
- public static <T extends Message> T readFile(File file, Parser<T> parser) {
+ /**
+ * Returns the message contained in the given file. Throws an unchecked exception
+ * if the file does not exist or is empty.
+ */
+ public static <MSG extends Message> MSG readFile(File file, Parser<MSG> parser) {
InputStream input = null;
try {
input = new BufferedInputStream(new FileInputStream(file));
return parser.parseFrom(input);
} catch (IOException e) {
- throw new IllegalStateException("Failed to read file: " + file, e);
+ throw new IllegalStateException(format("Unable to read file %s", file), e);
} finally {
IOUtils.closeQuietly(input);
}
}
+ /**
+ * Writes a single message to a file, by replacing existing content. The message is
+ * NOT appended.
+ */
public static void writeToFile(Message message, File toFile) {
OutputStream out = null;
try {
out = new BufferedOutputStream(new FileOutputStream(toFile, false));
message.writeTo(out);
} catch (IOException e) {
- throw new IllegalStateException("Unable to write protocol buffer data to file " + toFile, e);
+ throw new IllegalStateException(format("Unable to write protobuf message to file %s", toFile), e);
} finally {
IOUtils.closeQuietly(out);
}
}
- public static void appendToFile(Message message, File toFile) {
+ public static void writeStreamToFile(Iterable<? extends Message> messages, File toFile, boolean append) {
OutputStream out = null;
try {
- out = new BufferedOutputStream(new FileOutputStream(toFile, true));
- message.writeDelimitedTo(out);
+ out = new BufferedOutputStream(new FileOutputStream(toFile, append));
+ for (Message message : messages) {
+ message.writeDelimitedTo(out);
+ }
} catch (IOException e) {
- throw new IllegalStateException("Unable to append protocol buffer data to file " + toFile, e);
+ throw new IllegalStateException(format("Unable to write protobuf messages to file %s", toFile), e);
} finally {
IOUtils.closeQuietly(out);
}
}
- public static <MESSAGE extends Message> void writeMessagesToFile(Iterable<MESSAGE> messages, File file) {
- OutputStream out = null;
+ public static <MSG extends Message> CloseableIterator<MSG> readStreamFromFile(File file, Parser<MSG> parser) {
try {
- out = new BufferedOutputStream(new FileOutputStream(file, true));
- for (MESSAGE message : messages) {
- message.writeDelimitedTo(out);
- }
- } catch (IOException e) {
- throw new IllegalStateException("Failed to read file: " + file, e);
- } finally {
- IOUtils.closeQuietly(out);
+ return new ProtobufIterator<>(parser, new BufferedInputStream(new FileInputStream(file)));
+ } catch (FileNotFoundException e) {
+ throw new IllegalStateException(format("Unable to read protobuf file %s", file), e);
}
}
+ private static class ProtobufIterator<MSG extends Message> extends CloseableIterator<MSG> {
+ private final Parser<MSG> parser;
+ private final InputStream input;
+
+ private ProtobufIterator(Parser<MSG> parser, InputStream input) {
+ this.parser = parser;
+ this.input = input;
+ }
+
+ @Override
+ protected MSG doNext() {
+ try {
+ return parser.parseDelimitedFrom(input);
+ } catch (InvalidProtocolBufferException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ @Override
+ protected void doClose() throws Exception {
+ IOUtils.closeQuietly(input);
+ }
+ }
}
diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java
index 0c13820f339..70da7179b9f 100644
--- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java
+++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java
@@ -20,10 +20,9 @@
package org.sonar.batch.protocol.output;
import java.io.File;
-import java.util.Collections;
-import java.util.List;
import javax.annotation.CheckForNull;
import org.sonar.batch.protocol.ProtobufUtil;
+import org.sonar.core.util.CloseableIterator;
public class BatchReportReader {
@@ -35,26 +34,32 @@ public class BatchReportReader {
public BatchReport.Metadata readMetadata() {
File file = fileStructure.metadataFile();
- if (!doesFileExists(file)) {
+ if (!fileExists(file)) {
throw new IllegalStateException("Metadata file is missing in analysis report: " + file);
}
return ProtobufUtil.readFile(file, BatchReport.Metadata.PARSER);
}
- public List<BatchReport.Measure> readComponentMeasures(int componentRef) {
+ public CloseableIterator<BatchReport.ActiveRule> readActiveRules() {
+ File file = fileStructure.activeRules();
+ if (!fileExists(file)) {
+ return CloseableIterator.emptyCloseableIterator();
+ }
+ return ProtobufUtil.readStreamFromFile(file, BatchReport.ActiveRule.PARSER);
+ }
+
+ public CloseableIterator<BatchReport.Measure> readComponentMeasures(int componentRef) {
File file = fileStructure.fileFor(FileStructure.Domain.MEASURES, componentRef);
- if (doesFileExists(file)) {
- // all the measures are loaded in memory
- BatchReport.Measures measures = ProtobufUtil.readFile(file, BatchReport.Measures.PARSER);
- return measures.getMeasureList();
+ if (fileExists(file)) {
+ return ProtobufUtil.readStreamFromFile(file, BatchReport.Measure.PARSER);
}
- return Collections.emptyList();
+ return CloseableIterator.emptyCloseableIterator();
}
@CheckForNull
public BatchReport.Changesets readChangesets(int componentRef) {
File file = fileStructure.fileFor(FileStructure.Domain.CHANGESETS, componentRef);
- if (doesFileExists(file)) {
+ if (fileExists(file)) {
return ProtobufUtil.readFile(file, BatchReport.Changesets.PARSER);
}
return null;
@@ -62,40 +67,34 @@ public class BatchReportReader {
public BatchReport.Component readComponent(int componentRef) {
File file = fileStructure.fileFor(FileStructure.Domain.COMPONENT, componentRef);
- if (!doesFileExists(file)) {
+ if (!fileExists(file)) {
throw new IllegalStateException("Unable to find report for component #" + componentRef + ". File does not exist: " + file);
}
return ProtobufUtil.readFile(file, BatchReport.Component.PARSER);
}
- public List<BatchReport.Issue> readComponentIssues(int componentRef) {
+ public CloseableIterator<BatchReport.Issue> readComponentIssues(int componentRef) {
File file = fileStructure.fileFor(FileStructure.Domain.ISSUES, componentRef);
- if (doesFileExists(file)) {
- // all the issues are loaded in memory
- BatchReport.Issues issues = ProtobufUtil.readFile(file, BatchReport.Issues.PARSER);
- return issues.getIssueList();
+ if (fileExists(file)) {
+ return ProtobufUtil.readStreamFromFile(file, BatchReport.Issue.PARSER);
}
- return Collections.emptyList();
+ return CloseableIterator.emptyCloseableIterator();
}
- public List<BatchReport.Duplication> readComponentDuplications(int componentRef) {
+ public CloseableIterator<BatchReport.Duplication> readComponentDuplications(int componentRef) {
File file = fileStructure.fileFor(FileStructure.Domain.DUPLICATIONS, componentRef);
- if (doesFileExists(file)) {
- // all the duplications are loaded in memory
- BatchReport.Duplications duplications = ProtobufUtil.readFile(file, BatchReport.Duplications.PARSER);
- return duplications.getDuplicationList();
+ if (fileExists(file)) {
+ return ProtobufUtil.readStreamFromFile(file, BatchReport.Duplication.PARSER);
}
- return Collections.emptyList();
+ return CloseableIterator.emptyCloseableIterator();
}
- public List<BatchReport.Symbols.Symbol> readComponentSymbols(int componentRef) {
+ public CloseableIterator<BatchReport.Symbol> readComponentSymbols(int componentRef) {
File file = fileStructure.fileFor(FileStructure.Domain.SYMBOLS, componentRef);
- if (doesFileExists(file)) {
- // all the symbols are loaded in memory
- BatchReport.Symbols symbols = ProtobufUtil.readFile(file, BatchReport.Symbols.PARSER);
- return symbols.getSymbolList();
+ if (fileExists(file)) {
+ return ProtobufUtil.readStreamFromFile(file, BatchReport.Symbol.PARSER);
}
- return Collections.emptyList();
+ return CloseableIterator.emptyCloseableIterator();
}
public boolean hasSyntaxHighlighting(int componentRef) {
@@ -106,7 +105,7 @@ public class BatchReportReader {
@CheckForNull
public File readComponentSyntaxHighlighting(int fileRef) {
File file = fileStructure.fileFor(FileStructure.Domain.SYNTAX_HIGHLIGHTINGS, fileRef);
- if (doesFileExists(file)) {
+ if (fileExists(file)) {
return file;
}
return null;
@@ -115,7 +114,7 @@ public class BatchReportReader {
@CheckForNull
public File readComponentCoverage(int fileRef) {
File file = fileStructure.fileFor(FileStructure.Domain.COVERAGES, fileRef);
- if (doesFileExists(file)) {
+ if (fileExists(file)) {
return file;
}
return null;
@@ -123,7 +122,7 @@ public class BatchReportReader {
public File readFileSource(int fileRef) {
File file = fileStructure.fileFor(FileStructure.Domain.SOURCE, fileRef);
- if (!doesFileExists(file)) {
+ if (!fileExists(file)) {
throw new IllegalStateException("Unable to find source for file #" + fileRef + ". File does not exist: " + file);
}
return file;
@@ -132,7 +131,7 @@ public class BatchReportReader {
@CheckForNull
public File readTests(int testFileRef) {
File file = fileStructure.fileFor(FileStructure.Domain.TESTS, testFileRef);
- if (doesFileExists(file)) {
+ if (fileExists(file)) {
return file;
}
@@ -142,14 +141,14 @@ public class BatchReportReader {
@CheckForNull
public File readCoverageDetails(int testFileRef) {
File file = fileStructure.fileFor(FileStructure.Domain.COVERAGE_DETAILS, testFileRef);
- if (doesFileExists(file)) {
+ if (fileExists(file)) {
return file;
}
return null;
}
- private static boolean doesFileExists(File file) {
+ private static boolean fileExists(File file) {
return file.exists() && file.isFile();
}
}
diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportWriter.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportWriter.java
index b9be0da6170..b7ac04ed116 100644
--- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportWriter.java
+++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportWriter.java
@@ -50,6 +50,11 @@ public class BatchReportWriter {
return fileStructure.metadataFile();
}
+ public File writeActiveRules(Iterable<BatchReport.ActiveRule> activeRules) {
+ ProtobufUtil.writeStreamToFile(activeRules, fileStructure.activeRules(), false);
+ return fileStructure.metadataFile();
+ }
+
public File writeComponent(BatchReport.Component component) {
File file = fileStructure.fileFor(FileStructure.Domain.COMPONENT, component.getRef());
ProtobufUtil.writeToFile(component, file);
@@ -57,20 +62,14 @@ public class BatchReportWriter {
}
public File writeComponentIssues(int componentRef, Iterable<BatchReport.Issue> issues) {
- BatchReport.Issues.Builder issuesBuilder = BatchReport.Issues.newBuilder();
- issuesBuilder.setComponentRef(componentRef);
- issuesBuilder.addAllIssue(issues);
File file = fileStructure.fileFor(FileStructure.Domain.ISSUES, componentRef);
- ProtobufUtil.writeToFile(issuesBuilder.build(), file);
+ ProtobufUtil.writeStreamToFile(issues, file, false);
return file;
}
public File writeComponentMeasures(int componentRef, Iterable<BatchReport.Measure> measures) {
- BatchReport.Measures.Builder measuresBuilder = BatchReport.Measures.newBuilder();
- measuresBuilder.setComponentRef(componentRef);
- measuresBuilder.addAllMeasure(measures);
File file = fileStructure.fileFor(FileStructure.Domain.MEASURES, componentRef);
- ProtobufUtil.writeToFile(measuresBuilder.build(), file);
+ ProtobufUtil.writeStreamToFile(measures, file, false);
return file;
}
@@ -81,44 +80,38 @@ public class BatchReportWriter {
}
public File writeComponentDuplications(int componentRef, Iterable<BatchReport.Duplication> duplications) {
- BatchReport.Duplications.Builder builder = BatchReport.Duplications.newBuilder();
- builder.setComponentRef(componentRef);
- builder.addAllDuplication(duplications);
File file = fileStructure.fileFor(FileStructure.Domain.DUPLICATIONS, componentRef);
- ProtobufUtil.writeToFile(builder.build(), file);
+ ProtobufUtil.writeStreamToFile(duplications, file, false);
return file;
}
- public File writeComponentSymbols(int componentRef, Iterable<BatchReport.Symbols.Symbol> symbols) {
- BatchReport.Symbols.Builder builder = BatchReport.Symbols.newBuilder();
- builder.setFileRef(componentRef);
- builder.addAllSymbol(symbols);
+ public File writeComponentSymbols(int componentRef, Iterable<BatchReport.Symbol> symbols) {
File file = fileStructure.fileFor(FileStructure.Domain.SYMBOLS, componentRef);
- ProtobufUtil.writeToFile(builder.build(), file);
+ ProtobufUtil.writeStreamToFile(symbols, file, false);
return file;
}
public File writeComponentSyntaxHighlighting(int componentRef, Iterable<BatchReport.SyntaxHighlighting> syntaxHighlightingRules) {
File file = fileStructure.fileFor(FileStructure.Domain.SYNTAX_HIGHLIGHTINGS, componentRef);
- ProtobufUtil.writeMessagesToFile(syntaxHighlightingRules, file);
+ ProtobufUtil.writeStreamToFile(syntaxHighlightingRules, file, false);
return file;
}
public File writeComponentCoverage(int componentRef, Iterable<BatchReport.Coverage> coverageList) {
File file = fileStructure.fileFor(FileStructure.Domain.COVERAGES, componentRef);
- ProtobufUtil.writeMessagesToFile(coverageList, file);
+ ProtobufUtil.writeStreamToFile(coverageList, file, false);
return file;
}
public File writeTests(int componentRef, Iterable<BatchReport.Test> tests) {
File file = fileStructure.fileFor(FileStructure.Domain.TESTS, componentRef);
- ProtobufUtil.writeMessagesToFile(tests, file);
+ ProtobufUtil.writeStreamToFile(tests, file, false);
return file;
}
public File writeCoverageDetails(int componentRef, Iterable<BatchReport.CoverageDetail> tests) {
File file = fileStructure.fileFor(FileStructure.Domain.COVERAGE_DETAILS, componentRef);
- ProtobufUtil.writeMessagesToFile(tests, file);
+ ProtobufUtil.writeStreamToFile(tests, file, false);
return file;
}
diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/FileStructure.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/FileStructure.java
index da641621172..6d0c9f3fa67 100644
--- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/FileStructure.java
+++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/FileStructure.java
@@ -62,6 +62,10 @@ public class FileStructure {
return new File(dir, "metadata.pb");
}
+ public File activeRules() {
+ return new File(dir, "activerules.pb");
+ }
+
public File fileFor(Domain domain, int componentRef) {
return new File(dir, domain.filePrefix + componentRef + domain.fileSuffix);
}
diff --git a/sonar-batch-protocol/src/main/protobuf/batch_report.proto b/sonar-batch-protocol/src/main/protobuf/batch_report.proto
index 6632bb8a6f9..3520f5bee01 100644
--- a/sonar-batch-protocol/src/main/protobuf/batch_report.proto
+++ b/sonar-batch-protocol/src/main/protobuf/batch_report.proto
@@ -47,19 +47,17 @@ message Metadata {
optional int32 root_component_ref = 4;
}
-message ActiveRuleParameter {
- optional string key = 1;
- optional string value = 2;
-}
-
-/*
- The rules that are enabled in the Quality profiles associated with the project
-*/
message ActiveRule {
optional string rule_repository = 1;
optional string rule_key = 2;
optional Severity severity = 3;
- repeated ActiveRuleParameter parameter = 4;
+ repeated ActiveRuleParam param = 4;
+
+ // TODO replace by map
+ message ActiveRuleParam {
+ optional string key = 1;
+ optional string value = 2;
+ }
}
message ComponentLink {
@@ -107,12 +105,6 @@ message Measure {
optional int32 person_id = 20;
}
-/* TODO to be removed. It prevents streaming */
-message Measures {
- optional int32 component_ref = 1;
- repeated Measure measure = 2;
-}
-
message Issue {
optional string rule_repository = 1;
optional string rule_key = 2;
@@ -124,12 +116,6 @@ message Issue {
optional string attributes = 8;
}
-/* TODO to be removed. It prevents streaming */
-message Issues {
- optional int32 component_ref = 1;
- repeated Issue issue = 2;
-}
-
message Changesets {
optional int32 component_ref = 1;
repeated Changeset changeset = 2;
@@ -158,11 +144,6 @@ message Duplication {
repeated Duplicate duplicate = 2;
}
-message Duplications {
- optional int32 component_ref = 1;
- repeated Duplication duplication = 2;
-}
-
// Lines start at 1 and line offsets start at 0
message Range {
// Should never be null
@@ -175,14 +156,9 @@ message Range {
optional int32 end_offset = 4;
}
-message Symbols {
- optional int32 file_ref = 1;
- repeated Symbol symbol = 2;
-
- message Symbol {
- optional Range declaration = 1;
- repeated Range reference = 2;
- }
+message Symbol {
+ optional Range declaration = 1;
+ repeated Range reference = 2;
}
// Only FILE component has coverage information, and only executable lines should contains this information.
diff --git a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/ProtobufUtilTest.java b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/ProtobufUtilTest.java
index e9e57cf74dd..04ebcf7f989 100644
--- a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/ProtobufUtilTest.java
+++ b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/ProtobufUtilTest.java
@@ -19,16 +19,53 @@
*/
package org.sonar.batch.protocol;
+import java.io.File;
+import org.apache.commons.io.FileUtils;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.rules.TemporaryFolder;
+import org.sonar.batch.protocol.output.BatchReport;
import org.sonar.test.TestUtils;
import static org.assertj.core.api.Assertions.assertThat;
public class ProtobufUtilTest {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Rule
+ public TemporaryFolder temp = new TemporaryFolder();
+
@Test
public void only_utils() {
assertThat(TestUtils.hasOnlyPrivateConstructors(ProtobufUtil.class));
}
+ @Test
+ public void readFile_fails_if_file_does_not_exist() throws Exception {
+ thrown.expect(IllegalStateException.class);
+
+ File file = temp.newFile();
+ FileUtils.forceDelete(file);
+ ProtobufUtil.readFile(file, BatchReport.Metadata.PARSER);
+ }
+
+ @Test
+ public void readFile_returns_empty_message_if_file_is_empty() throws Exception {
+ File file = temp.newFile();
+ BatchReport.Metadata msg = ProtobufUtil.readFile(file, BatchReport.Metadata.PARSER);
+ assertThat(msg).isNotNull();
+ assertThat(msg.isInitialized()).isTrue();
+ }
+
+ @Test
+ public void readFile_returns_message() throws Exception {
+ File file = temp.newFile();
+ ProtobufUtil.writeToFile(BatchReport.Metadata.getDefaultInstance(), file);
+ BatchReport.Metadata message = ProtobufUtil.readFile(file, BatchReport.Metadata.PARSER);
+ assertThat(message).isNotNull();
+ assertThat(message.isInitialized()).isTrue();
+ }
}
diff --git a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java
index 50afe349b6d..9250a23042e 100644
--- a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java
+++ b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java
@@ -42,12 +42,12 @@ public class BatchReportReaderTest {
File dir;
- BatchReportReader underTest;
+ BatchReportReader sut;
@Before
public void setUp() throws Exception {
dir = temp.newFolder();
- underTest = new BatchReportReader(dir);
+ sut = new BatchReportReader(dir);
}
@Test
@@ -59,7 +59,7 @@ public class BatchReportReaderTest {
.setRootComponentRef(1);
writer.writeMetadata(metadata.build());
- BatchReport.Metadata readMetadata = underTest.readMetadata();
+ BatchReport.Metadata readMetadata = sut.readMetadata();
assertThat(readMetadata.getAnalysisDate()).isEqualTo(15000000L);
assertThat(readMetadata.getProjectKey()).isEqualTo("PROJECT_A");
assertThat(readMetadata.getRootComponentRef()).isEqualTo(1);
@@ -67,7 +67,7 @@ public class BatchReportReaderTest {
@Test(expected = IllegalStateException.class)
public void fail_if_missing_metadata_file() {
- underTest.readMetadata();
+ sut.readMetadata();
}
@Test
@@ -78,12 +78,12 @@ public class BatchReportReaderTest {
.setPath("src/main/java/Foo.java");
writer.writeComponent(component.build());
- assertThat(underTest.readComponent(1).getPath()).isEqualTo("src/main/java/Foo.java");
+ assertThat(sut.readComponent(1).getPath()).isEqualTo("src/main/java/Foo.java");
}
@Test(expected = IllegalStateException.class)
public void fail_if_missing_file_on_component() {
- underTest.readComponent(UNKNOWN_COMPONENT_REF);
+ sut.readComponent(UNKNOWN_COMPONENT_REF);
}
@Test
@@ -94,13 +94,13 @@ public class BatchReportReaderTest {
.build();
writer.writeComponentIssues(1, Arrays.asList(issue));
- assertThat(underTest.readComponentIssues(1)).hasSize(1);
- assertThat(underTest.readComponentIssues(200)).isEmpty();
+ assertThat(sut.readComponentIssues(1)).hasSize(1);
+ assertThat(sut.readComponentIssues(200)).isEmpty();
}
@Test
public void empty_list_if_no_issue_found() {
- assertThat(underTest.readComponentIssues(UNKNOWN_COMPONENT_REF)).isEmpty();
+ assertThat(sut.readComponentIssues(UNKNOWN_COMPONENT_REF)).isEmpty();
}
@Test
@@ -110,13 +110,12 @@ public class BatchReportReaderTest {
.setStringValue("value_a");
writer.writeComponentMeasures(1, Arrays.asList(measure.build()));
- assertThat(underTest.readComponentMeasures(1)).hasSize(1);
- assertThat(underTest.readComponentMeasures(1).get(0).getStringValue()).isEqualTo("value_a");
+ assertThat(sut.readComponentMeasures(1)).hasSize(1);
}
@Test
public void empty_list_if_no_measure_found() {
- assertThat(underTest.readComponentMeasures(UNKNOWN_COMPONENT_REF)).isEmpty();
+ assertThat(sut.readComponentMeasures(UNKNOWN_COMPONENT_REF)).isEmpty();
}
@Test
@@ -127,13 +126,13 @@ public class BatchReportReaderTest {
.addChangeset(BatchReport.Changesets.Changeset.newBuilder().setDate(123_456_789).setAuthor("jack.daniels").setRevision("123-456-789"));
writer.writeComponentChangesets(scm.build());
- assertThat(underTest.readChangesets(1).getChangesetList()).hasSize(1);
- assertThat(underTest.readChangesets(1).getChangeset(0).getDate()).isEqualTo(123_456_789L);
+ assertThat(sut.readChangesets(1).getChangesetList()).hasSize(1);
+ assertThat(sut.readChangesets(1).getChangeset(0).getDate()).isEqualTo(123_456_789L);
}
@Test
public void null_if_no_changeset_found() {
- assertThat(underTest.readChangesets(UNKNOWN_COMPONENT_REF)).isNull();
+ assertThat(sut.readChangesets(UNKNOWN_COMPONENT_REF)).isNull();
}
@Test
@@ -160,15 +159,13 @@ public class BatchReportReaderTest {
.build();
writer.writeComponentDuplications(1, Arrays.asList(duplication));
- BatchReportReader underTest = new BatchReportReader(dir);
- assertThat(underTest.readComponentDuplications(1)).hasSize(1);
- assertThat(underTest.readComponentDuplications(1).get(0).getOriginPosition()).isNotNull();
- assertThat(underTest.readComponentDuplications(1).get(0).getDuplicateList()).hasSize(1);
+ BatchReportReader sut = new BatchReportReader(dir);
+ assertThat(sut.readComponentDuplications(1)).hasSize(1);
}
@Test
public void empty_list_if_no_duplication_found() {
- assertThat(underTest.readComponentDuplications(UNKNOWN_COMPONENT_REF)).isEmpty();
+ assertThat(sut.readComponentDuplications(UNKNOWN_COMPONENT_REF)).isEmpty();
}
@Test
@@ -188,9 +185,9 @@ public class BatchReportReaderTest {
.build())
.setType(Constants.HighlightingType.ANNOTATION)
.build()
- ));
+ ));
- try (InputStream inputStream = FileUtils.openInputStream(underTest.readComponentSyntaxHighlighting(1))) {
+ try (InputStream inputStream = FileUtils.openInputStream(sut.readComponentSyntaxHighlighting(1))) {
BatchReport.SyntaxHighlighting syntaxHighlighting = BatchReport.SyntaxHighlighting.PARSER.parseDelimitedFrom(inputStream);
assertThat(syntaxHighlighting.getRange()).isNotNull();
assertThat(syntaxHighlighting.getRange().getStartLine()).isEqualTo(1);
@@ -201,7 +198,7 @@ public class BatchReportReaderTest {
@Test
public void return_null_if_no_highlighting_found() {
- assertThat(underTest.readComponentSyntaxHighlighting(UNKNOWN_COMPONENT_REF)).isNull();
+ assertThat(sut.readComponentSyntaxHighlighting(UNKNOWN_COMPONENT_REF)).isNull();
}
@Test
@@ -213,7 +210,7 @@ public class BatchReportReaderTest {
writer.writeComponent(BatchReport.Component.newBuilder()
.setRef(1).build());
- writer.writeComponentSymbols(1, Arrays.asList(BatchReport.Symbols.Symbol.newBuilder()
+ writer.writeComponentSymbols(1, Arrays.asList(BatchReport.Symbol.newBuilder()
.setDeclaration(BatchReport.Range.newBuilder()
.setStartLine(1)
.setStartOffset(3)
@@ -228,15 +225,13 @@ public class BatchReportReaderTest {
.build())
.build()));
- underTest = new BatchReportReader(dir);
- assertThat(underTest.readComponentSymbols(1)).hasSize(1);
- assertThat(underTest.readComponentSymbols(1).get(0).getDeclaration().getStartLine()).isEqualTo(1);
- assertThat(underTest.readComponentSymbols(1).get(0).getReference(0).getStartLine()).isEqualTo(10);
+ sut = new BatchReportReader(dir);
+ assertThat(sut.readComponentSymbols(1)).hasSize(1);
}
@Test
public void empty_list_if_no_symbol_found() {
- assertThat(underTest.readComponentSymbols(UNKNOWN_COMPONENT_REF)).isEmpty();
+ assertThat(sut.readComponentSymbols(UNKNOWN_COMPONENT_REF)).isEmpty();
}
@Test
@@ -268,7 +263,7 @@ public class BatchReportReaderTest {
.setOverallCoveredConditions(5)
.build()));
- underTest = new BatchReportReader(dir);
+ sut = new BatchReportReader(dir);
try (InputStream inputStream = FileUtils.openInputStream(new BatchReportReader(dir).readComponentCoverage(1))) {
BatchReport.Coverage coverage = BatchReport.Coverage.PARSER.parseDelimitedFrom(inputStream);
@@ -293,7 +288,7 @@ public class BatchReportReaderTest {
@Test
public void return_null_if_no_coverage_found() {
- assertThat(underTest.readComponentCoverage(UNKNOWN_COMPONENT_REF)).isNull();
+ assertThat(sut.readComponentCoverage(UNKNOWN_COMPONENT_REF)).isNull();
}
@Test
@@ -317,7 +312,7 @@ public class BatchReportReaderTest {
.setStatus(Constants.TestStatus.OK)
.build()));
- try (InputStream inputStream = FileUtils.openInputStream(underTest.readTests(1))) {
+ try (InputStream inputStream = FileUtils.openInputStream(sut.readTests(1))) {
BatchReport.Test testResult = BatchReport.Test.PARSER.parseDelimitedFrom(inputStream);
assertThat(testResult.getDurationInMs()).isEqualTo(60_000);
assertThat(testResult.getStacktrace()).isEqualTo("stacktrace");
@@ -328,7 +323,7 @@ public class BatchReportReaderTest {
@Test
public void null_if_no_test_found() {
- assertThat(underTest.readTests(UNKNOWN_COMPONENT_REF)).isNull();
+ assertThat(sut.readTests(UNKNOWN_COMPONENT_REF)).isNull();
}
@Test
@@ -338,13 +333,13 @@ public class BatchReportReaderTest {
BatchReport.CoverageDetail.newBuilder()
.setTestName("test-name")
.addCoveredFile(BatchReport.CoverageDetail.CoveredFile.newBuilder()
- .addAllCoveredLine(Arrays.asList(1, 2, 3, 5, 7))
- .setFileRef(2)
+ .addAllCoveredLine(Arrays.asList(1, 2, 3, 5, 7))
+ .setFileRef(2)
)
.build()
- ));
+ ));
- try (InputStream inputStream = FileUtils.openInputStream(underTest.readCoverageDetails(1))) {
+ try (InputStream inputStream = FileUtils.openInputStream(sut.readCoverageDetails(1))) {
BatchReport.CoverageDetail coverageDetail = BatchReport.CoverageDetail.PARSER.parseDelimitedFrom(inputStream);
assertThat(coverageDetail.getTestName()).isEqualTo("test-name");
assertThat(coverageDetail.getCoveredFile(0).getFileRef()).isEqualTo(2);
@@ -354,7 +349,7 @@ public class BatchReportReaderTest {
@Test
public void null_if_no_coverage_detail_found() {
- assertThat(underTest.readCoverageDetails(UNKNOWN_COMPONENT_REF)).isNull();
+ assertThat(sut.readCoverageDetails(UNKNOWN_COMPONENT_REF)).isNull();
}
}
diff --git a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportWriterTest.java b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportWriterTest.java
index 18716f7332f..9154effb05c 100644
--- a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportWriterTest.java
+++ b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportWriterTest.java
@@ -19,6 +19,9 @@
*/
package org.sonar.batch.protocol.output;
+import com.google.common.collect.Iterators;
+import java.io.File;
+import java.util.Arrays;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Rule;
@@ -27,9 +30,7 @@ import org.junit.rules.TemporaryFolder;
import org.sonar.batch.protocol.Constants;
import org.sonar.batch.protocol.ProtobufUtil;
import org.sonar.batch.protocol.output.BatchReport.Range;
-
-import java.io.File;
-import java.util.Arrays;
+import org.sonar.core.util.CloseableIterator;
import static org.assertj.core.api.Assertions.assertThat;
@@ -110,9 +111,9 @@ public class BatchReportWriterTest {
assertThat(underTest.hasComponentData(FileStructure.Domain.ISSUES, 1)).isTrue();
File file = underTest.getFileStructure().fileFor(FileStructure.Domain.ISSUES, 1);
assertThat(file).exists().isFile();
- BatchReport.Issues read = ProtobufUtil.readFile(file, BatchReport.Issues.PARSER);
- assertThat(read.getComponentRef()).isEqualTo(1);
- assertThat(read.getIssueCount()).isEqualTo(1);
+ try (CloseableIterator<BatchReport.Issue> read = ProtobufUtil.readStreamFromFile(file, BatchReport.Issue.PARSER)) {
+ assertThat(Iterators.size(read)).isEqualTo(1);
+ }
}
@Test
@@ -131,13 +132,9 @@ public class BatchReportWriterTest {
assertThat(underTest.hasComponentData(FileStructure.Domain.MEASURES, 1)).isTrue();
File file = underTest.getFileStructure().fileFor(FileStructure.Domain.MEASURES, 1);
assertThat(file).exists().isFile();
- BatchReport.Measures measures = ProtobufUtil.readFile(file, BatchReport.Measures.PARSER);
- assertThat(measures.getComponentRef()).isEqualTo(1);
- assertThat(measures.getMeasureCount()).isEqualTo(1);
- assertThat(measures.getMeasure(0).getStringValue()).isEqualTo("text-value");
- assertThat(measures.getMeasure(0).getDoubleValue()).isEqualTo(2.5d);
- assertThat(measures.getMeasure(0).getValueType()).isEqualTo(Constants.MeasureValueType.DOUBLE);
- assertThat(measures.getMeasure(0).getDescription()).isEqualTo("description");
+ try (CloseableIterator<BatchReport.Measure> read = ProtobufUtil.readStreamFromFile(file, BatchReport.Measure.PARSER)) {
+ assertThat(Iterators.size(read)).isEqualTo(1);
+ }
}
@Test
@@ -188,11 +185,11 @@ public class BatchReportWriterTest {
assertThat(underTest.hasComponentData(FileStructure.Domain.DUPLICATIONS, 1)).isTrue();
File file = underTest.getFileStructure().fileFor(FileStructure.Domain.DUPLICATIONS, 1);
assertThat(file).exists().isFile();
- BatchReport.Duplications duplications = ProtobufUtil.readFile(file, BatchReport.Duplications.PARSER);
- assertThat(duplications.getComponentRef()).isEqualTo(1);
- assertThat(duplications.getDuplicationList()).hasSize(1);
- assertThat(duplications.getDuplication(0).getOriginPosition()).isNotNull();
- assertThat(duplications.getDuplication(0).getDuplicateList()).hasSize(1);
+ try (CloseableIterator<BatchReport.Duplication> duplications = ProtobufUtil.readStreamFromFile(file, BatchReport.Duplication.PARSER)) {
+ BatchReport.Duplication dup = duplications.next();
+ assertThat(dup.getOriginPosition()).isNotNull();
+ assertThat(dup.getDuplicateList()).hasSize(1);
+ }
}
@Test
@@ -201,7 +198,7 @@ public class BatchReportWriterTest {
assertThat(underTest.hasComponentData(FileStructure.Domain.SYMBOLS, 1)).isFalse();
// write data
- BatchReport.Symbols.Symbol symbol = BatchReport.Symbols.Symbol.newBuilder()
+ BatchReport.Symbol symbol = BatchReport.Symbol.newBuilder()
.setDeclaration(BatchReport.Range.newBuilder()
.setStartLine(1)
.setStartOffset(3)
@@ -222,11 +219,9 @@ public class BatchReportWriterTest {
File file = underTest.getFileStructure().fileFor(FileStructure.Domain.SYMBOLS, 1);
assertThat(file).exists().isFile();
- BatchReport.Symbols read = ProtobufUtil.readFile(file, BatchReport.Symbols.PARSER);
- assertThat(read.getFileRef()).isEqualTo(1);
- assertThat(read.getSymbolList()).hasSize(1);
- assertThat(read.getSymbol(0).getDeclaration().getStartLine()).isEqualTo(1);
- assertThat(read.getSymbol(0).getReference(0).getStartLine()).isEqualTo(10);
+ try (CloseableIterator<BatchReport.Symbol> read = ProtobufUtil.readStreamFromFile(file, BatchReport.Symbol.PARSER)) {
+ assertThat(read).hasSize(1);
+ }
}
@Test
diff --git a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java
index 9b6ece676b1..c937a7fc32a 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java
@@ -22,6 +22,17 @@ package org.sonar.batch.mediumtest;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
+import java.io.File;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
@@ -37,36 +48,24 @@ import org.sonar.api.batch.sensor.duplication.Duplication;
import org.sonar.api.batch.sensor.highlighting.TypeOfText;
import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure;
import org.sonar.api.issue.Issue;
-import org.sonar.core.issue.DefaultIssue;
import org.sonar.api.measures.Measure;
import org.sonar.batch.duplication.DuplicationCache;
-import org.sonar.batch.index.Cache.Entry;
import org.sonar.batch.index.BatchComponentCache;
+import org.sonar.batch.index.Cache.Entry;
import org.sonar.batch.issue.IssueCache;
import org.sonar.batch.protocol.output.BatchReport;
import org.sonar.batch.protocol.output.BatchReport.Component;
import org.sonar.batch.protocol.output.BatchReport.Metadata;
import org.sonar.batch.protocol.output.BatchReport.Range;
-import org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol;
+import org.sonar.batch.protocol.output.BatchReport.Symbol;
import org.sonar.batch.protocol.output.BatchReportReader;
import org.sonar.batch.report.BatchReportUtils;
import org.sonar.batch.report.ReportPublisher;
import org.sonar.batch.scan.ProjectScanContainer;
import org.sonar.batch.scan.filesystem.InputPathCache;
import org.sonar.batch.scan.measure.MeasureCache;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import org.sonar.core.issue.DefaultIssue;
+import org.sonar.core.util.CloseableIterator;
public class TaskResult implements org.sonar.batch.mediumtest.ScanTaskObserver {
@@ -237,13 +236,12 @@ public class TaskResult implements org.sonar.batch.mediumtest.ScanTaskObserver {
@CheckForNull
public List<Range> symbolReferencesFor(InputFile file, int symbolStartLine, int symbolStartLineOffset) {
int ref = reportComponents.get(((DefaultInputFile) file).key()).getRef();
- List<Symbol> symbols = getReportReader().readComponentSymbols(ref);
- if (symbols.isEmpty()) {
- return Collections.emptyList();
- }
- for (Symbol symbol : symbols) {
- if (symbol.getDeclaration().getStartLine() == symbolStartLine && symbol.getDeclaration().getStartOffset() == symbolStartLineOffset) {
- return symbol.getReferenceList();
+ try (CloseableIterator<Symbol> symbols = getReportReader().readComponentSymbols(ref)) {
+ while (symbols.hasNext()) {
+ Symbol symbol = symbols.next();
+ if (symbol.getDeclaration().getStartLine() == symbolStartLine && symbol.getDeclaration().getStartOffset() == symbolStartLineOffset) {
+ return symbol.getReferenceList();
+ }
}
}
return Collections.emptyList();
diff --git a/sonar-batch/src/main/java/org/sonar/batch/report/ActiveRulesPublisher.java b/sonar-batch/src/main/java/org/sonar/batch/report/ActiveRulesPublisher.java
new file mode 100644
index 00000000000..b31bb9b3197
--- /dev/null
+++ b/sonar-batch/src/main/java/org/sonar/batch/report/ActiveRulesPublisher.java
@@ -0,0 +1,62 @@
+/*
+ * 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.batch.report;
+
+import com.google.common.base.Function;
+import com.google.common.collect.FluentIterable;
+import java.util.Map;
+import javax.annotation.Nonnull;
+import org.sonar.api.batch.rule.ActiveRule;
+import org.sonar.api.batch.rule.ActiveRules;
+import org.sonar.batch.protocol.Constants;
+import org.sonar.batch.protocol.output.BatchReport;
+import org.sonar.batch.protocol.output.BatchReportWriter;
+
+public class ActiveRulesPublisher implements ReportPublisherStep {
+
+ private final ActiveRules activeRules;
+
+ public ActiveRulesPublisher(ActiveRules activeRules) {
+ this.activeRules = activeRules;
+ }
+
+ @Override
+ public void publish(BatchReportWriter writer) {
+ Iterable<BatchReport.ActiveRule> activeRuleMessages = FluentIterable.from(activeRules.findAll()).transform(new ToMessage());
+ writer.writeActiveRules(activeRuleMessages);
+ }
+
+ private class ToMessage implements Function<ActiveRule, BatchReport.ActiveRule> {
+ private final BatchReport.ActiveRule.Builder builder = BatchReport.ActiveRule.newBuilder();
+
+ @Override
+ public BatchReport.ActiveRule apply(@Nonnull ActiveRule input) {
+ builder.clear();
+ builder.setRuleRepository(input.ruleKey().repository());
+ builder.setRuleKey(input.ruleKey().rule());
+ builder.setSeverity(Constants.Severity.valueOf(input.severity()));
+ for (Map.Entry<String, String> entry : input.params().entrySet()) {
+ builder.addParamBuilder().setKey(entry.getKey()).setValue(entry.getValue()).build();
+
+ }
+ return builder.build();
+ }
+ }
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/report/MetadataPublisher.java b/sonar-batch/src/main/java/org/sonar/batch/report/MetadataPublisher.java
index d5c4152d541..52e98b53d81 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/report/MetadataPublisher.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/report/MetadataPublisher.java
@@ -19,12 +19,8 @@
*/
package org.sonar.batch.report;
-import com.google.common.base.Function;
-import javax.annotation.Nonnull;
import org.sonar.api.CoreProperties;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.batch.rule.ActiveRule;
-import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.resources.Project;
import org.sonar.batch.index.BatchComponent;
import org.sonar.batch.index.BatchComponentCache;
@@ -32,18 +28,14 @@ import org.sonar.batch.protocol.output.BatchReport;
import org.sonar.batch.protocol.output.BatchReportWriter;
import org.sonar.batch.scan.ImmutableProjectReactor;
-import static com.google.common.collect.FluentIterable.from;
-
public class MetadataPublisher implements ReportPublisherStep {
private final BatchComponentCache componentCache;
private final ImmutableProjectReactor reactor;
- private final ActiveRules activeRules;
- public MetadataPublisher(BatchComponentCache componentCache, ImmutableProjectReactor reactor, ActiveRules activeRules) {
+ public MetadataPublisher(BatchComponentCache componentCache, ImmutableProjectReactor reactor) {
this.componentCache = componentCache;
this.reactor = reactor;
- this.activeRules = activeRules;
}
@Override
@@ -59,16 +51,6 @@ public class MetadataPublisher implements ReportPublisherStep {
if (branch != null) {
builder.setBranch(branch);
}
- builder.addAllActiveRuleKey(from(activeRules.findAll()).transform(ToRuleKey.INSTANCE));
writer.writeMetadata(builder.build());
}
-
- private enum ToRuleKey implements Function<ActiveRule, String> {
- INSTANCE;
- @Nonnull
- @Override
- public String apply(@Nonnull ActiveRule input) {
- return input.ruleKey().toString();
- }
- }
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
index 0d844339fba..06d0a4423a2 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
@@ -54,6 +54,7 @@ import org.sonar.batch.issue.tracking.ServerIssueRepository;
import org.sonar.batch.mediumtest.ScanTaskObservers;
import org.sonar.batch.phases.PhasesTimeProfiler;
import org.sonar.batch.profiling.PhasesSumUpTimeProfiler;
+import org.sonar.batch.report.ActiveRulesPublisher;
import org.sonar.batch.report.ComponentsPublisher;
import org.sonar.batch.report.CoveragePublisher;
import org.sonar.batch.report.DuplicationsPublisher;
@@ -184,6 +185,7 @@ public class ProjectScanContainer extends ComponentContainer {
// Report
ReportPublisher.class,
MetadataPublisher.class,
+ ActiveRulesPublisher.class,
ComponentsPublisher.class,
IssuesPublisher.class,
MeasuresPublisher.class,
diff --git a/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java b/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java
index 1d90a8ce3ff..f1adc47cf10 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java
@@ -200,12 +200,12 @@ public class DefaultSensorStorage implements SensorStorage {
public void store(DefaultInputFile inputFile, Map<Symbol, Set<TextRange>> referencesBySymbol) {
BatchReportWriter writer = reportPublisher.getWriter();
writer.writeComponentSymbols(resourceCache.get(inputFile).batchId(),
- Iterables.transform(referencesBySymbol.entrySet(), new Function<Map.Entry<Symbol, Set<TextRange>>, BatchReport.Symbols.Symbol>() {
- private BatchReport.Symbols.Symbol.Builder builder = BatchReport.Symbols.Symbol.newBuilder();
+ Iterables.transform(referencesBySymbol.entrySet(), new Function<Map.Entry<Symbol, Set<TextRange>>, BatchReport.Symbol>() {
+ private BatchReport.Symbol.Builder builder = BatchReport.Symbol.newBuilder();
private Range.Builder rangeBuilder = Range.newBuilder();
@Override
- public BatchReport.Symbols.Symbol apply(Map.Entry<Symbol, Set<TextRange>> input) {
+ public BatchReport.Symbol apply(Map.Entry<Symbol, Set<TextRange>> input) {
builder.clear();
rangeBuilder.clear();
DefaultSymbol symbol = (DefaultSymbol) input.getKey();
diff --git a/sonar-batch/src/test/java/org/sonar/batch/report/ActiveRulesPublisherTest.java b/sonar-batch/src/test/java/org/sonar/batch/report/ActiveRulesPublisherTest.java
new file mode 100644
index 00000000000..40a3acc7734
--- /dev/null
+++ b/sonar-batch/src/test/java/org/sonar/batch/report/ActiveRulesPublisherTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.batch.report;
+
+import java.io.File;
+import java.util.Arrays;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.sonar.api.batch.rule.ActiveRules;
+import org.sonar.api.batch.rule.Severity;
+import org.sonar.api.batch.rule.internal.ActiveRulesBuilder;
+import org.sonar.api.batch.rule.internal.DefaultActiveRules;
+import org.sonar.api.batch.rule.internal.NewActiveRule;
+import org.sonar.api.rule.RuleKey;
+import org.sonar.batch.protocol.Constants;
+import org.sonar.batch.protocol.output.BatchReport;
+import org.sonar.batch.protocol.output.BatchReportReader;
+import org.sonar.batch.protocol.output.BatchReportWriter;
+import org.sonar.core.util.CloseableIterator;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class ActiveRulesPublisherTest {
+
+ @Rule
+ public TemporaryFolder temp = new TemporaryFolder();
+
+ @Test
+ public void write() throws Exception {
+ File outputDir = temp.newFolder();
+ BatchReportWriter writer = new BatchReportWriter(outputDir);
+
+ NewActiveRule ar = new ActiveRulesBuilder().create(RuleKey.of("java", "S001")).setSeverity("BLOCKER").setParam("p1", "v1");
+ ActiveRules activeRules = new DefaultActiveRules(Arrays.asList(ar));
+
+ ActiveRulesPublisher underTest = new ActiveRulesPublisher(activeRules);
+ underTest.publish(writer);
+
+ BatchReportReader reader = new BatchReportReader(outputDir);
+ try (CloseableIterator<BatchReport.ActiveRule> readIt = reader.readActiveRules()) {
+ BatchReport.ActiveRule reportAr = readIt.next();
+ assertThat(reportAr.getRuleRepository()).isEqualTo("java");
+ assertThat(reportAr.getRuleKey()).isEqualTo("S001");
+ assertThat(reportAr.getSeverity()).isEqualTo(Constants.Severity.BLOCKER);
+ assertThat(reportAr.getParamCount()).isEqualTo(1);
+ assertThat(reportAr.getParam(0).getKey()).isEqualTo("p1");
+ assertThat(reportAr.getParam(0).getValue()).isEqualTo("v1");
+
+ assertThat(readIt.hasNext()).isFalse();
+ }
+ }
+}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/report/DuplicationsPublisherTest.java b/sonar-batch/src/test/java/org/sonar/batch/report/DuplicationsPublisherTest.java
index 4c64bd4b2c9..8fe1eff1f17 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/report/DuplicationsPublisherTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/report/DuplicationsPublisherTest.java
@@ -28,6 +28,7 @@ import org.sonar.api.batch.sensor.duplication.internal.DefaultDuplication;
import org.sonar.api.resources.Project;
import org.sonar.batch.duplication.DuplicationCache;
import org.sonar.batch.index.BatchComponentCache;
+import org.sonar.batch.protocol.output.BatchReport;
import org.sonar.batch.protocol.output.BatchReportReader;
import org.sonar.batch.protocol.output.BatchReportWriter;
@@ -35,6 +36,7 @@ import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import org.sonar.core.util.CloseableIterator;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.anyString;
@@ -85,31 +87,33 @@ public class DuplicationsPublisherTest {
BatchReportReader reader = new BatchReportReader(outputDir);
assertThat(reader.readComponentDuplications(1)).hasSize(0);
- List<org.sonar.batch.protocol.output.BatchReport.Duplication> componentDuplications = reader.readComponentDuplications(2);
- assertThat(componentDuplications).hasSize(3);
- org.sonar.batch.protocol.output.BatchReport.Duplication savedDup1 = componentDuplications.get(0);
- assertThat(savedDup1.getOriginPosition().getStartLine()).isEqualTo(1);
- assertThat(savedDup1.getOriginPosition().getEndLine()).isEqualTo(10);
- assertThat(savedDup1.getDuplicate(0).hasOtherFileKey()).isFalse();
- assertThat(savedDup1.getDuplicate(0).hasOtherFileRef()).isFalse();
- assertThat(savedDup1.getDuplicate(0).getRange().getStartLine()).isEqualTo(20);
- assertThat(savedDup1.getDuplicate(0).getRange().getEndLine()).isEqualTo(50);
-
- org.sonar.batch.protocol.output.BatchReport.Duplication savedDup2 = componentDuplications.get(1);
- assertThat(savedDup2.getOriginPosition().getStartLine()).isEqualTo(11);
- assertThat(savedDup2.getOriginPosition().getEndLine()).isEqualTo(20);
- assertThat(savedDup2.getDuplicate(0).getOtherFileKey()).isEqualTo("another");
- assertThat(savedDup2.getDuplicate(0).hasOtherFileRef()).isFalse();
- assertThat(savedDup2.getDuplicate(0).getRange().getStartLine()).isEqualTo(20);
- assertThat(savedDup2.getDuplicate(0).getRange().getEndLine()).isEqualTo(50);
-
- org.sonar.batch.protocol.output.BatchReport.Duplication savedDup3 = componentDuplications.get(2);
- assertThat(savedDup3.getOriginPosition().getStartLine()).isEqualTo(11);
- assertThat(savedDup3.getOriginPosition().getEndLine()).isEqualTo(20);
- assertThat(savedDup3.getDuplicate(0).hasOtherFileKey()).isFalse();
- assertThat(savedDup3.getDuplicate(0).getOtherFileRef()).isEqualTo(3);
- assertThat(savedDup3.getDuplicate(0).getRange().getStartLine()).isEqualTo(20);
- assertThat(savedDup3.getDuplicate(0).getRange().getEndLine()).isEqualTo(50);
+ try (CloseableIterator<BatchReport.Duplication> componentDuplications = reader.readComponentDuplications(2)) {
+ org.sonar.batch.protocol.output.BatchReport.Duplication savedDup1 = componentDuplications.next();
+ assertThat(savedDup1.getOriginPosition().getStartLine()).isEqualTo(1);
+ assertThat(savedDup1.getOriginPosition().getEndLine()).isEqualTo(10);
+ assertThat(savedDup1.getDuplicate(0).hasOtherFileKey()).isFalse();
+ assertThat(savedDup1.getDuplicate(0).hasOtherFileRef()).isFalse();
+ assertThat(savedDup1.getDuplicate(0).getRange().getStartLine()).isEqualTo(20);
+ assertThat(savedDup1.getDuplicate(0).getRange().getEndLine()).isEqualTo(50);
+
+ org.sonar.batch.protocol.output.BatchReport.Duplication savedDup2 = componentDuplications.next();
+ assertThat(savedDup2.getOriginPosition().getStartLine()).isEqualTo(11);
+ assertThat(savedDup2.getOriginPosition().getEndLine()).isEqualTo(20);
+ assertThat(savedDup2.getDuplicate(0).getOtherFileKey()).isEqualTo("another");
+ assertThat(savedDup2.getDuplicate(0).hasOtherFileRef()).isFalse();
+ assertThat(savedDup2.getDuplicate(0).getRange().getStartLine()).isEqualTo(20);
+ assertThat(savedDup2.getDuplicate(0).getRange().getEndLine()).isEqualTo(50);
+
+ org.sonar.batch.protocol.output.BatchReport.Duplication savedDup3 = componentDuplications.next();
+ assertThat(savedDup3.getOriginPosition().getStartLine()).isEqualTo(11);
+ assertThat(savedDup3.getOriginPosition().getEndLine()).isEqualTo(20);
+ assertThat(savedDup3.getDuplicate(0).hasOtherFileKey()).isFalse();
+ assertThat(savedDup3.getDuplicate(0).getOtherFileRef()).isEqualTo(3);
+ assertThat(savedDup3.getDuplicate(0).getRange().getStartLine()).isEqualTo(20);
+ assertThat(savedDup3.getDuplicate(0).getRange().getEndLine()).isEqualTo(50);
+
+ assertThat(componentDuplications.hasNext()).isFalse();
+ }
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java b/sonar-batch/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java
index 157f1e60f62..86d92891346 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java
@@ -22,7 +22,6 @@ package org.sonar.batch.report;
import java.io.File;
import java.util.Collections;
import java.util.Date;
-import java.util.List;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -35,9 +34,11 @@ import org.sonar.api.measures.MetricFinder;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.batch.index.BatchComponentCache;
+import org.sonar.batch.protocol.output.BatchReport;
import org.sonar.batch.protocol.output.BatchReportReader;
import org.sonar.batch.protocol.output.BatchReportWriter;
import org.sonar.batch.scan.measure.MeasureCache;
+import org.sonar.core.util.CloseableIterator;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
@@ -112,10 +113,9 @@ public class MeasuresPublisherTest {
BatchReportReader reader = new BatchReportReader(outputDir);
assertThat(reader.readComponentMeasures(1)).hasSize(0);
- List<org.sonar.batch.protocol.output.BatchReport.Measure> componentMeasures = reader.readComponentMeasures(2);
- assertThat(componentMeasures).hasSize(6);
- assertThat(componentMeasures.get(0).getDoubleValue()).isEqualTo(2.0);
- assertThat(componentMeasures.get(0).getPersonId()).isEqualTo(2);
+ try (CloseableIterator<BatchReport.Measure> componentMeasures = reader.readComponentMeasures(2)) {
+ assertThat(componentMeasures).hasSize(6);
+ }
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/report/MetadataPublisherTest.java b/sonar-batch/src/test/java/org/sonar/batch/report/MetadataPublisherTest.java
index 7e67177a5ec..eab392c374f 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/report/MetadataPublisherTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/report/MetadataPublisherTest.java
@@ -20,7 +20,6 @@
package org.sonar.batch.report;
import java.io.File;
-import java.util.Collections;
import java.util.Date;
import org.junit.Before;
import org.junit.Rule;
@@ -28,9 +27,6 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.CoreProperties;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.batch.rule.ActiveRules;
-import org.sonar.api.batch.rule.internal.DefaultActiveRules;
-import org.sonar.api.batch.rule.internal.NewActiveRule;
import org.sonar.api.resources.Project;
import org.sonar.batch.index.BatchComponentCache;
import org.sonar.batch.protocol.output.BatchReport;
@@ -45,7 +41,6 @@ public class MetadataPublisherTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
- ActiveRules activeRules = new DefaultActiveRules(Collections.<NewActiveRule>emptyList());
ProjectDefinition projectDef;
Project project;
@@ -59,12 +54,11 @@ public class MetadataPublisherTest {
org.sonar.api.resources.Resource sampleFile = org.sonar.api.resources.File.create("src/Foo.php").setEffectiveKey("foo:src/Foo.php");
componentCache.add(project, null);
componentCache.add(sampleFile, project);
- underTest = new MetadataPublisher(componentCache, new ImmutableProjectReactor(projectDef), activeRules);
+ underTest = new MetadataPublisher(componentCache, new ImmutableProjectReactor(projectDef));
}
@Test
public void write_metadata() throws Exception {
-
File outputDir = temp.newFolder();
BatchReportWriter writer = new BatchReportWriter(outputDir);
@@ -74,7 +68,6 @@ public class MetadataPublisherTest {
BatchReport.Metadata metadata = reader.readMetadata();
assertThat(metadata.getAnalysisDate()).isEqualTo(1234567L);
assertThat(metadata.getProjectKey()).isEqualTo("foo");
-
}
@Test
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java
index 9439aad99c5..5cc063aba2d 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java
@@ -265,8 +265,14 @@ public class DefaultIssue implements Issue, Trackable {
}
public DefaultIssue setEffortToFix(@Nullable Double d) {
- Preconditions.checkArgument(d == null || d >= 0, "Effort to fix must be greater than or equal 0 (got " + d + ")");
- this.effortToFix = d;
+ //Preconditions.checkArgument(d == null || d >= 0, "Effort to fix must be greater than or equal 0 (got " + d + ")");
+ if (d != null) {
+ // FIXME this is temp hack while Decorator are not dropped (Comment Density common-rule is buggy as
+ // the measure comment_line_density is compute by CE)
+ this.effortToFix = Math.max(d, 0.0);
+ } else {
+ this.effortToFix = null;
+ }
return this;
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/util/CloseableIterator.java b/sonar-core/src/main/java/org/sonar/core/util/CloseableIterator.java
index 2c7665b7492..ba8e6dca5fc 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/util/CloseableIterator.java
+++ b/sonar-core/src/main/java/org/sonar/core/util/CloseableIterator.java
@@ -17,7 +17,7 @@
* 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.util;
+package org.sonar.core.util;
import com.google.common.base.Throwables;
import java.util.Iterator;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/util/CloseableIteratorTest.java b/sonar-core/src/test/java/org/sonar/core/util/CloseableIteratorTest.java
index 74bf4ddb82e..e2ed7b82a28 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/util/CloseableIteratorTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/CloseableIteratorTest.java
@@ -17,7 +17,7 @@
* 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.util;
+package org.sonar.core.util;
import java.io.IOException;
import java.util.Collections;