Skip to content

Commit

Permalink
Fix some warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Apr 15, 2024
1 parent 9281180 commit 038161c
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 23 deletions.
2 changes: 2 additions & 0 deletions src/main/java/edu/hm/hafner/analysis/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,8 @@ private void writeLongString(final ObjectOutputStream output, final String value
}

@SuppressWarnings("unchecked")
@SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_READ_OBJECT",
justification = "False positive, the overridden method is in already initialized objects")
private void readObject(final ObjectInputStream input) throws IOException, ClassNotFoundException {
elements = new LinkedHashSet<>();
readIssues(input, input.readInt());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class PyLintDescriptions {
/**
* Loads the available rules into a map.
*/
@SuppressWarnings("PMD.LooseCoupling")
public PyLintDescriptions() {
JSONParser parser = new JSONParser(JSONParser.MODE_JSON_SIMPLE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ void shouldIdentifyModuleByReadingAntProjectFile() {
});
ModuleDetector detector = new ModuleDetector(ROOT, factory);

assertThat(detector.guessModuleName(PREFIX + (PATH_PREFIX_ANT + "something.txt")))
assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_ANT + "something.txt"))
.isEqualTo(EXPECTED_ANT_MODULE);
assertThat(detector.guessModuleName(PREFIX + (PATH_PREFIX_ANT + "in/between/something.txt")))
assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_ANT + "in/between/something.txt"))
.isEqualTo(EXPECTED_ANT_MODULE);
assertThat(detector.guessModuleName(PREFIX + "path/to/something.txt"))
.isEqualTo(StringUtils.EMPTY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void shouldIdentifyModuleByReadingGradlePath() {

ModuleDetector detector = new ModuleDetector(ROOT, factory);

assertThat(detector.guessModuleName(PREFIX + (PATH_PREFIX_GRADLE + "build/reports/something.txt")))
assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_GRADLE + "build/reports/something.txt"))
.isEqualTo(EXPECTED_GRADLE_MODULE_ROOT_BY_PATH);
assertThat(detector.guessModuleName(PREFIX + "build/reports/something.txt"))
.isEqualTo(StringUtils.EMPTY);
Expand Down Expand Up @@ -77,7 +77,7 @@ void shouldIdentifyModuleByReadingGradleKtsPath() {

ModuleDetector detector = new ModuleDetector(ROOT, factory);

assertThat(detector.guessModuleName(PREFIX + (PATH_PREFIX_GRADLE + "build/reports/something.txt")))
assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_GRADLE + "build/reports/something.txt"))
.isEqualTo(EXPECTED_GRADLE_MODULE_ROOT_BY_PATH);
assertThat(detector.guessModuleName(PREFIX + "build/reports/something.txt"))
.isEqualTo(StringUtils.EMPTY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import edu.hm.hafner.analysis.ModuleDetector.FileSystem;

import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;

class MavenModuleDetectorTest extends AbstractModuleDetectorTest {
Expand Down Expand Up @@ -39,9 +38,9 @@ void shouldIdentifyModuleByReadingMavenPom() {

ModuleDetector detector = new ModuleDetector(ROOT, factory);

assertThat(detector.guessModuleName(PREFIX + (PATH_PREFIX_MAVEN + "something.txt"))).isEqualTo(
assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_MAVEN + "something.txt")).isEqualTo(
EXPECTED_MAVEN_MODULE);
assertThat(detector.guessModuleName(PREFIX + (PATH_PREFIX_MAVEN + "in/between/something.txt"))).isEqualTo(
assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_MAVEN + "in/between/something.txt")).isEqualTo(
EXPECTED_MAVEN_MODULE);
assertThat(detector.guessModuleName(PREFIX + "path/to/something.txt")).isEqualTo(StringUtils.EMPTY);
}
Expand All @@ -56,11 +55,11 @@ void shouldIdentifyModuleByReadingMavenPomWithoutName() {
ModuleDetector detector = new ModuleDetector(ROOT, factory);

String artifactId = "com.avaloq.adt.core";
assertThat(detector.guessModuleName(PREFIX + (PATH_PREFIX_MAVEN + "something.txt")))
assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_MAVEN + "something.txt"))
.isEqualTo(artifactId);
assertThat(detector.guessModuleName(PREFIX + (PATH_PREFIX_MAVEN + "in/between/something.txt")))
assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_MAVEN + "in/between/something.txt"))
.isEqualTo(artifactId);
assertThat(detector.guessModuleName(PREFIX + "path/to/something.txt"))
.isEqualTo(StringUtils.EMPTY);
}
}
}
4 changes: 2 additions & 2 deletions src/test/java/edu/hm/hafner/analysis/ModuleDetectorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ void shouldIdentifyModuleIfThereAreMoreEntries() {

ModuleDetector detector = new ModuleDetector(ROOT, factory);

assertThat(detector.guessModuleName(PREFIX + (PATH_PREFIX_ANT + "something.txt")))
assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_ANT + "something.txt"))
.isEqualTo(EXPECTED_ANT_MODULE);
assertThat(detector.guessModuleName(PREFIX + (PATH_PREFIX_MAVEN + "something.txt")))
assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_MAVEN + "something.txt"))
.isEqualTo(EXPECTED_MAVEN_MODULE);
}

Expand Down
17 changes: 8 additions & 9 deletions src/test/java/edu/hm/hafner/analysis/OsgiModuleDetectorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import edu.hm.hafner.analysis.ModuleDetector.FileSystem;

import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;

/**
Expand Down Expand Up @@ -41,9 +40,9 @@ void shouldIdentifyModuleByReadingOsgiBundle() {

ModuleDetector detector = new ModuleDetector(ROOT, factory);

assertThat(detector.guessModuleName(PREFIX + (PATH_PREFIX_OSGI + "something.txt")))
assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_OSGI + "something.txt"))
.isEqualTo(EXPECTED_OSGI_MODULE);
assertThat(detector.guessModuleName(PREFIX + (PATH_PREFIX_OSGI + "in/between/something.txt")))
assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_OSGI + "in/between/something.txt"))
.isEqualTo(EXPECTED_OSGI_MODULE);
assertThat(detector.guessModuleName(PREFIX + "path/to/something.txt"))
.isEqualTo(StringUtils.EMPTY);
Expand All @@ -59,9 +58,9 @@ void shouldIdentifyModuleByReadingOsgiBundleWithVendorInL10nProperties() {
ModuleDetector detector = new ModuleDetector(ROOT, factory);

String expectedName = "de.faktorlogik.prototyp (My Vendor)";
assertThat(detector.guessModuleName(PREFIX + (PATH_PREFIX_OSGI + "something.txt")))
assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_OSGI + "something.txt"))
.isEqualTo(expectedName);
assertThat(detector.guessModuleName(PREFIX + (PATH_PREFIX_OSGI + "in/between/something.txt")))
assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_OSGI + "in/between/something.txt"))
.isEqualTo(expectedName);
assertThat(detector.guessModuleName(PREFIX + "path/to/something.txt"))
.isEqualTo(StringUtils.EMPTY);
Expand All @@ -78,11 +77,11 @@ void shouldIdentifyModuleByReadingOsgiBundleWithManifestName() {
ModuleDetector detector = new ModuleDetector(ROOT, fileSystem);

String expectedName = "My Bundle";
assertThat(detector.guessModuleName(PREFIX + (PATH_PREFIX_OSGI + "something.txt")))
assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_OSGI + "something.txt"))
.isEqualTo(expectedName);
assertThat(detector.guessModuleName(PREFIX + (PATH_PREFIX_OSGI + "in/between/something.txt")))
assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_OSGI + "in/between/something.txt"))
.isEqualTo(expectedName);
assertThat(detector.guessModuleName(PREFIX + "path/to/something.txt"))
.isEqualTo(StringUtils.EMPTY);
}
}
}
2 changes: 1 addition & 1 deletion src/test/java/edu/hm/hafner/analysis/ReportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ void shouldWriteLongMessages() {
private String createLongMessage() {
char[] chars = new char[100_000];

return new String(chars);
return String.valueOf(chars);
}

/** Verifies that equals checks all properties. */
Expand Down

0 comments on commit 038161c

Please sign in to comment.