Browse Source

Remove deprecated APIs since at least 6.7

tags/8.3.0.34182
Julien HENRY 4 years ago
parent
commit
28faf35ead
43 changed files with 12 additions and 1928 deletions
  1. 0
    61
      server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/DeprecatedViews.java
  2. 0
    48
      server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/PageDecorations.java
  3. 0
    101
      server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/DeprecatedViewsTest.java
  4. 0
    46
      server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/PageDecorationsTest.java
  5. 0
    4
      server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
  6. 0
    95
      sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
  7. 0
    13
      sonar-plugin-api/src/main/java/org/sonar/api/SonarQubeVersion.java
  8. 1
    1
      sonar-plugin-api/src/main/java/org/sonar/api/i18n/I18n.java
  9. 0
    1
      sonar-plugin-api/src/main/java/org/sonar/api/platform/Server.java
  10. 0
    7
      sonar-plugin-api/src/main/java/org/sonar/api/scan/issue/filter/FilterableIssue.java
  11. 0
    38
      sonar-plugin-api/src/main/java/org/sonar/api/web/AbstractDashboardWidget.java
  12. 0
    89
      sonar-plugin-api/src/main/java/org/sonar/api/web/AbstractRubyTemplate.java
  13. 0
    203
      sonar-plugin-api/src/main/java/org/sonar/api/web/Dashboard.java
  14. 0
    77
      sonar-plugin-api/src/main/java/org/sonar/api/web/DashboardLayout.java
  15. 0
    47
      sonar-plugin-api/src/main/java/org/sonar/api/web/DashboardTemplate.java
  16. 0
    39
      sonar-plugin-api/src/main/java/org/sonar/api/web/DefaultTab.java
  17. 0
    35
      sonar-plugin-api/src/main/java/org/sonar/api/web/Description.java
  18. 0
    38
      sonar-plugin-api/src/main/java/org/sonar/api/web/Footer.java
  19. 0
    61
      sonar-plugin-api/src/main/java/org/sonar/api/web/NavigationSection.java
  20. 0
    29
      sonar-plugin-api/src/main/java/org/sonar/api/web/Page.java
  21. 0
    34
      sonar-plugin-api/src/main/java/org/sonar/api/web/PageDecoration.java
  22. 0
    44
      sonar-plugin-api/src/main/java/org/sonar/api/web/ResourceLanguage.java
  23. 0
    44
      sonar-plugin-api/src/main/java/org/sonar/api/web/ResourceQualifier.java
  24. 0
    44
      sonar-plugin-api/src/main/java/org/sonar/api/web/ResourceScope.java
  25. 0
    34
      sonar-plugin-api/src/main/java/org/sonar/api/web/RubyRailsPage.java
  26. 0
    42
      sonar-plugin-api/src/main/java/org/sonar/api/web/RubyRailsWidget.java
  27. 0
    29
      sonar-plugin-api/src/main/java/org/sonar/api/web/Section.java
  28. 0
    37
      sonar-plugin-api/src/main/java/org/sonar/api/web/View.java
  29. 0
    41
      sonar-plugin-api/src/main/java/org/sonar/api/web/Webservice.java
  30. 0
    28
      sonar-plugin-api/src/main/java/org/sonar/api/web/Widget.java
  31. 0
    36
      sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetCategory.java
  32. 0
    36
      sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetLayout.java
  33. 0
    29
      sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetLayoutType.java
  34. 0
    32
      sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetProperties.java
  35. 0
    60
      sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetProperty.java
  36. 0
    95
      sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetPropertyType.java
  37. 0
    46
      sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetScope.java
  38. 0
    71
      sonar-plugin-api/src/test/java/org/sonar/api/web/AbstractRubyTemplateTest.java
  39. 0
    84
      sonar-plugin-api/src/test/java/org/sonar/api/web/DashboardTest.java
  40. 1
    1
      sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerWsClientProvider.java
  41. 3
    12
      sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultFilterableIssue.java
  42. 5
    8
      sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssueFilters.java
  43. 2
    8
      sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/DefaultFilterableIssueTest.java

+ 0
- 61
server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/DeprecatedViews.java View File

@@ -1,61 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.ui;

import org.sonar.api.Startable;
import org.sonar.api.server.ServerSide;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.api.web.View;
import org.sonar.api.web.Widget;
import org.sonar.api.web.page.PageDefinition;

/**
* @deprecated since 6.3 see {@link org.sonar.api.web.page.PageDefinition}. This class logs warnings at startup if there are pages using the old page API.
*/
@ServerSide
@Deprecated
public class DeprecatedViews implements Startable {

private static final Logger LOGGER = Loggers.get(DeprecatedViews.class);

private final View[] views;

public DeprecatedViews() {
this.views = new View[0];
}

public DeprecatedViews(View[] views) {
this.views = views;
}

@Override
public void start() {
for (View view : views) {
String pageOrWidget = view instanceof Widget ? "Widget" : "Page";
LOGGER.warn("{} '{}' ({}) is ignored. See {} to define pages.", pageOrWidget, view.getTitle(), view.getId(), PageDefinition.class.getCanonicalName());
}
}

@Override
public void stop() {
// do nothing
}
}

+ 0
- 48
server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/PageDecorations.java View File

@@ -1,48 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.ui;

import java.util.Collections;
import java.util.List;
import org.sonar.api.server.ServerSide;
import org.sonar.api.web.PageDecoration;

/**
* @since 3.3
* @deprecated since 6.3 see {@link org.sonar.api.web.page.PageDefinition}. This class has not effect.
*/
@ServerSide
@Deprecated
public final class PageDecorations {

private final PageDecoration[] decorations;

public PageDecorations(List<PageDecoration> decorations) {
this.decorations = decorations.toArray(new PageDecoration[decorations.size()]);
}

public PageDecorations() {
this(Collections.emptyList());
}

public PageDecoration[] get() {
return decorations;// NOSONAR expose internal representation
}
}

+ 0
- 101
server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/DeprecatedViewsTest.java View File

@@ -1,101 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.ui;

import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.utils.log.LogTester;
import org.sonar.api.utils.log.LoggerLevel;
import org.sonar.api.web.Page;
import org.sonar.api.web.View;
import org.sonar.api.web.Widget;

import static org.assertj.core.api.Assertions.assertThat;

public class DeprecatedViewsTest {

@Rule
public LogTester logger = new LogTester();

private DeprecatedViews underTest;

@Test
public void no_log_when_no_views() {
underTest = new DeprecatedViews();
underTest.start();

assertThat(logger.logs()).isEmpty();
}

@Test
public void log_one_warning_by_view() {
underTest = new DeprecatedViews(new View[] {
new FakePage("governance/my_page", "My Page"),
new FakeWidget("governance/my_widget", "My Widget")});
assertThat(logger.logs()).isEmpty();

underTest.start();

assertThat(logger.logs()).hasSize(2);
assertThat(logger.logs(LoggerLevel.WARN)).containsExactly(
"Page 'My Page' (governance/my_page) is ignored. See org.sonar.api.web.page.PageDefinition to define pages.",
"Widget 'My Widget' (governance/my_widget) is ignored. See org.sonar.api.web.page.PageDefinition to define pages.");
}

private static final class FakeWidget implements Widget {
private final String id;
private final String name;

private FakeWidget(String id, String name) {
this.id = id;
this.name = name;
}

@Override
public String getId() {
return id;
}

@Override
public String getTitle() {
return name;
}
}

private static class FakePage implements Page {
private final String id;
private final String name;

FakePage(String id, String name) {
this.id = id;
this.name = name;
}

@Override
public String getId() {
return id;
}

@Override
public String getTitle() {
return name;
}
}
}

+ 0
- 46
server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/PageDecorationsTest.java View File

@@ -1,46 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.ui;

import org.junit.Test;
import org.sonar.api.web.PageDecoration;

import java.util.Arrays;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;

public class PageDecorationsTest {

@Test
public void should_not_fail_if_no_decorations() {
assertThat(new PageDecorations().get()).isEmpty();
}

@Test
public void should_register_decorations() {
PageDecoration deco1 = mock(PageDecoration.class);
PageDecoration deco2 = mock(PageDecoration.class);

PageDecorations decorations = new PageDecorations(Arrays.asList(deco1, deco2));

assertThat(decorations.get()).hasSize(2);
}
}

+ 0
- 4
server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java View File

@@ -192,8 +192,6 @@ import org.sonar.server.telemetry.TelemetryDaemon;
import org.sonar.server.telemetry.TelemetryDataJsonWriter;
import org.sonar.server.telemetry.TelemetryDataLoaderImpl;
import org.sonar.server.text.MacroInterpreter;
import org.sonar.server.ui.DeprecatedViews;
import org.sonar.server.ui.PageDecorations;
import org.sonar.server.ui.PageRepository;
import org.sonar.server.ui.WebAnalyticsLoaderImpl;
import org.sonar.server.ui.ws.NavigationWsModule;
@@ -250,12 +248,10 @@ public class PlatformLevel4 extends PlatformLevel {
LogOAuthWarning.class,
PluginDownloader.class,
PluginUninstaller.class,
DeprecatedViews.class,
PageRepository.class,
ResourceTypes.class,
DefaultResourceTypes.get(),
SettingsChangeNotifier.class,
PageDecorations.class,
ServerWs.class,
BackendCleanup.class,
IndexDefinitions.class,

+ 0
- 95
sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java View File

@@ -111,13 +111,6 @@ public interface CoreProperties {
*/
String CATEGORY_SECURITY = "security";

/**
* @since 2.11
* @deprecated since 6.0
*/
@Deprecated
String CATEGORY_JAVA = "java";

/**
* @since 3.3
*/
@@ -206,29 +199,6 @@ public interface CoreProperties {
String CORE_FORCE_AUTHENTICATION_PROPERTY = "sonar.forceAuthentication";
boolean CORE_FORCE_AUTHENTICATION_DEFAULT_VALUE = false;

/**
* @deprecated since 6.3. This feature is not supported anymore
* @see <a href="https://jira.sonarsource.com/browse/SONAR-7762">SONAR-7762/a>
*/
@Deprecated
String CORE_ALLOW_USERS_TO_SIGNUP_PROPERTY = "sonar.allowUsersToSignUp";

/**
* @deprecated since 6.4. The default group is hardcoded to 'sonar-users'
* @see <a href="https://jira.sonarsource.com/browse/SONAR-9014">SONAR-9014/a>
*/
@Deprecated
String CORE_DEFAULT_GROUP = "sonar.defaultGroup";

/**
* @deprecated since 6.4. The default group is hardcoded to 'sonar-users'
* @see <a href="https://jira.sonarsource.com/browse/SONAR-9014">SONAR-9014/a>
*/
@Deprecated
String CORE_DEFAULT_GROUP_DEFAULT_VALUE = "sonar-users";

boolean CORE_ALLOW_USERS_TO_SIGNUP_DEAULT_VALUE = false;

/**
* @deprecated since 2.14. See http://jira.sonarsource.com/browse/SONAR-3153. Replaced by {@link #CORE_AUTHENTICATOR_REALM}.
*/
@@ -275,15 +245,6 @@ public interface CoreProperties {
*/
String SERVER_BASE_URL = "sonar.core.serverBaseURL";

/**
* @see #SERVER_BASE_URL
* @since 2.10
* @deprecated since 5.6. This constant default value is incorrect if a host and/or a port and/or a context have been configured.
* The correct default value when {@link #SERVER_BASE_URL} is not set is provided by {@link Server#getURL()}.
*/
@Deprecated
String SERVER_BASE_URL_DEFAULT_VALUE = "http://localhost:9000";

/**
* @since 2.11
* @deprecated since 6.7
@@ -296,27 +257,6 @@ public interface CoreProperties {
*/
String CPD_EXCLUSIONS = "sonar.cpd.exclusions";

/**
* @since 2.11
* @deprecated in 6.7. See {@link Server#getPermanentServerId()}
*/
@Deprecated
String ORGANISATION = "sonar.organisation";

/**
* @since 2.11
* @deprecated in 6.7. See {@link Server#getPermanentServerId()}
*/
@Deprecated
String PERMANENT_SERVER_ID = "sonar.server_id";

/**
* @since 2.11
* @deprecated in 6.7. See {@link Server#getPermanentServerId()}
*/
@Deprecated
String SERVER_ID_IP_ADDRESS = "sonar.server_id.ip_address";

/**
* @since 3.3
*/
@@ -374,13 +314,6 @@ public interface CoreProperties {
// TODO remove?
String PROFILING_LOG_PROPERTY = "sonar.showProfiling";

/**
* @since 4.0
* @deprecated replaced in 5.2 by the permission 'provisioning'
*/
@Deprecated
String CORE_PREVENT_AUTOMATIC_PROJECT_CREATION = "sonar.preventAutoProjectCreation";

/**
* @since 4.0
*/
@@ -394,27 +327,6 @@ public interface CoreProperties {
String GLOBAL_WORKING_DIRECTORY = "sonar.globalWorking.directory";
String GLOBAL_WORKING_DIRECTORY_DEFAULT_VALUE = "";

/**
* @since 4.2
* @deprecated no more used since 5.5
*/
@Deprecated
String CORE_AUTHENTICATOR_LOCAL_USERS = "sonar.security.localUsers";

/**
* @since 4.0
* @deprecated no more used since 6.3. See https://jira.sonarsource.com/browse/SONAR-8610
*/
@Deprecated
String HOURS_IN_DAY = "sonar.technicalDebt.hoursInDay";

/**
* @since 4.5
* @deprecated no used anymore since 5.2
*/
@Deprecated
String SIZE_METRIC = "sonar.technicalDebt.sizeMetric";

/**
* @since 4.5
*/
@@ -475,13 +387,6 @@ public interface CoreProperties {
*/
String SCM_PROVIDER_KEY = "sonar.scm.provider";

/**
* @since 5.1
* @deprecated since 6.3. No longer taken into consideration as all files are always imported.
*/
@Deprecated
String IMPORT_UNKNOWN_FILES_KEY = "sonar.import_unknown_files";

/**
* @since 5.1
*/

+ 0
- 13
sonar-plugin-api/src/main/java/org/sonar/api/SonarQubeVersion.java View File

@@ -137,19 +137,6 @@ import static java.util.Objects.requireNonNull;
@Immutable
@Deprecated
public class SonarQubeVersion {
/**
* Constant for version 5.5
* @deprecated in 6.0. Please define your own constants.
*/
@Deprecated
public static final Version V5_5 = Version.create(5, 5);

/**
* Constant for version 5.6
* @deprecated in 6.0. Please define your own constants.
*/
@Deprecated
public static final Version V5_6 = Version.create(5, 6);

private final Version version;


+ 1
- 1
sonar-plugin-api/src/main/java/org/sonar/api/i18n/I18n.java View File

@@ -29,7 +29,7 @@ import org.sonar.api.server.ServerSide;
* Main component that provides translation facilities.
*
* @since 2.10
* @deprecated since 7.8 as plugins as no reason to use it anymore
* @deprecated since 7.8 as plugins have no reason to use it anymore
*/
@ServerSide
@ComputeEngineSide

+ 0
- 1
sonar-plugin-api/src/main/java/org/sonar/api/platform/Server.java View File

@@ -87,7 +87,6 @@ public abstract class Server {

/**
* Return the public root url, without trailing slash, for instance : https://nemo.sonarqube.org.
* Default value is {@link org.sonar.api.CoreProperties#SERVER_BASE_URL_DEFAULT_VALUE}
*
* @since 5.4
*/

+ 0
- 7
sonar-plugin-api/src/main/java/org/sonar/api/scan/issue/filter/FilterableIssue.java View File

@@ -19,7 +19,6 @@
*/
package org.sonar.api.scan.issue.filter;

import java.util.Date;
import javax.annotation.CheckForNull;
import javax.annotation.concurrent.ThreadSafe;
import org.sonar.api.batch.fs.TextRange;
@@ -64,12 +63,6 @@ public interface FilterableIssue {
@CheckForNull
Double gap();

/**
* @deprecated since 6.6 useless since creation date is computed on server side
*/
@Deprecated
Date creationDate();

/**
* @deprecated since 7.6 filtering issue should not depend on the key
*/

+ 0
- 38
sonar-plugin-api/src/main/java/org/sonar/api/web/AbstractDashboardWidget.java View File

@@ -1,38 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

/**
* @since 1.10
* @deprecated override org.sonar.api.web.AbstractRubyTemplate and implement org.sonar.api.web.RubyRailsWidget
*/
@Deprecated
public abstract class AbstractDashboardWidget extends AbstractRubyTemplate implements RubyRailsWidget {

@Override
public String getId() {
return getClass().getSimpleName();
}

@Override
public String getTitle() {
return getClass().getSimpleName();
}
}

+ 0
- 89
sonar-plugin-api/src/main/java/org/sonar/api/web/AbstractRubyTemplate.java View File

@@ -1,89 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.sonar.api.utils.SonarException;

import static java.nio.charset.StandardCharsets.UTF_8;

/**
* @since 1.11
* @deprecated since 6.3. This class is ignored.
*/
@Deprecated
public abstract class AbstractRubyTemplate {

private String cache = null;

public String getTemplate() {
String result = loadTemplateFromCache();
try {
if (result == null) {
result = loadTemplateFromClasspath();
}
if (result == null) {
result = loadTemplateFromAbsolutePath();
}
return result;

} catch (IOException e) {
throw new SonarException("Can not read the file " + getTemplatePath(), e);
}
}

private String loadTemplateFromAbsolutePath() throws IOException {
File file = new File(getTemplatePath());
if (file.exists()) {
// the result is not cached
return FileUtils.readFileToString(file, UTF_8);
}
throw new FileNotFoundException(getTemplatePath());
}

private String loadTemplateFromClasspath() throws IOException {
InputStream input = getClass().getResourceAsStream(getTemplatePath());
try {
if (input != null) {
cache = IOUtils.toString(input);
return cache;
}
} finally {
IOUtils.closeQuietly(input);
}
return null;
}

protected String loadTemplateFromCache() {
return cache;
}

/**
* the path of the template. In production environment, it's the classloader path (for example "/org/sonar/my_template.erb").
* In dev mode, it's useful to return an absolute path (for example C:/temp/my_template.erb). In such a case the result is not cached.
*/
protected abstract String getTemplatePath();

}

+ 0
- 203
sonar-plugin-api/src/main/java/org/sonar/api/web/Dashboard.java View File

@@ -1,203 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* Definition of a dashboard.
* <br>
* Its name and description can be retrieved using the i18n mechanism, using the keys "dashboard.&lt;id&gt;.name" and
* "dashboard.&lt;id&gt;.description".
*
* @since 2.13
* @deprecated since 6.2, this extension is ignored as dashboards have been removed
*/
@Deprecated
public final class Dashboard {

private String description;
private DashboardLayout layout = DashboardLayout.TWO_COLUMNS;
private Map<Integer, List<Widget>> widgetsByColumn = new HashMap<>();
private boolean activated = true;
private boolean global = false;

private Dashboard() {
}

/**
* Creates a new {@link Dashboard}.
*/
public static Dashboard create() {
return new Dashboard();
}

/**
* Add a widget with the given parameters, and return the newly created {@link Widget} object if one wants to add parameters to it.
* <p>The widget ids are listed by the web service /api/widgets
*
* @param widgetId id of an existing widget
* @param columnId column starts with 1. The widget is ignored if the column id does not match the layout.
*/
public Widget addWidget(String widgetId, int columnId) {
if (columnId < 1) {
throw new IllegalArgumentException("Widget column starts with 1");
}

Widget widget = new Widget(widgetId);
widgetsByColumn.computeIfAbsent(columnId, x -> new ArrayList<>()).add(widget);
return widget;
}

public Collection<Widget> getWidgets() {
return widgetsByColumn.values().stream().flatMap(List::stream).collect(Collectors.toList());
}

public List<Widget> getWidgetsOfColumn(int columnId) {
return widgetsByColumn.get(columnId);
}

/**
* Returns the description of the dashboard.
*
* @return the description
*/
public String getDescription() {
return description;
}

/**
* Sets the description of the dashboard.
* <br>
* Note: you should use the i18n mechanism for the description.
*
* @param description the description to set
*/
public Dashboard setDescription(String description) {
this.description = description;
return this;
}

/**
* Returns the layout. Default value is the 2 columns mode with width 50%/50%.
*
* @return the layout
*/
public DashboardLayout getLayout() {
return layout;
}

public Dashboard setLayout(DashboardLayout dl) {
if (dl == null) {
throw new IllegalArgumentException("The layout can not be null");
}
this.layout = dl;
return this;
}

/**
* A dashboard is global when it doesn't display information from a project but rather more general information.
* <p>Before version 3.1 no dashboard was global.
* <p>Since version 6.1, project dashboards are dropped. Project dashboards (global=false) are ignored.</p>
*
* @since 3.1
*/
public boolean isGlobal() {
return global;
}

/**
* A dashboard is global when it doesn't display information from a project but rather more general information.
* <p>Before version 3.1 no dashboard was global.</p>
* <p>Since version 6.1, project dashboards are dropped. Project dashboards (global=false) are ignored.</p>
*
* @since 3.1
*/
public Dashboard setGlobal(boolean global) {
this.global = global;
return this;
}

/**
* A dashboard can be activated for all anonymous users or users who haven't configured their own dashboards.
* <p>Before version 3.1 every dashboard created through this extension point was automatically activated.
* This is still the default behavior.
*
* @since 3.1
*/
public boolean isActivated() {
return activated;
}

/**
* Set whether the dashboard is activated for all anonymous users or users who haven't configured their own dashboards.
*
* @since 3.1
*/
public Dashboard setActivated(boolean activated) {
this.activated = activated;
return this;
}

/**
* Note that this class is an inner class to avoid confusion with the extension point org.sonar.api.web.Widget.
*/
public static final class Widget {
private String id;
private Map<String, String> properties;

Widget(String id) {
this.id = id;
this.properties = new HashMap<>();
}

public Widget setProperty(String key, String value) {
properties.put(key, value);
return this;
}

/**
* Returns the properties of this widget.
*
* @return the properties
*/
public Map<String, String> getProperties() {
return properties;
}

public String getProperty(String key) {
return properties.get(key);
}

/**
* Returns the identifier of this widget.
*
* @return the id
*/
public String getId() {
return id;
}
}
}

+ 0
- 77
sonar-plugin-api/src/main/java/org/sonar/api/web/DashboardLayout.java View File

@@ -1,77 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

/**
* Possible layouts for a dashboard.
*
* @since 2.13
* @deprecated since 6.2, this extension is ignored as dashboards have been removed
*/
@Deprecated
public enum DashboardLayout {

/**
* Only 1 column that take all the page
*/
ONE_COLUMN("100%", 1),

/**
* 2 columns of the same width
*/
TWO_COLUMNS("50%-50%", 2),

/**
* 2 columns with the first one smaller than the second
*/
TWO_COLUMNS_30_70("30%-70%", 2),

/**
* 2 columns with the first one bigger than the second
*/
TWO_COLUMNS_70_30("70%-30%", 2),

/**
* 3 columns of the same width
*/
TREE_COLUMNS("33%-33%-33%", 3);

private String code;
private int columns;

DashboardLayout(String code, int columns) {
this.code = code;
this.columns = columns;
}

public String getCode() {
return code;
}

public int getColumns() {
return columns;
}

@Override
public String toString() {
return code;
}

}

+ 0
- 47
sonar-plugin-api/src/main/java/org/sonar/api/web/DashboardTemplate.java View File

@@ -1,47 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import org.sonar.api.ExtensionPoint;
import org.sonar.api.server.ServerSide;

/**
* This extension point must be implemented to define a new dashboard.
*
* @since 2.13
* @deprecated since 6.2, this extension is ignored as dashboards have been removed
*/
@Deprecated
@ServerSide
@ExtensionPoint
public abstract class DashboardTemplate {

/**
* Returns the {@link Dashboard} object that represents the dashboard to use.
*
* @return the dashboard
*/
public abstract Dashboard createDashboard();

/**
* Dashboard name
*/
public abstract String getName();
}

+ 0
- 39
sonar-plugin-api/src/main/java/org/sonar/api/web/DefaultTab.java View File

@@ -1,39 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* @since 2.0
* @deprecated since 6.3 see {@link org.sonar.api.web.page.PageDefinition}. This class is ignored.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Deprecated
public @interface DefaultTab {

// default value is all metrics
String[] metrics() default {};
}

+ 0
- 35
sonar-plugin-api/src/main/java/org/sonar/api/web/Description.java View File

@@ -1,35 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* @deprecated since 6.3 see {@link org.sonar.api.web.page.PageDefinition}. This class is ignored.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Deprecated
public @interface Description {
String value();
}

+ 0
- 38
sonar-plugin-api/src/main/java/org/sonar/api/web/Footer.java View File

@@ -1,38 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import org.sonar.api.ExtensionPoint;
import org.sonar.api.server.ServerSide;

/**
* @since 1.10
* @deprecated since 6.3. This extension is ignored.
*/
@ServerSide
@ExtensionPoint
@Deprecated
public interface Footer {

/**
* Static HTML
*/
String getHtml();
}

+ 0
- 61
sonar-plugin-api/src/main/java/org/sonar/api/web/NavigationSection.java View File

@@ -1,61 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* The Page is displayed only in listed sections. This annotation is ignored on Widgets.
*
* @since 1.11
* @deprecated since 6.3 see {@link org.sonar.api.web.page.PageDefinition}. This class is ignored.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Deprecated
public @interface NavigationSection {

String HOME = "home";
String RESOURCE = "resource";

/**
* Support removed in 5.1. See https://jira.sonarsource.com/browse/SONAR-6016.
* @deprecated in 4.5, as it costs too much to maintain and update.
* @see <a href="https://jira.sonarsource.com/browse/SONAR-5321">SONAR-5321</a>
*/
@Deprecated
String RESOURCE_TAB = "resource_tab";

String CONFIGURATION = "configuration";

/**
* Only Ruby and rails application. See "Extend Web Application" section of https://redirect.sonarsource.com/doc/extension-guide.html.
* Use the resource parameter in order to get the current resource.
*
* @since 3.6
*/
String RESOURCE_CONFIGURATION = "resource_configuration";

String[] value() default { HOME };

}

+ 0
- 29
sonar-plugin-api/src/main/java/org/sonar/api/web/Page.java View File

@@ -1,29 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

/**
* @since 2.0
* @deprecated since 6.3 see {@link org.sonar.api.web.page.PageDefinition}. This class is ignored.
*/
@Deprecated
public interface Page extends View {
}

+ 0
- 34
sonar-plugin-api/src/main/java/org/sonar/api/web/PageDecoration.java View File

@@ -1,34 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import org.sonar.api.ExtensionPoint;
import org.sonar.api.server.ServerSide;

/**
* @since 3.3
* @deprecated since 6.3 see {@link org.sonar.api.web.page.PageDefinition}. This class is ignored.
*/
@ServerSide
@ExtensionPoint
@Deprecated
public abstract class PageDecoration extends AbstractRubyTemplate {

}

+ 0
- 44
sonar-plugin-api/src/main/java/org/sonar/api/web/ResourceLanguage.java View File

@@ -1,44 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* The view is displayed only if the selected resource has the same language.
*
* @since 1.11
* @deprecated since 6.3 see {@link org.sonar.api.web.page.PageDefinition}. This class is ignored.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Deprecated
public @interface ResourceLanguage {

/**
* An empty value means all resource scopes.
*/
String[] value() default {};

}


+ 0
- 44
sonar-plugin-api/src/main/java/org/sonar/api/web/ResourceQualifier.java View File

@@ -1,44 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* The view is displayed only if the selected resource has the same qualifier.
*
* @since 1.11
* @deprecated since 6.3 see {@link org.sonar.api.web.page.PageDefinition}. This class is ignored.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Deprecated
public @interface ResourceQualifier {

/**
* An empty value means all resource scopes.
*/
String[] value() default {};

}


+ 0
- 44
sonar-plugin-api/src/main/java/org/sonar/api/web/ResourceScope.java View File

@@ -1,44 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;


/**
* The view is displayed only if the selected resource has the same qualifier.
*
* @since 1.11
* @deprecated since 6.3 see {@link org.sonar.api.web.page.PageDefinition}. This class is ignored.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Deprecated
public @interface ResourceScope {

/**
* An empty value means all resource scopes.
*/
String[] value() default {};

}

+ 0
- 34
sonar-plugin-api/src/main/java/org/sonar/api/web/RubyRailsPage.java View File

@@ -1,34 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

/**
* @since 1.11
* @deprecated since 6.3 see {@link org.sonar.api.web.page.PageDefinition}. This class is ignored.
*/
@Deprecated
public interface RubyRailsPage extends Page {

/**
* @return Content of the Ruby on Rails template
*/
String getTemplate();

}

+ 0
- 42
sonar-plugin-api/src/main/java/org/sonar/api/web/RubyRailsWidget.java View File

@@ -1,42 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

/**
* Widget in project dashboard page. It's recommended to also extend AbstractRubyTemplate :
* <br>
* <code>
* public class MyWidget extends AbstractRubyTemplate implements RubyRailsWidget {
* protected String getTemplatePath() {
* return "/myplugin/my_template.erb";
* }
* }
* </code>
*
* @since 1.11
* @deprecated since 6.2, this extension is ignored as dashboards have been removed
*/
@Deprecated
public interface RubyRailsWidget extends Widget {
/**
* @return content of the Ruby on Rails template
*/
String getTemplate();
}

+ 0
- 29
sonar-plugin-api/src/main/java/org/sonar/api/web/Section.java View File

@@ -1,29 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

/**
* @since 1.10
* @deprecated add annotation org.sonar.api.web.NavigationSection to View extensions
*/
@Deprecated
public enum Section {
HOME, PROJECT, CONFIGURATION
}

+ 0
- 37
sonar-plugin-api/src/main/java/org/sonar/api/web/View.java View File

@@ -1,37 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import org.sonar.api.ExtensionPoint;
import org.sonar.api.server.ServerSide;

/**
* @since 1.11
* @deprecated since 6.3 see {@link org.sonar.api.web.page.PageDefinition}. This class is ignored.
*/
@ServerSide
@ExtensionPoint
@Deprecated
public interface View {

String getId();

String getTitle();
}

+ 0
- 41
sonar-plugin-api/src/main/java/org/sonar/api/web/Webservice.java View File

@@ -1,41 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import org.sonar.api.ExtensionPoint;
import org.sonar.api.server.ServerSide;

/**
* Interface to create a web service extension point
*
* @since 1.11
* @deprecated in 4.2. Replaced by {@link org.sonar.api.server.ws.WebService}
*/
@Deprecated
@ServerSide
@ExtensionPoint
public interface Webservice {

/**
* @return The id of the web service
*/
String getId();

}

+ 0
- 28
sonar-plugin-api/src/main/java/org/sonar/api/web/Widget.java View File

@@ -1,28 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

/**
* @since 1.11
* @deprecated since 6.2, this extension is ignored as dashboards have been removed
*/
@Deprecated
public interface Widget extends View {
}

+ 0
- 36
sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetCategory.java View File

@@ -1,36 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* @since 2.4
* @deprecated since 6.2, this extension is ignored as dashboards have been removed
*/
@Deprecated
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface WidgetCategory {
String[] value();
}

+ 0
- 36
sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetLayout.java View File

@@ -1,36 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* @since 2.4
* @deprecated since 6.2, this extension is ignored as dashboards have been removed
*/
@Deprecated
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface WidgetLayout {
WidgetLayoutType value();
}

+ 0
- 29
sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetLayoutType.java View File

@@ -1,29 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

/**
* @since 2.4
* @deprecated since 6.2, this extension is ignored as dashboards have been removed
*/
@Deprecated
public enum WidgetLayoutType {
DEFAULT, NONE
}

+ 0
- 32
sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetProperties.java View File

@@ -1,32 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
* @deprecated since 6.2, this extension is ignored as dashboards have been removed
*/
@Deprecated
@Retention(RetentionPolicy.RUNTIME)
public @interface WidgetProperties {
WidgetProperty[] value() default {};
}

+ 0
- 60
sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetProperty.java View File

@@ -1,60 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* @deprecated since 6.2, this extension is ignored as dashboards have been removed
*/
@Deprecated
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface WidgetProperty {

String key();

WidgetPropertyType type() default WidgetPropertyType.STRING;

String defaultValue() default "";

String description() default "";

boolean optional() default true;

/**
* @since 3.3 Options for property of type {@link WidgetPropertyType#METRIC}.
*
* If no option is specified, any metric will match.
* If options are specified, all must match for the metric to be displayed.
* Three types of filter are supported <code>key:REGEXP</code>, <code>domain:REGEXP</code> and <code>type:comma_separated__list_of_types</code>.
* For example <code>key:new_.*</code> will match any metric which key starts by <code>new_</code>.
* For example <code>type:INT,FLOAT</code> will match any metric of type <code>INT</code> or <code>FLOAT</code>.
* For example <code>type:NUMERIC</code> will match any metric of numerictype.
*
* @since 3.5 Options for property of type {@link WidgetPropertyType#SINGLE_SELECT_LIST}.
* For example {"property_1", "property_3", "property_3"}).
*
*/
String[] options() default {};
}

+ 0
- 95
sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetPropertyType.java View File

@@ -1,95 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

/**
* @deprecated since 6.2, this extension is ignored as dashboards have been removed
*/
@Deprecated
public enum WidgetPropertyType {
/**
* Integer value, positive or negative
*/
INTEGER,

/**
* True/False
*/
BOOLEAN,

/**
* Floating point number
*/
FLOAT,

/**
* Basic single line input field
*/
STRING,

/**
* Sonar Metric
*
* @since 2.10
*/
METRIC,

/**
* Measure Filter id
*
* @since 3.1
*/
FILTER,

/**
* Issue Filter id
*
* @since 3.7
*/
ISSUE_FILTER,

/**
* Multiple line text-area
*
* @since 3.2
*/
TEXT,

/**
* Variation of {#STRING} with masked characters
*
* @since 3.2
*/
PASSWORD,

/**
* Regular expression
*
* @since 3.2
*/
REGULAR_EXPRESSION,

/**
* Single select list with a list of options
*
* @since 3.5
*/
SINGLE_SELECT_LIST
}

+ 0
- 46
sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetScope.java View File

@@ -1,46 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Depending on its scope, a widget can be available for project dashboards <code>(value = "PROJECT")</code>,
* global dashboards <code>(value = "GLOBAL")</code> or both <code>(value = {"PROJECT", "GLOBAL"})</code>.
*
* <p>Before version 3.1 all widget had a scope <code>"PROJECT"</code>. If a widget is not annotated with @WidgetScope,
* then is is assumed project scoped.
*
* @since 3.1
/**
* @deprecated since 6.2, this extension is ignored as dashboards have been removed
*/
@Deprecated
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface WidgetScope {
String PROJECT = "PROJECT";
String GLOBAL = "GLOBAL";

String[] value() default PROJECT;
}

+ 0
- 71
sonar-plugin-api/src/test/java/org/sonar/api/web/AbstractRubyTemplateTest.java View File

@@ -1,71 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import org.junit.Test;
import org.sonar.api.utils.SonarException;

import java.net.URL;

import static org.assertj.core.api.Assertions.assertThat;

public class AbstractRubyTemplateTest {

@Test
public void useCacheWhenTemplateIsInClassloader() {
final AbstractRubyTemplate template = new AbstractRubyTemplate() {
@Override
protected String getTemplatePath() {
return "/org/sonar/api/web/AbstractRubyTemplateTest/template.erb";
}
};

assertThat(template.loadTemplateFromCache()).isNull();
assertThat(template.getTemplate()).isEqualTo("ok");
assertThat(template.loadTemplateFromCache()).isEqualTo("ok");
}

@Test
public void doNotCacheWhenAbsolutePath() {
final AbstractRubyTemplate template = new AbstractRubyTemplate() {
@Override
protected String getTemplatePath() {
final URL url = AbstractRubyTemplateTest.class.getResource("/org/sonar/api/web/AbstractRubyTemplateTest/template.erb");
return url.getPath();
}
};

assertThat(template.loadTemplateFromCache()).isNull();
assertThat(template.getTemplate()).isEqualTo("ok");
assertThat(template.loadTemplateFromCache()).isNull();
}

@Test(expected = SonarException.class)
public void failIfTemplateNotFound() {
final AbstractRubyTemplate template = new AbstractRubyTemplate() {
@Override
protected String getTemplatePath() {
return "/unknown.erb";
}
};

template.getTemplate();
}
}

+ 0
- 84
sonar-plugin-api/src/test/java/org/sonar/api/web/DashboardTest.java View File

@@ -1,84 +0,0 @@
/*
* SonarQube
* Copyright (C) 2009-2020 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.api.web;

import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class DashboardTest {

@Test
public void shouldCreateDashboard() {
Dashboard dashboard = Dashboard.create();
assertThat(dashboard.getLayout()).isEqualTo(DashboardLayout.TWO_COLUMNS);
assertThat(dashboard.getDescription()).isNull();
assertThat(dashboard.getWidgets()).hasSize(0);
}

@Test
public void shouldAddWidgets() {
Dashboard dashboard = Dashboard.create();
Dashboard.Widget mostViolatedRules = dashboard.addWidget("most_violated_rules", 1);
assertThat(mostViolatedRules.getId()).isEqualTo("most_violated_rules");
assertThat(dashboard.getWidgets()).hasSize(1);
assertThat(dashboard.getWidgetsOfColumn(1)).hasSize(1);

dashboard.addWidget("hotspots", 1);
assertThat(dashboard.getWidgets()).hasSize(2);
assertThat(dashboard.getWidgetsOfColumn(1)).hasSize(2);

// widgets are sorted by order of insertion
assertThat(dashboard.getWidgetsOfColumn(1).get(1).getId()).isEqualTo("hotspots");
}

@Test
public void shouldAddWidgetsOnDifferentColumns() {
Dashboard dashboard = Dashboard.create();

dashboard.addWidget("most_violated_rules", 1);
assertThat(dashboard.getWidgets().size()).isEqualTo(1);
assertThat(dashboard.getWidgetsOfColumn(1).size()).isEqualTo(1);

dashboard.addWidget("hotspots", 2);
assertThat(dashboard.getWidgets().size()).isEqualTo(2);
assertThat(dashboard.getWidgetsOfColumn(2).size()).isEqualTo(1);
}

@Test
public void shouldAddSeveralTimesTheSameWidget() {
Dashboard dashboard = Dashboard.create();
dashboard.addWidget("most_violated_rules", 1);
dashboard.addWidget("most_violated_rules", 1).setProperty("foo", "bar");

assertThat(dashboard.getWidgets().size()).isEqualTo(2);
assertThat(dashboard.getWidgetsOfColumn(1).get(0).getProperties().size()).isEqualTo(0);
assertThat(dashboard.getWidgetsOfColumn(1).get(1).getProperty("foo")).isEqualTo("bar");
}

@Test
public void shouldSetWidgetProperty() {
Dashboard dashboard = Dashboard.create();
Dashboard.Widget widget = dashboard.addWidget("fake-widget", 1);
widget.setProperty("foo", "bar");

assertThat(widget.getProperties().get("foo")).isEqualTo("bar");
}
}

+ 1
- 1
sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerWsClientProvider.java View File

@@ -41,7 +41,7 @@ public class ScannerWsClientProvider extends ProviderAdapter {
public synchronized DefaultScannerWsClient provide(final RawScannerProperties scannerProps,
final EnvironmentInformation env, GlobalAnalysisMode globalMode, System2 system) {
if (wsClient == null) {
String url = defaultIfBlank(scannerProps.property("sonar.host.url"), CoreProperties.SERVER_BASE_URL_DEFAULT_VALUE);
String url = defaultIfBlank(scannerProps.property("sonar.host.url"), "http://localhost:9000");
HttpConnector.Builder connectorBuilder = HttpConnector.newBuilder();

String timeoutSec = defaultIfBlank(scannerProps.property(READ_TIMEOUT_SEC_PROPERTY), valueOf(DEFAULT_READ_TIMEOUT_SEC));

+ 3
- 12
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultFilterableIssue.java View File

@@ -19,30 +19,26 @@
*/
package org.sonar.scanner.issue;

import java.util.Date;
import javax.annotation.concurrent.ThreadSafe;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.sonar.api.batch.fs.InputComponent;
import org.sonar.api.batch.fs.TextRange;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.scan.issue.filter.FilterableIssue;
import org.sonar.scanner.ProjectInfo;
import org.sonar.api.batch.fs.internal.DefaultInputProject;
import org.sonar.api.batch.fs.internal.DefaultTextPointer;
import org.sonar.api.batch.fs.internal.DefaultTextRange;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.scan.issue.filter.FilterableIssue;
import org.sonar.scanner.protocol.output.ScannerReport.Issue;

@ThreadSafe
public class DefaultFilterableIssue implements FilterableIssue {
private final Issue rawIssue;
private final InputComponent component;
private final ProjectInfo projectInfo;
private DefaultInputProject project;

public DefaultFilterableIssue(DefaultInputProject project, ProjectInfo projectInfo, Issue rawIssue, InputComponent component) {
public DefaultFilterableIssue(DefaultInputProject project, Issue rawIssue, InputComponent component) {
this.project = project;
this.projectInfo = projectInfo;
this.rawIssue = rawIssue;
this.component = component;
}
@@ -89,11 +85,6 @@ public class DefaultFilterableIssue implements FilterableIssue {
return rawIssue.getGap() != 0 ? rawIssue.getGap() : null;
}

@Override
public Date creationDate() {
return projectInfo.getAnalysisDate();
}

@Override
public String projectKey() {
return project.key();

+ 5
- 8
sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssueFilters.java View File

@@ -20,11 +20,10 @@
package org.sonar.scanner.issue;

import org.sonar.api.batch.fs.InputComponent;
import org.sonar.api.batch.fs.internal.DefaultInputProject;
import org.sonar.api.scan.issue.filter.FilterableIssue;
import org.sonar.api.scan.issue.filter.IssueFilter;
import org.sonar.api.scan.issue.filter.IssueFilterChain;
import org.sonar.scanner.ProjectInfo;
import org.sonar.api.batch.fs.internal.DefaultInputProject;
import org.sonar.scanner.protocol.output.ScannerReport;

/**
@@ -34,20 +33,18 @@ import org.sonar.scanner.protocol.output.ScannerReport;
public class IssueFilters {
private final IssueFilterChain filterChain;
private final DefaultInputProject project;
private final ProjectInfo projectInfo;

public IssueFilters(DefaultInputProject project, ProjectInfo projectInfo, IssueFilter[] exclusionFilters) {
public IssueFilters(DefaultInputProject project, IssueFilter[] exclusionFilters) {
this.project = project;
this.filterChain = new DefaultIssueFilterChain(exclusionFilters);
this.projectInfo = projectInfo;
}

public IssueFilters(DefaultInputProject project, ProjectInfo projectInfo) {
this(project, projectInfo, new IssueFilter[0]);
public IssueFilters(DefaultInputProject project) {
this(project, new IssueFilter[0]);
}

public boolean accept(InputComponent component, ScannerReport.Issue rawIssue) {
FilterableIssue fIssue = new DefaultFilterableIssue(project, projectInfo, rawIssue, component);
FilterableIssue fIssue = new DefaultFilterableIssue(project, rawIssue, component);
return filterChain.accept(fIssue);
}


+ 2
- 8
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/DefaultFilterableIssueTest.java View File

@@ -19,11 +19,9 @@
*/
package org.sonar.scanner.issue;

import java.util.Date;
import org.junit.Before;
import org.junit.Test;
import org.sonar.api.batch.fs.InputComponent;
import org.sonar.scanner.ProjectInfo;
import org.sonar.api.batch.fs.internal.DefaultInputProject;
import org.sonar.scanner.protocol.Constants.Severity;
import org.sonar.scanner.protocol.output.ScannerReport.Issue;
@@ -36,14 +34,12 @@ import static org.mockito.Mockito.when;
public class DefaultFilterableIssueTest {
private DefaultFilterableIssue issue;
private DefaultInputProject mockedProject;
private ProjectInfo projectInfo;
private InputComponent component;
private Issue rawIssue;

@Before
public void setUp() {
mockedProject = mock(DefaultInputProject.class);
projectInfo = mock(ProjectInfo.class);
component = mock(InputComponent.class);
when(component.key()).thenReturn("foo");
}
@@ -70,13 +66,11 @@ public class DefaultFilterableIssueTest {
@Test
public void testRoundTrip() {
rawIssue = createIssue();
issue = new DefaultFilterableIssue(mockedProject, projectInfo, rawIssue, component);
issue = new DefaultFilterableIssue(mockedProject, rawIssue, component);

when(projectInfo.getAnalysisDate()).thenReturn(new Date(10_000));
when(mockedProject.key()).thenReturn("projectKey");

assertThat(issue.componentKey()).isEqualTo(component.key());
assertThat(issue.creationDate()).isEqualTo(new Date(10_000));
assertThat(issue.line()).isEqualTo(30);
assertThat(issue.textRange().start().line()).isEqualTo(30);
assertThat(issue.textRange().start().lineOffset()).isEqualTo(10);
@@ -90,7 +84,7 @@ public class DefaultFilterableIssueTest {
@Test
public void nullValues() {
rawIssue = createIssueWithoutFields();
issue = new DefaultFilterableIssue(mockedProject, projectInfo, rawIssue, component);
issue = new DefaultFilterableIssue(mockedProject, rawIssue, component);

assertThat(issue.line()).isNull();
assertThat(issue.gap()).isNull();

Loading…
Cancel
Save