aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api-impl
diff options
context:
space:
mode:
authorPierre <pierre.guillot@sonarsource.com>2020-12-11 17:20:41 +0100
committersonartech <sonartech@sonarsource.com>2020-12-14 20:07:14 +0000
commitffcea568c79640227b2fd9c562f642b9d087ea10 (patch)
tree6b0c16201bdc6308048744fea48f4e4a9667fd5d /sonar-plugin-api-impl
parent4e07979ccca556d5f05a1be05b88f0bd85ff3f66 (diff)
downloadsonarqube-ffcea568c79640227b2fd9c562f642b9d087ea10.tar.gz
sonarqube-ffcea568c79640227b2fd9c562f642b9d087ea10.zip
fix code smells
Diffstat (limited to 'sonar-plugin-api-impl')
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputFileTest.java14
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/FileMetadataTest.java2
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/rule/internal/DefaultRulesTest.java4
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java6
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/impl/utils/WorkDurationTest.java42
5 files changed, 34 insertions, 34 deletions
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputFileTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputFileTest.java
index 888b7ea81c7..e9b5c82a50f 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputFileTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputFileTest.java
@@ -177,7 +177,7 @@ public class DefaultInputFileTest {
Metadata metadata = new Metadata(2, 2, "", new int[] {0, 10}, new int[] {9, 15}, 16);
DefaultInputFile file = new DefaultInputFile(new DefaultIndexedFile("ABCDE", Paths.get("module"), MODULE_RELATIVE_PATH, null), f -> f.setMetadata(metadata));
assertThat(file.newPointer(1, 0).line()).isEqualTo(1);
- assertThat(file.newPointer(1, 0).lineOffset()).isEqualTo(0);
+ assertThat(file.newPointer(1, 0).lineOffset()).isZero();
// Don't fail
file.newPointer(1, 9);
file.newPointer(2, 0);
@@ -214,14 +214,14 @@ public class DefaultInputFileTest {
Metadata metadata = new Metadata(2, 2, "", new int[] {0, 10}, new int[] {8, 15}, 16);
DefaultInputFile file = new DefaultInputFile(new DefaultIndexedFile("ABCDE", Paths.get("module"), MODULE_RELATIVE_PATH, null), f -> f.setMetadata(metadata));
assertThat(file.newPointer(0).line()).isEqualTo(1);
- assertThat(file.newPointer(0).lineOffset()).isEqualTo(0);
+ assertThat(file.newPointer(0).lineOffset()).isZero();
assertThat(file.newPointer(9).line()).isEqualTo(1);
// Ignore eol characters
assertThat(file.newPointer(9).lineOffset()).isEqualTo(8);
assertThat(file.newPointer(10).line()).isEqualTo(2);
- assertThat(file.newPointer(10).lineOffset()).isEqualTo(0);
+ assertThat(file.newPointer(10).lineOffset()).isZero();
assertThat(file.newPointer(15).line()).isEqualTo(2);
assertThat(file.newPointer(15).lineOffset()).isEqualTo(5);
@@ -277,15 +277,15 @@ public class DefaultInputFileTest {
DefaultInputFile file = new DefaultInputFile(new DefaultIndexedFile("ABCDE", Paths.get("module"), MODULE_RELATIVE_PATH, null), f -> f.setMetadata(metadata));
assertThat(file.selectLine(1).start().line()).isEqualTo(1);
- assertThat(file.selectLine(1).start().lineOffset()).isEqualTo(0);
+ assertThat(file.selectLine(1).start().lineOffset()).isZero();
assertThat(file.selectLine(1).end().line()).isEqualTo(1);
assertThat(file.selectLine(1).end().lineOffset()).isEqualTo(9);
// Don't fail when selecting empty line
assertThat(file.selectLine(3).start().line()).isEqualTo(3);
- assertThat(file.selectLine(3).start().lineOffset()).isEqualTo(0);
+ assertThat(file.selectLine(3).start().lineOffset()).isZero();
assertThat(file.selectLine(3).end().line()).isEqualTo(3);
- assertThat(file.selectLine(3).end().lineOffset()).isEqualTo(0);
+ assertThat(file.selectLine(3).end().lineOffset()).isZero();
try {
file.selectLine(5);
@@ -301,7 +301,7 @@ public class DefaultInputFileTest {
DefaultInputFile file = new DefaultInputFile(new DefaultIndexedFile("ABCDE", Paths.get("module"), MODULE_RELATIVE_PATH, null), f -> f.setMetadata(metadata));
TextRange newRange = file.newRange(10, 13);
assertThat(newRange.start().line()).isEqualTo(2);
- assertThat(newRange.start().lineOffset()).isEqualTo(0);
+ assertThat(newRange.start().lineOffset()).isZero();
assertThat(newRange.end().line()).isEqualTo(2);
assertThat(newRange.end().lineOffset()).isEqualTo(3);
}
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/FileMetadataTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/FileMetadataTest.java
index 00642518985..a1946838ab9 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/FileMetadataTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/FileMetadataTest.java
@@ -64,7 +64,7 @@ public class FileMetadataTest {
Metadata metadata = new FileMetadata(analysisWarnings).readMetadata(new FileInputStream(tempFile), StandardCharsets.UTF_8, tempFile.getName());
assertThat(metadata.lines()).isEqualTo(1);
- assertThat(metadata.nonBlankLines()).isEqualTo(0);
+ assertThat(metadata.nonBlankLines()).isZero();
assertThat(metadata.hash()).isNotEmpty();
assertThat(metadata.originalLineStartOffsets()).containsOnly(0);
assertThat(metadata.originalLineEndOffsets()).containsOnly(0);
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/rule/internal/DefaultRulesTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/rule/internal/DefaultRulesTest.java
index f4fdc67c8b9..b9bc7ba5612 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/rule/internal/DefaultRulesTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/rule/internal/DefaultRulesTest.java
@@ -47,9 +47,9 @@ public class DefaultRulesTest {
newRules.add(createRule("key2", "repo", "internal"));
DefaultRules rules = new DefaultRules(newRules);
- assertThat(rules.findByInternalKey("xx", "xx")).hasSize(0);
+ assertThat(rules.findByInternalKey("xx", "xx")).isEmpty();
assertThat(rules.find(RuleKey.of("xxx", "xx"))).isNull();
- assertThat(rules.findByRepository("xxxx")).hasSize(0);
+ assertThat(rules.findByRepository("xxxx")).isEmpty();
}
@Test
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java
index 6cf2c86c021..0c1014bd093 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java
@@ -219,7 +219,7 @@ public class MapSettingsTest {
@Test
public void default_number_values_are_zero() {
Settings settings = new MapSettings();
- assertThat(settings.getInt("foo")).isEqualTo(0);
+ assertThat(settings.getInt("foo")).isZero();
assertThat(settings.getLong("foo")).isEqualTo(0L);
}
@@ -471,7 +471,7 @@ public class MapSettingsTest {
@Test
public void getStringLines_no_value() {
- Assertions.assertThat(new MapSettings().getStringLines("foo")).hasSize(0);
+ Assertions.assertThat(new MapSettings().getStringLines("foo")).isEmpty();
}
@Test
@@ -517,7 +517,7 @@ public class MapSettingsTest {
assertThat(settings.getKeysStartingWith("sonar")).containsOnly("sonar.jdbc.url", "sonar.jdbc.username", "sonar.security");
assertThat(settings.getKeysStartingWith("sonar.jdbc")).containsOnly("sonar.jdbc.url", "sonar.jdbc.username");
- assertThat(settings.getKeysStartingWith("other")).hasSize(0);
+ assertThat(settings.getKeysStartingWith("other")).isEmpty();
}
@Test
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/impl/utils/WorkDurationTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/impl/utils/WorkDurationTest.java
index a4f2cc322ee..d32a88fb13c 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/impl/utils/WorkDurationTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/impl/utils/WorkDurationTest.java
@@ -45,8 +45,8 @@ public class WorkDurationTest {
public void create_from_value_and_unit() {
WorkDuration result = WorkDuration.createFromValueAndUnit(1, WorkDuration.UNIT.DAYS, HOURS_IN_DAY);
assertThat(result.days()).isEqualTo(1);
- assertThat(result.hours()).isEqualTo(0);
- assertThat(result.minutes()).isEqualTo(0);
+ assertThat(result.hours()).isZero();
+ assertThat(result.minutes()).isZero();
assertThat(result.hoursInDay()).isEqualTo(HOURS_IN_DAY);
assertThat(result.toMinutes()).isEqualTo(ONE_DAY_IN_MINUTES);
@@ -58,40 +58,40 @@ public class WorkDurationTest {
@Test
public void create_from_minutes() {
WorkDuration workDuration = WorkDuration.createFromMinutes(ONE_MINUTE, HOURS_IN_DAY);
- assertThat(workDuration.days()).isEqualTo(0);
- assertThat(workDuration.hours()).isEqualTo(0);
+ assertThat(workDuration.days()).isZero();
+ assertThat(workDuration.hours()).isZero();
assertThat(workDuration.minutes()).isEqualTo(1);
workDuration = WorkDuration.createFromMinutes(ONE_HOUR_IN_MINUTES, HOURS_IN_DAY);
- assertThat(workDuration.days()).isEqualTo(0);
+ assertThat(workDuration.days()).isZero();
assertThat(workDuration.hours()).isEqualTo(1);
- assertThat(workDuration.minutes()).isEqualTo(0);
+ assertThat(workDuration.minutes()).isZero();
workDuration = WorkDuration.createFromMinutes(ONE_DAY_IN_MINUTES, HOURS_IN_DAY);
assertThat(workDuration.days()).isEqualTo(1);
- assertThat(workDuration.hours()).isEqualTo(0);
- assertThat(workDuration.minutes()).isEqualTo(0);
+ assertThat(workDuration.hours()).isZero();
+ assertThat(workDuration.minutes()).isZero();
}
@Test
public void create_from_working_long() {
// 1 minute
WorkDuration workDuration = WorkDuration.createFromLong(1L, HOURS_IN_DAY);
- assertThat(workDuration.days()).isEqualTo(0);
- assertThat(workDuration.hours()).isEqualTo(0);
+ assertThat(workDuration.days()).isZero();
+ assertThat(workDuration.hours()).isZero();
assertThat(workDuration.minutes()).isEqualTo(1);
// 1 hour
workDuration = WorkDuration.createFromLong(100L, HOURS_IN_DAY);
- assertThat(workDuration.days()).isEqualTo(0);
+ assertThat(workDuration.days()).isZero();
assertThat(workDuration.hours()).isEqualTo(1);
- assertThat(workDuration.minutes()).isEqualTo(0);
+ assertThat(workDuration.minutes()).isZero();
// 1 day
workDuration = WorkDuration.createFromLong(10000L, HOURS_IN_DAY);
assertThat(workDuration.days()).isEqualTo(1);
- assertThat(workDuration.hours()).isEqualTo(0);
- assertThat(workDuration.minutes()).isEqualTo(0);
+ assertThat(workDuration.hours()).isZero();
+ assertThat(workDuration.minutes()).isZero();
}
@Test
@@ -126,12 +126,12 @@ public class WorkDurationTest {
WorkDuration result = WorkDuration.createFromValueAndUnit(4, WorkDuration.UNIT.HOURS, HOURS_IN_DAY).add(WorkDuration.createFromValueAndUnit(5, WorkDuration.UNIT.HOURS, HOURS_IN_DAY));
assertThat(result.days()).isEqualTo(1);
assertThat(result.hours()).isEqualTo(1);
- assertThat(result.minutes()).isEqualTo(0);
+ assertThat(result.minutes()).isZero();
assertThat(result.hoursInDay()).isEqualTo(HOURS_IN_DAY);
// 40 m + 30m = 1h 10m
result = WorkDuration.createFromValueAndUnit(40, WorkDuration.UNIT.MINUTES, HOURS_IN_DAY).add(WorkDuration.createFromValueAndUnit(30, WorkDuration.UNIT.MINUTES, HOURS_IN_DAY));
- assertThat(result.days()).isEqualTo(0);
+ assertThat(result.days()).isZero();
assertThat(result.hours()).isEqualTo(1);
assertThat(result.minutes()).isEqualTo(10);
assertThat(result.hoursInDay()).isEqualTo(HOURS_IN_DAY);
@@ -148,15 +148,15 @@ public class WorkDurationTest {
public void subtract() {
// 1d 1h - 5h = 4h
WorkDuration result = WorkDuration.create(1, 1, 0, HOURS_IN_DAY).subtract(WorkDuration.createFromValueAndUnit(5, WorkDuration.UNIT.HOURS, HOURS_IN_DAY));
- assertThat(result.days()).isEqualTo(0);
+ assertThat(result.days()).isZero();
assertThat(result.hours()).isEqualTo(4);
- assertThat(result.minutes()).isEqualTo(0);
+ assertThat(result.minutes()).isZero();
assertThat(result.hoursInDay()).isEqualTo(HOURS_IN_DAY);
// 1h 10m - 30m = 40m
result = WorkDuration.create(0, 1, 10, HOURS_IN_DAY).subtract(WorkDuration.createFromValueAndUnit(30, WorkDuration.UNIT.MINUTES, HOURS_IN_DAY));
- assertThat(result.days()).isEqualTo(0);
- assertThat(result.hours()).isEqualTo(0);
+ assertThat(result.days()).isZero();
+ assertThat(result.hours()).isZero();
assertThat(result.minutes()).isEqualTo(40);
assertThat(result.hoursInDay()).isEqualTo(HOURS_IN_DAY);
@@ -173,7 +173,7 @@ public class WorkDurationTest {
WorkDuration result = WorkDuration.createFromValueAndUnit(5, WorkDuration.UNIT.HOURS, HOURS_IN_DAY).multiply(2);
assertThat(result.days()).isEqualTo(1);
assertThat(result.hours()).isEqualTo(2);
- assertThat(result.minutes()).isEqualTo(0);
+ assertThat(result.minutes()).isZero();
assertThat(result.hoursInDay()).isEqualTo(HOURS_IN_DAY);
}