]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws in API
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 3 Apr 2015 07:32:59 +0000 (09:32 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 3 Apr 2015 07:33:13 +0000 (09:33 +0200)
28 files changed:
sonar-plugin-api/src/main/java/org/sonar/api/batch/Phase.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/DebtRemediationFunction.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/FileSystem.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/AbsolutePathPredicate.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/FileMetadata.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/PathPattern.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameCommand.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/dependency/internal/DefaultDependency.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/duplication/Duplication.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/Issue.java
sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Action.java
sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java
sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java
sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileExporter.java
sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileImporter.java
sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleKey.java
sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java
sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileSystemFilter.java
sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtCharacteristic.java
sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtRemediationFunction.java
sonar-plugin-api/src/main/java/org/sonar/api/task/TaskDefinition.java
sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/batch/internal/DefaultRequirement.java
sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristic.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/WorkUnit.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/WorkDuration.java
sonar-plugin-api/src/main/java/org/sonar/api/violations/ViolationQuery.java

index b1b1214d491a66fe8b2ecb853004b2a0bb2e07ff..24a1b58e522768fa68dacdd14f88b91c5a9a050e 100644 (file)
@@ -33,7 +33,7 @@ public @interface Phase {
 
   Name name();
 
-  public enum Name {
+  enum Name {
     PRE, DEFAULT, POST
   }
 }
index 20874e5553da67e7befa72d1586d94e0404b8f74..afc120524a551fbdf3f07db492465e15c78c4a37 100644 (file)
@@ -620,11 +620,8 @@ public class ProjectDefinition {
     }
     ProjectDefinition that = (ProjectDefinition) o;
     String key = getKey();
-    if (key != null ? !key.equals(that.getKey()) : that.getKey() != null) {
-      return false;
-    }
+    return !(key != null ? !key.equals(that.getKey()) : that.getKey() != null);
 
-    return true;
   }
 
   @Override
index 97fd9e0a591f44648484015a1816bd03da220dc7..f70f7c5c033fa6375b4e5de08852f119a429281d 100644 (file)
@@ -34,7 +34,7 @@ import javax.annotation.Nullable;
  */
 public class DebtRemediationFunction {
 
-  public static enum Type {
+  public enum Type {
     LINEAR, LINEAR_OFFSET, CONSTANT_ISSUE
   }
 
index bc240e5610b795fae96a89cc968c52819b5e236d..64b80ea8b3cfd2aaee983d1cedb948b5395864ca 100644 (file)
@@ -153,7 +153,7 @@ public interface FileSystem extends BatchComponent {
   /**
    * Interface of the underlying file index.
    */
-  public static interface Index {
+  interface Index {
     Iterable<InputFile> inputFiles();
 
     @CheckForNull
index ab18e3c76ee084608971d10f23e7168487a0ec8a..e947a9da6c333d46e9fd2e8d42803838d4e79340 100644 (file)
@@ -51,7 +51,7 @@ class AbsolutePathPredicate extends AbstractFilePredicate {
   public Iterable<InputFile> get(Index index) {
     String relative = PathUtils.sanitize(new PathResolver().relativePath(baseDir.toFile(), new File(path)));
     if (relative == null) {
-      return Collections.<InputFile>emptyList();
+      return Collections.emptyList();
     }
     InputFile f = index.inputFile(relative);
     return f != null ? Arrays.asList(f) : Collections.<InputFile>emptyList();
index bb35754223986d265b07199ef76aaf615eadce60..d6ef257afa89e192bfbfe316941b0c7cb2af0761 100644 (file)
@@ -316,7 +316,7 @@ public class FileMetadata implements BatchComponent {
     }
   }
 
-  public static interface LineHashConsumer {
+  public interface LineHashConsumer {
 
     void consume(int lineIdx, @Nullable byte[] hash);
 
index 93d865d171199f1a581606bdf83e7f798834d5ce..c1b53b68a406629f744cb4a1ed1ceb7726ee1e69 100644 (file)
@@ -66,7 +66,7 @@ public abstract class PathPattern {
     public boolean match(InputFile inputFile, boolean caseSensitiveFileExtension) {
       String path = inputFile.absolutePath();
       if (!caseSensitiveFileExtension) {
-        String extension = super.sanitizeExtension(FilenameUtils.getExtension(inputFile.file().getName()));
+        String extension = sanitizeExtension(FilenameUtils.getExtension(inputFile.file().getName()));
         if (StringUtils.isNotBlank(extension)) {
           path = StringUtils.removeEndIgnoreCase(path, extension);
           path = path + extension;
@@ -98,7 +98,7 @@ public abstract class PathPattern {
     public boolean match(InputFile inputFile, boolean caseSensitiveFileExtension) {
       String path = inputFile.relativePath();
       if (!caseSensitiveFileExtension) {
-        String extension = super.sanitizeExtension(FilenameUtils.getExtension(inputFile.file().getName()));
+        String extension = sanitizeExtension(FilenameUtils.getExtension(inputFile.file().getName()));
         if (StringUtils.isNotBlank(extension)) {
           path = StringUtils.removeEndIgnoreCase(path, extension);
           path = path + extension;
index afb0d28662b981e07fbc75b8414da8adb0f9e8ab..b6e16d48bc74525a97187236ea7f945e2c053d9d 100644 (file)
@@ -44,7 +44,7 @@ public abstract class BlameCommand implements BatchComponent {
   /**
    * Callback for the provider to report results of blame per file.
    */
-  public static interface BlameInput {
+  public interface BlameInput {
 
     /**
      * Filesystem of the current (sub )project.
@@ -61,7 +61,7 @@ public abstract class BlameCommand implements BatchComponent {
   /**
    * Callback for the provider to report results of blame per file.
    */
-  public static interface BlameOutput {
+  public interface BlameOutput {
 
     /**
      * Add result of the blame command for a single file. Number of lines should
index 56161c2964634577896cd7f5ee3ba031aee3ebc0..59b2eb350b58aad6370b0fdb95b94889736e3685 100644 (file)
@@ -72,7 +72,7 @@ public class DefaultDependency extends DefaultStorable implements Dependency, Ne
     Preconditions.checkState(!this.fromKey.equals(this.toKey), "From and To can't be the same inputFile");
     Preconditions.checkNotNull(this.fromKey, "From inputFile can't be null");
     Preconditions.checkNotNull(this.toKey, "To inputFile can't be null");
-    storage.store((Dependency) this);
+    storage.store(this);
   }
 
   @Override
index e449063b7b041ac49f21eaaf3c47fbd06da82d0b..e445d5ce498944585f2fa5500a34c089aab9d20f 100644 (file)
@@ -39,7 +39,7 @@ import java.util.List;
 @Beta
 public interface Duplication {
 
-  public static class Block {
+  class Block {
     private final String resourceKey;
     private final int startLine;
     private final int length;
index e6456ec880342b5fbda0cc6ffa4abd1100f6ad0b..e235b33abb4d28ecffcd76b41a940845233d90bc 100644 (file)
@@ -34,12 +34,12 @@ import javax.annotation.CheckForNull;
 @Beta
 public interface Issue {
 
-  public enum Severity {
+  enum Severity {
     INFO,
     MINOR,
     MAJOR,
     CRITICAL,
-    BLOCKER;
+    BLOCKER
   }
 
   /**
index 071739d90601fc2cff55ef3abf3e487a41f21a4c..b7d967aa35d88406060d4cd982fb76c13c94ea77 100644 (file)
@@ -87,10 +87,7 @@ public class Action {
       return false;
     }
     Action that = (Action) o;
-    if (!key.equals(that.key)) {
-      return false;
-    }
-    return true;
+    return key.equals(that.key);
   }
 
   @Override
index 05d5d0fc5bdd0f598c21f4ce58370b1bdd227a37..d2827256243074bdcf374810f2fbb67272b1e575 100644 (file)
@@ -559,10 +559,7 @@ public class DefaultIssue implements Issue {
       return false;
     }
     DefaultIssue that = (DefaultIssue) o;
-    if (key != null ? !key.equals(that.key) : that.key != null) {
-      return false;
-    }
-    return true;
+    return !(key != null ? !key.equals(that.key) : that.key != null);
   }
 
   @Override
index 1901863576a1c2ac0c1fc4bd36169541fe57de87..0cd77c10ddfa9ec54cc0b670ace33df844a65ebb 100644 (file)
@@ -736,10 +736,7 @@ public class Measure<G extends Serializable> implements Serializable {
     if (characteristic != null ? !characteristic.equals(measure.characteristic) : measure.characteristic != null) {
       return false;
     }
-    if (personId != null ? !personId.equals(measure.personId) : measure.personId != null) {
-      return false;
-    }
-    return true;
+    return !(personId != null ? !personId.equals(measure.personId) : measure.personId != null);
   }
 
   @Override
index c4ea3e9b56854067fe181f2a36fd712a051e0605..f8ca5084ae555754c05f6102d8273a09f67e4fc5 100644 (file)
@@ -94,10 +94,7 @@ public abstract class ProfileExporter implements BatchExtension, ServerExtension
       return false;
     }
     ProfileExporter that = (ProfileExporter) o;
-    if (key != null ? !key.equals(that.key) : that.key != null) {
-      return false;
-    }
-    return true;
+    return !(key != null ? !key.equals(that.key) : that.key != null);
   }
 
   @Override
index 0f34fa467091d5b0283581ee414fec81ea118508..a468e2a9acc6007fe1d0c1487020a20cf526fcfe 100644 (file)
@@ -81,10 +81,7 @@ public abstract class ProfileImporter implements ServerExtension {
       return false;
     }
     ProfileImporter that = (ProfileImporter) o;
-    if (importerKey != null ? !importerKey.equals(that.importerKey) : that.importerKey != null) {
-      return false;
-    }
-    return true;
+    return !(importerKey != null ? !importerKey.equals(that.importerKey) : that.importerKey != null);
   }
 
   @Override
index 9d316d5a250451eb4730828147e0be038ac02a5e..e62752f3b7249ef6fa65db6f04060025776add52 100644 (file)
@@ -90,10 +90,7 @@ public class RuleKey implements Serializable {
     if (!repository.equals(ruleKey.repository)) {
       return false;
     }
-    if (!rule.equals(ruleKey.rule)) {
-      return false;
-    }
-    return true;
+    return rule.equals(ruleKey.rule);
   }
 
   @Override
index db4653f8a1a5d205c5b521acdcf39b0c29187e27..493267a4b9128cc6ff12217e7f4cc97ee5f54d62 100644 (file)
@@ -268,11 +268,8 @@ public class ActiveRule implements Cloneable {
     if (!rule.equals(that.rule)) {
       return false;
     }
-    if (rulesProfile != null ? !rulesProfile.equals(that.rulesProfile) : that.rulesProfile != null) {
-      return false;
-    }
+    return !(rulesProfile != null ? !rulesProfile.equals(that.rulesProfile) : that.rulesProfile != null);
 
-    return true;
   }
 
   @Override
index f80cad292c7110e12d2de85aca19f4c60f204dc9..7665b406f1b49eaae4ac82be41781af3a70e12c8 100644 (file)
@@ -40,7 +40,7 @@ public interface FileSystemFilter extends BatchExtension {
   /**
    * Plugins must not implement this interface. It is provided at runtime.
    */
-  public interface Context {
+  interface Context {
     ModuleFileSystem fileSystem();
 
     FileType type();
index 205dca4af46e72e24dfa8e1f236438cf8145b85d..32b9af374b88455b2fc2a4411c63689cfbac6446 100644 (file)
@@ -30,7 +30,7 @@ public interface DebtCharacteristic {
   /**
    * Only used when a characteristic is disabled (id is -1 in dto) by the user. see {@link org.sonar.server.rule.index.RuleNormalizer}
    */
-  static String NONE = "NONE";
+  String NONE = "NONE";
 
   String key();
 
index fdb10ce1a6a9055696050c693280d7e0f703c7b4..d8f6456e9f2e57314dac254a7dceb9ea08ac859a 100644 (file)
@@ -42,7 +42,7 @@ import javax.annotation.CheckForNull;
  */
 public interface DebtRemediationFunction {
 
-  static enum Type {
+  enum Type {
     LINEAR, LINEAR_OFFSET, CONSTANT_ISSUE
   }
 
index fa8fd07f79bd7d0b23711c339dafd92af0c3b38c..858c37b725d2d84d5c342a002ecbefab996a9486 100644 (file)
@@ -75,10 +75,7 @@ public class TaskDefinition implements TaskExtension, Comparable<TaskDefinition>
     }
 
     TaskDefinition that = (TaskDefinition) o;
-    if (!key.equals(that.key)) {
-      return false;
-    }
-    return true;
+    return key.equals(that.key);
   }
 
   @Override
index 8d0a49c5a564d3eec47913b99ef8e9eeac519952..26e5c74f180d96d3a2e94164d25a3e98f2e07946 100644 (file)
@@ -248,11 +248,8 @@ public class DefaultRequirement implements Requirement {
     if (!characteristic.equals(that.characteristic)) {
       return false;
     }
-    if (!ruleKey.equals(that.ruleKey)) {
-      return false;
-    }
+    return ruleKey.equals(that.ruleKey);
 
-    return true;
   }
 
   @Override
index de351f51a512e2ece3fadf09a0f840cd8786d4e5..bdda2b6a865cb4cf953127ebca23fc563c9620b3 100644 (file)
@@ -331,11 +331,8 @@ public class DefaultCharacteristic implements Characteristic {
     if (key != null ? !key.equals(that.key) : that.key != null) {
       return false;
     }
-    if (ruleKey != null ? !ruleKey.equals(that.ruleKey) : that.ruleKey != null) {
-      return false;
-    }
+    return !(ruleKey != null ? !ruleKey.equals(that.ruleKey) : that.ruleKey != null);
 
-    return true;
   }
 
   @Override
index d542a667eda9a65f2cb791249042228a3c5fa6a8..d008af886213ec6bf0081f909f8afe21dd09690a 100644 (file)
@@ -176,11 +176,8 @@ public class Duration implements Serializable {
     }
 
     Duration that = (Duration) o;
-    if (durationInMinutes != that.durationInMinutes) {
-      return false;
-    }
+    return durationInMinutes == that.durationInMinutes;
 
-    return true;
   }
 
   @Override
index 3f782ff51f00437d5ce00b3464a42d6f70ca16b7..22df70c50167fe4176a28b2d378703ec9b2ec118 100644 (file)
@@ -88,11 +88,8 @@ public final class WorkUnit implements Serializable {
     if (Double.compare(workUnit.value, value) != 0) {
       return false;
     }
-    if (!unit.equals(workUnit.unit)) {
-      return false;
-    }
+    return unit.equals(workUnit.unit);
 
-    return true;
   }
 
   @Override
index 73657269f17bd7f081f662e45935db5aa2121a09..7f4e946686c5a21b1344f35c9342d122a941540a 100644 (file)
@@ -37,7 +37,7 @@ public class WorkDuration implements Serializable {
   static final int HOUR_POSITION_IN_LONG = 100;
   static final int MINUTE_POSITION_IN_LONG = 1;
 
-  public static enum UNIT {
+  public enum UNIT {
     DAYS, HOURS, MINUTES
   }
 
@@ -181,11 +181,8 @@ public class WorkDuration implements Serializable {
     }
 
     WorkDuration that = (WorkDuration) o;
-    if (durationInMinutes != that.durationInMinutes) {
-      return false;
-    }
+    return durationInMinutes == that.durationInMinutes;
 
-    return true;
   }
 
   @Override
index 224fde2667f6616e7c79e2c5fc13869adbfe0a29..5f40106efc1be29b686153236fc314863008d8e7 100644 (file)
@@ -30,7 +30,7 @@ import org.sonar.api.resources.Resource;
 @Deprecated
 public final class ViolationQuery {
 
-  public static enum SwitchMode {
+  public enum SwitchMode {
     OFF, ON, BOTH
   }