diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-09-08 23:49:59 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-09-09 00:34:17 +0400 |
commit | 7e914e1eb6b9cfcdbc43930e8b40b256e3846989 (patch) | |
tree | 8c2a7ea51785e1e5883fa299dd7ff9d19193c8e6 /plugins/sonar-cpd-plugin | |
parent | 691ae00bf9e8cdfe5bd5528f2c58f8c5415601e2 (diff) | |
download | sonarqube-7e914e1eb6b9cfcdbc43930e8b40b256e3846989.tar.gz sonarqube-7e914e1eb6b9cfcdbc43930e8b40b256e3846989.zip |
SONAR-1091 New properties and category 'Duplications'
Diffstat (limited to 'plugins/sonar-cpd-plugin')
3 files changed, 32 insertions, 18 deletions
diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdPlugin.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdPlugin.java index da09e8e5adf..08c33002753 100644 --- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdPlugin.java +++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdPlugin.java @@ -31,38 +31,51 @@ import org.sonar.plugins.cpd.decorators.SumDuplicationsDecorator; @Properties({ @Property( + key = CoreProperties.CPD_ENGINE, + defaultValue = CoreProperties.CPD_ENGINE_DEFAULT_VALUE, + name = "Engine", + description = "Engine for detection of duplications. Possible values: sonar, pmd.", + project = true, + module = true, + global = true, + category = CoreProperties.CATEGORY_DUPLICATIONS), + @Property( + key = CoreProperties.CPD_CROSS_RPOJECT, + defaultValue = CoreProperties.CPD_CROSS_RPOJECT_DEFAULT_VALUE + "", + name = "(Sonar) Detection across projects", + description = "", + project = true, + module = true, + global = true, + category = CoreProperties.CATEGORY_DUPLICATIONS), + @Property( key = CoreProperties.CPD_MINIMUM_TOKENS_PROPERTY, defaultValue = CoreProperties.CPD_MINIMUM_TOKENS_DEFAULT_VALUE + "", - name = "Minimum tokens", + name = "(PMD) Minimum tokens", description = "The number of duplicate tokens above which a block is considered as a duplication.", project = true, module = true, - global = true), + global = true, + category = CoreProperties.CATEGORY_DUPLICATIONS), @Property( key = CoreProperties.CPD_IGNORE_LITERALS_PROPERTY, defaultValue = CoreProperties.CPD_IGNORE_LITERALS_DEFAULT_VALUE + "", - name = "Ignore literals", - description = "if true, CPD ignores literal value differences when evaluating a duplicate block. " + + name = "(PMD) Ignore literals", + description = "if true, PMD-CPD ignores literal value differences when evaluating a duplicate block. " + "This means that foo=\"first string\"; and foo=\"second string\"; will be seen as equivalent.", project = true, module = true, - global = true), + global = true, + category = CoreProperties.CATEGORY_DUPLICATIONS), @Property( key = CoreProperties.CPD_IGNORE_IDENTIFIERS_PROPERTY, defaultValue = CoreProperties.CPD_IGNORE_IDENTIFIERS_DEFAULT_VALUE + "", - name = "Ignore identifiers", + name = "(PMD) Ignore identifiers", description = "Similar to 'Ignore literals' but for identifiers; i.e., variable names, methods names, and so forth.", project = true, module = true, - global = true), - @Property( - key = CoreProperties.CPD_SKIP_PROPERTY, - defaultValue = "false", - name = "Skip detection of duplicated code", - description = "Searching for duplicated code is memory hungry therefore for very big projects it can be necessary to turn the functionality off.", - project = true, - module = true, - global = true) + global = true, + category = CoreProperties.CATEGORY_DUPLICATIONS) }) public class CpdPlugin extends SonarPlugin { diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdSensor.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdSensor.java index 3aecb265e2f..8405e839c27 100644 --- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdSensor.java +++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdSensor.java @@ -22,6 +22,7 @@ package org.sonar.plugins.cpd; import org.apache.commons.configuration.Configuration; import org.apache.commons.lang.StringUtils; import org.slf4j.LoggerFactory; +import org.sonar.api.CoreProperties; import org.sonar.api.batch.Sensor; import org.sonar.api.batch.SensorContext; import org.sonar.api.resources.Project; @@ -66,13 +67,13 @@ public class CpdSensor implements Sensor { boolean isSonarEngineEnabled(Project project) { Configuration conf = project.getConfiguration(); - return StringUtils.equalsIgnoreCase(conf.getString("sonar.cpd.engine", "sonar"), "sonar"); + return StringUtils.equalsIgnoreCase(conf.getString(CoreProperties.CPD_ENGINE, CoreProperties.CPD_ENGINE_DEFAULT_VALUE), "sonar"); } boolean isSkipped(Project project) { Configuration conf = project.getConfiguration(); return conf.getBoolean("sonar.cpd." + project.getLanguageKey() + ".skip", - conf.getBoolean("sonar.cpd.skip", false)); + conf.getBoolean(CoreProperties.CPD_SKIP_PROPERTY, false)); } public void analyse(Project project, SensorContext context) { diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java index 12de1033609..b6f7b93def3 100644 --- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java +++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java @@ -82,7 +82,7 @@ public class SonarEngine extends CpdEngine { * @return true, if was enabled by user and database is available */ private boolean isCrossProject(Project project) { - return project.getConfiguration().getBoolean("sonar.cpd.cross_project", false) + return project.getConfiguration().getBoolean(CoreProperties.CPD_CROSS_RPOJECT, CoreProperties.CPD_CROSS_RPOJECT_DEFAULT_VALUE) && resourcePersister != null && dbSession != null && StringUtils.isBlank(project.getConfiguration().getString(CoreProperties.PROJECT_BRANCH_PROPERTY)); } |