diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-08-16 11:54:32 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-08-16 11:54:32 +0200 |
commit | 424cffa7da8a34ab30cf4426cb3ee897ba01c743 (patch) | |
tree | ea2078f5bd396a4182685d3c523235048420cfc9 /sonar-batch | |
parent | 5db787d457fdf31c73322d9dad0b8dc726ddb2d1 (diff) | |
download | sonarqube-424cffa7da8a34ab30cf4426cb3ee897ba01c743.tar.gz sonarqube-424cffa7da8a34ab30cf4426cb3ee897ba01c743.zip |
Fix quality flaws
Diffstat (limited to 'sonar-batch')
10 files changed, 21 insertions, 22 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionUtils.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionUtils.java index ce585828cc2..1111e7fbfd2 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionUtils.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionUtils.java @@ -68,7 +68,7 @@ public class ExtensionUtils { } public static boolean isType(Object extension, Class<?> extensionClass) { - Class clazz = (extension instanceof Class ? (Class) extension : extension.getClass()); + Class clazz = extension instanceof Class ? (Class) extension : extension.getClass(); return extensionClass.isAssignableFrom(clazz); } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java index a046369d920..fe75a71053d 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java @@ -87,7 +87,7 @@ public class ServerClient implements BatchComponent { try { return IOUtils.toString(inputSupplier.getInput(), "UTF-8"); } catch (HttpDownloader.HttpException e) { - throw (wrapHttpException ? handleHttpException(e) : e); + throw wrapHttpException ? handleHttpException(e) : e; } catch (IOException e) { throw new SonarException(String.format("Unable to request: %s", pathStartingWithSlash), e); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshot.java b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshot.java index e252433c3ff..24c0ae618c8 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshot.java +++ b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshot.java @@ -73,7 +73,7 @@ public class PastSnapshot { } public Date getDate() { - return (projectSnapshot != null ? projectSnapshot.getCreatedAt() : null); + return projectSnapshot != null ? projectSnapshot.getCreatedAt() : null; } public String getMode() { @@ -90,11 +90,11 @@ public class PastSnapshot { } Integer getProjectSnapshotId() { - return (projectSnapshot != null ? projectSnapshot.getId() : null); + return projectSnapshot != null ? projectSnapshot.getId() : null; } public String getQualifier() { - return (projectSnapshot != null ? projectSnapshot.getQualifier() : null); + return projectSnapshot != null ? projectSnapshot.getQualifier() : null; } public Date getTargetDate() { diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByDate.java b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByDate.java index 5dc9b0d0eb4..3767e174b39 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByDate.java +++ b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByDate.java @@ -58,6 +58,6 @@ public class PastSnapshotFinderByDate implements BatchExtension { .setMaxResults(1) .getResultList(); - return (snapshots.isEmpty() ? null : snapshots.get(0)); + return snapshots.isEmpty() ? null : snapshots.get(0); } }
\ No newline at end of file diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java index 0d754d215d6..15b0933f77c 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java @@ -194,7 +194,7 @@ public final class DefaultResourcePersister implements ResourcePersister { if (snapshots.isEmpty()) { snapshots = session.getResults(Snapshot.class, "resourceId", resourceId, "version", version, "scope", Scopes.PROJECT, "qualifier", Qualifiers.LIBRARY); } - return (snapshots.isEmpty() ? null : snapshots.get(0)); + return snapshots.isEmpty() ? null : snapshots.get(0); } /** diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/DefaultIssuable.java b/sonar-batch/src/main/java/org/sonar/batch/issue/DefaultIssuable.java index 5f5ead3d3f1..0be18b5dff9 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/issue/DefaultIssuable.java +++ b/sonar-batch/src/main/java/org/sonar/batch/issue/DefaultIssuable.java @@ -50,7 +50,7 @@ public class DefaultIssuable implements Issuable { @Override public boolean addIssue(Issue issue) { - return scanIssues.initAndAddIssue(((DefaultIssue) issue)); + return scanIssues.initAndAddIssue((DefaultIssue) issue); } @SuppressWarnings("unchecked") diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/IssueFilters.java b/sonar-batch/src/main/java/org/sonar/batch/issue/IssueFilters.java index d33d1fcce07..190b4ea1916 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/issue/IssueFilters.java +++ b/sonar-batch/src/main/java/org/sonar/batch/issue/IssueFilters.java @@ -50,7 +50,7 @@ public class IssueFilters implements BatchExtension { } } if (!deprecatedFilters.isEmpty()) { - Violation v = (violation != null ? violation : deprecatedViolations.toViolation(issue)); + Violation v = violation != null ? violation : deprecatedViolations.toViolation(issue); return !deprecatedFilters.isIgnored(v); } return true; diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/DefaultProjectBootstrapper.java b/sonar-batch/src/main/java/org/sonar/batch/scan/DefaultProjectBootstrapper.java index e8f1a6b5fc4..b141ff79ffe 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/DefaultProjectBootstrapper.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/DefaultProjectBootstrapper.java @@ -20,6 +20,7 @@ package org.sonar.batch.scan; import com.google.common.annotations.VisibleForTesting; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import org.apache.commons.io.IOUtils; import org.apache.commons.io.filefilter.AndFileFilter; @@ -74,14 +75,12 @@ class DefaultProjectBootstrapper implements ProjectBootstrapper { private static final String PROPERTY_OLD_TESTS = "tests"; private static final String PROPERTY_OLD_BINARIES = "binaries"; private static final String PROPERTY_OLD_LIBRARIES = "libraries"; - private static final Map<String, String> DEPRECATED_PROPS_TO_NEW_PROPS = new HashMap<String, String>() { - { - put(PROPERTY_OLD_SOURCES, PROPERTY_SOURCES); - put(PROPERTY_OLD_TESTS, PROPERTY_TESTS); - put(PROPERTY_OLD_BINARIES, PROPERTY_BINARIES); - put(PROPERTY_OLD_LIBRARIES, PROPERTY_LIBRARIES); - } - }; + private static final Map<String, String> DEPRECATED_PROPS_TO_NEW_PROPS = ImmutableMap.of( + PROPERTY_OLD_SOURCES, PROPERTY_SOURCES, + PROPERTY_OLD_TESTS, PROPERTY_TESTS, + PROPERTY_OLD_BINARIES, PROPERTY_BINARIES, + PROPERTY_OLD_LIBRARIES, PROPERTY_LIBRARIES + ); /** * @since 1.4 diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/DeprecatedJsonReport.java b/sonar-batch/src/main/java/org/sonar/batch/scan/DeprecatedJsonReport.java index 4f20681d120..10a61278be7 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/DeprecatedJsonReport.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/DeprecatedJsonReport.java @@ -119,7 +119,7 @@ public class DeprecatedJsonReport implements BatchComponent { .name("rule_repository").value(issue.ruleKey().repository()) .name("rule_name").value(ruleName(issue.ruleKey())) .name("switched_off").value(Issue.RESOLUTION_FALSE_POSITIVE.equals(issue.resolution())) - .name("is_new").value((issue.isNew())) + .name("is_new").value(issue.isNew()) .name("created_at").value(DateUtils.formatDateTime(issue.creationDate())) .endObject(); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java index 1028417cd2d..e8e3eab9943 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java @@ -57,7 +57,7 @@ public class ExclusionFilters implements FileSystemFilter, ResourceFilter, Batch } public boolean accept(File file, Context context) { - PathPattern[] inclusionPatterns = (context.type() == FileType.TEST ? testInclusions() : sourceInclusions()); + PathPattern[] inclusionPatterns = context.type() == FileType.TEST ? testInclusions() : sourceInclusions(); if (inclusionPatterns.length > 0) { boolean matchInclusion = false; for (PathPattern pattern : inclusionPatterns) { @@ -67,7 +67,7 @@ public class ExclusionFilters implements FileSystemFilter, ResourceFilter, Batch return false; } } - PathPattern[] exclusionPatterns = (context.type() == FileType.TEST ? testExclusions() : sourceExclusions()); + PathPattern[] exclusionPatterns = context.type() == FileType.TEST ? testExclusions() : sourceExclusions(); for (PathPattern pattern : exclusionPatterns) { if (pattern.match(context)) { return false; @@ -78,11 +78,11 @@ public class ExclusionFilters implements FileSystemFilter, ResourceFilter, Batch public boolean isIgnored(Resource resource) { if (ResourceUtils.isFile(resource)) { - PathPattern[] inclusionPatterns = (ResourceUtils.isUnitTestClass(resource) ? testInclusions() : sourceInclusions()); + PathPattern[] inclusionPatterns = ResourceUtils.isUnitTestClass(resource) ? testInclusions() : sourceInclusions(); if (isIgnoredByInclusions(resource, inclusionPatterns)) { return true; } - PathPattern[] exclusionPatterns = (ResourceUtils.isUnitTestClass(resource) ? testExclusions() : sourceExclusions()); + PathPattern[] exclusionPatterns = ResourceUtils.isUnitTestClass(resource) ? testExclusions() : sourceExclusions(); return isIgnoredByExclusions(resource, exclusionPatterns); } return false; |