diff options
author | Jenkins CI <ci@sonarsource.com> | 2015-12-11 08:01:20 +0100 |
---|---|---|
committer | Jenkins CI <ci@sonarsource.com> | 2015-12-11 08:01:20 +0100 |
commit | d547fdddf958c20cddd00cdbf7a280182400f595 (patch) | |
tree | 2ffb39ec347ad77c4a772c7fe0f7dfc49120c96d | |
parent | 39f16286bfcd6dc247352e34f0fb93cc202104c4 (diff) | |
parent | 56a4685a6061731fe701ea3ec8afbf9a8a1015f0 (diff) | |
download | sonarqube-d547fdddf958c20cddd00cdbf7a280182400f595.tar.gz sonarqube-d547fdddf958c20cddd00cdbf7a280182400f595.zip |
Automatic merge from branch-5.3
* origin/branch-5.3:
SONAR-6968 Bad error message when analyzer detects that no language plugins are installed
SONAR-6905 Batch should dump analysis-related URL into a properties file
fix displaying of the workspace on the overview pages
SONAR-7030 Remove dashboards bundles
Reactivate devcockpit in PluginsTest
fix link to added issues from the debt overview
respect precision of float metrics during web formatting
17 files changed, 68 insertions, 44 deletions
diff --git a/it/it-tests/src/test/java/it/analysis/ReportDumpTest.java b/it/it-tests/src/test/java/it/analysis/ReportDumpTest.java index 91129f299a7..74d58aebaa4 100644 --- a/it/it-tests/src/test/java/it/analysis/ReportDumpTest.java +++ b/it/it-tests/src/test/java/it/analysis/ReportDumpTest.java @@ -44,9 +44,10 @@ public class ReportDumpTest { // verify properties Properties props = new Properties(); props.load(new StringReader(FileUtils.readFileToString(metadata, StandardCharsets.UTF_8))); - assertThat(props).hasSize(4); + assertThat(props).hasSize(5); assertThat(props.getProperty("projectKey")).isEqualTo("dump_metadata_of_uploaded_report"); assertThat(props.getProperty("ceTaskId")).isNotEmpty(); + verifyUrl(props.getProperty("serverUrl")); verifyUrl(props.getProperty("dashboardUrl")); verifyUrl(props.getProperty("ceTaskUrl")); } diff --git a/it/it-tests/src/test/java/it/plugins/PluginsTest.java b/it/it-tests/src/test/java/it/plugins/PluginsTest.java index a65564a1cad..9c4e824ab36 100644 --- a/it/it-tests/src/test/java/it/plugins/PluginsTest.java +++ b/it/it-tests/src/test/java/it/plugins/PluginsTest.java @@ -49,7 +49,7 @@ public class PluginsTest { /** * Temporarily disabled plugins. To be re-enabled. */ - static final Set<String> DISABLED_PLUGINS = Sets.newHashSet("devcockpit", + static final Set<String> DISABLED_PLUGINS = Sets.newHashSet( // internal plugin used for integration tests of language plugins "lits"); diff --git a/server/sonar-web/src/main/js/apps/overview/components/issue-measure.js b/server/sonar-web/src/main/js/apps/overview/components/issue-measure.js index 8387f2b6feb..a0f703d8026 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/issue-measure.js +++ b/server/sonar-web/src/main/js/apps/overview/components/issue-measure.js @@ -67,12 +67,14 @@ export const AddedRemovedMeasure = React.createClass({ let added = this.props.leak[this.props.leakMetric] || 0; let removed = added - leak; + let createdAfter = moment(this.props.leakPeriodDate).format('YYYY-MM-DDTHH:mm:ssZZ'); + return <div className="overview-detailed-measure-leak"> <ul> <li style={{ display: 'flex', alignItems: 'baseline' }}> <small className="flex-1 text-left">{window.t('overview.added')}</small> <IssuesLink className="text-danger" - component={this.props.component.key} params={{ resolved: 'false' }}> + component={this.props.component.key} params={{ resolved: 'false', createdAfter }}> <span className="overview-detailed-measure-value"> {formatMeasure(added, getShortType(this.props.type))} </span> diff --git a/server/sonar-web/src/main/js/components/workspace/main.js b/server/sonar-web/src/main/js/components/workspace/main.js index 3718625541e..6ae1dd2c3b4 100644 --- a/server/sonar-web/src/main/js/components/workspace/main.js +++ b/server/sonar-web/src/main/js/components/workspace/main.js @@ -5,6 +5,8 @@ import Items from './models/items'; import ItemsView from './views/items-view'; import ViewerView from './views/viewer-view'; import RuleView from './views/rule-view'; +import '../../helpers/handlebars-helpers'; + var instance = null, diff --git a/server/sonar-web/src/main/js/helpers/measures.js b/server/sonar-web/src/main/js/helpers/measures.js index 2137e40c6b8..ffb6e576152 100644 --- a/server/sonar-web/src/main/js/helpers/measures.js +++ b/server/sonar-web/src/main/js/helpers/measures.js @@ -125,11 +125,11 @@ function shortIntVariationFormatter (value) { } function floatFormatter (value) { - return numeral(value).format('0,0.0'); + return numeral(value).format('0,0.0[0000]'); } function floatVariationFormatter (value) { - return value === 0 ? '+0.0' : numeral(value).format('+0,0.0'); + return value === 0 ? '+0.0' : numeral(value).format('+0,0.0[0000]'); } function percentFormatter (value) { diff --git a/server/sonar-web/tests/helpers/measures-test.js b/server/sonar-web/tests/helpers/measures-test.js index cc8e7a4a25c..2caabb3cdf5 100644 --- a/server/sonar-web/tests/helpers/measures-test.js +++ b/server/sonar-web/tests/helpers/measures-test.js @@ -68,14 +68,21 @@ describe('Measures', function () { expect(formatMeasure(0.0, 'FLOAT')).to.equal('0.0'); expect(formatMeasure(1.0, 'FLOAT')).to.equal('1.0'); expect(formatMeasure(1.3, 'FLOAT')).to.equal('1.3'); - expect(formatMeasure(1.34, 'FLOAT')).to.equal('1.3'); - expect(formatMeasure(50.89, 'FLOAT')).to.equal('50.9'); + expect(formatMeasure(1.34, 'FLOAT')).to.equal('1.34'); + expect(formatMeasure(50.89, 'FLOAT')).to.equal('50.89'); expect(formatMeasure(100.0, 'FLOAT')).to.equal('100.0'); - expect(formatMeasure(123.456, 'FLOAT')).to.equal('123.5'); + expect(formatMeasure(123.456, 'FLOAT')).to.equal('123.456'); expect(formatMeasure(123456.7, 'FLOAT')).to.equal('123,456.7'); expect(formatMeasure(1234567890.0, 'FLOAT')).to.equal('1,234,567,890.0'); }); + it('should respect FLOAT precision', function () { + expect(formatMeasure(0.1, 'FLOAT')).to.equal('0.1'); + expect(formatMeasure(0.12, 'FLOAT')).to.equal('0.12'); + expect(formatMeasure(0.12345, 'FLOAT')).to.equal('0.12345'); + expect(formatMeasure(0.123456, 'FLOAT')).to.equal('0.12346'); + }); + it('should format PERCENT', function () { expect(formatMeasure(0.0, 'PERCENT')).to.equal('0.0%'); expect(formatMeasure(1.0, 'PERCENT')).to.equal('1.0%'); @@ -180,8 +187,15 @@ describe('Measures', function () { expect(formatMeasureVariation(0.0, 'FLOAT')).to.equal('+0.0'); expect(formatMeasureVariation(1.0, 'FLOAT')).to.equal('+1.0'); expect(formatMeasureVariation(-1.0, 'FLOAT')).to.equal('-1.0'); - expect(formatMeasureVariation(50.89, 'FLOAT')).to.equal('+50.9'); - expect(formatMeasureVariation(-50.89, 'FLOAT')).to.equal('-50.9'); + expect(formatMeasureVariation(50.89, 'FLOAT')).to.equal('+50.89'); + expect(formatMeasureVariation(-50.89, 'FLOAT')).to.equal('-50.89'); + }); + + it('should respect FLOAT precision', function () { + expect(formatMeasureVariation(0.1, 'FLOAT')).to.equal('+0.1'); + expect(formatMeasureVariation(0.12, 'FLOAT')).to.equal('+0.12'); + expect(formatMeasureVariation(0.12345, 'FLOAT')).to.equal('+0.12345'); + expect(formatMeasureVariation(0.123456, 'FLOAT')).to.equal('+0.12346'); }); it('should format PERCENT', function () { diff --git a/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java b/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java index 2da734f8dde..1d9c4a81145 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java +++ b/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java @@ -173,7 +173,8 @@ public class ReportPublisher implements Startable { Map<String, String> metadata = new LinkedHashMap<>(); String effectiveKey = projectReactor.getRoot().getKeyWithBranch(); metadata.put("projectKey", effectiveKey); - + metadata.put("serverUrl", publicUrl()); + URL dashboardUrl = HttpUrl.parse(publicUrl()).newBuilder() .addPathSegment("dashboard").addPathSegment("index").addPathSegment(effectiveKey) .build() diff --git a/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultQualityProfileLoader.java b/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultQualityProfileLoader.java index 8f6e0dd5e07..8b26d4bc1d0 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultQualityProfileLoader.java +++ b/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultQualityProfileLoader.java @@ -19,8 +19,9 @@ */ package org.sonar.batch.repository; -import org.sonarqube.ws.QualityProfiles.SearchWsResponse; +import org.sonar.api.utils.MessageException; +import org.sonarqube.ws.QualityProfiles.SearchWsResponse; import org.sonar.batch.util.BatchUtils; import org.apache.commons.io.IOUtils; import org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile; @@ -34,8 +35,6 @@ import java.io.IOException; import java.io.InputStream; import java.util.List; -import static com.google.common.base.Preconditions.checkState; - public class DefaultQualityProfileLoader implements QualityProfileLoader { private static final String WS_URL = "/api/qualityprofiles/search.protobuf"; @@ -48,7 +47,7 @@ public class DefaultQualityProfileLoader implements QualityProfileLoader { @Override public List<QualityProfile> loadDefault(@Nullable String profileName, @Nullable MutableBoolean fromCache) { String url = WS_URL + "?defaults=true"; - if(profileName != null) { + if (profileName != null) { url += "&profileName=" + BatchUtils.encodeForUrl(profileName); } return loadResource(url, fromCache); @@ -80,8 +79,9 @@ public class DefaultQualityProfileLoader implements QualityProfileLoader { } List<QualityProfile> profilesList = profiles.getProfilesList(); - checkState(profilesList != null && !profilesList.isEmpty(), - "No quality profiles has been found this project, you probably don't have any language plugin suitable for this analysis."); + if (profilesList == null || profilesList.isEmpty()) { + throw MessageException.of("No quality profiles have been found, you probably don't have any language plugin installed."); + } return profilesList; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/repository/language/DefaultLanguagesRepository.java b/sonar-batch/src/main/java/org/sonar/batch/repository/language/DefaultLanguagesRepository.java index e1f0c915cfb..b42d9584226 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/repository/language/DefaultLanguagesRepository.java +++ b/sonar-batch/src/main/java/org/sonar/batch/repository/language/DefaultLanguagesRepository.java @@ -19,6 +19,8 @@ */ package org.sonar.batch.repository.language; +import org.picocontainer.Startable; + import org.sonar.api.resources.Languages; import javax.annotation.CheckForNull; @@ -30,7 +32,7 @@ import java.util.Collection; * Languages repository using {@link Languages} * @since 4.4 */ -public class DefaultLanguagesRepository implements LanguagesRepository { +public class DefaultLanguagesRepository implements LanguagesRepository, Startable { private Languages languages; @@ -38,6 +40,7 @@ public class DefaultLanguagesRepository implements LanguagesRepository { this.languages = languages; } + @Override public void start() { if (languages.all().length == 0) { throw new IllegalStateException("No language plugins are installed."); @@ -67,4 +70,9 @@ public class DefaultLanguagesRepository implements LanguagesRepository { return result; } + @Override + public void stop() { + // nothing to do + } + } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorValidator.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorValidator.java index 6aa753723b8..97a36e5541d 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorValidator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorValidator.java @@ -19,8 +19,9 @@ */ package org.sonar.batch.scan; -import org.sonar.batch.analysis.DefaultAnalysisMode; +import org.sonar.api.utils.MessageException; +import org.sonar.batch.analysis.DefaultAnalysisMode; import com.google.common.base.Joiner; import java.util.ArrayList; @@ -66,7 +67,7 @@ public class ProjectReactorValidator { validateBranch(validationMessages, branch); if (!validationMessages.isEmpty()) { - throw new IllegalStateException("Validation of project reactor failed:\n o " + Joiner.on("\n o ").join(validationMessages)); + throw MessageException.of("Validation of project reactor failed:\n o " + Joiner.on("\n o ").join(validationMessages)); } } diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/ProjectBuilderMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/ProjectBuilderMediumTest.java index ed7a35a4836..a8979340a61 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/ProjectBuilderMediumTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/ProjectBuilderMediumTest.java @@ -19,6 +19,8 @@ */ package org.sonar.batch.mediumtest.fs; +import org.sonar.api.utils.MessageException; + import com.google.common.collect.ImmutableMap; import org.apache.commons.io.FileUtils; import org.junit.After; @@ -102,7 +104,7 @@ public class ProjectBuilderMediumTest { public void testProjectBuilderWithNewLine() throws IOException { File baseDir = prepareProject(); - exception.expect(IllegalStateException.class); + exception.expect(MessageException.class); exception.expectMessage("is not a valid branch name"); tester.newTask() .properties(ImmutableMap.<String, String>builder() diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/tasks/TasksMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/tasks/TasksMediumTest.java index ec151f29874..f81789b937f 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/tasks/TasksMediumTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/tasks/TasksMediumTest.java @@ -87,7 +87,7 @@ public class TasksMediumTest { thrown.expect(IllegalStateException.class); thrown.expectMessage( - "Unable to load component class org.sonar.batch.mediumtest.tasks.TasksMediumTest$BrokenTask: org.sonar.batch.mediumtest.tasks.TasksMediumTest$BrokenTask has unsatisfied dependency 'class org.sonar.api.issue.action.Actions'"); + "Unable to load component class org.sonar.batch.mediumtest.tasks.TasksMediumTest$BrokenTask"); tester.newTask() .properties(ImmutableMap.<String, String>builder() diff --git a/sonar-batch/src/test/java/org/sonar/batch/report/ReportPublisherTest.java b/sonar-batch/src/test/java/org/sonar/batch/report/ReportPublisherTest.java index 576a2dcdf8a..04c1b4ff161 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/report/ReportPublisherTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/report/ReportPublisherTest.java @@ -81,6 +81,7 @@ public class ReportPublisherTest { File detailsFile = new File(temp.getRoot(), "report-task.txt"); assertThat(readFileToString(detailsFile)).isEqualTo( "projectKey=struts\n" + + "serverUrl=https://localhost/\n" + "dashboardUrl=https://localhost/dashboard/index/struts\n" + "ceTaskId=TASK-123\n" + "ceTaskUrl=https://localhost/api/ce/task?id=TASK-123\n" @@ -101,6 +102,7 @@ public class ReportPublisherTest { File detailsFile = new File(temp.getRoot(), "report-task.txt"); assertThat(readFileToString(detailsFile)).isEqualTo( "projectKey=struts\n" + + "serverUrl=https://publicserver/sonarqube/\n" + "dashboardUrl=https://publicserver/sonarqube/dashboard/index/struts\n" + "ceTaskId=TASK-123\n" + "ceTaskUrl=https://publicserver/sonarqube/api/ce/task?id=TASK-123\n" diff --git a/sonar-batch/src/test/java/org/sonar/batch/repository/DefaultQualityProfileLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/repository/DefaultQualityProfileLoaderTest.java index b3c2b79dcb3..4caba83ec70 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/repository/DefaultQualityProfileLoaderTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/repository/DefaultQualityProfileLoaderTest.java @@ -19,8 +19,9 @@ */ package org.sonar.batch.repository; -import org.sonarqube.ws.QualityProfiles; +import org.sonar.api.utils.MessageException; +import org.sonarqube.ws.QualityProfiles; import com.google.common.io.Resources; import org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile; import org.sonar.batch.cache.WSLoaderResult; @@ -77,7 +78,7 @@ public class DefaultQualityProfileLoaderTest { InputStream is = createEncodedQP(); when(ws.loadStream(anyString())).thenReturn(new WSLoaderResult<InputStream>(is, false)); - exception.expect(IllegalStateException.class); + exception.expect(MessageException.class); exception.expectMessage("No quality profiles"); qpLoader.load("project", null, null); diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorValidatorTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorValidatorTest.java index 761c608c8cd..40b68bf21cb 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorValidatorTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorValidatorTest.java @@ -21,6 +21,8 @@ package org.sonar.batch.scan; import static org.mockito.Mockito.when; +import org.sonar.api.utils.MessageException; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -67,7 +69,7 @@ public class ProjectReactorValidatorTest { validator.validate(createProjectReactor("project/key")); when(mode.isIssues()).thenReturn(false); - thrown.expect(IllegalStateException.class); + thrown.expect(MessageException.class); thrown.expectMessage("is not a valid project or module key"); validator.validate(createProjectReactor("project/key")); } @@ -106,7 +108,7 @@ public class ProjectReactorValidatorTest { public void fail_with_invalid_key() { ProjectReactor reactor = createProjectReactor("foo$bar"); - thrown.expect(IllegalStateException.class); + thrown.expect(MessageException.class); thrown.expectMessage("\"foo$bar\" is not a valid project or module key"); validator.validate(reactor); } @@ -115,7 +117,7 @@ public class ProjectReactorValidatorTest { public void fail_with_backslash_in_key() { ProjectReactor reactor = createProjectReactor("foo\\bar"); - thrown.expect(IllegalStateException.class); + thrown.expect(MessageException.class); thrown.expectMessage("\"foo\\bar\" is not a valid project or module key"); validator.validate(reactor); } @@ -133,7 +135,7 @@ public class ProjectReactorValidatorTest { @Test public void fail_with_invalid_branch() { ProjectReactor reactor = createProjectReactor("foo", "bran#ch"); - thrown.expect(IllegalStateException.class); + thrown.expect(MessageException.class); thrown.expectMessage("\"bran#ch\" is not a valid branch name"); validator.validate(reactor); } @@ -141,7 +143,7 @@ public class ProjectReactorValidatorTest { @Test public void fail_with_colon_in_branch() { ProjectReactor reactor = createProjectReactor("foo", "bran:ch"); - thrown.expect(IllegalStateException.class); + thrown.expect(MessageException.class); thrown.expectMessage("\"bran:ch\" is not a valid branch name"); validator.validate(reactor); } @@ -150,7 +152,7 @@ public class ProjectReactorValidatorTest { public void fail_with_only_digits() { ProjectReactor reactor = createProjectReactor("12345"); - thrown.expect(IllegalStateException.class); + thrown.expect(MessageException.class); thrown.expectMessage("\"12345\" is not a valid project or module key"); validator.validate(reactor); } @@ -160,7 +162,7 @@ public class ProjectReactorValidatorTest { ProjectReactor reactor = createProjectReactor("foo"); settings.setProperty("sonar.phase", "phase"); - thrown.expect(IllegalStateException.class); + thrown.expect(MessageException.class); thrown.expectMessage("\"sonar.phase\" is deprecated"); validator.validate(reactor); } diff --git a/sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java b/sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java index 6789d45e61b..ff4dceaef4c 100644 --- a/sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java +++ b/sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java @@ -59,7 +59,7 @@ public class ComponentContainer implements ContainerPopulator.Container { try { return super.getComponent(componentKeyOrType, annotation); } catch (Throwable t) { - throw new IllegalStateException("Unable to load component " + componentKeyOrType + ": " + t.getMessage(), t); + throw new IllegalStateException("Unable to load component " + componentKeyOrType, t); } } diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 01d36315595..e249705826b 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1046,18 +1046,6 @@ property.error.notFloat=Not a floating point number property.error.notInOptions=Not a valid option property.category.scm=SCM - -#------------------------------------------------------------------------------ -# -# DASHBOARDS -# -#------------------------------------------------------------------------------ - -# Default dashboard -dashboard.Dashboard.name=Custom -dashboard.Hotspots.name=Hotspots -dashboard.Reviews.name=Reviews - #------------------------------------------------------------------------------ # # SEARCH ENGINE FOR RESOURCES |