SONAR-23250 Revert changes made in the plugin API for ActiveRule
This commit is contained in:
parent
691fe9681e
commit
dd9ebd6a6f
|
|
@ -5,7 +5,7 @@ version=10.8
|
|||
# 30 months from the release date for LTA versions
|
||||
# No change required for patch versions
|
||||
versionEOL=2025-05-27
|
||||
pluginApiVersion=10.12.0.2522
|
||||
pluginApiVersion=10.11.0.2468
|
||||
description=Open source platform for continuous inspection of code quality
|
||||
projectTitle=SonarQube
|
||||
org.gradle.jvmargs=-Xmx2048m
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ public class DefaultActiveRule implements ActiveRule {
|
|||
return severity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<SoftwareQuality, Severity> impacts() {
|
||||
return impacts;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import org.apache.commons.io.FileUtils;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.sonar.api.batch.rule.LoadedActiveRule;
|
||||
import org.sonar.scanner.rule.LoadedActiveRule;
|
||||
import org.sonar.api.rule.RuleKey;
|
||||
import org.sonar.scanner.mediumtest.AnalysisResult;
|
||||
import org.sonar.scanner.mediumtest.ScannerMediumTester;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import org.junit.Rule;
|
|||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.slf4j.event.Level;
|
||||
import org.sonar.api.batch.rule.LoadedActiveRule;
|
||||
import org.sonar.scanner.rule.LoadedActiveRule;
|
||||
import org.sonar.api.rule.RuleKey;
|
||||
import org.sonar.api.testfixtures.log.LogTester;
|
||||
import org.sonar.scanner.mediumtest.AnalysisResult;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import org.sonar.api.batch.fs.internal.DefaultInputComponent;
|
|||
import org.sonar.api.batch.fs.internal.DefaultInputFile;
|
||||
import org.sonar.api.batch.rule.ActiveRule;
|
||||
import org.sonar.api.batch.rule.ActiveRules;
|
||||
import org.sonar.api.batch.rule.internal.DefaultActiveRule;
|
||||
import org.sonar.api.batch.sensor.issue.ExternalIssue;
|
||||
import org.sonar.api.batch.sensor.issue.Issue;
|
||||
import org.sonar.api.batch.sensor.issue.Issue.Flow;
|
||||
|
|
@ -78,7 +79,7 @@ public class IssuePublisher {
|
|||
return false;
|
||||
}
|
||||
|
||||
ScannerReport.Issue rawIssue = createReportIssue(issue, inputComponent.scannerId(), activeRule.severity(), activeRule.impacts());
|
||||
ScannerReport.Issue rawIssue = createReportIssue(issue, inputComponent.scannerId(), activeRule.severity(), ((DefaultActiveRule) activeRule).impacts());
|
||||
|
||||
if (filters.accept(inputComponent, rawIssue)) {
|
||||
write(inputComponent.scannerId(), rawIssue);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
package org.sonar.scanner.rule;
|
||||
|
||||
import java.util.List;
|
||||
import org.sonar.api.batch.rule.LoadedActiveRule;
|
||||
|
||||
public interface ActiveRulesLoader {
|
||||
List<LoadedActiveRule> load(String qualityProfileKey);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.sonar.api.batch.rule.LoadedActiveRule;
|
||||
import org.sonar.api.batch.rule.internal.ActiveRulesBuilder;
|
||||
import org.sonar.api.batch.rule.internal.DefaultActiveRules;
|
||||
import org.sonar.api.batch.rule.internal.NewActiveRule;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.sonar.api.batch.rule.LoadedActiveRule;
|
||||
import org.sonar.api.impl.utils.ScannerUtils;
|
||||
import org.sonar.api.issue.impact.Severity;
|
||||
import org.sonar.api.issue.impact.SoftwareQuality;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* SonarQube
|
||||
* Copyright (C) 2009-2024 SonarSource SA
|
||||
* mailto:info AT sonarsource DOT com
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.scanner.rule;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nullable;
|
||||
import org.sonar.api.issue.impact.Severity;
|
||||
import org.sonar.api.issue.impact.SoftwareQuality;
|
||||
import org.sonar.api.rule.RuleKey;
|
||||
|
||||
public class LoadedActiveRule {
|
||||
private RuleKey ruleKey;
|
||||
private String severity;
|
||||
private Map<SoftwareQuality, Severity> impacts;
|
||||
private String name;
|
||||
private String language;
|
||||
private Map<String, String> params;
|
||||
private long createdAt;
|
||||
private long updatedAt;
|
||||
private String templateRuleKey;
|
||||
private String internalKey;
|
||||
private Set<RuleKey> deprecatedKeys;
|
||||
|
||||
public LoadedActiveRule() {
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
public RuleKey getRuleKey() {
|
||||
return ruleKey;
|
||||
}
|
||||
|
||||
public void setRuleKey(RuleKey ruleKey) {
|
||||
this.ruleKey = ruleKey;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getSeverity() {
|
||||
return severity;
|
||||
}
|
||||
|
||||
public void setSeverity(String severity) {
|
||||
this.severity = severity;
|
||||
}
|
||||
|
||||
public Map<SoftwareQuality, Severity> getImpacts() {
|
||||
return impacts;
|
||||
}
|
||||
|
||||
public void setImpacts(Map<SoftwareQuality, Severity> impacts) {
|
||||
this.impacts = impacts;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public Map<String, String> getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(Map<String, String> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public long getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(long updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
@CheckForNull
|
||||
public String getTemplateRuleKey() {
|
||||
return templateRuleKey;
|
||||
}
|
||||
|
||||
public void setTemplateRuleKey(@Nullable String templateRuleKey) {
|
||||
this.templateRuleKey = templateRuleKey;
|
||||
}
|
||||
|
||||
public String getInternalKey() {
|
||||
return internalKey;
|
||||
}
|
||||
|
||||
public void setInternalKey(String internalKey) {
|
||||
this.internalKey = internalKey;
|
||||
}
|
||||
|
||||
public Set<RuleKey> getDeprecatedKeys() {
|
||||
return deprecatedKeys;
|
||||
}
|
||||
|
||||
public void setDeprecatedKeys(Set<RuleKey> deprecatedKeys) {
|
||||
this.deprecatedKeys = deprecatedKeys;
|
||||
}
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@ import org.assertj.core.groups.Tuple;
|
|||
import org.junit.Test;
|
||||
import org.sonar.api.batch.rule.ActiveRule;
|
||||
import org.sonar.api.batch.rule.ActiveRules;
|
||||
import org.sonar.api.batch.rule.LoadedActiveRule;
|
||||
import org.sonar.api.batch.rule.internal.DefaultActiveRule;
|
||||
import org.sonar.api.batch.rule.internal.DefaultActiveRules;
|
||||
import org.sonar.api.issue.impact.Severity;
|
||||
import org.sonar.api.issue.impact.SoftwareQuality;
|
||||
|
|
@ -73,11 +73,11 @@ public class ActiveRulesProviderTest {
|
|||
RuleKey.of("rule1", "rule1"), RuleKey.of("rule2", "rule2"), RuleKey.of("rule3", "rule3"));
|
||||
|
||||
Map<String, ActiveRule> activeRuleByKey = activeRules.findAll().stream().collect(Collectors.toMap(e -> e.ruleKey().rule(), e -> e));
|
||||
assertThat(activeRuleByKey.get("rule1").impacts())
|
||||
assertThat(((DefaultActiveRule) activeRuleByKey.get("rule1")).impacts())
|
||||
.containsExactlyInAnyOrderEntriesOf(Map.of(SoftwareQuality.MAINTAINABILITY, Severity.HIGH));
|
||||
|
||||
assertThat(activeRuleByKey.get("rule2").impacts()).isEmpty();
|
||||
assertThat(activeRuleByKey.get("rule3").impacts()).isEmpty();
|
||||
assertThat(((DefaultActiveRule) activeRuleByKey.get("rule2")).impacts()).isEmpty();
|
||||
assertThat(((DefaultActiveRule) activeRuleByKey.get("rule3")).impacts()).isEmpty();
|
||||
|
||||
verify(loader).load("qp1");
|
||||
verify(loader).load("qp2");
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import java.util.Map;
|
|||
import java.util.stream.IntStream;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.sonar.api.batch.rule.LoadedActiveRule;
|
||||
import org.sonar.scanner.rule.LoadedActiveRule;
|
||||
import org.sonar.api.issue.impact.SoftwareQuality;
|
||||
import org.sonar.api.rule.RuleKey;
|
||||
import org.sonar.api.rule.Severity;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* SonarQube
|
||||
* Copyright (C) 2009-2024 SonarSource SA
|
||||
* mailto:info AT sonarsource DOT com
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.scanner.rule;
|
||||
|
||||
import java.util.Map;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.sonar.api.issue.impact.Severity;
|
||||
import org.sonar.api.issue.impact.SoftwareQuality;
|
||||
|
||||
class LoadedActiveRuleTest {
|
||||
|
||||
@Test
|
||||
void should_return_expected_field() {
|
||||
LoadedActiveRule loadedActiveRule = new LoadedActiveRule();
|
||||
loadedActiveRule.setImpacts(Map.of(SoftwareQuality.MAINTAINABILITY, Severity.MEDIUM));
|
||||
|
||||
Assertions.assertThat(loadedActiveRule.getImpacts())
|
||||
.containsExactlyInAnyOrderEntriesOf(Map.of(SoftwareQuality.MAINTAINABILITY, Severity.MEDIUM));
|
||||
}
|
||||
}
|
||||
|
|
@ -49,7 +49,6 @@ import org.sonar.api.SonarEdition;
|
|||
import org.sonar.api.SonarProduct;
|
||||
import org.sonar.api.SonarQubeSide;
|
||||
import org.sonar.api.SonarRuntime;
|
||||
import org.sonar.api.batch.rule.LoadedActiveRule;
|
||||
import org.sonar.api.impl.server.RulesDefinitionContext;
|
||||
import org.sonar.api.measures.CoreMetrics;
|
||||
import org.sonar.api.measures.Metric;
|
||||
|
|
@ -76,6 +75,7 @@ import org.sonar.scanner.repository.SingleProjectRepository;
|
|||
import org.sonar.scanner.repository.settings.GlobalSettingsLoader;
|
||||
import org.sonar.scanner.repository.settings.ProjectSettingsLoader;
|
||||
import org.sonar.scanner.rule.ActiveRulesLoader;
|
||||
import org.sonar.scanner.rule.LoadedActiveRule;
|
||||
import org.sonar.scanner.rule.RulesLoader;
|
||||
import org.sonar.scanner.scan.ScanProperties;
|
||||
import org.sonar.scanner.scan.branch.BranchConfiguration;
|
||||
|
|
@ -280,7 +280,6 @@ public class ScannerMediumTester extends ExternalResource implements BeforeTestE
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public AnalysisBuilder newAnalysis() {
|
||||
return new AnalysisBuilder(this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue