diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2018-06-22 16:03:36 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2018-06-29 09:10:16 +0200 |
commit | ca183f7f3f45e1ae2338f3a5c37d44fc0e295111 (patch) | |
tree | 53fe65285d19dd6874315c664bf89e61980a3eac /sonar-core | |
parent | e5827b3671013c14776ca189e400e3687bfa0983 (diff) | |
download | sonarqube-ca183f7f3f45e1ae2338f3a5c37d44fc0e295111.tar.gz sonarqube-ca183f7f3f45e1ae2338f3a5c37d44fc0e295111.zip |
SONAR-10138 Remove support for API < 5.6
Diffstat (limited to 'sonar-core')
13 files changed, 11 insertions, 377 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/component/ComponentKeys.java b/sonar-core/src/main/java/org/sonar/core/component/ComponentKeys.java index ea751749ca9..04e2e494ad3 100644 --- a/sonar-core/src/main/java/org/sonar/core/component/ComponentKeys.java +++ b/sonar-core/src/main/java/org/sonar/core/component/ComponentKeys.java @@ -22,8 +22,6 @@ package org.sonar.core.component; import javax.annotation.Nullable; import org.apache.commons.lang.StringUtils; import org.sonar.api.batch.fs.InputPath; -import org.sonar.api.resources.Resource; -import org.sonar.api.resources.Scopes; import static com.google.common.base.Preconditions.checkArgument; @@ -48,21 +46,6 @@ public final class ComponentKeys { // only static stuff } - /** - * @return the full key of a component, based on its parent projects' key and own key - */ - public static String createEffectiveKey(String moduleKey, Resource resource) { - if (!StringUtils.equals(Scopes.PROJECT, resource.getScope())) { - // not a project nor a library - return new StringBuilder(MAX_COMPONENT_KEY_LENGTH) - .append(moduleKey) - .append(':') - .append(resource.getKey()) - .toString(); - } - return resource.getKey(); - } - public static String createEffectiveKey(String moduleKey, InputPath inputPath) { return createEffectiveKey(moduleKey, inputPath.relativePath()); } diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java b/sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java index 4471e59626f..2077b53f896 100644 --- a/sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java +++ b/sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java @@ -25,7 +25,6 @@ import java.net.URL; import java.net.URLClassLoader; import java.util.List; import org.sonar.api.Plugin; -import org.sonar.api.SonarPlugin; import org.sonar.core.platform.PluginInfo; import org.sonar.core.platform.PluginRepository; 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 f74bcb71e1e..04513564a03 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 @@ -273,16 +273,6 @@ public class DefaultIssue implements Issue, Trackable, org.sonar.api.ce.measure. return this; } - /** - * @deprecated since5.5, replaced by {@link #gap()} - */ - @Deprecated - @Override - @CheckForNull - public Double effortToFix() { - return gap(); - } - @Override @CheckForNull public Double gap() { @@ -296,16 +286,6 @@ public class DefaultIssue implements Issue, Trackable, org.sonar.api.ce.measure. } /** - * @deprecated since5.5, replaced by {@link #effort()} - */ - @Deprecated - @Override - @CheckForNull - public Duration debt() { - return effort(); - } - - /** * Elapsed time to fix the issue */ @Override @@ -346,16 +326,6 @@ public class DefaultIssue implements Issue, Trackable, org.sonar.api.ce.measure. return this; } - /** - * @deprecated since 5.5, manual issue feature has been dropped. - */ - @Deprecated - @Override - @CheckForNull - public String reporter() { - return null; - } - @Override @CheckForNull public String assignee() { @@ -517,13 +487,6 @@ public class DefaultIssue implements Issue, Trackable, org.sonar.api.ce.measure. return this; } - @Override - @CheckForNull - public String actionPlanKey() { - // In 5.5, action plan is dropped. - return null; - } - public DefaultIssue setFieldChange(IssueChangeContext context, String field, @Nullable Serializable oldValue, @Nullable Serializable newValue) { if (!Objects.equals(oldValue, newValue)) { if (currentChange == null) { diff --git a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueBuilder.java b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueBuilder.java deleted file mode 100644 index a8df4846429..00000000000 --- a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueBuilder.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.core.issue; - -import com.google.common.base.MoreObjects; -import com.google.common.base.Preconditions; -import com.google.common.collect.Maps; -import java.util.Map; -import javax.annotation.Nullable; -import org.sonar.api.batch.sensor.issue.NewIssueLocation; -import org.sonar.api.issue.Issuable; -import org.sonar.api.issue.Issuable.IssueBuilder; -import org.sonar.api.issue.Issue; -import org.sonar.api.rule.RuleKey; -import org.sonar.api.rules.RuleType; -import org.sonar.core.util.Uuids; - -public class DefaultIssueBuilder implements Issuable.IssueBuilder { - - private String componentKey; - private String projectKey; - private RuleKey ruleKey; - private Integer line; - private String message; - private String severity; - private Double effortToFix; - private String assigneeUuid; - private RuleType type; - private Map<String, String> attributes; - private boolean isFromExternalRuleEngine; - - public DefaultIssueBuilder componentKey(String componentKey) { - this.componentKey = componentKey; - return this; - } - - public DefaultIssueBuilder projectKey(String projectKey) { - this.projectKey = projectKey; - return this; - } - - public DefaultIssueBuilder fromExternalRuleEngine(boolean fromExternalRuleEngine) { - isFromExternalRuleEngine = fromExternalRuleEngine; - return this; - } - - @Override - public DefaultIssueBuilder ruleKey(RuleKey ruleKey) { - this.ruleKey = ruleKey; - return this; - } - - @Override - public DefaultIssueBuilder line(@Nullable Integer line) { - this.line = line; - return this; - } - - @Override - public DefaultIssueBuilder message(@Nullable String s) { - this.message = s; - return this; - } - - @Override - public NewIssueLocation newLocation() { - throw unsupported(); - } - - @Override - public IssueBuilder addLocation(NewIssueLocation secondaryLocation) { - throw unsupported(); - } - - @Override - public IssueBuilder addFlow(Iterable<NewIssueLocation> flow) { - throw unsupported(); - } - - @Override - public IssueBuilder at(NewIssueLocation location) { - throw unsupported(); - } - - private static UnsupportedOperationException unsupported() { - return new UnsupportedOperationException("Not supported for manual issues"); - } - - @Override - public DefaultIssueBuilder severity(@Nullable String severity) { - this.severity = severity; - return this; - } - - @Override - public DefaultIssueBuilder effortToFix(@Nullable Double d) { - this.effortToFix = d; - return this; - } - - /** - * @deprecated since 5.5, manual issue feature has been dropped. - */ - @Deprecated - @Override - public DefaultIssueBuilder reporter(@Nullable String s) { - return this; - } - - public DefaultIssueBuilder assigneeUuid(@Nullable String s) { - this.assigneeUuid = s; - return this; - } - - public DefaultIssueBuilder type(@Nullable RuleType type) { - this.type = type; - return this; - } - - @Override - public DefaultIssueBuilder attribute(String key, @Nullable String value) { - if (attributes == null) { - attributes = Maps.newLinkedHashMap(); - } - attributes.put(key, value); - return this; - } - - @Override - public DefaultIssue build() { - Preconditions.checkNotNull(projectKey, "Project key must be set"); - Preconditions.checkNotNull(componentKey, "Component key must be set"); - Preconditions.checkNotNull(ruleKey, "Rule key must be set"); - - DefaultIssue issue = new DefaultIssue(); - String key = Uuids.create(); - issue.setKey(key); - issue.setType(MoreObjects.firstNonNull(type, RuleType.CODE_SMELL)); - issue.setComponentKey(componentKey); - issue.setProjectKey(projectKey); - issue.setRuleKey(ruleKey); - issue.setMessage(message); - issue.setSeverity(severity); - issue.setManualSeverity(false); - issue.setGap(effortToFix); - issue.setLine(line); - issue.setAssigneeUuid(assigneeUuid); - issue.setAttributes(attributes); - issue.setResolution(null); - issue.setStatus(Issue.STATUS_OPEN); - issue.setCloseDate(null); - issue.setNew(true); - issue.setCopied(false); - issue.setBeingClosed(false); - issue.setOnDisabledRule(false); - issue.setIsFromExternalRuleEngine(isFromExternalRuleEngine); - return issue; - } -} diff --git a/sonar-core/src/test/java/org/sonar/core/component/ComponentKeysTest.java b/sonar-core/src/test/java/org/sonar/core/component/ComponentKeysTest.java index 43533c48dbb..3d7c0d6f193 100644 --- a/sonar-core/src/test/java/org/sonar/core/component/ComponentKeysTest.java +++ b/sonar-core/src/test/java/org/sonar/core/component/ComponentKeysTest.java @@ -26,10 +26,7 @@ import static org.mockito.Mockito.when; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.api.batch.bootstrap.ProjectDefinition; import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.resources.Directory; -import org.sonar.api.resources.Project; public class ComponentKeysTest { @Rule @@ -37,12 +34,6 @@ public class ComponentKeysTest { @Test public void create_effective_key() { - Project project = new Project(ProjectDefinition.create().setKey("my_project")); - assertThat(ComponentKeys.createEffectiveKey("my_project", project)).isEqualTo("my_project"); - - Directory dir = Directory.create("src/org/foo"); - assertThat(ComponentKeys.createEffectiveKey("my_project", dir)).isEqualTo("my_project:src/org/foo"); - InputFile file = mock(InputFile.class); when(file.relativePath()).thenReturn("foo/Bar.php"); assertThat(ComponentKeys.createEffectiveKey("my_project", file)).isEqualTo("my_project:foo/Bar.php"); diff --git a/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueBuilderTest.java b/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueBuilderTest.java deleted file mode 100644 index 8c214f89873..00000000000 --- a/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueBuilderTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.core.issue; - -import org.junit.Test; -import org.sonar.api.issue.Issue; -import org.sonar.api.rule.RuleKey; -import org.sonar.api.rule.Severity; - -import static org.assertj.core.api.Assertions.assertThat; - -public class DefaultIssueBuilderTest { - - @Test - public void build_new_issue() { - String componentKey = "org.apache.struts:struts-core:Action.java"; - String projectKey = "org.apache.struts"; - DefaultIssue issue = (DefaultIssue) new DefaultIssueBuilder() - .componentKey(componentKey) - .projectKey(projectKey) - .message("the message") - .line(123) - .effortToFix(10000.0) - .ruleKey(RuleKey.of("squid", "NullDereference")) - .fromExternalRuleEngine(false) - .severity(Severity.CRITICAL) - .attribute("JIRA", "FOO-123") - .attribute("YOUTRACK", "YT-123") - .build(); - - assertThat(issue).isNotNull(); - assertThat(issue.key()).isNotNull(); - assertThat(issue.effortToFix()).isEqualTo(10000.0); - assertThat(issue.componentKey()).isEqualTo(componentKey); - assertThat(issue.projectKey()).isEqualTo(projectKey); - assertThat(issue.message()).isEqualTo("the message"); - assertThat(issue.line()).isEqualTo(123); - assertThat(issue.ruleKey().repository()).isEqualTo("squid"); - assertThat(issue.ruleKey().rule()).isEqualTo("NullDereference"); - assertThat(issue.isFromExternalRuleEngine()).isFalse(); - assertThat(issue.severity()).isEqualTo(Severity.CRITICAL); - assertThat(issue.assignee()).isNull(); - assertThat(issue.isNew()).isTrue(); - assertThat(issue.resolution()).isNull(); - assertThat(issue.status()).isEqualTo(Issue.STATUS_OPEN); - assertThat(issue.attribute("JIRA")).isEqualTo("FOO-123"); - assertThat(issue.attribute("YOUTRACK")).isEqualTo("YT-123"); - assertThat(issue.attributes()).hasSize(2); - } - - @Test - public void not_set_default_severity() { - DefaultIssue issue = (DefaultIssue) new DefaultIssueBuilder() - .componentKey("Action.java") - .projectKey("org.apache.struts") - .ruleKey(RuleKey.of("squid", "NullDereference")) - .build(); - - assertThat(issue.severity()).isNull(); - } -} diff --git a/sonar-core/src/test/java/org/sonar/core/platform/PluginLoaderTest.java b/sonar-core/src/test/java/org/sonar/core/platform/PluginLoaderTest.java index 432296e40fc..76a1268f933 100644 --- a/sonar-core/src/test/java/org/sonar/core/platform/PluginLoaderTest.java +++ b/sonar-core/src/test/java/org/sonar/core/platform/PluginLoaderTest.java @@ -24,19 +24,14 @@ import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.Collections; -import java.util.List; -import java.util.Map; import org.assertj.core.data.MapEntry; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.sonar.api.Plugin; -import org.sonar.api.SonarPlugin; import org.sonar.updatecenter.common.Version; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; -import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; public class PluginLoaderTest { @@ -48,29 +43,6 @@ public class PluginLoaderTest { private PluginLoader loader = new PluginLoader(new FakePluginExploder(), classloaderFactory); @Test - public void instantiate_plugin_entry_point() { - PluginClassLoaderDef def = new PluginClassLoaderDef("fake"); - def.addMainClass("fake", FakePlugin.class.getName()); - - Map<String, Plugin> instances = loader.instantiatePluginClasses(ImmutableMap.of(def, getClass().getClassLoader())); - assertThat(instances).containsOnlyKeys("fake"); - assertThat(instances.get("fake")).isInstanceOf(FakePlugin.class); - } - - @Test - public void plugin_entry_point_must_be_no_arg_public() { - PluginClassLoaderDef def = new PluginClassLoaderDef("fake"); - def.addMainClass("fake", IncorrectPlugin.class.getName()); - - try { - loader.instantiatePluginClasses(ImmutableMap.of(def, getClass().getClassLoader())); - fail(); - } catch (IllegalStateException e) { - assertThat(e).hasMessage("Fail to instantiate class [org.sonar.core.platform.PluginLoaderTest$IncorrectPlugin] of plugin [fake]"); - } - } - - @Test public void define_classloader() throws Exception { File jarFile = temp.newFile(); PluginInfo info = new PluginInfo("foo") @@ -172,27 +144,7 @@ public class PluginLoaderTest { private static class FakePluginExploder extends PluginJarExploder { @Override public ExplodedPlugin explode(PluginInfo info) { - return new ExplodedPlugin(info.getKey(), info.getNonNullJarFile(), Collections.<File>emptyList()); - } - } - - public static class FakePlugin extends SonarPlugin { - @Override - public List getExtensions() { - return Collections.emptyList(); - } - } - - /** - * No public empty-param constructor - */ - public static class IncorrectPlugin extends SonarPlugin { - public IncorrectPlugin(String s) { - } - - @Override - public List getExtensions() { - return Collections.emptyList(); + return new ExplodedPlugin(info.getKey(), info.getNonNullJarFile(), Collections.emptyList()); } } } diff --git a/sonar-core/src/test/projects/base-plugin/pom.xml b/sonar-core/src/test/projects/base-plugin/pom.xml index 484d5b78dea..95c772b15c4 100644 --- a/sonar-core/src/test/projects/base-plugin/pom.xml +++ b/sonar-core/src/test/projects/base-plugin/pom.xml @@ -13,7 +13,7 @@ <dependency> <groupId>org.sonarsource.sonarqube</groupId> <artifactId>sonar-plugin-api</artifactId> - <version>5.2-SNAPSHOT</version> + <version>7.2-SNAPSHOT</version> <scope>provided</scope> </dependency> </dependencies> diff --git a/sonar-core/src/test/projects/base-plugin/src/org/sonar/plugins/base/BasePlugin.java b/sonar-core/src/test/projects/base-plugin/src/org/sonar/plugins/base/BasePlugin.java index 6afa10ce96c..d6619367f09 100644 --- a/sonar-core/src/test/projects/base-plugin/src/org/sonar/plugins/base/BasePlugin.java +++ b/sonar-core/src/test/projects/base-plugin/src/org/sonar/plugins/base/BasePlugin.java @@ -2,11 +2,11 @@ package org.sonar.plugins.base; import java.util.Collections; import java.util.List; -import org.sonar.api.SonarPlugin; +import org.sonar.api.Plugin; -public class BasePlugin extends SonarPlugin { +public class BasePlugin implements Plugin { + + public void define(Plugin.Context context) { - public List getExtensions() { - return Collections.emptyList(); } } diff --git a/sonar-core/src/test/projects/base-plugin/target/base-plugin-0.1-SNAPSHOT.jar b/sonar-core/src/test/projects/base-plugin/target/base-plugin-0.1-SNAPSHOT.jar Binary files differindex c2bdb08c95c..87f9e2899cd 100644 --- a/sonar-core/src/test/projects/base-plugin/target/base-plugin-0.1-SNAPSHOT.jar +++ b/sonar-core/src/test/projects/base-plugin/target/base-plugin-0.1-SNAPSHOT.jar diff --git a/sonar-core/src/test/projects/dependent-plugin/pom.xml b/sonar-core/src/test/projects/dependent-plugin/pom.xml index dcb4754e3fc..9bd5580863d 100644 --- a/sonar-core/src/test/projects/dependent-plugin/pom.xml +++ b/sonar-core/src/test/projects/dependent-plugin/pom.xml @@ -13,7 +13,7 @@ <dependency> <groupId>org.sonarsource.sonarqube</groupId> <artifactId>sonar-plugin-api</artifactId> - <version>5.2-SNAPSHOT</version> + <version>7.2-SNAPSHOT</version> <scope>provided</scope> </dependency> <dependency> diff --git a/sonar-core/src/test/projects/dependent-plugin/src/org/sonar/plugins/dependent/DependentPlugin.java b/sonar-core/src/test/projects/dependent-plugin/src/org/sonar/plugins/dependent/DependentPlugin.java index 2b7783ae4fe..907a09ee83f 100644 --- a/sonar-core/src/test/projects/dependent-plugin/src/org/sonar/plugins/dependent/DependentPlugin.java +++ b/sonar-core/src/test/projects/dependent-plugin/src/org/sonar/plugins/dependent/DependentPlugin.java @@ -2,17 +2,17 @@ package org.sonar.plugins.dependent; import java.util.Collections; import java.util.List; -import org.sonar.api.SonarPlugin; +import org.sonar.api.Plugin; import org.sonar.plugins.base.api.BaseApi; -public class DependentPlugin extends SonarPlugin { +public class DependentPlugin implements Plugin { public DependentPlugin() { // uses a class that is exported by base-plugin new BaseApi().doNothing(); } - public List getExtensions() { - return Collections.emptyList(); + public void define(Plugin.Context context) { + } } diff --git a/sonar-core/src/test/projects/dependent-plugin/target/dependent-plugin-0.1-SNAPSHOT.jar b/sonar-core/src/test/projects/dependent-plugin/target/dependent-plugin-0.1-SNAPSHOT.jar Binary files differindex b828a8c6386..81b8475944e 100644 --- a/sonar-core/src/test/projects/dependent-plugin/target/dependent-plugin-0.1-SNAPSHOT.jar +++ b/sonar-core/src/test/projects/dependent-plugin/target/dependent-plugin-0.1-SNAPSHOT.jar |