Skip to content

Commit

Permalink
Review justified and false positive PMD findings
Browse files Browse the repository at this point in the history
  • Loading branch information
spannm committed Oct 11, 2024
1 parent a98da91 commit 49a19c1
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ public Map<String, Database> getLinkedDatabases() {
}

@Override
@SuppressWarnings("PMD.SimplifyBooleanReturns")
public boolean isLinkedTable(Table table) throws IOException {

if (table == null || this == table.getDatabase()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ protected PositionImpl getRowPosition(RowIdImpl rowId) throws IOException {
return new IndexPosition(_entryCursor.getNextEntry());
}

@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override
protected boolean findAnotherRowImpl(
ColumnImpl columnPattern, Object valuePattern, boolean moveForward,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ private void validateChildren(DataPageMain dpMain, DataPageExtra dpExtra) throws
Integer subPageNumber = e.getSubPageNumber();
DataPageMain childMain = getPageForValidate(subPageNumber);
if (childMain != null) {
if (prevPageNumber != null && (int) childMain._prevPageNumber != prevPageNumber) {
if (prevPageNumber != null && !childMain._prevPageNumber.equals(prevPageNumber)) {
throw new IllegalStateException(withErrorContext("Child's prevPageNumber is not the previous child for " + childMain + " " + dpExtra._entryView + " " + prevPageNumber));
}
if (nextPageNumber != null && childMain._pageNumber != nextPageNumber) {
Expand Down Expand Up @@ -1388,7 +1388,7 @@ private void validatePeerStatus(DataPageMain dpMain, DataPageMain peerMain) {
throw new IllegalStateException(withErrorContext("Mismatched peer status " + dpMain._leaf + " " + peerMain._leaf));
}
if (!dpMain._leaf) {
if (dpMain._parentPageNumber != null && peerMain._parentPageNumber != null && (int) dpMain._parentPageNumber != (int) peerMain._parentPageNumber) {
if (dpMain._parentPageNumber != null && peerMain._parentPageNumber != null && !dpMain._parentPageNumber.equals(peerMain._parentPageNumber)) {
throw new IllegalStateException(withErrorContext("Mismatched node parents " + dpMain._parentPageNumber + " " + peerMain._parentPageNumber));
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/github/spannm/jackcess/impl/OleUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import io.github.spannm.jackcess.DataType;
import io.github.spannm.jackcess.util.OleBlob;
import io.github.spannm.jackcess.util.OleBlob.*;
import io.github.spannm.jackcess.util.OleBlob.*; // NOPMD
import io.github.spannm.jackcess.util.ToStringBuilder;

import java.io.*;
Expand Down Expand Up @@ -100,6 +100,7 @@ public static OleBlob parseBlob(byte[] bytes) {
/**
* Creates a new OlBlob instance using the given information.
*/
@SuppressWarnings("PMD.UseTryWithResources")
public static OleBlob createBlob(Builder oleBuilder) throws IOException {
try {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import io.github.spannm.jackcess.expr.*;
import io.github.spannm.jackcess.impl.DatabaseImpl;
import io.github.spannm.jackcess.impl.expr.FunctionSupport.*;
import io.github.spannm.jackcess.impl.expr.FunctionSupport.*; // NOPMD

import java.lang.System.Logger;
import java.lang.System.Logger.Level;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public Database resolveLinkedDatabase(Database linkerDb, String linkeeFileName)
return createTempDb(customFile, getDefaultFormat(), isDefaultInMemory(),
getDefaultTempDirectory(), readOnly);
}
return LinkResolver.DEFAULT.resolveLinkedDatabase(linkerDb, linkeeFileName);
return DEFAULT.resolveLinkedDatabase(linkerDb, linkeeFileName);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/test/java/io/github/spannm/jackcess/BigIndexTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void testComplexIndex(TestDb testDb) throws IOException {

@ParameterizedTest(name = "[{index}] {0}")
@TestDbSource(BIG_INDEX)
@SuppressWarnings("PMD.JumbledIncrementer")
void testBigIndex(TestDb testDb) throws IOException {
// this file has an index with "compressed" entries and node pages
try (Database db = testDb.openMem()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
String value();

static class DbsInPathSourceArgumentsProvider implements ArgumentsProvider {
class DbsInPathSourceArgumentsProvider implements ArgumentsProvider {

@Override
public Stream<Arguments> provideArguments(ExtensionContext _context) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
Basename[] value() default {};

static class TestDbReadOnlyArgumentsProvider implements ArgumentsProvider {
class TestDbReadOnlyArgumentsProvider implements ArgumentsProvider {
@Override
public Stream<Arguments> provideArguments(ExtensionContext _context) {
TestDbReadOnlySource src = _context.getElement().map(elem -> AnnotationSupport.findAnnotation(elem, TestDbReadOnlySource.class).get()).orElse(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/
Basename[] value() default {};

static class TestDbArgumentsProvider implements ArgumentsProvider {
class TestDbArgumentsProvider implements ArgumentsProvider {

/** Charset for access 97 databases. */
private static final Charset ACC97_CHARSET = Charset.forName("windows-1252");
Expand Down

0 comments on commit 49a19c1

Please sign in to comment.