aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2025-03-13 15:39:47 +0100
committersonartech <sonartech@sonarsource.com>2025-03-18 20:04:07 +0000
commitb9ce98f71c6bf7dbc337fae00f0a49d346d9c481 (patch)
tree32eba680ef7b40418c8786e583075ae67b128747
parent9d0c5fc1bab676e52d935c0d65d56fecdc12747f (diff)
downloadsonarqube-b9ce98f71c6bf7dbc337fae00f0a49d346d9c481.tar.gz
sonarqube-b9ce98f71c6bf7dbc337fae00f0a49d346d9c481.zip
SONAR-24623 Remove the support of ProfileExporter and ProfileImporter
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java7
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooFakeExporter.java55
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooFakeImporter.java50
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooFakeImporterWithMessages.java47
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDto.java5
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileExportersIT.java278
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/CreateActionIT.java110
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ExportActionIT.java87
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java207
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/BuiltInQProfileRepositoryImpl.java1
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java51
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ExportAction.java43
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ExportersAction.java32
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ImportersAction.java28
-rw-r--r--server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualityprofile/ws/exporters-example.json29
-rw-r--r--server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualityprofile/ws/importers-example.json29
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ExportersActionTest.java25
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ImportersActionTest.java27
-rw-r--r--server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java2
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java5
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorContext.java1
21 files changed, 38 insertions, 1081 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java
index b32bca06bda..b4aad85bdb0 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java
@@ -78,9 +78,6 @@ import org.sonar.xoo.rule.Xoo2SonarWayProfile;
import org.sonar.xoo.rule.XooBasicProfile;
import org.sonar.xoo.rule.XooBuiltInQualityProfilesDefinition;
import org.sonar.xoo.rule.XooEmptyProfile;
-import org.sonar.xoo.rule.XooFakeExporter;
-import org.sonar.xoo.rule.XooFakeImporter;
-import org.sonar.xoo.rule.XooFakeImporterWithMessages;
import org.sonar.xoo.rule.XooRulesDefinition;
import org.sonar.xoo.rule.XooSonarWayProfile;
import org.sonar.xoo.rule.hotspot.HotspotWithContextsSensor;
@@ -138,10 +135,6 @@ public class XooPlugin implements Plugin {
Xoo2BasicProfile.class,
XooEmptyProfile.class,
- XooFakeExporter.class,
- XooFakeImporter.class,
- XooFakeImporterWithMessages.class,
-
// SCM
XooScmProvider.class,
XooBlameCommand.class,
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooFakeExporter.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooFakeExporter.java
deleted file mode 100644
index 69a6068731e..00000000000
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooFakeExporter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 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.xoo.rule;
-
-import org.sonar.api.profiles.ProfileExporter;
-import org.sonar.api.profiles.RulesProfile;
-import org.sonar.xoo.Xoo;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/**
- * Fake exporter just for test
- */
-public class XooFakeExporter extends ProfileExporter {
- public XooFakeExporter() {
- super("XooFakeExporter", "Xoo Fake Exporter");
- }
-
- @Override
- public String[] getSupportedLanguages() {
- return new String[]{Xoo.KEY};
- }
-
- @Override
- public String getMimeType() {
- return "plain/custom";
- }
-
- @Override
- public void exportProfile(RulesProfile profile, Writer writer) {
- try {
- writer.write("xoo -> " + profile.getName() + " -> " + profile.getActiveRules().size());
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
-}
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooFakeImporter.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooFakeImporter.java
deleted file mode 100644
index a89374e504b..00000000000
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooFakeImporter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 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.xoo.rule;
-
-import org.sonar.api.profiles.ProfileImporter;
-import org.sonar.api.profiles.RulesProfile;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.rules.RulePriority;
-import org.sonar.api.utils.ValidationMessages;
-import org.sonar.xoo.Xoo;
-
-import java.io.Reader;
-
-/**
- * Fake importer just for test, it will NOT take into account the given file but will create some hard-coded rules
- */
-public class XooFakeImporter extends ProfileImporter {
- public XooFakeImporter() {
- super("XooProfileImporter", "Xoo Profile Importer");
- }
-
- @Override
- public String[] getSupportedLanguages() {
- return new String[] {Xoo.KEY};
- }
-
- @Override
- public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
- RulesProfile rulesProfile = RulesProfile.create();
- rulesProfile.activateRule(Rule.create(XooRulesDefinition.XOO_REPOSITORY, "x1"), RulePriority.CRITICAL);
- return rulesProfile;
- }
-}
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooFakeImporterWithMessages.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooFakeImporterWithMessages.java
deleted file mode 100644
index e7f31ec0ec1..00000000000
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooFakeImporterWithMessages.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 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.xoo.rule;
-
-import org.sonar.api.profiles.ProfileImporter;
-import org.sonar.api.profiles.RulesProfile;
-import org.sonar.api.utils.ValidationMessages;
-
-import java.io.Reader;
-
-/**
- * Fake importer just for test, it will NOT take into account the given file but will display some info and warning messages
- */
-public class XooFakeImporterWithMessages extends ProfileImporter {
- public XooFakeImporterWithMessages() {
- super("XooFakeImporterWithMessages", "Xoo Profile Importer With Messages");
- }
-
- @Override
- public String[] getSupportedLanguages() {
- return new String[] {};
- }
-
- @Override
- public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
- messages.addWarningText("a warning");
- messages.addInfoText("an info");
- return RulesProfile.create();
- }
-}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDto.java
index 7187f8d4c2c..0c4b7798934 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDto.java
@@ -31,7 +31,6 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import org.sonar.api.issue.impact.Severity;
import org.sonar.api.issue.impact.SoftwareQuality;
import org.sonar.api.rule.RuleKey;
-import org.sonar.api.rules.ActiveRule;
import org.sonar.db.rule.RuleDto;
import org.sonar.db.rule.SeverityUtil;
@@ -39,8 +38,8 @@ import static java.util.Objects.requireNonNull;
public class ActiveRuleDto {
- public static final String INHERITED = ActiveRule.INHERITED;
- public static final String OVERRIDES = ActiveRule.OVERRIDES;
+ public static final String INHERITED = "INHERITED";
+ public static final String OVERRIDES = "OVERRIDES";
private static final Gson GSON = new Gson();
private static final Type TYPE = new TypeToken<Map<SoftwareQuality, Severity>>() {
}.getType();
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileExportersIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileExportersIT.java
deleted file mode 100644
index 9e06d87c0d6..00000000000
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileExportersIT.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 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.server.qualityprofile;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.sonar.api.impl.utils.AlwaysIncreasingSystem2;
-import org.sonar.api.profiles.ProfileExporter;
-import org.sonar.api.profiles.ProfileImporter;
-import org.sonar.api.profiles.RulesProfile;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.rules.RuleFinder;
-import org.sonar.api.rules.RulePriority;
-import org.sonar.api.utils.System2;
-import org.sonar.api.utils.ValidationMessages;
-import org.sonar.db.DbSession;
-import org.sonar.db.DbTester;
-import org.sonar.db.qualityprofile.QProfileDto;
-import org.sonar.db.rule.RuleDto;
-import org.sonar.server.exceptions.BadRequestException;
-import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.rule.DefaultRuleFinder;
-import org.sonar.server.rule.RuleDescriptionFormatter;
-import org.sonar.server.tester.UserSessionRule;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.apache.commons.io.IOUtils.toInputStream;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.sonar.db.qualityprofile.QualityProfileTesting.newQualityProfileDto;
-
-public class QProfileExportersIT {
-
- @org.junit.Rule
- public UserSessionRule userSessionRule = UserSessionRule.standalone();
-
- private final System2 system2 = new AlwaysIncreasingSystem2();
-
- @org.junit.Rule
- public DbTester db = DbTester.create(system2);
-
- private final RuleFinder ruleFinder = new DefaultRuleFinder(db.getDbClient(), mock(RuleDescriptionFormatter.class));
- private final ProfileExporter[] exporters = new ProfileExporter[] {
- new StandardExporter(), new XooExporter()};
- private final ProfileImporter[] importers = new ProfileImporter[] {
- new XooProfileImporter(), new XooProfileImporterWithMessages(), new XooProfileImporterWithError()};
- private RuleDto rule;
- private final QProfileRules qProfileRules = mock(QProfileRules.class);
- private final QProfileExporters underTest = new QProfileExporters(db.getDbClient(), ruleFinder, qProfileRules, exporters, importers);
-
- @Before
- public void setUp() {
- rule = db.rules().insert(r -> r.setLanguage("xoo").setRepositoryKey("SonarXoo").setRuleKey("R1"));
- }
-
- @Test
- public void exportersForLanguage() {
- assertThat(underTest.exportersForLanguage("xoo")).hasSize(2);
- assertThat(underTest.exportersForLanguage("java")).hasSize(1);
- assertThat(underTest.exportersForLanguage("java").get(0)).isInstanceOf(StandardExporter.class);
- }
-
- @Test
- public void mimeType() {
- assertThat(underTest.mimeType("xootool")).isEqualTo("plain/custom");
-
- // default mime type
- assertThat(underTest.mimeType("standard")).isEqualTo("text/plain");
- }
-
- @Test
- public void import_xml() {
- QProfileDto profile = createProfile();
-
- underTest.importXml(profile, "XooProfileImporter", toInputStream("<xml/>", UTF_8), db.getSession());
-
- ArgumentCaptor<QProfileDto> profileCapture = ArgumentCaptor.forClass(QProfileDto.class);
- Class<Collection<RuleActivation>> collectionClass = (Class<Collection<RuleActivation>>) (Class) Collection.class;
- ArgumentCaptor<Collection<RuleActivation>> activationCapture = ArgumentCaptor.forClass(collectionClass);
- verify(qProfileRules).activateAndCommit(any(DbSession.class), profileCapture.capture(), activationCapture.capture());
-
- assertThat(profileCapture.getValue().getKee()).isEqualTo(profile.getKee());
- Collection<RuleActivation> activations = activationCapture.getValue();
- assertThat(activations).hasSize(1);
- RuleActivation activation = activations.iterator().next();
- assertThat(activation.getRuleUuid()).isEqualTo(rule.getUuid());
- assertThat(activation.getSeverity()).isEqualTo("CRITICAL");
- }
-
- @Test
- public void import_xml_return_messages() {
- QProfileDto profile = createProfile();
-
- QProfileResult result = underTest.importXml(profile, "XooProfileImporterWithMessages", toInputStream("<xml/>", UTF_8), db.getSession());
-
- assertThat(result.infos()).containsOnly("an info");
- assertThat(result.warnings()).containsOnly("a warning");
- }
-
- @Test
- public void fail_to_import_xml_when_error_in_importer() {
- QProfileDto qProfileDto = newQualityProfileDto();
- InputStream inputStream = toInputStream("<xml/>", UTF_8);
- DbSession dbSession = db.getSession();
- assertThatThrownBy(() -> underTest.importXml(
- qProfileDto, "XooProfileImporterWithError", inputStream, dbSession))
- .isInstanceOf(BadRequestException.class)
- .hasMessage("error!");
- }
-
- @Test
- public void fail_to_import_xml_on_unknown_importer() {
- QProfileDto qProfileDto = newQualityProfileDto();
- InputStream inputStream = toInputStream("<xml/>", UTF_8);
- DbSession dbSession = db.getSession();
- assertThatThrownBy(() -> underTest.importXml(qProfileDto, "Unknown", inputStream, dbSession))
- .isInstanceOf(BadRequestException.class)
- .hasMessage("No such importer : Unknown");
- }
-
- @Test
- public void export_empty_profile() {
- QProfileDto profile = createProfile();
-
- StringWriter writer = new StringWriter();
- underTest.export(db.getSession(), profile, "standard", writer);
- assertThat(writer).hasToString("standard -> " + profile.getName() + " -> 0");
-
- writer = new StringWriter();
- underTest.export(db.getSession(), profile, "xootool", writer);
- assertThat(writer).hasToString("xoo -> " + profile.getName() + " -> 0");
- }
-
- @Test
- public void export_profile() {
- QProfileDto profile = createProfile();
- db.qualityProfiles().activateRule(profile, rule);
-
- StringWriter writer = new StringWriter();
- underTest.export(db.getSession(), profile, "standard", writer);
- assertThat(writer).hasToString("standard -> " + profile.getName() + " -> 1");
-
- writer = new StringWriter();
- underTest.export(db.getSession(), profile, "xootool", writer);
- assertThat(writer).hasToString("xoo -> " + profile.getName() + " -> 1");
- }
-
- @Test
- public void export_throws_NotFoundException_if_exporter_does_not_exist() {
- QProfileDto profile = createProfile();
-
- assertThatThrownBy(() -> {
- underTest.export(db.getSession(), profile, "does_not_exist", new StringWriter());
- })
- .isInstanceOf(NotFoundException.class)
- .hasMessage("Unknown quality profile exporter: does_not_exist");
- }
-
- private QProfileDto createProfile() {
- return db.qualityProfiles().insert(p -> p.setLanguage(rule.getLanguage()));
- }
-
- public static class XooExporter extends ProfileExporter {
- public XooExporter() {
- super("xootool", "Xoo Tool");
- }
-
- @Override
- public String[] getSupportedLanguages() {
- return new String[] {"xoo"};
- }
-
- @Override
- public String getMimeType() {
- return "plain/custom";
- }
-
- @Override
- public void exportProfile(RulesProfile profile, Writer writer) {
- try {
- writer.write("xoo -> " + profile.getName() + " -> " + profile.getActiveRules().size());
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
- }
-
- public static class StandardExporter extends ProfileExporter {
- public StandardExporter() {
- super("standard", "Standard");
- }
-
- @Override
- public void exportProfile(RulesProfile profile, Writer writer) {
- try {
- writer.write("standard -> " + profile.getName() + " -> " + profile.getActiveRules().size());
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
- }
-
- public class XooProfileImporter extends ProfileImporter {
- public XooProfileImporter() {
- super("XooProfileImporter", "Xoo Profile Importer");
- }
-
- @Override
- public String[] getSupportedLanguages() {
- return new String[] {"xoo"};
- }
-
- @Override
- public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
- RulesProfile rulesProfile = RulesProfile.create();
- rulesProfile.activateRule(Rule.create(rule.getRepositoryKey(), rule.getRuleKey()), RulePriority.CRITICAL);
- return rulesProfile;
- }
- }
-
- public static class XooProfileImporterWithMessages extends ProfileImporter {
- public XooProfileImporterWithMessages() {
- super("XooProfileImporterWithMessages", "Xoo Profile Importer With Message");
- }
-
- @Override
- public String[] getSupportedLanguages() {
- return new String[] {};
- }
-
- @Override
- public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
- messages.addWarningText("a warning");
- messages.addInfoText("an info");
- return RulesProfile.create();
- }
- }
-
- public static class XooProfileImporterWithError extends ProfileImporter {
- public XooProfileImporterWithError() {
- super("XooProfileImporterWithError", "Xoo Profile Importer With Error");
- }
-
- @Override
- public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
- messages.addErrorText("error!");
- return RulesProfile.create();
- }
- }
-
-}
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/CreateActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/CreateActionIT.java
index 395b4147c18..8206511d176 100644
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/CreateActionIT.java
+++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/CreateActionIT.java
@@ -19,20 +19,12 @@
*/
package org.sonar.server.qualityprofile.ws;
-import com.google.common.collect.ImmutableMap;
-import java.io.Reader;
-import java.util.Collections;
-import java.util.Map;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.api.config.Configuration;
-import org.sonar.api.profiles.ProfileImporter;
-import org.sonar.api.profiles.RulesProfile;
-import org.sonar.api.rules.RulePriority;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.server.ws.WebService.Param;
import org.sonar.api.utils.System2;
-import org.sonar.api.utils.ValidationMessages;
import org.sonar.api.utils.Version;
import org.sonar.core.platform.SonarQubeVersion;
import org.sonar.core.util.UuidFactoryFast;
@@ -44,10 +36,8 @@ import org.sonar.db.qualityprofile.QProfileDto;
import org.sonar.db.rule.RuleDto;
import org.sonar.db.rule.RuleTesting;
import org.sonar.server.es.EsTester;
-import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.pushapi.qualityprofile.QualityProfileChangeEventService;
-import org.sonar.server.qualityprofile.QProfileExporters;
import org.sonar.server.qualityprofile.QProfileFactoryImpl;
import org.sonar.server.qualityprofile.QProfileRules;
import org.sonar.server.qualityprofile.QProfileRulesImpl;
@@ -55,7 +45,6 @@ import org.sonar.server.qualityprofile.builtin.RuleActivator;
import org.sonar.server.qualityprofile.index.ActiveRuleIndexer;
import org.sonar.server.rule.index.RuleIndex;
import org.sonar.server.rule.index.RuleIndexer;
-import org.sonar.server.rule.index.RuleQuery;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.TestResponse;
@@ -92,15 +81,14 @@ class CreateActionIT {
private final RuleIndex ruleIndex = new RuleIndex(es.client(), System2.INSTANCE, config);
private final RuleIndexer ruleIndexer = new RuleIndexer(es.client(), dbClient);
private final ActiveRuleIndexer activeRuleIndexer = new ActiveRuleIndexer(dbClient, es.client());
- private final ProfileImporter[] profileImporters = createImporters();
private final QualityProfileChangeEventService qualityProfileChangeEventService = mock(QualityProfileChangeEventService.class);
private final SonarQubeVersion sonarQubeVersion = new SonarQubeVersion(Version.create(10, 3));
- private final RuleActivator ruleActivator = new RuleActivator(System2.INSTANCE, dbClient, UuidFactoryImpl.INSTANCE, null, userSession, mock(Configuration.class), sonarQubeVersion);
+ private final RuleActivator ruleActivator = new RuleActivator(System2.INSTANCE, dbClient, UuidFactoryImpl.INSTANCE, null, userSession, mock(Configuration.class),
+ sonarQubeVersion);
private final QProfileRules qProfileRules = new QProfileRulesImpl(dbClient, ruleActivator, ruleIndex, activeRuleIndexer, qualityProfileChangeEventService);
- private final QProfileExporters qProfileExporters = new QProfileExporters(dbClient, null, qProfileRules, profileImporters);
private final CreateAction underTest = new CreateAction(dbClient, new QProfileFactoryImpl(dbClient, UuidFactoryFast.getInstance(), System2.INSTANCE, activeRuleIndexer),
- qProfileExporters, newLanguages(XOO_LANGUAGE), userSession, activeRuleIndexer, profileImporters);
+ newLanguages(XOO_LANGUAGE), userSession, activeRuleIndexer);
private WsActionTester ws = new WsActionTester(underTest);
@@ -111,7 +99,7 @@ class CreateActionIT {
assertThat(definition.responseExampleAsString()).isNotEmpty();
assertThat(definition.isPost()).isTrue();
assertThat(definition.params()).extracting(Param::key)
- .containsExactlyInAnyOrder("language", "name", "backup_with_messages", "backup_with_errors", "backup_xoo_lint");
+ .containsExactlyInAnyOrder("language", "name");
}
@Test
@@ -136,30 +124,6 @@ class CreateActionIT {
}
@Test
- void create_profile_from_backup_xml() {
- logInAsQProfileAdministrator();
- insertRule(RULE);
-
- executeRequest("New Profile", XOO_LANGUAGE, ImmutableMap.of("xoo_lint", "<xml/>"));
-
- QProfileDto dto = dbClient.qualityProfileDao().selectByNameAndLanguage(dbSession, "New Profile", XOO_LANGUAGE);
- assertThat(dto.getKee()).isNotNull();
- assertThat(dbClient.activeRuleDao().selectByProfileUuid(dbSession, dto.getKee())).hasSize(1);
- assertThat(ruleIndex.searchAll(new RuleQuery().setQProfile(dto).setActivation(true))).toIterable().hasSize(1);
- }
-
- @Test
- void create_profile_with_messages() {
- logInAsQProfileAdministrator();
-
- CreateWsResponse response = executeRequest("Profile with messages", XOO_LANGUAGE, ImmutableMap.of("with_messages", "<xml/>"));
-
- QualityProfile profile = response.getProfile();
- assertThat(profile.getInfos().getInfosList()).containsOnly("an info");
- assertThat(profile.getWarnings().getWarningsList()).containsOnly("a warning");
- }
-
- @Test
void fail_if_unsufficient_privileges() {
userSession
.logIn()
@@ -175,16 +139,6 @@ class CreateActionIT {
}
@Test
- void fail_if_import_generate_error() {
- logInAsQProfileAdministrator();
-
- assertThatThrownBy(() -> {
- executeRequest("Profile with errors", XOO_LANGUAGE, ImmutableMap.of("with_errors", "<xml/>"));
- })
- .isInstanceOf(BadRequestException.class);
- }
-
- @Test
void test_json() {
logInAsQProfileAdministrator();
@@ -206,16 +160,9 @@ class CreateActionIT {
}
private CreateWsResponse executeRequest(String name, String language) {
- return executeRequest(name, language, Collections.emptyMap());
- }
-
- private CreateWsResponse executeRequest(String name, String language, Map<String, String> xmls) {
TestRequest request = ws.newRequest()
.setParam("name", name)
.setParam("language", language);
- for (Map.Entry<String, String> entry : xmls.entrySet()) {
- request.setParam("backup_" + entry.getKey(), entry.getValue());
- }
return executeRequest(request);
}
@@ -223,55 +170,6 @@ class CreateActionIT {
return request.executeProtobuf(CreateWsResponse.class);
}
- private ProfileImporter[] createImporters() {
- class DefaultProfileImporter extends ProfileImporter {
- private DefaultProfileImporter() {
- super("xoo_lint", "Xoo Lint");
- setSupportedLanguages(XOO_LANGUAGE);
- }
-
- @Override
- public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
- RulesProfile rulesProfile = RulesProfile.create();
- rulesProfile.activateRule(org.sonar.api.rules.Rule.create(RULE.getRepositoryKey(), RULE.getRuleKey()), RulePriority.BLOCKER);
- return rulesProfile;
- }
- }
-
- class ProfileImporterGeneratingMessages extends ProfileImporter {
- private ProfileImporterGeneratingMessages() {
- super("with_messages", "With messages");
- setSupportedLanguages(XOO_LANGUAGE);
- }
-
- @Override
- public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
- RulesProfile rulesProfile = RulesProfile.create();
- messages.addWarningText("a warning");
- messages.addInfoText("an info");
- return rulesProfile;
- }
- }
-
- class ProfileImporterGeneratingErrors extends ProfileImporter {
- private ProfileImporterGeneratingErrors() {
- super("with_errors", "With errors");
- setSupportedLanguages(XOO_LANGUAGE);
- }
-
- @Override
- public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
- RulesProfile rulesProfile = RulesProfile.create();
- messages.addErrorText("error!");
- return rulesProfile;
- }
- }
-
- return new ProfileImporter[] {
- new DefaultProfileImporter(), new ProfileImporterGeneratingMessages(), new ProfileImporterGeneratingErrors()
- };
- }
-
private void logInAsQProfileAdministrator() {
userSession
.logIn()
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ExportActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ExportActionIT.java
index 8b33646673d..c22c3ddd306 100644
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ExportActionIT.java
+++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ExportActionIT.java
@@ -23,11 +23,8 @@ import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import javax.annotation.Nullable;
-import org.apache.commons.lang3.StringUtils;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.profiles.ProfileExporter;
-import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.System2;
import org.sonar.db.DbClient;
@@ -37,7 +34,6 @@ import org.sonar.db.qualityprofile.QProfileDto;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.language.LanguageTesting;
import org.sonar.server.qualityprofile.QProfileBackuper;
-import org.sonar.server.qualityprofile.QProfileExporters;
import org.sonar.server.qualityprofile.QProfileRestoreSummary;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsActionTester;
@@ -60,39 +56,10 @@ public class ExportActionIT {
private final QProfileBackuper backuper = new TestBackuper();
@Test
- public void export_profile() {
+ public void return_backup() {
QProfileDto profile = createProfile(false);
- WsActionTester tester = newWsActionTester(newExporter("polop"), newExporter("palap"));
- String result = tester.newRequest()
- .setParam("language", profile.getLanguage())
- .setParam("qualityProfile", profile.getName())
- .setParam("exporterKey", "polop").execute()
- .getInput();
-
- assertThat(result).isEqualTo("Profile " + profile.getLanguage() + "/" + profile.getName() + " exported by polop");
- }
-
- @Test
- public void export_default_profile() {
- QProfileDto nonDefaultProfile = createProfile(false);
- QProfileDto defaultProfile = createProfile(true);
-
- WsActionTester tester = newWsActionTester(newExporter("polop"), newExporter("palap"));
- String result = tester.newRequest()
- .setParam("language", XOO_LANGUAGE)
- .setParam("exporterKey", "polop")
- .execute()
- .getInput();
-
- assertThat(result).isEqualTo("Profile " + defaultProfile.getLanguage() + "/" + defaultProfile.getName() + " exported by polop");
- }
-
- @Test
- public void return_backup_when_exporter_is_not_specified() {
- QProfileDto profile = createProfile(false);
-
- String result = newWsActionTester(newExporter("polop")).newRequest()
+ String result = newWsActionTester().newRequest()
.setParam("language", profile.getLanguage())
.setParam("qualityProfile", profile.getName())
.execute()
@@ -112,20 +79,7 @@ public class ExportActionIT {
}
@Test
- public void throw_IAE_if_export_with_specified_key_does_not_exist() {
- QProfileDto profile = createProfile(true);
-
- assertThatThrownBy(() -> {
- newWsActionTester(newExporter("polop"), newExporter("palap")).newRequest()
- .setParam("language", XOO_LANGUAGE)
- .setParam("exporterKey", "unknown").execute();
- })
- .isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Value of parameter 'exporterKey' (unknown) must be one of: [polop, palap]");
- }
-
- @Test
- public void definition_without_exporters() {
+ public void definition() {
WebService.Action definition = newWsActionTester().getDef();
assertThat(definition.isPost()).isFalse();
@@ -139,18 +93,6 @@ public class ExportActionIT {
assertThat(language.deprecatedSince()).isNullOrEmpty();
}
- @Test
- public void definition_with_exporters() {
- WebService.Action definition = newWsActionTester(newExporter("polop"), newExporter("palap")).getDef();
-
- assertThat(definition.isPost()).isFalse();
- assertThat(definition.isInternal()).isFalse();
- assertThat(definition.params()).extracting("key").containsExactlyInAnyOrder("language", "qualityProfile", "exporterKey");
- WebService.Param exportersParam = definition.param("exporterKey");
- assertThat(exportersParam.possibleValues()).containsOnly("polop", "palap");
- assertThat(exportersParam.isInternal()).isFalse();
- }
-
private QProfileDto createProfile(boolean isDefault) {
QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO_LANGUAGE));
if (isDefault) {
@@ -159,27 +101,8 @@ public class ExportActionIT {
return profile;
}
- private WsActionTester newWsActionTester(ProfileExporter... profileExporters) {
- QProfileExporters exporters = new QProfileExporters(dbClient, null, null, profileExporters, null);
- return new WsActionTester(new ExportAction(dbClient, backuper, exporters, LanguageTesting.newLanguages(XOO_LANGUAGE, JAVA_LANGUAGE)));
- }
-
- private static ProfileExporter newExporter(String key) {
- return new ProfileExporter(key, StringUtils.capitalize(key)) {
- @Override
- public String getMimeType() {
- return "text/plain+" + key;
- }
-
- @Override
- public void exportProfile(RulesProfile profile, Writer writer) {
- try {
- writer.write(format("Profile %s/%s exported by %s", profile.getLanguage(), profile.getName(), key));
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
- }
- }
- };
+ private WsActionTester newWsActionTester() {
+ return new WsActionTester(new ExportAction(dbClient, backuper, LanguageTesting.newLanguages(XOO_LANGUAGE, JAVA_LANGUAGE)));
}
private static class TestBackuper implements QProfileBackuper {
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java
deleted file mode 100644
index a6f2fc4bcc0..00000000000
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 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.server.qualityprofile;
-
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ListMultimap;
-import com.google.common.collect.Lists;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.Writer;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import javax.annotation.CheckForNull;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.sonar.api.profiles.ProfileExporter;
-import org.sonar.api.profiles.ProfileImporter;
-import org.sonar.api.profiles.RulesProfile;
-import org.sonar.api.rule.RuleKey;
-import org.sonar.api.rules.ActiveRule;
-import org.sonar.api.rules.ActiveRuleParam;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.rules.RuleFinder;
-import org.sonar.api.rules.RulePriority;
-import org.sonar.api.server.ServerSide;
-import org.sonar.api.utils.ValidationMessages;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.qualityprofile.ActiveRuleDto;
-import org.sonar.db.qualityprofile.ActiveRuleParamDto;
-import org.sonar.db.qualityprofile.OrgActiveRuleDto;
-import org.sonar.db.qualityprofile.QProfileDto;
-import org.sonar.db.rule.RuleDto;
-import org.sonar.server.exceptions.BadRequestException;
-import org.sonar.server.exceptions.NotFoundException;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import static org.sonar.server.exceptions.BadRequestException.checkRequest;
-
-@ServerSide
-public class QProfileExporters {
-
- private final DbClient dbClient;
- private final RuleFinder ruleFinder;
- private final QProfileRules qProfileRules;
- private final ProfileExporter[] exporters;
- private final ProfileImporter[] importers;
-
- @Autowired(required = false)
- public QProfileExporters(DbClient dbClient, RuleFinder ruleFinder, QProfileRules qProfileRules, ProfileExporter[] exporters, ProfileImporter[] importers) {
- this.dbClient = dbClient;
- this.ruleFinder = ruleFinder;
- this.qProfileRules = qProfileRules;
- this.exporters = exporters;
- this.importers = importers;
- }
-
- /**
- * Used by the ioc container if no {@link ProfileImporter} is found
- */
- @Autowired(required = false)
- public QProfileExporters(DbClient dbClient, RuleFinder ruleFinder, QProfileRules qProfileRules, ProfileExporter[] exporters) {
- this(dbClient, ruleFinder, qProfileRules, exporters, new ProfileImporter[0]);
- }
-
- /**
- * Used by the ioc container if no {@link ProfileExporter} is found
- */
- @Autowired(required = false)
- public QProfileExporters(DbClient dbClient, RuleFinder ruleFinder, QProfileRules qProfileRules, ProfileImporter[] importers) {
- this(dbClient, ruleFinder, qProfileRules, new ProfileExporter[0], importers);
- }
-
- /**
- * Used by the ioc container if no {@link ProfileImporter} nor {@link ProfileExporter} is found
- */
- @Autowired(required = false)
- public QProfileExporters(DbClient dbClient, RuleFinder ruleFinder, QProfileRules qProfileRules) {
- this(dbClient, ruleFinder, qProfileRules, new ProfileExporter[0], new ProfileImporter[0]);
- }
-
- public List<ProfileExporter> exportersForLanguage(String language) {
- List<ProfileExporter> result = new ArrayList<>();
- for (ProfileExporter exporter : exporters) {
- if (exporter.getSupportedLanguages() == null || exporter.getSupportedLanguages().length == 0 || ArrayUtils.contains(exporter.getSupportedLanguages(), language)) {
- result.add(exporter);
- }
- }
- return result;
- }
-
- public String mimeType(String exporterKey) {
- ProfileExporter exporter = findExporter(exporterKey);
- return exporter.getMimeType();
- }
-
- public void export(DbSession dbSession, QProfileDto profile, String exporterKey, Writer writer) {
- ProfileExporter exporter = findExporter(exporterKey);
- exporter.exportProfile(wrap(dbSession, profile), writer);
- }
-
- private RulesProfile wrap(DbSession dbSession, QProfileDto profile) {
- RulesProfile target = new RulesProfile(profile.getName(), profile.getLanguage());
- List<OrgActiveRuleDto> activeRuleDtos = dbClient.activeRuleDao().selectByProfile(dbSession, profile);
- List<ActiveRuleParamDto> activeRuleParamDtos = dbClient.activeRuleDao().selectParamsByActiveRuleUuids(dbSession, Lists.transform(activeRuleDtos, ActiveRuleDto::getUuid));
- ListMultimap<String, ActiveRuleParamDto> activeRuleParamsByActiveRuleUuid = FluentIterable.from(activeRuleParamDtos).index(ActiveRuleParamDto::getActiveRuleUuid);
-
- for (ActiveRuleDto activeRule : activeRuleDtos) {
- // TODO all rules should be loaded by using one query with all active rule keys as parameter
- Rule rule = ruleFinder.findByKey(activeRule.getRuleKey());
- org.sonar.api.rules.ActiveRule wrappedActiveRule = target.activateRule(rule, RulePriority.valueOf(activeRule.getSeverityString()));
- List<ActiveRuleParamDto> paramDtos = activeRuleParamsByActiveRuleUuid.get(activeRule.getUuid());
- for (ActiveRuleParamDto activeRuleParamDto : paramDtos) {
- wrappedActiveRule.setParameter(activeRuleParamDto.getKey(), activeRuleParamDto.getValue());
- }
- }
- return target;
- }
-
- private ProfileExporter findExporter(String exporterKey) {
- for (ProfileExporter e : exporters) {
- if (exporterKey.equals(e.getKey())) {
- return e;
- }
- }
- throw new NotFoundException("Unknown quality profile exporter: " + exporterKey);
- }
-
- public QProfileResult importXml(QProfileDto profile, String importerKey, InputStream xml, DbSession dbSession) {
- return importXml(profile, importerKey, new InputStreamReader(xml, StandardCharsets.UTF_8), dbSession);
- }
-
- private QProfileResult importXml(QProfileDto profile, String importerKey, Reader xml, DbSession dbSession) {
- QProfileResult result = new QProfileResult();
- ValidationMessages messages = ValidationMessages.create();
- ProfileImporter importer = getProfileImporter(importerKey);
- RulesProfile definition = importer.importProfile(xml, messages);
- List<ActiveRuleChange> changes = importProfile(profile, definition, dbSession);
- result.addChanges(changes);
- processValidationMessages(messages, result);
- return result;
- }
-
- private List<ActiveRuleChange> importProfile(QProfileDto profile, RulesProfile definition, DbSession dbSession) {
- Map<RuleKey, RuleDto> rulesByRuleKey = dbClient.ruleDao().selectAll(dbSession)
- .stream()
- .collect(Collectors.toMap(RuleDto::getKey, Function.identity()));
- List<ActiveRule> activeRules = definition.getActiveRules();
- List<RuleActivation> activations = activeRules.stream()
- .map(activeRule -> toRuleActivation(activeRule, rulesByRuleKey))
- .filter(Objects::nonNull)
- .toList();
- return qProfileRules.activateAndCommit(dbSession, profile, activations);
- }
-
- private ProfileImporter getProfileImporter(String importerKey) {
- for (ProfileImporter importer : importers) {
- if (StringUtils.equals(importerKey, importer.getKey())) {
- return importer;
- }
- }
- throw BadRequestException.create("No such importer : " + importerKey);
- }
-
- private static void processValidationMessages(ValidationMessages messages, QProfileResult result) {
- checkRequest(messages.getErrors().isEmpty(), messages.getErrors());
- result.addWarnings(messages.getWarnings());
- result.addInfos(messages.getInfos());
- }
-
- @CheckForNull
- private static RuleActivation toRuleActivation(ActiveRule activeRule, Map<RuleKey, RuleDto> rulesByRuleKey) {
- RuleKey ruleKey = activeRule.getRule().ruleKey();
- RuleDto ruleDto = rulesByRuleKey.get(ruleKey);
- if (ruleDto == null) {
- return null;
- }
- String severity = activeRule.getSeverity().name();
- Map<String, String> params = activeRule.getActiveRuleParams().stream()
- .collect(Collectors.toMap(ActiveRuleParam::getKey, ActiveRuleParam::getValue));
- return RuleActivation.create(ruleDto.getUuid(), severity, params);
- }
-
-}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/BuiltInQProfileRepositoryImpl.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/BuiltInQProfileRepositoryImpl.java
index 5a5b0d07f77..dd20b9c78c8 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/BuiltInQProfileRepositoryImpl.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/BuiltInQProfileRepositoryImpl.java
@@ -32,7 +32,6 @@ import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
-import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.resources.Language;
import org.sonar.api.resources.Languages;
import org.sonar.api.rule.RuleKey;
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java
index bd38a0f3d2e..cc833d15e83 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java
@@ -19,13 +19,8 @@
*/
package org.sonar.server.qualityprofile.ws;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
import javax.annotation.Nullable;
-import org.sonar.api.profiles.ProfileImporter;
import org.sonar.api.resources.Languages;
-import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
@@ -33,10 +28,9 @@ import org.sonar.api.server.ws.WebService.NewAction;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.qualityprofile.QProfileDto;
-import org.sonar.server.qualityprofile.QProfileExporters;
import org.sonar.server.qualityprofile.QProfileFactory;
-import org.sonar.server.qualityprofile.builtin.QProfileName;
import org.sonar.server.qualityprofile.QProfileResult;
+import org.sonar.server.qualityprofile.builtin.QProfileName;
import org.sonar.server.qualityprofile.index.ActiveRuleIndexer;
import org.sonar.server.user.UserSession;
import org.sonarqube.ws.Qualityprofiles.CreateWsResponse;
@@ -48,37 +42,24 @@ import static org.sonar.server.ws.WsUtils.writeProtobuf;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_CREATE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_NAME;
-import org.springframework.beans.factory.annotation.Autowired;
public class CreateAction implements QProfileWsAction {
- private static final String PARAM_BACKUP_FORMAT = "backup_%s";
static final int NAME_MAXIMUM_LENGTH = 100;
private final DbClient dbClient;
private final QProfileFactory profileFactory;
- private final QProfileExporters exporters;
private final Languages languages;
- private final ProfileImporter[] importers;
private final UserSession userSession;
private final ActiveRuleIndexer activeRuleIndexer;
- @Autowired(required = false)
- public CreateAction(DbClient dbClient, QProfileFactory profileFactory, QProfileExporters exporters, Languages languages,
- UserSession userSession, ActiveRuleIndexer activeRuleIndexer, ProfileImporter... importers) {
+ public CreateAction(DbClient dbClient, QProfileFactory profileFactory, Languages languages,
+ UserSession userSession, ActiveRuleIndexer activeRuleIndexer) {
this.dbClient = dbClient;
this.profileFactory = profileFactory;
- this.exporters = exporters;
this.languages = languages;
this.userSession = userSession;
this.activeRuleIndexer = activeRuleIndexer;
- this.importers = importers;
- }
-
- @Autowired(required = false)
- public CreateAction(DbClient dbClient, QProfileFactory profileFactory, QProfileExporters exporters, Languages languages,
- UserSession userSession, ActiveRuleIndexer activeRuleIndexer) {
- this(dbClient, profileFactory, exporters, languages, userSession, activeRuleIndexer, new ProfileImporter[0]);
}
@Override
@@ -90,7 +71,6 @@ public class CreateAction implements QProfileWsAction {
.setResponseExample(getClass().getResource("create-example.json"))
.setSince("5.2")
.setHandler(this);
- List<Change> changelog = new ArrayList<>();
create.createParam(PARAM_NAME)
.setRequired(true)
@@ -103,16 +83,6 @@ public class CreateAction implements QProfileWsAction {
.setDescription("Quality profile language")
.setExampleValue("js")
.setPossibleValues(getOrderedLanguageKeys(languages));
-
- for (ProfileImporter importer : importers) {
- String backupParamName = getBackupParamName(importer.getKey());
- create.createParam(backupParamName)
- .setDescription(String.format("A configuration file for %s.", importer.getName()))
- .setDeprecatedSince("9.8");
- changelog.add(new Change("9.8", String.format("'%s' parameter is deprecated", backupParamName)));
- }
-
- create.setChangelog(changelog.toArray(new Change[0]));
}
@Override
@@ -121,21 +91,14 @@ public class CreateAction implements QProfileWsAction {
try (DbSession dbSession = dbClient.openSession(false)) {
userSession.checkPermission(ADMINISTER_QUALITY_PROFILES);
CreateRequest createRequest = toRequest(request);
- writeProtobuf(doHandle(dbSession, createRequest, request), request, response);
+ writeProtobuf(doHandle(dbSession, createRequest), request, response);
}
}
- private CreateWsResponse doHandle(DbSession dbSession, CreateRequest createRequest, Request request) {
+ private CreateWsResponse doHandle(DbSession dbSession, CreateRequest createRequest) {
QProfileResult result = new QProfileResult();
QProfileDto profile = profileFactory.checkAndCreateCustom(dbSession, QProfileName.createFor(createRequest.getLanguage(), createRequest.getName()));
result.setProfile(profile);
- for (ProfileImporter importer : importers) {
- String importerKey = importer.getKey();
- InputStream contentToImport = request.paramAsInputStream(getBackupParamName(importerKey));
- if (contentToImport != null) {
- result.add(exporters.importXml(profile, importerKey, contentToImport, dbSession));
- }
- }
activeRuleIndexer.commitAndIndex(dbSession, result.getChanges());
return buildResponse(result);
}
@@ -165,10 +128,6 @@ public class CreateAction implements QProfileWsAction {
return CreateWsResponse.newBuilder().setProfile(builder.build()).build();
}
- private static String getBackupParamName(String importerKey) {
- return String.format(PARAM_BACKUP_FORMAT, importerKey);
- }
-
private static class CreateRequest {
private final String name;
private final String language;
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ExportAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ExportAction.java
index ce8e5c5bdc0..bd39c10a605 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ExportAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ExportAction.java
@@ -24,14 +24,10 @@ import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Set;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.apache.commons.io.IOUtils;
-import org.sonar.api.profiles.ProfileExporter;
import org.sonar.api.resources.Languages;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.Response.Stream;
@@ -42,7 +38,6 @@ import org.sonar.db.DbSession;
import org.sonar.db.qualityprofile.QProfileDto;
import org.sonar.server.language.LanguageParamUtils;
import org.sonar.server.qualityprofile.QProfileBackuper;
-import org.sonar.server.qualityprofile.QProfileExporters;
import org.sonarqube.ws.MediaTypes;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -52,17 +47,13 @@ import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.
public class ExportAction implements QProfileWsAction {
- private static final String PARAM_EXPORTER_KEY = "exporterKey";
-
private final DbClient dbClient;
private final QProfileBackuper backuper;
- private final QProfileExporters exporters;
private final Languages languages;
- public ExportAction(DbClient dbClient, QProfileBackuper backuper, QProfileExporters exporters, Languages languages) {
+ public ExportAction(DbClient dbClient, QProfileBackuper backuper, Languages languages) {
this.dbClient = dbClient;
this.backuper = backuper;
- this.exporters = exporters;
this.languages = languages;
}
@@ -72,7 +63,10 @@ public class ExportAction implements QProfileWsAction {
.setSince("5.2")
.setDescription("Export a quality profile.")
.setResponseExample(getClass().getResource("export-example.xml"))
- .setHandler(this);
+ .setHandler(this)
+ .setDeprecatedSince("25.4")
+ .setChangelog(
+ new Change("25.4", "Deprecated. Use GET /api/qualityprofiles/backup instead"));
action.createParam(PARAM_QUALITY_PROFILE)
.setDescription("Quality profile name to export. If left empty, the default profile for the language is exported.")
@@ -84,17 +78,6 @@ public class ExportAction implements QProfileWsAction {
.setExampleValue(LanguageParamUtils.getExampleValue(languages))
.setPossibleValues(LanguageParamUtils.getOrderedLanguageKeys(languages));
- Set<String> exporterKeys = Arrays.stream(languages.all())
- .map(language -> exporters.exportersForLanguage(language.getKey()))
- .flatMap(Collection::stream)
- .map(ProfileExporter::getKey)
- .collect(Collectors.toSet());
- if (!exporterKeys.isEmpty()) {
- action.createParam(PARAM_EXPORTER_KEY)
- .setDescription("Output format. If left empty, the same format as api/qualityprofiles/backup is used. " +
- "Possible values are described by api/qualityprofiles/exporters.")
- .setPossibleValues(exporterKeys);
- }
}
@Override
@@ -104,22 +87,16 @@ public class ExportAction implements QProfileWsAction {
try (DbSession dbSession = dbClient.openSession(false)) {
QProfileDto profile = loadProfile(dbSession, language, name);
- String exporterKey = exporters.exportersForLanguage(profile.getLanguage()).isEmpty() ? null : request.param(PARAM_EXPORTER_KEY);
- writeResponse(dbSession, profile, exporterKey, response);
+ writeResponse(dbSession, profile, response);
}
}
- private void writeResponse(DbSession dbSession, QProfileDto profile, @Nullable String exporterKey, Response response) throws IOException {
+ private void writeResponse(DbSession dbSession, QProfileDto profile, Response response) throws IOException {
Stream stream = response.stream();
ByteArrayOutputStream bufferStream = new ByteArrayOutputStream();
try (Writer writer = new OutputStreamWriter(bufferStream, UTF_8)) {
- if (exporterKey == null) {
- stream.setMediaType(MediaTypes.XML);
- backuper.backup(dbSession, profile, writer);
- } else {
- stream.setMediaType(exporters.mimeType(exporterKey));
- exporters.export(dbSession, profile, exporterKey, writer);
- }
+ stream.setMediaType(MediaTypes.XML);
+ backuper.backup(dbSession, profile, writer);
}
OutputStream output = response.stream().output();
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ExportersAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ExportersAction.java
index de3190bcf3f..57a318e4761 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ExportersAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ExportersAction.java
@@ -19,53 +19,27 @@
*/
package org.sonar.server.qualityprofile.ws;
-import org.sonar.api.profiles.ProfileExporter;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService.NewController;
import org.sonar.api.utils.text.JsonWriter;
-import org.springframework.beans.factory.annotation.Autowired;
public class ExportersAction implements QProfileWsAction {
- private final ProfileExporter[] exporters;
-
- @Autowired(required = false)
- public ExportersAction(ProfileExporter[] exporters) {
- this.exporters = exporters;
- }
-
- /**
- * Used by the container if no {@link ProfileExporter} is found
- */
- @Autowired(required = false)
- public ExportersAction() {
- this(new ProfileExporter[0]);
- }
-
@Override
public void define(NewController context) {
context.createAction("exporters")
- .setDescription("Lists available profile export formats.")
+ .setDescription("Deprecated. No more custom profile exporters.")
.setHandler(this)
.setResponseExample(getClass().getResource("exporters-example.json"))
- .setSince("5.2");
+ .setSince("5.2")
+ .setDeprecatedSince("25.4");
}
@Override
public void handle(Request request, Response response) throws Exception {
try (JsonWriter json = response.newJsonWriter()) {
json.beginObject().name("exporters").beginArray();
- for (ProfileExporter exporter : exporters) {
- json.beginObject()
- .prop("key", exporter.getKey())
- .prop("name", exporter.getName());
- json.name("languages").beginArray();
- for (String language : exporter.getSupportedLanguages()) {
- json.value(language);
- }
- json.endArray().endObject();
- }
json.endArray().endObject();
}
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ImportersAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ImportersAction.java
index 078434db363..3d93cc675bb 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ImportersAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ImportersAction.java
@@ -19,50 +19,28 @@
*/
package org.sonar.server.qualityprofile.ws;
-import org.sonar.api.profiles.ProfileImporter;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.text.JsonWriter;
-import org.springframework.beans.factory.annotation.Autowired;
public class ImportersAction implements QProfileWsAction {
- private final ProfileImporter[] importers;
-
- @Autowired(required = false)
- public ImportersAction(ProfileImporter[] importers) {
- this.importers = importers;
- }
-
- @Autowired(required = false)
- public ImportersAction() {
- this(new ProfileImporter[0]);
- }
-
@Override
public void define(WebService.NewController controller) {
controller.createAction("importers")
+ .setDescription("Deprecated. No more custom profile importers.")
.setSince("5.2")
.setDescription("List supported importers.")
.setResponseExample(getClass().getResource("importers-example.json"))
- .setHandler(this);
+ .setHandler(this)
+ .setDeprecatedSince("25.4");
}
@Override
public void handle(Request request, Response response) throws Exception {
try (JsonWriter json = response.newJsonWriter()) {
json.beginObject().name("importers").beginArray();
- for (ProfileImporter importer : importers) {
- json.beginObject()
- .prop("key", importer.getKey())
- .prop("name", importer.getName())
- .name("languages").beginArray();
- for (String languageKey : importer.getSupportedLanguages()) {
- json.value(languageKey);
- }
- json.endArray().endObject();
- }
json.endArray().endObject();
}
}
diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualityprofile/ws/exporters-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualityprofile/ws/exporters-example.json
index 642a2bde09d..2d1cd2df442 100644
--- a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualityprofile/ws/exporters-example.json
+++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualityprofile/ws/exporters-example.json
@@ -1,33 +1,4 @@
{
"exporters": [
- {
- "key": "pmd",
- "name": "PMD",
- "languages": [
- "java"
- ]
- },
- {
- "key": "checkstyle",
- "name": "Checkstyle",
- "languages": [
- "java"
- ]
- },
- {
- "key": "js-lint",
- "name": "JS Lint",
- "languages": [
- "js"
- ]
- },
- {
- "key": "android-lint",
- "name": "Android Lint",
- "languages": [
- "xml",
- "java"
- ]
- }
]
}
diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualityprofile/ws/importers-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualityprofile/ws/importers-example.json
index 8750609887a..a6d01b82776 100644
--- a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualityprofile/ws/importers-example.json
+++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualityprofile/ws/importers-example.json
@@ -1,33 +1,4 @@
{
"importers": [
- {
- "key": "pmd",
- "name": "PMD",
- "languages": [
- "java"
- ]
- },
- {
- "key": "checkstyle",
- "name": "Checkstyle",
- "languages": [
- "java"
- ]
- },
- {
- "key": "js-lint",
- "name": "JS Lint",
- "languages": [
- "js"
- ]
- },
- {
- "key": "android-lint",
- "name": "Android Lint",
- "languages": [
- "xml",
- "java"
- ]
- }
]
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ExportersActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ExportersActionTest.java
index 4ab5db1b9ba..d2298c7f0d5 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ExportersActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ExportersActionTest.java
@@ -19,10 +19,7 @@
*/
package org.sonar.server.qualityprofile.ws;
-import java.io.Writer;
import org.junit.Test;
-import org.sonar.api.profiles.ProfileExporter;
-import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.server.ws.WebService;
import org.sonar.server.ws.WsActionTester;
@@ -30,7 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.test.JsonAssert.assertJson;
public class ExportersActionTest {
- private WsActionTester ws = new WsActionTester(new ExportersAction(createExporters()));
+ private final WsActionTester ws = new WsActionTester(new ExportersAction());
@Test
public void importers_nominal() {
@@ -48,24 +45,4 @@ public class ExportersActionTest {
assertThat(exporters.responseExampleAsString()).isNotEmpty();
}
- private ProfileExporter[] createExporters() {
- class NoopImporter extends ProfileExporter {
- private NoopImporter(String key, String name, String... languages) {
- super(key, name);
- setSupportedLanguages(languages);
- }
-
- @Override
- public void exportProfile(RulesProfile profile, Writer writer) {
- // Nothing
- }
-
- }
- return new ProfileExporter[] {
- new NoopImporter("pmd", "PMD", "java"),
- new NoopImporter("checkstyle", "Checkstyle", "java"),
- new NoopImporter("js-lint", "JS Lint", "js"),
- new NoopImporter("android-lint", "Android Lint", "xml", "java")
- };
- }
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ImportersActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ImportersActionTest.java
index 067a394af5a..63918caa13f 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ImportersActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ImportersActionTest.java
@@ -19,12 +19,8 @@
*/
package org.sonar.server.qualityprofile.ws;
-import java.io.Reader;
import org.junit.Test;
-import org.sonar.api.profiles.ProfileImporter;
-import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.server.ws.WebService;
-import org.sonar.api.utils.ValidationMessages;
import org.sonar.server.ws.WsActionTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -32,7 +28,7 @@ import static org.sonar.test.JsonAssert.assertJson;
public class ImportersActionTest {
- private WsActionTester ws = new WsActionTester(new ImportersAction(createImporters()));
+ private WsActionTester ws = new WsActionTester(new ImportersAction());
@Test
public void empty_importers() {
@@ -59,25 +55,4 @@ public class ImportersActionTest {
assertThat(importers.responseExampleAsString()).isNotEmpty();
}
- private ProfileImporter[] createImporters() {
- class NoopImporter extends ProfileImporter {
- private NoopImporter(String key, String name, String... languages) {
- super(key, name);
- setSupportedLanguages(languages);
- }
-
- @Override
- public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
- return RulesProfile.create();
- }
-
- }
-
- return new ProfileImporter[] {
- new NoopImporter("pmd", "PMD", "java"),
- new NoopImporter("checkstyle", "Checkstyle", "java"),
- new NoopImporter("js-lint", "JS Lint", "js"),
- new NoopImporter("android-lint", "Android Lint", "xml", "java")
- };
- }
}
diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
index a9885cbf8d6..cb5cb05bc90 100644
--- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
+++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
@@ -248,7 +248,6 @@ import org.sonar.server.qualitygate.ws.QualityGateWsModule;
import org.sonar.server.qualityprofile.QProfileBackuperImpl;
import org.sonar.server.qualityprofile.QProfileComparison;
import org.sonar.server.qualityprofile.QProfileCopier;
-import org.sonar.server.qualityprofile.QProfileExporters;
import org.sonar.server.qualityprofile.QProfileFactoryImpl;
import org.sonar.server.qualityprofile.QProfileParser;
import org.sonar.server.qualityprofile.QProfileResetImpl;
@@ -372,7 +371,6 @@ public class PlatformLevel4 extends PlatformLevel {
QProfileRulesImpl.class,
RuleActivator.class,
QualityProfileChangeEventServiceImpl.class,
- QProfileExporters.class,
QProfileFactoryImpl.class,
QProfileCopier.class,
QProfileBackuperImpl.class,
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java
index b4fd5512335..e84f2d3d5c8 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java
@@ -19,8 +19,6 @@
*/
package org.sonar.api.batch.sensor.internal;
-import static java.util.Collections.unmodifiableMap;
-
import java.io.File;
import java.io.InputStream;
import java.io.Serializable;
@@ -90,6 +88,8 @@ import org.sonar.api.scanner.fs.InputProject;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.Version;
+import static java.util.Collections.unmodifiableMap;
+
/**
* Utility class to help testing {@link Sensor}. This is not an API and method signature may evolve.
* <p>
@@ -462,4 +462,5 @@ public class SensorContextTester implements SensorContext {
public NewSignificantCode newSignificantCode() {
return new DefaultSignificantCode(sensorStorage);
}
+
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorContext.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorContext.java
index 855fd945109..6fb38fa4563 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorContext.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorContext.java
@@ -260,4 +260,5 @@ public class ProjectSensorContext implements SensorContext {
}
return false;
}
+
}