Browse Source

Fix code quality issues

tags/8.0
Duarte Meneses 4 years ago
parent
commit
0621ff4a47

+ 1
- 1
sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultIndexedFile.java View File

@@ -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;
}


+ 1
- 1
sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultTextPointer.java View File

@@ -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;

+ 1
- 1
sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultTextRange.java View File

@@ -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;

+ 2
- 2
sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/TestInputFileBuilder.java View File

@@ -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++;
}


+ 2
- 2
sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultStorable.java View File

@@ -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;

+ 4
- 1
sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/ws/ValidatingRequest.java View File

@@ -85,6 +85,9 @@ public abstract class ValidatingRequest extends Request {
@Override
public List<String> multiParam(String key) {
WebService.Param definition = action.param(key);
if (definition == null) {
throw new IllegalArgumentException("Parameter '" + key + "' not found for action '" + action.key() + "'");
}
List<String> 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));

+ 1
- 1
sonar-plugin-api/src/test/java/org/sonar/api/server/ws/RequestTest.java View File

@@ -591,7 +591,7 @@ public class RequestTest {
@Test
public void fail_if_multi_param_is_not_defined() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("BUG - parameter 'unknown' is undefined for action 'my_action'");
expectedException.expectMessage("Parameter 'unknown' not found for action 'my_action'");

underTest.multiParam("unknown");
}

Loading…
Cancel
Save