]> source.dussan.org Git - sonarqube.git/commitdiff
Fix some quality flaws
authorsimonbrandhof <simon.brandhof@gmail.com>
Sat, 31 Dec 2011 09:17:26 +0000 (10:17 +0100)
committersimonbrandhof <simon.brandhof@gmail.com>
Sat, 31 Dec 2011 09:17:26 +0000 (10:17 +0100)
sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectFilter.java
sonar-core/src/main/java/org/sonar/core/dashboard/ActiveDashboardDto.java
sonar-core/src/main/java/org/sonar/core/persistence/DatabaseUtils.java
sonar-core/src/main/java/org/sonar/core/persistence/DefaultDatabase.java
sonar-core/src/main/java/org/sonar/core/persistence/dialect/MsSql.java
sonar-core/src/main/java/org/sonar/core/persistence/dialect/OracleSequenceGenerator.java
sonar-core/src/main/java/org/sonar/core/persistence/dialect/PostgreSQLSequenceGenerator.java
sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerMapper.java
sonar-plugin-api/src/main/java/org/sonar/api/resources/DefaultProjectFileSystem.java

index e6b5b9866315d035711322fcd6fccf7cef4212cf..8b2810750abc901c65fbb9f5ff753db718062e7a 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.batch.bootstrap;
 
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
-import org.slf4j.LoggerFactory;
 import org.sonar.api.config.Settings;
 import org.sonar.api.resources.Project;
 
index b5c7b00b50746e7a09dfed0c3cf56fc56cfb3d85..496796483a7b2c536e12789bee43181f7e71017e 100644 (file)
@@ -85,24 +85,21 @@ public final class ActiveDashboardDto {
     this.orderIndex = orderIndex;
   }
 
-  /*
-   * (non-Javadoc)
-   * 
-   * @see java.lang.Object#hashCode()
-   */
   @Override
-  public int hashCode() {
-    return HashCodeBuilder.reflectionHashCode(this, new String[]{"id"});
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+    ActiveDashboardDto that = (ActiveDashboardDto) o;
+    return !(id != null ? !id.equals(that.id) : that.id != null);
+
   }
 
-  /*
-   * (non-Javadoc)
-   * 
-   * @see java.lang.Object#equals(java.lang.Object)
-   */
   @Override
-  public boolean equals(Object obj) {
-    return EqualsBuilder.reflectionEquals(this, obj, new String[]{"id"});
+  public int hashCode() {
+    return id != null ? id.hashCode() : 0;
   }
-
 }
index f8b1117898f4bc537a2421e964064b9c900f427e..097456278c69128ac7007e6d2c2eec9316fd6012 100644 (file)
@@ -36,7 +36,7 @@ public final class DatabaseUtils {
    * This list is hardcoded because we didn't succeed in using java.sql.DatabaseMetaData#getTables() in the same way
    * for all the supported databases, particularly due to Oracle results.
    */
-  public static final String[] TABLE_NAMES = {
+  static final String[] TABLE_NAMES = {
     "action_plans",
     "action_plans_reviews",
     "active_dashboards",
index ca18563cdeb593362338f95c5f0e2ebdb446344d..84a1f78fa176befe210d5643d110099c898bdba8 100644 (file)
@@ -107,7 +107,9 @@ public class DefaultDatabase implements Database {
     }
   }
 
-  private void initDatasource() throws Exception {
+  private void initDatasource() throws Exception {//NOSONAR this exception is thrown by BasicDataSourceFactory
+    // but it's correctly caught by start()
+
     LOG.info("Create JDBC datasource");
     datasource = (BasicDataSource) BasicDataSourceFactory.createDataSource(extractCommonsDbcpProperties(properties));
 
index 0e421ff50b97df229afee1b8caf0e8ffaeb9c187..2d4f28b22e20d25266e45d72e7aa67f76ee58598 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.core.persistence.dialect;
 
 import org.apache.commons.lang.StringUtils;
-import org.hibernate.HibernateException;
 import org.hibernate.dialect.SQLServerDialect;
 import org.sonar.api.database.DatabaseProperties;
 
@@ -61,7 +60,7 @@ public class MsSql implements Dialect {
       registerColumnType(Types.CLOB, "nvarchar(max)");
     }
 
-    public String getTypeName(int code, int length, int precision, int scale) throws HibernateException {
+    public String getTypeName(int code, int length, int precision, int scale) {
       if (code != 2005) {
         return super.getTypeName(code, length, precision, scale);
       } else {
index 63501c69ac8d8aa75cb7d5f43121b3eff79ba424..7202e7375ec0fd2bd1f6c25003ad38fa5cf61c4e 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.core.persistence.dialect;
 
 import org.apache.commons.lang.StringUtils;
-import org.hibernate.MappingException;
 import org.hibernate.dialect.Dialect;
 import org.hibernate.id.PersistentIdentifierGenerator;
 import org.hibernate.id.SequenceGenerator;
@@ -36,20 +35,14 @@ public class OracleSequenceGenerator extends SequenceGenerator {
   public static final String SEQUENCE_NAME_SUFFIX = "_SEQ";
 
   @Override
-  public void configure(Type type, Properties params, Dialect dialect)
-    throws MappingException {
-
+  public void configure(Type type, Properties params, Dialect dialect) {
     String tableName = params.getProperty(PersistentIdentifierGenerator.TABLE);
-
     if (tableName != null) {
       StringBuilder sequenceNameBuilder = new StringBuilder();
-
       sequenceNameBuilder.append(tableName);
       sequenceNameBuilder.append(SEQUENCE_NAME_SUFFIX);
-
       params.setProperty(SEQUENCE, StringUtils.upperCase(sequenceNameBuilder.toString()));
     }
-
     super.configure(type, params, dialect);
   }
 
index 514b204e8be888ed0eceb517368c15b4094b319c..9d97141d5f1fb1318fe6f2875824e15c100bb32b 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.core.persistence.dialect;
 
-import org.hibernate.MappingException;
 import org.hibernate.dialect.Dialect;
 import org.hibernate.id.PersistentIdentifierGenerator;
 import org.hibernate.id.SequenceGenerator;
@@ -40,8 +39,7 @@ public class PostgreSQLSequenceGenerator extends SequenceGenerator {
   public static final String SEQUENCE_NAME_SUFFIX = "seq";
 
   @Override
-  public void configure(Type type, Properties params, Dialect dialect)
-    throws MappingException {
+  public void configure(Type type, Properties params, Dialect dialect) {
 
     String tableName = params.getProperty(PersistentIdentifierGenerator.TABLE);
     String columnName = params.getProperty(PersistentIdentifierGenerator.PK);
index a9b044f23fa520f6bdaf445f7ac0dd0f5682f89e..c59c43c8174aa12303f512a5e923c04e88568363 100644 (file)
@@ -19,8 +19,6 @@
  */
 package org.sonar.core.resource;
 
-import java.util.List;
-
 public interface ResourceIndexerMapper {
 
   ResourceIndexDto selectMasterIndexByResourceId(int resourceId);
index 7ab9dc30d4d03ead3a575ccd9f0723835d85d0d7..0850d818fa95db898c45d73892e6f4ca74683993 100644 (file)
 package org.sonar.api.resources;
 
 import com.google.common.base.Predicate;
-import com.google.common.collect.*;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOCase;
 import org.apache.commons.io.filefilter.*;
 import org.apache.commons.lang.CharEncoding;
 import org.apache.commons.lang.StringUtils;
@@ -41,7 +43,7 @@ import java.util.*;
 /**
  * An implementation of {@link ProjectFileSystem}.
  * For internal use only.
- * 
+ *
  * @since 1.10
  * @deprecated in 2.8. In fact this class should not be located in sonar-plugin-api and most of the methods were overridden by a component in sonar-batch.
  */
@@ -215,7 +217,7 @@ public class DefaultProjectFileSystem implements ProjectFileSystem {
     WildcardPattern[] exclusionPatterns = getExclusionPatterns(applyExclusionPatterns);
 
     IOFileFilter initialFilesFilter = TrueFileFilter.INSTANCE;
-    if (initialFiles!=null && !initialFiles.isEmpty()) {
+    if (initialFiles != null && !initialFiles.isEmpty()) {
       initialFilesFilter = new FileSelectionFilter(initialFiles);
     }
 
@@ -313,7 +315,7 @@ public class DefaultProjectFileSystem implements ProjectFileSystem {
 
   /**
    * getRelativePath("c:/foo/src/my/package/Hello.java", "c:/foo/src") is "my/package/Hello.java"
-   * 
+   *
    * @return null if file is not in dir (including recursive subdirectories)
    */
   public static String getRelativePath(File file, File dir) {
@@ -325,7 +327,7 @@ public class DefaultProjectFileSystem implements ProjectFileSystem {
    * <p>
    * Relative path is composed of slashes. Windows backslaches are replaced by /
    * </p>
-   * 
+   *
    * @return null if file is not in dir (including recursive subdirectories)
    */
   public static String getRelativePath(File file, List<File> dirs) {