]> source.dussan.org Git - sonarqube.git/commitdiff
Fix coding violations
authorsimonbrandhof <simon.brandhof@gmail.com>
Sun, 27 Mar 2011 21:43:19 +0000 (23:43 +0200)
committersimonbrandhof <simon.brandhof@gmail.com>
Sun, 27 Mar 2011 21:43:19 +0000 (23:43 +0200)
37 files changed:
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CoverageDecorator.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyDecorator.java
plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdPlugin.java
plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java
plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java
plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/bridges/ChidamberKemererBridge.java
sonar-batch/src/main/java/org/sonar/batch/Module.java
sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByPreviousAnalysis.java
sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java
sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java
sonar-core/src/main/java/org/sonar/jpa/dao/RulesDao.java
sonar-duplications/src/main/java/org/sonar/duplications/cpd/Match.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractCoverageExtension.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java
sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java
sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java
sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
sonar-plugin-api/src/main/java/org/sonar/api/rules/Iso9126RulesCategories.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/KeyValueFormat.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/ServerHttpClient.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java
sonar-server/src/main/java/org/sonar/server/charts/jruby/TrendsChart.java
sonar-server/src/main/java/org/sonar/server/configuration/ConfigurationFactory.java
sonar-server/src/main/java/org/sonar/server/filters/FilterResult.java
sonar-server/src/main/java/org/sonar/server/platform/PlatformLifecycleListener.java
sonar-server/src/main/java/org/sonar/server/startup/EnableProfiles.java
sonar-server/src/main/java/org/sonar/server/startup/RegisterProvidedProfiles.java
sonar-server/src/main/java/org/sonar/server/startup/RegisterQualityModels.java
sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java
sonar-squid/src/main/java/org/sonar/squid/api/SourceCode.java
sonar-testing-harness/src/main/java/org/sonar/test/TestUtils.java
sonar-testing-harness/src/main/java/org/sonar/test/channel/ReaderHasNextCharMatcher.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/Dependency.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/ProfileQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/UpdateCenterQuery.java

index 8363f5b9297e031a6dd9e0972153078104002a3c..236581dc351ff6bb061a1978a0d6e2ad5c28a5f8 100644 (file)
@@ -113,7 +113,9 @@ import java.util.List;
     @Property(
         key = "sonar.timemachine.period1",
         name = "Period 1",
-        description = "Period used to compare measures and track new violations. Values are : <ul class='bullet'><li>Number of days before analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, for example 2010-12-25</li><li>'previous_analysis' to compare to previous analysis</li><li>A version, for example 1.2</li></ul>",
+        description = "Period used to compare measures and track new violations. Values are : <ul class='bullet'><li>Number of days before " +
+            "analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, for example 2010-12-25</li><li>'previous_analysis' to " +
+            "compare to previous analysis</li><li>A version, for example 1.2</li></ul>",
         project = false,
         global = true,
         defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_1
@@ -137,7 +139,9 @@ import java.util.List;
     @Property(
         key = "sonar.timemachine.period4",
         name = "Period 4",
-        description = "Period used to compare measures and track new violations. This property is specific to the project. Values are : <ul class='bullet'><li>Number of days before analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, for example 2010-12-25</li><li>'previous_analysis' to compare to previous analysis</li><li>A version, for example 1.2</li></ul>",
+        description = "Period used to compare measures and track new violations. This property is specific to the project. Values are : " +
+            "<ul class='bullet'><li>Number of days before analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, " +
+            "for example 2010-12-25</li><li>'previous_analysis' to compare to previous analysis</li><li>A version, for example 1.2</li></ul>",
         project = true,
         global = false,
         defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_4
index 0944f8dabcd0336e147cc98e9065467d9d138eb0..1ea98d87a157a913d5ba56367bf5abcba640b3a0 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.plugins.core.sensors;
 
 import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.batch.DependedUpon;
 import org.sonar.api.batch.DependsUpon;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.measures.MeasureUtils;
@@ -28,7 +27,6 @@ import org.sonar.api.measures.Metric;
 
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.List;
 
 public final class CoverageDecorator extends AbstractCoverageDecorator {
 
@@ -61,7 +59,6 @@ public final class CoverageDecorator extends AbstractCoverageDecorator {
   }
 
 
-
   @Override
   protected Metric getGeneratedMetricForNewCode() {
     return CoreMetrics.NEW_COVERAGE;
@@ -70,7 +67,7 @@ public final class CoverageDecorator extends AbstractCoverageDecorator {
   @Override
   protected Long countElementsForNewCode(DecoratorContext context, int periodIndex) {
     Long newLinesToCover = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_LINES_TO_COVER), periodIndex);
-    if (newLinesToCover!=null) {
+    if (newLinesToCover != null) {
       long newConditionsToCover = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_CONDITIONS_TO_COVER), periodIndex, 0L);
       return newLinesToCover + newConditionsToCover;
     }
index e68ae61ce77e8d676cc300a62fbe4664ffa2d124..0758fdeb57d0c8049a7bebf27544e1b900a2506c 100644 (file)
@@ -30,7 +30,6 @@ import org.sonar.api.measures.Metric;
 import org.sonar.api.measures.MetricFinder;
 import org.sonar.api.resources.Project;
 import org.sonar.api.resources.Resource;
-import org.sonar.api.resources.ResourceUtils;
 import org.sonar.api.resources.Scopes;
 import org.sonar.batch.components.TimeMachineConfiguration;
 
index 3c64cd47ff46ec97dbfe713ed60298dac625e9a4..4950b178270912030c5541a8cec9e7d933507cf9 100644 (file)
  */
 package org.sonar.plugins.cpd;
 
-import org.sonar.api.*;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.Plugin;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
 import org.sonar.plugins.cpd.decorators.DuplicationDensityDecorator;
 import org.sonar.plugins.cpd.decorators.SumDuplicationsDecorator;
 
-import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 @Properties({
@@ -36,14 +39,14 @@ import java.util.List;
         module = true,
         global = true),
     @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. " +
-                       "This means that foo=\"first string\"; and foo=\"second string\"; will be seen as equivalent.",
-            project = true,
-            module = true,
-            global = true),
+        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. " +
+            "This means that foo=\"first string\"; and foo=\"second string\"; will be seen as equivalent.",
+        project = true,
+        module = true,
+        global = true),
     @Property(
         key = CoreProperties.CPD_IGNORE_IDENTIFIERS_PROPERTY,
         defaultValue = CoreProperties.CPD_IGNORE_IDENTIFIERS_DEFAULT_VALUE + "",
@@ -75,12 +78,7 @@ public class CpdPlugin implements Plugin {
     return "Find duplicated source code within project.";
   }
 
-  public List<Class<? extends Extension>> getExtensions() {
-    List<Class<? extends Extension>> list = new ArrayList<Class<? extends Extension>>();
-    list.add(CpdSensor.class);
-    list.add(SumDuplicationsDecorator.class);
-    list.add(DuplicationDensityDecorator.class);
-    list.add(JavaCpdMapping.class);
-    return list;
+  public List getExtensions() {
+    return Arrays.asList(CpdSensor.class, SumDuplicationsDecorator.class, DuplicationDensityDecorator.class, JavaCpdMapping.class);
   }
 }
\ No newline at end of file
index 29eb7551453195a1257fa52adf3a775700f572ec..994b9e46f46170889a9066f9f8950b754186972c 100644 (file)
  */
 package org.sonar.plugins.findbugs;
 
+import org.sonar.api.*;
+
 import java.util.ArrayList;
 import java.util.List;
 
-import org.sonar.api.CoreProperties;
-import org.sonar.api.Extension;
-import org.sonar.api.Plugin;
-import org.sonar.api.Properties;
-import org.sonar.api.Property;
-
 @Properties({
     @Property(
         key = CoreProperties.FINDBUGS_EFFORT_PROPERTY,
         defaultValue = CoreProperties.FINDBUGS_EFFORT_DEFAULT_VALUE,
         name = "Effort",
-        description = "Effort of the bug finders. Valid values are Min, Default and Max. Setting 'Max' increases precision but also increases memory consumption.",
+        description = "Effort of the bug finders. Valid values are Min, Default and Max. Setting 'Max' increases precision but also increases " +
+            "memory consumption.",
         project = true, module = true, global = true),
     @Property(
         key = CoreProperties.FINDBUGS_TIMEOUT_PROPERTY,
         defaultValue = CoreProperties.FINDBUGS_TIMEOUT_DEFAULT_VALUE + "",
         name = "Timeout",
-        description = "Specifies the amount of time, in milliseconds, that FindBugs may run before it is assumed to be hung and is terminated. The default is 600,000 milliseconds, which is ten minutes.",
+        description = "Specifies the amount of time, in milliseconds, that FindBugs may run before it is assumed to be hung and is terminated. " +
+            "The default is 600,000 milliseconds, which is ten minutes.",
         project = true, module = true, global = true) })
 public class FindbugsPlugin implements Plugin {
 
@@ -52,7 +50,8 @@ public class FindbugsPlugin implements Plugin {
   }
 
   public String getDescription() {
-    return "FindBugs is a program that uses static analysis to look for bugs in Java code. It can detect a variety of common coding mistakes, including thread synchronization problems, misuse of API methods... You can find more by going to the <a href='http://findbugs.sourceforge.net'>Findbugs web site</a>.";
+    return "FindBugs is a program that uses static analysis to look for bugs in Java code. It can detect a variety of common coding mistakes, " +
+        "including thread synchronization problems, misuse of API methods... You can find more by going to the <a href='http://findbugs.sourceforge.net'>Findbugs web site</a>.";
   }
 
   public List<Class<? extends Extension>> getExtensions() {
index e1552a340f7c5dae4bb02e396400538c177ffb33..e60b2b06748a3285bd5bac14cfdc767c23ea8a82 100644 (file)
@@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
 import org.sonar.api.BatchExtension;
 import org.sonar.api.resources.Java;
 import org.sonar.api.resources.Project;
+import org.sonar.api.utils.SonarException;
 import org.sonar.api.utils.TimeProfiler;
 import org.sonar.java.api.JavaUtils;
 
@@ -122,7 +123,7 @@ public class PmdExecutor implements BatchExtension {
       return stream;
 
     } catch (FileNotFoundException e) {
-      throw new RuntimeException("The PMD ruleset can not be found: " + rulesetPath);
+      throw new SonarException("The PMD ruleset can not be found: " + rulesetPath, e);
     }
   }
 
@@ -159,7 +160,7 @@ public class PmdExecutor implements BatchExtension {
         LOG.info("Java version: " + javaVersion);
         pmd.setJavaVersion(sourceType);
       } else {
-        throw new RuntimeException("Unsupported Java version for PMD: " + javaVersion);
+        throw new SonarException("Unsupported Java version for PMD: " + javaVersion);
       }
     }
   }
index 8a103e593eabf87401d13154bd02c5877d265c66..f09b08e5a5d5ede812125858a5e027bc42315926 100644 (file)
@@ -21,8 +21,6 @@ package org.sonar.plugins.squid.bridges;
 
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.resources.Resource;
-import org.sonar.java.api.JavaClass;
-import org.sonar.squid.api.SourceClass;
 import org.sonar.squid.api.SourceFile;
 import org.sonar.squid.measures.Metric;
 
@@ -39,7 +37,7 @@ public class ChidamberKemererBridge extends Bridge {
     context.saveMeasure(sonarFile, CoreMetrics.RFC, squidFile.getDouble(Metric.RFC));
 
     double lcom4 = squidFile.getDouble(Metric.LCOM4);
-    if (lcom4>0.0) {
+    if (lcom4 > 0.0) {
       context.saveMeasure(sonarFile, CoreMetrics.LCOM4, lcom4);
     }
   }
index f4ee3279c2deea629e405686a794651bdb10e5d5..6bf82c970518e3d3fe477be082b0c9ac791eb487 100644 (file)
@@ -46,7 +46,7 @@ public abstract class Module {
   /**
    * @return this
    */
-  private final Module init(MutablePicoContainer container) {
+  private Module init(MutablePicoContainer container) {
     this.container = container;
     configure();
     return this;
index 2168ad2bfb4b965d9ebe4933c52170051700f2d2..d3eb23519e9c09be83d9d23c42cfce0fe725c5f6 100644 (file)
@@ -23,14 +23,12 @@ import org.sonar.api.BatchExtension;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.database.DatabaseSession;
 import org.sonar.api.database.model.Snapshot;
-import org.sonar.api.resources.Project;
+import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.utils.DateUtils;
 
 import java.text.SimpleDateFormat;
 import java.util.List;
 
-import org.sonar.api.resources.Qualifiers;
-
 public class PastSnapshotFinderByPreviousAnalysis implements BatchExtension {
 
   private DatabaseSession session;
index fb8d071f5d25999d3fa1ae4e1e9d06255b40f4fe..ff317f2b01aa6aafb3141b95db34323c56744b92 100644 (file)
@@ -27,7 +27,6 @@ import org.sonar.api.BatchExtension;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.database.model.Snapshot;
 import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.Resource;
 import org.sonar.api.utils.Logs;
 
 import java.util.Collections;
index ca65806e20ebab76575eb3baef2b1f7fb162eba5..157867cbe2a088c1aa0b368175cce536a2f8477d 100644 (file)
@@ -228,7 +228,7 @@ public final class DefaultResourcePersister implements ResourcePersister {
       return model;
 
     } catch (NonUniqueResultException e) {
-      throw new SonarException("The resource '" + resource.getEffectiveKey() + "' is duplicated in database.");
+      throw new SonarException("The resource '" + resource.getEffectiveKey() + "' is duplicated in database.", e);
     }
   }
 
index 4870ad168e7e7ab781c21f8a41ebb967effce237..94f5e9b377b87bb047ea91f00102d5c28923566a 100644 (file)
 package org.sonar.jpa.dao;
 
 import org.sonar.api.database.DatabaseSession;
-import org.sonar.api.database.model.RuleFailureModel;
-import org.sonar.api.database.model.Snapshot;
-import org.sonar.api.profiles.RulesProfile;
-import org.sonar.api.rules.ActiveRule;
-import org.sonar.api.rules.ActiveRuleParam;
 import org.sonar.api.rules.Rule;
 import org.sonar.api.rules.RuleParam;
 
-import java.util.Iterator;
 import java.util.List;
 
 public class RulesDao extends BaseDao {
index a4f44aa335aebf60bb127dbe42920b346738536e..0ec9a9ad72c1166ec18679e69be01647aca74c6a 100644 (file)
@@ -59,10 +59,12 @@ public class Match implements Comparable<Match> {
   public static final Comparator<Match> LabelComparator = new Comparator<Match>() {
 
     public int compare(Match ma, Match mb) {
-      if (ma.getLabel() == null)
+      if (ma.getLabel() == null) {
         return 1;
-      if (mb.getLabel() == null)
+      }
+      if (mb.getLabel() == null) {
         return -1;
+      }
       return mb.getLabel().compareTo(ma.getLabel());
     }
   };
index 2567b0c79cac21166fed1f6e1d9fa210789842a4..92bd5fa8132dbcf25938ea3873b0a63240f6e3ca 100644 (file)
@@ -29,6 +29,7 @@ import org.sonar.api.resources.Project;
  * @since 1.10
  * @deprecated since 2.6 was superseded by interface {@link CoverageExtension}
  */
+@Deprecated
 public abstract class AbstractCoverageExtension implements CoverageExtension {
 
   /**
index 872e6f7f027218a739686a27f1794c6ab172f096..8f09a59e68fed6e4477288870bed61dd5dfc07cc 100644 (file)
@@ -194,7 +194,7 @@ public interface SensorContext {
    *          if the source has already been set on this resource
    * @since 1.10. Returns a boolean since 2.6.
    */
-  void saveSource(Resource reference, String source) throws DuplicatedSourceException;
+  void saveSource(Resource reference, String source);
 
   // ----------- LINKS --------------
 
index 017ab98ac347ae342e794884760307b39f155a9b..7844a375578e82139815faf8214d769951c29cb7 100644 (file)
@@ -138,7 +138,7 @@ public final class AnnotationCheckFactory extends CheckFactory {
         throw new SonarException("The type of the field " + field + " is not supported: " + field.getType());
       }
     } catch (IllegalAccessException e) {
-      throw new SonarException("Can not set the value of the field " + field + " in the class: " + check.getClass().getName());
+      throw new SonarException("Can not set the value of the field " + field + " in the class: " + check.getClass().getName(), e);
     }
   }
 
index adc29ed1ddf1afc3e49d19df04cfd63bef98e860..2afffb5e307370bad0ee95b405aa3a2c7f95d381 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.api.database.model;
 
 import org.apache.commons.lang.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.commons.lang.builder.ToStringStyle;
 import org.sonar.api.database.DatabaseSession;
 import org.sonar.api.measures.Metric;
index ec6c75f5af14e707aefa5296b64a1057b41efacf..33c3f4b468095734c4ce83b9a45dd36421fb0a74 100644 (file)
@@ -365,6 +365,9 @@ public final class CoreMetrics {
       .setBestValue(100.0)
       .create();
 
+  /**
+   * @deprecated since 2.7. Replaced by COVERED_CONDITIONS_BY_LINE_KEY and COVERED_CONDITIONS_BY_LINE_KEY
+   */
   @Deprecated
   public static final String BRANCH_COVERAGE_HITS_DATA_KEY = "branch_coverage_hits_data";
 
index 4fc69f2332e1c6f236030509bf471a56b9b373d7..70501b4afdd1ceab4123ceb0615a255f44e260ba 100644 (file)
@@ -31,11 +31,16 @@ public final class Iso9126RulesCategories {
   private Iso9126RulesCategories() {
   }
 
-  public static final RulesCategory RELIABILITY = new RulesCategory("Reliability", "The extent to which the project can be expected to perform its intended function with rescission. Some examples : are loop indexes range tested? Is input data checked for range errors ? Is divide-by-zero avoided ? Is exception handling provided ?");
-  public static final RulesCategory EFFICIENCY = new RulesCategory("Efficiency", "The extent to which the project fulfills its purpose without waste of resources. This means resources in the sense of memory utilisation and processor speed.");
-  public static final RulesCategory PORTABILITY = new RulesCategory("Portability", "The extent to which the project can be operated easily and well on multiple computer configurations. Portability can mean both between different hardware setups and between different operating systems -- such as running on both Mac OS X and GNU/Linux.");
-  public static final RulesCategory USABILITY = new RulesCategory("Usability", "The extent to which the project can be understood, learned, operated, attractive and compliant with usability regulations and guidelines. It commonly relies on naming conventions and formatting rules.");
-  public static final RulesCategory MAINTAINABILITY = new RulesCategory("Maintainability", "The extent to which the project facilitates updating to satisfy new requirements. Thus the the project which is maintainable should be not complex.");
+  public static final RulesCategory RELIABILITY = new RulesCategory("Reliability",
+      "The extent to which the project can be expected to perform its intended function with rescission. Some examples : are loop indexes range tested? Is input data checked for range errors ? Is divide-by-zero avoided ? Is exception handling provided ?");
+  public static final RulesCategory EFFICIENCY = new RulesCategory("Efficiency",
+      "The extent to which the project fulfills its purpose without waste of resources. This means resources in the sense of memory utilisation and processor speed.");
+  public static final RulesCategory PORTABILITY = new RulesCategory("Portability",
+      "The extent to which the project can be operated easily and well on multiple computer configurations. Portability can mean both between different hardware setups and between different operating systems -- such as running on both Mac OS X and GNU/Linux.");
+  public static final RulesCategory USABILITY = new RulesCategory("Usability",
+      "The extent to which the project can be understood, learned, operated, attractive and compliant with usability regulations and guidelines. It commonly relies on naming conventions and formatting rules.");
+  public static final RulesCategory MAINTAINABILITY = new RulesCategory("Maintainability",
+      "The extent to which the project facilitates updating to satisfy new requirements. Thus the the project which is maintainable should be not complex.");
 
   public static final List<RulesCategory> ALL = Collections.unmodifiableList(Arrays.asList(RELIABILITY, EFFICIENCY, PORTABILITY, USABILITY, MAINTAINABILITY));
 }
index 4d19a4144acbdbeee58be3ff120ad99adc57d244..d3b431ae076126efec2a21c5ccbaf54673614fbc 100644 (file)
@@ -50,7 +50,7 @@ public final class DateUtils {
       return dateFormat.parse(s);
 
     } catch (ParseException e) {
-      throw new SonarException("The date '" + s + "' does not respect format '" + DATE_FORMAT + "'");
+      throw new SonarException("The date '" + s + "' does not respect format '" + DATE_FORMAT + "'", e);
     }
   }
 
@@ -59,7 +59,7 @@ public final class DateUtils {
       return dateTimeFormat.parse(s);
 
     } catch (ParseException e) {
-      throw new SonarException("The date '" + s + "' does not respect format '" + DATETIME_FORMAT + "'");
+      throw new SonarException("The date '" + s + "' does not respect format '" + DATETIME_FORMAT + "'", e);
     }
   }
 
index 996bfccd826fb2f4ac0b73f0bfd4e85df71c77bb..6b4ff0f72937c46c9c0e722fea94263ad30c7551 100644 (file)
@@ -432,7 +432,7 @@ public final class KeyValueFormat {
 
 
   /**
-   * @deprecated since 2.7 replaced by Converter
+   * @deprecated since 2.7. Replaced by Converter
    */
   @Deprecated
   public interface Transformer<KEY, VALUE> {
@@ -452,6 +452,7 @@ public final class KeyValueFormat {
 
   /**
    * Implementation of Transformer<Double, Double>
+   * @deprecated since 2.7. Replaced by Converter
    */
   @Deprecated
   public static class DoubleNumbersPairTransformer implements Transformer<Double, Double> {
@@ -462,6 +463,7 @@ public final class KeyValueFormat {
 
   /**
    * Implementation of Transformer<Integer, Integer>
+   * @deprecated since 2.7. Replaced by Converter
    */
   @Deprecated
   public static class IntegerNumbersPairTransformer implements Transformer<Integer, Integer> {
@@ -473,6 +475,7 @@ public final class KeyValueFormat {
 
   /**
    * Implementation of Transformer<RulePriority, Integer>
+   * @deprecated since 2.7. Replaced by Converter
    */
   @Deprecated
   public static class RulePriorityNumbersPairTransformer implements Transformer<RulePriority, Integer> {
index 50f1933ca525667bb4e6e918e9b669a36592af4c..6f174980bb920bb6d3c07a30d97058d6ccc49112 100644 (file)
@@ -96,7 +96,7 @@ public class ServerHttpClient implements BatchComponent {
 
   protected String executeAction(String action) {
     String result = getRemoteContent(url + action);
-    if (result.trim().length() == 0) {
+    if (StringUtils.isBlank(result)) {
       throw new ServerApiEmptyContentException("Empty " + action + " returned from server");
     }
     return result;
index a4d107347a53d4ba783ce1d2ffbb69c6b2f21619..413aa9c1758ce99351fa9f9bcca512a2f48e59b5 100644 (file)
@@ -157,7 +157,7 @@ public final class ZipUtils {
     }
   }
 
-  public static interface ZipEntryFilter {
+  private static interface ZipEntryFilter {
     boolean accept(ZipEntry entry);
   }
 
index e8f62192a6ff5688d394579b8921e884b01e9803..f0c8fc2fad3c657a618fb86bdc7fd0cea842bf18 100644 (file)
@@ -45,12 +45,13 @@ import java.text.DateFormat;
 import java.text.DecimalFormat;
 import java.text.ParseException;
 import java.util.Date;
+import java.util.SortedMap;
 import java.util.TreeMap;
 
 public class TrendsChart extends BaseChart {
 
   private XYPlot plot;
-  private TreeMap<Long, TimeSeries> seriesById;
+  private SortedMap<Long, TimeSeries> seriesById;
   private int percentAxisId = -1;
   private boolean displayLegend;
 
index e4d3b9d05861b55299aad9da2f6f60643fc37f41..bc7f086ec6de1489c79f5af10f16bd7a9549bca2 100644 (file)
@@ -58,7 +58,7 @@ public final class ConfigurationFactory {
     return result;
   }
 
-  protected PropertiesConfiguration getConfigurationFromPropertiesFile(String filename) throws ConfigurationException {
+  protected PropertiesConfiguration getConfigurationFromPropertiesFile(String filename) {
     try {
       return new PropertiesConfiguration(ConfigurationFactory.class.getResource(filename));
 
@@ -67,7 +67,7 @@ public final class ConfigurationFactory {
     }
   }
 
-  public PropertiesConfiguration getConfigurationFromPropertiesFile() throws ConfigurationException {
+  public PropertiesConfiguration getConfigurationFromPropertiesFile() {
     return getConfigurationFromPropertiesFile("/conf/sonar.properties");
   }
 
index c0b54e1c8ad9ba01b71c3e486483aea187e82404..9dfc0a5c2602dde92d1754d486bf0f512f3b7110 100644 (file)
@@ -21,6 +21,7 @@ package org.sonar.server.filters;
 
 import org.apache.commons.collections.comparators.ReverseComparator;
 
+import java.io.Serializable;
 import java.util.*;
 
 public class FilterResult {
@@ -97,7 +98,8 @@ public class FilterResult {
     }
   }
 
-  static class RowComparator implements Comparator {
+  static final class RowComparator implements Comparator, Serializable {
+    private static final long serialVersionUID = 4627704879575964978L;
     private int index;
 
     RowComparator(int index) {
index 31bb8bf0f09334f6eb6439119f8070066279c259..22d798048c1a83c529f09ba0c76e40e972cd534d 100644 (file)
@@ -20,8 +20,6 @@
 package org.sonar.server.platform;
 
 import org.apache.commons.configuration.Configuration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.sonar.server.configuration.ConfigurationFactory;
 
 import javax.servlet.ServletContextEvent;
@@ -29,8 +27,6 @@ import javax.servlet.ServletContextListener;
 
 public final class PlatformLifecycleListener implements ServletContextListener {
 
-  private static final Logger LOG = LoggerFactory.getLogger(PlatformLifecycleListener.class);
-
   public void contextInitialized(ServletContextEvent event) {
     Configuration configuration = new ConfigurationFactory().getConfiguration(event);
     Platform.getInstance().init(configuration);
index 2ae0845dd024b6be32540169b8cc63513d2515e7..64bdab896152e323f8e4605c7994da512f5ad5e0 100644 (file)
@@ -37,8 +37,8 @@ public final class EnableProfiles {
   private Language[] languages;
   private DatabaseSessionFactory sessionFactory;
 
-  // NOSONAR the parameter registerProfilesBefore is used to define the execution order of startup components
-  public EnableProfiles(Language[] languages, DatabaseSessionFactory sessionFactory, RegisterProvidedProfiles registerProfilesBefore) {
+
+  public EnableProfiles(Language[] languages, DatabaseSessionFactory sessionFactory, RegisterProvidedProfiles registerProfilesBefore) {// NOSONAR the parameter registerProfilesBefore is used to define the execution order of startup components
     this.languages = languages;
     this.sessionFactory = sessionFactory;
   }
index 5f36e4b84b28ad7bf37a76bfd925e4d980d6fce1..2392c4e6213783c2c0dfe78db0608ac82ecc9bb4 100644 (file)
@@ -46,7 +46,7 @@ public final class RegisterProvidedProfiles {
   private RuleFinder ruleFinder;
 
   public RegisterProvidedProfiles(RuleFinder ruleFinder, DatabaseSessionFactory sessionFactory,
-                                  DeprecatedProfiles deprecatedBridge, RegisterRules registerRulesBefore,
+                                  DeprecatedProfiles deprecatedBridge, RegisterRules registerRulesBefore,// NOSONAR the parameter registerRulesBefore is unused must be declared for execution order of tasks
                                   ProfileDefinition[] definitions) {
     this.ruleFinder = ruleFinder;
     this.sessionFactory = sessionFactory;
@@ -55,7 +55,7 @@ public final class RegisterProvidedProfiles {
   }
 
   public RegisterProvidedProfiles(RuleFinder ruleFinder, DatabaseSessionFactory sessionFactory,
-                                  DeprecatedProfiles deprecatedBridge, RegisterRules registerRulesBefore) {
+                                  DeprecatedProfiles deprecatedBridge, RegisterRules registerRulesBefore) {// NOSONAR the parameter registerRulesBefore is unused must be declared for execution order of tasks
     this.ruleFinder = ruleFinder;
     this.sessionFactory = sessionFactory;
     this.deprecatedProfiles = deprecatedBridge;
index bc9cc902396827aa41bcb73db07ff81dd1f75de4..d17cabf48fcc09549d01e254bced7039648e422c 100644 (file)
@@ -29,8 +29,7 @@ public final class RegisterQualityModels {
   /**
    * @param registerRulesBeforeModels used only to be started after the creation of check templates
    */
-  // NOSONAR the parameter registerRulesBeforeModels is only used to provide the execution order by picocontainer
-  public RegisterQualityModels(ModelManager manager, RegisterRules registerRulesBeforeModels) {
+  public RegisterQualityModels(ModelManager manager, RegisterRules registerRulesBeforeModels) {// NOSONAR the parameter registerRulesBeforeModels is only used to provide the execution order by picocontainer
     this.manager = manager;
   }
 
index c8f33678b7dd8bf7e1bde1a300499b99dba280df..cd02ce58e5f7461d2b5d251862cdfcdf6ea7bbeb 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.server.ui;
 
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.Resource;
 import org.sonar.api.web.*;
 
 /**
@@ -84,7 +83,8 @@ public final class DefaultPages {
       CoreMetrics.CRITICAL_VIOLATIONS_KEY, CoreMetrics.MAJOR_VIOLATIONS_KEY, CoreMetrics.MINOR_VIOLATIONS_KEY, CoreMetrics.INFO_VIOLATIONS_KEY,
       CoreMetrics.NEW_VIOLATIONS_KEY, CoreMetrics.NEW_BLOCKER_VIOLATIONS_KEY, CoreMetrics.NEW_CRITICAL_VIOLATIONS_KEY, CoreMetrics.NEW_MAJOR_VIOLATIONS_KEY,
       CoreMetrics.NEW_MINOR_VIOLATIONS_KEY, CoreMetrics.NEW_INFO_VIOLATIONS_KEY})
-  @ResourceQualifier({Qualifiers.VIEW, Qualifiers.SUBVIEW, Qualifiers.PROJECT, Qualifiers.MODULE, Qualifiers.PACKAGE, Qualifiers.DIRECTORY, Qualifiers.FILE, Qualifiers.CLASS}) /* all exept unit tests...*/
+  @ResourceQualifier({Qualifiers.VIEW, Qualifiers.SUBVIEW, Qualifiers.PROJECT, Qualifiers.MODULE, Qualifiers.PACKAGE, Qualifiers.DIRECTORY, Qualifiers.FILE, Qualifiers.CLASS})
+  /* all exept unit tests...*/
   @UserRole(UserRole.CODEVIEWER)
   private static final class ViolationsTab implements RubyRailsPage {
     public String getTemplate() {
index 4114818c0e77a52af1a67780fea78591f5d0b383..44440fd469d922aeac3923087485fe7181ce5616 100644 (file)
@@ -141,6 +141,7 @@ public abstract class SourceCode implements Measurable, Comparable<SourceCode> {
   /**
    * @deprecated since 2.1. It's replaced by getData(MetricDef). It's still defined for binary compatibility.
    */
+  @Deprecated
   public Object getData(Metric metric) {
     return measures.getData(metric);
   }
index 302d78538bc5d0f6217af056db0d1a7d5fc0c58a..a5cb54aa4879fb8a671d958abde0f2df17053fde 100644 (file)
@@ -107,13 +107,13 @@ public class TestUtils {
       try {
         FileUtils.deleteDirectory(dir);
       } catch (IOException e) {
-        throw new RuntimeException("Can not delete the directory " + dir);
+        throw new SonarException("Can not delete the directory " + dir, e);
       }
     }
     try {
       FileUtils.forceMkdir(dir);
     } catch (IOException e) {
-      throw new RuntimeException("Can not create the directory " + dir);
+      throw new SonarException("Can not create the directory " + dir, e);
     }
     return dir;
   }
@@ -134,7 +134,6 @@ public class TestUtils {
 
   static Diff isSimilarXml(String expectedXml, String xml) throws IOException, SAXException {
     XMLUnit.setIgnoreWhitespace(true);
-    Diff diff = XMLUnit.compareXML(xml, expectedXml);
-    return diff;
+    return XMLUnit.compareXML(xml, expectedXml);
   }
 }
index c92be0960aa5a49006c5e58f82324d4f0b94a735..ab664c07fc7d3946a4377f2f27bb2a2694fff6e7 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.test.channel;
 
 import org.hamcrest.BaseMatcher;
 import org.hamcrest.Description;
-import org.sonar.channel.Channel;
 import org.sonar.channel.CodeReader;
 
 public class ReaderHasNextCharMatcher extends BaseMatcher<CodeReader> {
index b7aebd57ca18edb9b2007e2ef2d667ab1d603e62..72d209735429ee8ed976d5224893fb42470e534f 100644 (file)
@@ -134,7 +134,9 @@ public class Dependency extends Model {
 
   @Override
   public boolean equals(Object o) {
-    if (this == o) return true;
+    if (this == o) {
+      return true;
+    }
     if (o == null || getClass() != o.getClass()) {
       return false;
     }
index 0012c3e11dfd8790809687412dda47f02fe946f1..8f49a7213d0ae4476bd83528e29ce1b8a7ed391f 100644 (file)
@@ -22,7 +22,7 @@ package org.sonar.wsclient.services;
 /**
  * @since 2.7
  */
-public class ProfileQuery extends Query<Profile> {
+public final class ProfileQuery extends Query<Profile> {
   public static final String BASE_URL = "/api/profiles";
 
   private String language;
index 19a3b989cb4ee8b837d563d030de2e8e09809386..1feefbb2d7b9ce47646d28092ea75d4ad5e1f76b 100644 (file)
@@ -22,7 +22,7 @@ package org.sonar.wsclient.services;
 /**
  * @since 2.4
  */
-public class UpdateCenterQuery extends Query<Plugin> {
+public final class UpdateCenterQuery extends Query<Plugin> {
 
   public static final String BASE_URL = "/api/updatecenter/";
   private String action;