Skip to content

Commit

Permalink
Implement static code analysis findings
Browse files Browse the repository at this point in the history
  • Loading branch information
spannm committed May 14, 2024
1 parent d6517df commit cb68344
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private CalculatedColumnUtil() {
*
* @param args column construction info
*/
static ColumnImpl create(ColumnImpl.InitArgs args) throws IOException {
static ColumnImpl create(ColumnImpl.InitArgs args) {
switch (args.type) {
case BOOLEAN:
return new CalcBooleanColImpl(args);
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/io/github/spannm/jackcess/impl/UsageMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -678,11 +678,9 @@ private ReferenceHandler() throws IOException {
// extra page reference on top of the number of page references that fit
// in the table
for (int i = 0; i < numUsagePages; i++) {
int mapPageNum = getTableBuffer().getInt(
calculateMapPagePointerOffset(i));
int mapPageNum = getTableBuffer().getInt(calculateMapPagePointerOffset(i));
if (mapPageNum > 0) {
ByteBuffer mapPageBuffer =
_mapPageHolder.withPage(getPageChannel(), mapPageNum);
ByteBuffer mapPageBuffer = _mapPageHolder.withPage(getPageChannel(), mapPageNum);
byte pageType = mapPageBuffer.get();
if (pageType != PageTypes.USAGE_MAP) {
throw new IOException("Looking for usage map at page " + mapPageNum + ", but page type is " + pageType);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/github/spannm/jackcess/DatabaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void testDeleteRow(FileFormat fileFormat) throws Exception {
}

@Test
void testMissingFile() throws Exception {
void testMissingFile() {
File bogusFile = new File("fooby-dooby.mdb");
assertFalse(bogusFile.exists());
DatabaseBuilder dbb = DatabaseBuilder.newDatabase(bogusFile).withReadOnly(true).withAutoSync(getTestAutoSync());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ void testEnforceForeignKeys(TestDb testDb) throws Exception {
c.moveToNextRow();
c.deleteCurrentRow();
}, "Table3[id]");
tests.entrySet().forEach(e -> {
IOException ex = assertThrows(IOException.class, e.getKey());
assertTrue(ex.getMessage().contains(e.getValue()));
tests.forEach((key, value) -> {
IOException ex = assertThrows(IOException.class, key);
assertTrue(ex.getMessage().contains(value));

});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ static Object eval(String _expr) {

String[] testValues() default {};

static class CustomFormatArgumentsProvider implements ArgumentsProvider {
class CustomFormatArgumentsProvider implements ArgumentsProvider {
@Override
public Stream<Arguments> provideArguments(ExtensionContext context) {
return context.getElement().map(elem -> AnnotationSupport.findRepeatableAnnotations(elem, CustomFormatSource.class)).orElse(List.of()).stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ void testLiteralDefaultValue() {
"DEFAULT_VALUE; TEXT; '+P-E'",
"FIELD_VALIDATOR; TEXT; Is Not Null"
})
void testParseSomeExprs(Expressionator.Type _type, DataType _dType, String _exprStr) throws Exception {
void testParseSomeExprs(Expressionator.Type _type, DataType _dType, String _exprStr) {
TestContext tc = new TestContext() {
@Override
public Value getThisColumnValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void testUnionQuery() {

removeRows(query, TABLE_ATTRIBUTE);

assertThrows(IllegalStateException.class, () -> query.toSQLString());
assertThrows(IllegalStateException.class, query::toSQLString);
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/github/spannm/jackcess/test/TestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ static String getCurrentUser() {
.findFirst().orElse(null);
}

public static final File getTestTempDir() {
public static File getTestTempDir() {
return TEST_TEMP_DIR;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
String[] exclude() default {};

static class FileFormatArgumentsProvider implements ArgumentsProvider {
class FileFormatArgumentsProvider implements ArgumentsProvider {

/**
* Defines currently supported database file formats that are neither read-only nor {@value FileFormat#MSISAM} (MS Money).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*/
boolean endInclusive() default false;

static class IntMatrixArgumentsProvider implements ArgumentsProvider {
class IntMatrixArgumentsProvider implements ArgumentsProvider {

@Override
public Stream<Arguments> provideArguments(ExtensionContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*/
boolean endInclusive() default false;

static class IntRangeArgumentsProvider implements ArgumentsProvider {
class IntRangeArgumentsProvider implements ArgumentsProvider {

@Override
public Stream<Arguments> provideArguments(ExtensionContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
*/
Basename value();

static class ReadOnlyTestDbArgumentsProvider implements ArgumentsProvider {
class ReadOnlyTestDbArgumentsProvider implements ArgumentsProvider {
@Override
public Stream<Arguments> provideArguments(ExtensionContext _context) throws Exception {
public Stream<Arguments> provideArguments(ExtensionContext _context) {
TestDbReadOnlySource src = _context.getElement().map(elem -> AnnotationSupport.findAnnotation(elem, TestDbReadOnlySource.class).get()).orElse(null);
return src == null ? Stream.empty() : TestDbArgumentsProvider.getDbs(src.value(), FileFormat.values()).stream().map(Arguments::of);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/
Basename value();

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 Expand Up @@ -92,7 +92,7 @@ static List<TestDb> getDbs(Basename _basename, FileFormat[] _fileFormats) {
}

@Override
public Stream<Arguments> provideArguments(ExtensionContext _context) throws Exception {
public Stream<Arguments> provideArguments(ExtensionContext _context) {
TestDbSource src = _context.getElement().map(elem -> AnnotationSupport.findAnnotation(elem, TestDbSource.class).get()).orElse(null);
return src == null ? Stream.empty() : getDbs(src.value(), FILE_FORMATS_WRITE).stream().map(Arguments::of);
}
Expand Down

0 comments on commit cb68344

Please sign in to comment.