Skip to content

Commit

Permalink
Fix sonar findings
Browse files Browse the repository at this point in the history
  • Loading branch information
kaklakariada committed Sep 1, 2024
1 parent ca0cde1 commit acfe0e9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/main/java/org/itsallcode/jdbc/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ private Context() {
*
* @return parameter mapper
*/
@SuppressWarnings("java:S2325") // Not-static by intention
public ParameterMapper getParameterMapper() {
return ParameterMapper.create();
}
Expand All @@ -39,6 +40,7 @@ private ContextBuilder() {
*
* @return a new context
*/
@SuppressWarnings("java:S2325") // Not-static by intention
public Context build() {
return new Context();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ private Row buildRow(final ResultSet resultSet, final int rowIndex) {
return new Row(rowIndex, columns, fields);
}

private ColumnValue getField(final ResultSet resultSet, final ColumnMetaData column, final int rowIndex) {
private static ColumnValue getField(final ResultSet resultSet, final ColumnMetaData column,
final int rowIndex) {
final Object value = getValue(resultSet, column, rowIndex);
return new ColumnValue(column.type(), value);
}

private Object getValue(final ResultSet resultSet, final ColumnMetaData column, final int rowIndex) {
private static Object getValue(final ResultSet resultSet, final ColumnMetaData column, final int rowIndex) {
try {
return resultSet.getObject(column.columnIndex());
} catch (final SQLException e) {
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/org/itsallcode/jdbc/SimpleConnectionITest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.itsallcode.jdbc;

import static java.util.stream.Collectors.toList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertAll;
Expand Down Expand Up @@ -66,7 +65,7 @@ void executeQueryWithGenericRowMapper() {
connection.executeScript("CREATE TABLE TEST(ID INT, NAME VARCHAR(255));"
+ "insert into test (id, name) values (1, 'test');");
try (SimpleResultSet<Row> resultSet = connection.query("select count(*) as result from test")) {
final List<Row> rows = resultSet.stream().collect(toList());
final List<Row> rows = resultSet.stream().toList();
assertAll(
() -> assertThat(rows).hasSize(1),
() -> assertThat(rows.get(0).rowIndex()).isZero(),
Expand Down

0 comments on commit acfe0e9

Please sign in to comment.