From 0621ff4a475e52aeb0a3d770a339a5d59a1991e6 Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Wed, 10 Jul 2019 10:41:04 -0500 Subject: Fix code quality issues --- .../java/org/sonar/api/batch/fs/internal/DefaultIndexedFile.java | 2 +- .../java/org/sonar/api/batch/fs/internal/DefaultTextPointer.java | 2 +- .../main/java/org/sonar/api/batch/fs/internal/DefaultTextRange.java | 2 +- .../java/org/sonar/api/batch/fs/internal/TestInputFileBuilder.java | 4 ++-- .../java/org/sonar/api/batch/sensor/internal/DefaultStorable.java | 4 ++-- .../src/main/java/org/sonar/api/impl/ws/ValidatingRequest.java | 5 ++++- 6 files changed, 11 insertions(+), 8 deletions(-) (limited to 'sonar-plugin-api-impl') diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultIndexedFile.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultIndexedFile.java index 229280fca5b..59b9c06fff2 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultIndexedFile.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultIndexedFile.java @@ -126,7 +126,7 @@ public class DefaultIndexedFile extends DefaultInputComponent implements Indexed return true; } - if (!(o instanceof DefaultIndexedFile)) { + if (o == null || o.getClass() != this.getClass()) { return false; } diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultTextPointer.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultTextPointer.java index c10efd01de7..200bda8427b 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultTextPointer.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultTextPointer.java @@ -51,7 +51,7 @@ public class DefaultTextPointer implements TextPointer { @Override public boolean equals(Object obj) { - if (!(obj instanceof DefaultTextPointer)) { + if (obj == null || obj.getClass() != this.getClass()) { return false; } DefaultTextPointer other = (DefaultTextPointer) obj; diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultTextRange.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultTextRange.java index efef79cf367..c46deeffe14 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultTextRange.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultTextRange.java @@ -59,7 +59,7 @@ public class DefaultTextRange implements TextRange { @Override public boolean equals(Object obj) { - if (!(obj instanceof DefaultTextRange)) { + if (obj == null || obj.getClass() != this.getClass()) { return false; } DefaultTextRange other = (DefaultTextRange) obj; diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/TestInputFileBuilder.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/TestInputFileBuilder.java index 00f9319c2d4..bcbb27428d7 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/TestInputFileBuilder.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/TestInputFileBuilder.java @@ -86,10 +86,10 @@ public class TestInputFileBuilder { * filePath must point to a file that is within the module base directory. */ public TestInputFileBuilder(String projectKey, File moduleBaseDir, File filePath) { - String relativePath = moduleBaseDir.toPath().relativize(filePath.toPath()).toString(); + String relativePathStr = moduleBaseDir.toPath().relativize(filePath.toPath()).toString(); this.projectKey = projectKey; setModuleBaseDir(moduleBaseDir.toPath()); - this.relativePath = PathUtils.sanitize(relativePath); + this.relativePath = PathUtils.sanitize(relativePathStr); this.id = batchId++; } diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultStorable.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultStorable.java index 822ffbc2a40..d0ff1b59e60 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultStorable.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultStorable.java @@ -28,8 +28,8 @@ import static org.sonar.api.utils.Preconditions.checkState; public abstract class DefaultStorable { - protected final transient SensorStorage storage; - private transient boolean saved = false; + protected final SensorStorage storage; + private boolean saved = false; public DefaultStorable() { this.storage = null; diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/ws/ValidatingRequest.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/ws/ValidatingRequest.java index 6e7d90b6a06..dda4cbd337c 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/ws/ValidatingRequest.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/ws/ValidatingRequest.java @@ -85,6 +85,9 @@ public abstract class ValidatingRequest extends Request { @Override public List multiParam(String key) { WebService.Param definition = action.param(key); + if (definition == null) { + throw new IllegalArgumentException("Parameter '" + key + "' not found for action '" + action.key() + "'"); + } List values = readMultiParamOrDefaultValue(key, definition); return validateValues(values, definition); } @@ -224,7 +227,7 @@ public abstract class ValidatingRequest extends Request { checkArgument(valueAsInt <= maximumValue, "'%s' value (%s) must be less than %s", key, valueAsInt, maximumValue); } - private static void validateRequiredValue(String key, WebService.Param definition, String value) { + private static void validateRequiredValue(String key, WebService.Param definition, @Nullable String value) { boolean required = definition.isRequired(); if (required) { checkArgument(value != null, format(MSG_PARAMETER_MISSING, key)); -- cgit v1.2.3