From: Fabrice Bellingard Date: Wed, 23 May 2012 14:16:57 +0000 (+0200) Subject: SONAR-3240 Fully remove support of old format for DUPLICATIONS_DATA X-Git-Tag: 3.1~100 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f6ea70e6856631981203982673eafea61045bf95;p=sonarqube.git SONAR-3240 Fully remove support of old format for DUPLICATIONS_DATA --- diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties index 6a2c59d61b2..2c665b569a8 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -831,6 +831,7 @@ violations_viewer.review_filter.unreviewed_violations=Unreviewed violations duplications.no_duplicated_block=No duplicated blocks. duplications.dups_found_on_deleted_resource=This file contains duplicated blocks with some deleted resources. This project should be reanalyzed to remove these obsolete duplicated blocks. +duplications.old_format_should_reanalyze=This file contains duplications but a new analysis must be done in order to be able to display them. duplications.blocks=Blocks duplications.number_of_lines=Nb Lines duplications.from_line=From line diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java index ca742701dec..f5cca2cf7e0 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java @@ -198,11 +198,11 @@ public final class CoreMetrics { .setDomain(DOMAIN_SIZE) .create(); - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- // // DOCUMENTATION // - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- public static final String COMMENT_LINES_KEY = "comment_lines"; public static final Metric COMMENT_LINES = new Metric.Builder(COMMENT_LINES_KEY, "Comment lines", Metric.ValueType.INT) @@ -266,12 +266,11 @@ public final class CoreMetrics { .setOptimizedBestValue(true) .create(); - - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- // // COMPLEXITY // - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- public static final String COMPLEXITY_KEY = "complexity"; public static final Metric COMPLEXITY = new Metric.Builder(COMPLEXITY_KEY, "Complexity", Metric.ValueType.INT) @@ -346,7 +345,8 @@ public final class CoreMetrics { .create(); public static final String FUNCTION_COMPLEXITY_DISTRIBUTION_KEY = "function_complexity_distribution"; - public static final Metric FUNCTION_COMPLEXITY_DISTRIBUTION = new Metric.Builder(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, "Functions distribution /complexity", Metric.ValueType.DISTRIB) + public static final Metric FUNCTION_COMPLEXITY_DISTRIBUTION = new Metric.Builder(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, "Functions distribution /complexity", + Metric.ValueType.DISTRIB) .setDescription("Functions distribution /complexity") .setDirection(Metric.DIRECTION_NONE) .setQualitative(true) @@ -372,7 +372,8 @@ public final class CoreMetrics { * @deprecated since Sonar 2.14 - See SONAR-3239 */ @Deprecated - public static final Metric PARAGRAPH_COMPLEXITY_DISTRIBUTION = new Metric.Builder(PARAGRAPH_COMPLEXITY_DISTRIBUTION_KEY, "Paragraph distribution /complexity", Metric.ValueType.DISTRIB) + public static final Metric PARAGRAPH_COMPLEXITY_DISTRIBUTION = new Metric.Builder(PARAGRAPH_COMPLEXITY_DISTRIBUTION_KEY, "Paragraph distribution /complexity", + Metric.ValueType.DISTRIB) .setDescription("Paragraph distribution /complexity") .setDirection(Metric.DIRECTION_NONE) .setQualitative(true) @@ -380,11 +381,11 @@ public final class CoreMetrics { .setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY)) .create(); - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- // // UNIT TESTS // - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- public static final String TESTS_KEY = "tests"; @@ -545,7 +546,7 @@ public final class CoreMetrics { .setWorstValue(0.0) .setBestValue(100.0) .setDomain(DOMAIN_TESTS) - .setDeleteHistoricalData(true) + .setDeleteHistoricalData(true) .create(); public static final String COVERAGE_LINE_HITS_DATA_KEY = "coverage_line_hits_data"; @@ -663,12 +664,11 @@ public final class CoreMetrics { .setDeleteHistoricalData(true) .create(); - - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- // // INTEGRATION TESTS // - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- /** * @since 2.12 @@ -948,12 +948,11 @@ public final class CoreMetrics { .setDeleteHistoricalData(true) .create(); - - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- // // DUPLICATIONS // - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- public static final String DUPLICATED_LINES_KEY = "duplicated_lines"; public static final Metric DUPLICATED_LINES = new Metric.Builder(DUPLICATED_LINES_KEY, "Duplicated lines", Metric.ValueType.INT) @@ -1004,9 +1003,10 @@ public final class CoreMetrics { public static final String DUPLICATIONS_DATA_KEY = "duplications_data"; /** - * Information about duplications, which is represented as an XML string. There are two formats: - * + * } + * */ public static final Metric DUPLICATIONS_DATA = new Metric.Builder(DUPLICATIONS_DATA_KEY, "Duplications details", Metric.ValueType.DATA) .setDescription("Duplications details") @@ -1042,11 +1027,11 @@ public final class CoreMetrics { .setDeleteHistoricalData(true) .create(); - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- // // CODING RULES // - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- /** * @deprecated since 2.5 See SONAR-2007 @@ -1263,12 +1248,11 @@ public final class CoreMetrics { .setDeleteHistoricalData(true) .create(); - - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- // // DESIGN // - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- public static final String ABSTRACTNESS_KEY = "abstractness"; public static final Metric ABSTRACTNESS = new Metric.Builder(ABSTRACTNESS_KEY, "Abstractness", Metric.ValueType.PERCENT) @@ -1492,13 +1476,12 @@ public final class CoreMetrics { .setDeleteHistoricalData(true) .create(); - - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- // // SCM // These metrics are computed by the SCM Activity plugin, since version 1.2 and introduced here since version 2.7. // - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- /** * @since 2.7 @@ -1522,7 +1505,12 @@ public final class CoreMetrics { * * @since 2.7 */ - public static final Metric SCM_LAST_COMMIT_DATE = new Metric.Builder(SCM_LAST_COMMIT_DATE_KEY, "Last commit", Metric.ValueType.STRING /* TODO: move to date */) + public static final Metric SCM_LAST_COMMIT_DATE = new Metric.Builder(SCM_LAST_COMMIT_DATE_KEY, "Last commit", Metric.ValueType.STRING /* + * TODO: + * move + * to + * date + */) .setDomain(DOMAIN_SCM) .create(); @@ -1587,12 +1575,11 @@ public final class CoreMetrics { .setDomain(DOMAIN_SCM) .create(); - - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- // // REVIEWS (since 2.14) // - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- /** * @since 2.14 @@ -1736,11 +1723,11 @@ public final class CoreMetrics { .setDomain(DOMAIN_DOCUMENTATION) .create(); - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- // // OTHERS // - //-------------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------------- public static final String ALERT_STATUS_KEY = "alert_status"; public static final Metric ALERT_STATUS = new Metric.Builder(ALERT_STATUS_KEY, "Alert", Metric.ValueType.LEVEL) @@ -1750,7 +1737,6 @@ public final class CoreMetrics { .setDomain(DOMAIN_GENERAL) .create(); - public static final String PROFILE_KEY = "profile"; public static final Metric PROFILE = new Metric.Builder(PROFILE_KEY, "Profile", Metric.ValueType.DATA) .setDescription("Selected quality profile") diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb index 27ab395c1f8..549af613a80 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb @@ -248,7 +248,8 @@ class ResourceController < ApplicationController if XPath.match(dups, "//g").size > 0 parse_duplications(dups, @duplication_groups) else - parse_duplications_old_format(dups, @duplication_groups) + # This is the format prior to Sonar 2.12 => we display nothing but a message + @duplication_group_warning = message('duplications.old_format_should_reanalyze') end end @@ -307,24 +308,6 @@ class ResourceController < ApplicationController @duplication_group_warning = message('duplications.dups_found_on_deleted_resource') if dups_found_on_deleted_resource end - # Format before sonar 2.12 - def parse_duplications_old_format(dups, duplication_groups) - resource_by_key = {} - dups.elements.each("duplications/duplication") do |dup| - group = [] - target_key = dup.attributes['target-resource'] - target_resource = resource_by_key[target_key] - unless target_resource - # we use the resource_by_id map for optimization - target_resource = Project.by_key(target_key) - resource_by_key[target_key] = target_resource - end - group << {:lines_count => dup.attributes['lines'], :from_line => dup.attributes['start'], :resource => @resource} - group << {:lines_count => dup.attributes['lines'], :from_line => dup.attributes['target-start'], :resource => target_resource} - duplication_groups << group - end - end - def render_violations load_sources()