aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api-impl/src/main
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2019-12-09 09:34:43 -0600
committerSonarTech <sonartech@sonarsource.com>2019-12-10 20:46:09 +0100
commitd1fd889554bccbb50122550899dbb66b90b04f78 (patch)
tree9cad838366292ee79b77ac3513403f7489b06355 /sonar-plugin-api-impl/src/main
parentf86a1094588e4e47b3abf612891af0431653cd0e (diff)
downloadsonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.tar.gz
sonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.zip
Fix code quality issues and reduce dependency on Guava
Diffstat (limited to 'sonar-plugin-api-impl/src/main')
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/AbsolutePathPredicate.java2
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/URIPredicate.java2
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptor.java4
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/utils/AlwaysIncreasingSystem2.java2
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/utils/WorkDuration.java12
5 files changed, 10 insertions, 12 deletions
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/AbsolutePathPredicate.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/AbsolutePathPredicate.java
index 56414c5c951..acb17f03062 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/AbsolutePathPredicate.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/AbsolutePathPredicate.java
@@ -53,7 +53,7 @@ class AbsolutePathPredicate extends AbstractFilePredicate {
return Collections.emptyList();
}
InputFile f = index.inputFile(relative);
- return f != null ? Arrays.asList(f) : Collections.<InputFile>emptyList();
+ return f != null ? Arrays.asList(f) : Collections.emptyList();
}
@Override
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/URIPredicate.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/URIPredicate.java
index 8dd2a301563..25552add6e4 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/URIPredicate.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/URIPredicate.java
@@ -55,7 +55,7 @@ class URIPredicate extends AbstractFilePredicate {
return Collections.emptyList();
}
InputFile f = index.inputFile(relative.get());
- return f != null ? Arrays.asList(f) : Collections.<InputFile>emptyList();
+ return f != null ? Arrays.asList(f) : Collections.emptyList();
}
@Override
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptor.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptor.java
index ef29870e1c5..bfddd446f11 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptor.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptor.java
@@ -27,8 +27,6 @@ import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.sensor.SensorDescriptor;
import org.sonar.api.config.Configuration;
-import static java.util.Arrays.asList;
-
public class DefaultSensorDescriptor implements SensorDescriptor {
private String name;
@@ -104,7 +102,7 @@ public class DefaultSensorDescriptor implements SensorDescriptor {
@Override
public DefaultSensorDescriptor requireProperties(String... propertyKeys) {
- this.configurationPredicate = config -> asList(propertyKeys).stream().allMatch(config::hasKey);
+ this.configurationPredicate = config -> Arrays.stream(propertyKeys).allMatch(config::hasKey);
return this;
}
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/utils/AlwaysIncreasingSystem2.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/utils/AlwaysIncreasingSystem2.java
index ab25411b6b2..b7d3aee4830 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/utils/AlwaysIncreasingSystem2.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/utils/AlwaysIncreasingSystem2.java
@@ -66,6 +66,6 @@ public class AlwaysIncreasingSystem2 extends System2 {
}
private static long randomInitialValue() {
- return (long) Math.abs(new Random().nextInt(2_000_000));
+ return Math.abs(new Random().nextInt(2_000_000));
}
}
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/utils/WorkDuration.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/utils/WorkDuration.java
index 20349ba155c..a57c1ba5d11 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/utils/WorkDuration.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/utils/WorkDuration.java
@@ -78,31 +78,31 @@ public class WorkDuration implements Serializable {
int minutes = 0;
long time = duration;
- Long currentTime = time / WorkDuration.DAY_POSITION_IN_LONG;
+ long currentTime = time / WorkDuration.DAY_POSITION_IN_LONG;
if (currentTime > 0) {
- days = currentTime.intValue();
+ days = (int) currentTime;
time = time - (currentTime * WorkDuration.DAY_POSITION_IN_LONG);
}
currentTime = time / WorkDuration.HOUR_POSITION_IN_LONG;
if (currentTime > 0) {
- hours = currentTime.intValue();
+ hours = (int) currentTime;
time = time - (currentTime * WorkDuration.HOUR_POSITION_IN_LONG);
}
currentTime = time / WorkDuration.MINUTE_POSITION_IN_LONG;
if (currentTime > 0) {
- minutes = currentTime.intValue();
+ minutes = (int) currentTime;
}
return WorkDuration.create(days, hours, minutes, hoursInDay);
}
static WorkDuration createFromMinutes(long duration, int hoursInDay) {
int days = (int)(duration / (double)hoursInDay / 60.0);
- Long currentDurationInMinutes = duration - (60L * days * hoursInDay);
+ long currentDurationInMinutes = duration - (60L * days * hoursInDay);
int hours = (int)(currentDurationInMinutes / 60.0);
currentDurationInMinutes = currentDurationInMinutes - (60L * hours);
- return new WorkDuration(duration, days, hours, currentDurationInMinutes.intValue(), hoursInDay);
+ return new WorkDuration(duration, days, hours, (int) currentDurationInMinutes, hoursInDay);
}
/**