Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update qulice-maven-plugin to v0.23.0 #294

Merged
merged 40 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
daae19a
qulice-maven-plugin-0.23.0
uchitsa Nov 24, 2024
9e193ae
fix quality violations
uchitsa Nov 25, 2024
8716192
replace vulnerable dependency log4j
uchitsa Nov 25, 2024
811376b
fix quality violations
uchitsa Nov 25, 2024
b73c61d
fix quality violations
uchitsa Nov 25, 2024
30770bd
fix quality violations
uchitsa Nov 25, 2024
e57f435
fix quality violations
uchitsa Nov 25, 2024
1eef9b1
fix quality violations
uchitsa Nov 25, 2024
bb13ab3
fix quality violations
uchitsa Nov 26, 2024
6053b72
fix quality violations
uchitsa Nov 26, 2024
8c0afbe
fix quality violations
uchitsa Nov 26, 2024
a27a71d
fix quality violations
uchitsa Nov 26, 2024
688a6f3
fix quality violations
uchitsa Nov 26, 2024
c7f1ebb
fix quality violations
uchitsa Nov 26, 2024
fc8f0f9
fix quality violations
uchitsa Nov 26, 2024
bd96f16
fix quality violations
uchitsa Nov 26, 2024
f491c9f
fix quality violations
uchitsa Nov 26, 2024
f6f8574
fix quality violations
uchitsa Nov 26, 2024
bf596af
fix quality violations
uchitsa Nov 26, 2024
8a94f82
fix quality violations
uchitsa Nov 26, 2024
cce8149
fix quality violations
uchitsa Nov 26, 2024
c81eac9
fix quality violations
uchitsa Nov 26, 2024
aa7fdf8
fix quality violations
uchitsa Nov 26, 2024
caba7c1
fix quality violations
uchitsa Nov 26, 2024
c42177f
fix quality violations
uchitsa Nov 26, 2024
bbc748d
fix quality violations
uchitsa Nov 26, 2024
ac2afac
fix quality violations
uchitsa Nov 26, 2024
58b40f7
fix quality violations
uchitsa Nov 26, 2024
d418087
fix quality violations
uchitsa Nov 26, 2024
5e397b7
fix quality violations
uchitsa Nov 26, 2024
abea072
fix quality violations
uchitsa Nov 26, 2024
acbc23e
fix quality violations
uchitsa Nov 26, 2024
e076054
fix quality violations
uchitsa Nov 26, 2024
598fcba
fix quality violations
uchitsa Nov 26, 2024
c932769
fix quality violations
uchitsa Nov 26, 2024
34ff54d
fix quality violations
uchitsa Nov 26, 2024
cc0f526
fix quality violations
uchitsa Nov 26, 2024
0711866
fix quality violations
uchitsa Nov 26, 2024
838ec14
fix quality violations
uchitsa Nov 26, 2024
6e077be
fix pom.xml
uchitsa Nov 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.24.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -237,6 +237,14 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>9</source>
<target>9</target>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
Expand All @@ -247,7 +255,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
<plugin>
<groupId>com.qulice</groupId>
<artifactId>qulice-maven-plugin</artifactId>
<version>0.22.0</version>
<version>0.23.0</version>
<configuration>
<excludes combine.children="append">
<exclude>duplicatefinder:.*</exclude>
Expand Down
13 changes: 3 additions & 10 deletions src/main/java/com/jcabi/jdbc/JdbcSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public JdbcSession execute() throws SQLException {
vendor = conn.getMetaData().getDatabaseProductName();
}
final Connect connect;
if (vendor.equalsIgnoreCase("mysql")) {
if ("mysql".equalsIgnoreCase(vendor)) {
connect = new Connect.WithKeys(this.query);
} else {
connect = new Connect.Plain(this.query);
Expand Down Expand Up @@ -482,19 +482,12 @@ private <T> T run(final Outcome<T> outcome,
private <T> T fetch(final Outcome<T> outcome,
final Request request, final PreparedStatement stmt) throws SQLException {
final T result;
try {
try (stmt) {
this.configure(stmt);
final ResultSet rset = request.fetch(stmt);
// @checkstyle NestedTryDepth (5 lines)
try {
try (ResultSet rset = request.fetch(stmt)) {
result = outcome.handle(rset, stmt);
} finally {
if (rset != null) {
rset.close();
}
}
} finally {
stmt.close();
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jcabi/jdbc/ListOutcome.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
* )
* );</pre>
*
* @since 0.13
* @param <T> Type of items
* @since 0.13
*/
@ToString
@EqualsAndHashCode(of = "mapping")
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jcabi/jdbc/StoredProcedureOutcome.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@

/**
* Outcome of a stored procedure with OUT parameters.
* @since 0.17
* @param <T> Type of the returned result, which <b>has to be</b> Object[]
* @since 0.17
*/
@ToString
@EqualsAndHashCode
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/jcabi/jdbc/ColumnOutcomeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void retrievesFirstColumn() throws Exception {
.sql("SELECT name FROM foo")
.select(new ColumnOutcome<>(String.class));
MatcherAssert.assertThat(
names, Matchers.hasSize(2)
"result collection should have size 2", names, Matchers.hasSize(2)
);
}

Expand Down
9 changes: 6 additions & 3 deletions src/test/java/com/jcabi/jdbc/JdbcSessionITCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void manipulatesUuidTypes() throws Exception {
final UUID id = new JdbcSession(source)
.sql("SELECT id FROM uuidtb")
.select(new SingleOutcome<>(UUID.class));
MatcherAssert.assertThat(id, Matchers.equalTo(uuid));
MatcherAssert.assertThat("get id should be equal set id", id, Matchers.equalTo(uuid));
}

/**
Expand Down Expand Up @@ -148,12 +148,14 @@ void callsFunctionWithOutParam() throws Exception {
}
)
.call(new StoredProcedureOutcome<Object[]>(1, 2));
MatcherAssert.assertThat(result.length, Matchers.is(2));
MatcherAssert.assertThat("result array size should be 2", result.length, Matchers.is(2));
MatcherAssert.assertThat(
"first item of result collection should contains user name Charles",
result[0].toString(),
Matchers.containsString("Charles")
);
MatcherAssert.assertThat(
"second item of result collection should be not null date",
(Date) result[1],
Matchers.notNullValue()
);
Expand Down Expand Up @@ -194,8 +196,9 @@ void callsFunctionWithInOutParam() throws Exception {
}
)
.call(new StoredProcedureOutcome<Object[]>(2));
MatcherAssert.assertThat(result.length, Matchers.is(1));
MatcherAssert.assertThat("result array length should be 1", result.length, Matchers.is(1));
MatcherAssert.assertThat(
"first item of result collection should contains user name Polo",
result[0].toString(),
Matchers.containsString("Polo")
);
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/com/jcabi/jdbc/JdbcSessionMySqlITCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ void worksLastInsertId() throws Exception {
)
.execute();
MatcherAssert.assertThat(
"result should be equal 1",
new JdbcSession(this.source())
.sql("INSERT INTO foo (name) VALUES (?)")
.set("test")
Expand All @@ -113,6 +114,7 @@ void worksLastInsertIdAndTransaction() throws Exception {
.execute();
final JdbcSession session = new JdbcSession(this.source());
MatcherAssert.assertThat(
"result should be equal 1",
session
.autocommit(false)
.sql("START TRANSACTION")
Expand Down Expand Up @@ -152,6 +154,7 @@ void callsFunctionWithOutParam() throws Exception {
)
.call(new StoredProcedureOutcome<>(1, 2));
MatcherAssert.assertThat(
"first item of result array should contains user name Jeff Charles and not null date",
result,
Matchers.arrayContaining(
Matchers.is("Jeff Charles"),
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/com/jcabi/jdbc/JdbcSessionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public String handle(final ResultSet rset,
}
}
);
MatcherAssert.assertThat(name, Matchers.startsWith("Jeff"));
MatcherAssert.assertThat("result starts with Jeff", name, Matchers.startsWith("Jeff"));
}

/**
Expand Down Expand Up @@ -127,7 +127,7 @@ public String handle(final ResultSet rset,
}
}
);
MatcherAssert.assertThat(name, Matchers.startsWith("Wa"));
MatcherAssert.assertThat("result starts with Wa", name, Matchers.startsWith("Wa"));
}

/**
Expand Down Expand Up @@ -180,6 +180,7 @@ void rollbacksTransaction() throws Exception {
.execute()
.rollback();
MatcherAssert.assertThat(
"result should contains foo",
new JdbcSession(source).sql("SELECT * FROM t228x")
.select(new ListOutcome<>(rset -> rset.getString("name"))),
Matchers.contains("foo")
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/jcabi/jdbc/ListOutcomeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void retrievesList() throws Exception {
)
);
MatcherAssert.assertThat(
names, Matchers.hasSize(2)
"names collection size should be 2", names, Matchers.hasSize(2)
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/jcabi/jdbc/OutcomeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void fetchesLastInsertId() throws Exception {
.sql("INSERT INTO foo (name) VALUES (?)")
.set("Jeff Lebowski")
.update(Outcome.LAST_INSERT_ID);
MatcherAssert.assertThat(num, Matchers.equalTo(1L));
MatcherAssert.assertThat("last insert id is equal 1", num, Matchers.equalTo(1L));
}

}
7 changes: 6 additions & 1 deletion src/test/java/com/jcabi/jdbc/SingleOutcomeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ final class SingleOutcomeTest {
@Test
void retrievesByte() throws Exception {
MatcherAssert.assertThat(
"retrieve byte 'A'",
new JdbcSession(this.datasource())
.sql("CALL 65")
.select(new SingleOutcome<>(Byte.class)),
Expand All @@ -57,6 +58,7 @@ void retrievesByte() throws Exception {
@Test
void retrievesBigDecimal() throws Exception {
MatcherAssert.assertThat(
"received value should be 1.0E+10",
new JdbcSession(this.datasource())
.sql("CALL POWER(10, 10)")
.select(new SingleOutcome<>(BigDecimal.class)),
Expand All @@ -68,6 +70,7 @@ void retrievesBigDecimal() throws Exception {
void retrievesBytes() throws Exception {
final int size = 256;
MatcherAssert.assertThat(
"received bytes length should be 256",
new JdbcSession(this.datasource())
.sql(String.format("CALL SECURE_RAND(%d)", size))
.select(new SingleOutcome<>(byte[].class))
Expand All @@ -79,6 +82,7 @@ void retrievesBytes() throws Exception {
@Test
void retrievesUtc() throws Exception {
MatcherAssert.assertThat(
"received timestamp should be current timestamp",
new JdbcSession(this.datasource())
.sql("CALL CURRENT_TIMESTAMP()")
.select(new SingleOutcome<>(Utc.class)),
Expand All @@ -89,6 +93,7 @@ void retrievesUtc() throws Exception {
@Test
void retrievesDate() throws Exception {
MatcherAssert.assertThat(
"received date should be current date",
new JdbcSession(this.datasource())
.sql("CALL CURRENT_DATE()")
.select(new SingleOutcome<>(Date.class)),
Expand All @@ -112,7 +117,7 @@ void retrievesString() throws Exception {
final String name = new JdbcSession(source)
.sql("SELECT name FROM foo")
.select(new SingleOutcome<String>(String.class));
MatcherAssert.assertThat(name, Matchers.startsWith("Jeff"));
MatcherAssert.assertThat("name should be Jeff", name, Matchers.startsWith("Jeff"));
}

@Test
Expand Down
45 changes: 19 additions & 26 deletions src/test/java/com/jcabi/jdbc/UtcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,23 @@ void savesDateWithUtcTimezone() throws Exception {
);
final Date date = this.fmt.parse("2008-05-24 05:06:07.000");
final String saved;
try (Connection conn = this.source.getConnection()) {
final PreparedStatement ustmt = conn.prepareStatement(
try (Connection conn = this.source.getConnection();
PreparedStatement ustmt = conn.prepareStatement(
"INSERT INTO foo (date) VALUES (?)"
);
)) {
new Utc(date).setTimestamp(ustmt, 1);
ustmt.executeUpdate();
final PreparedStatement rstmt = conn.prepareStatement(
try (PreparedStatement rstmt = conn.prepareStatement(
"SELECT date FROM foo"
);
try (ResultSet rset = rstmt.executeQuery()) {
); ResultSet rset = rstmt.executeQuery()) {
if (!rset.next()) {
throw new IllegalArgumentException();
}
saved = rset.getString(1);
}
}
MatcherAssert.assertThat(
"saved date is 2008-05-24 10:06:07",
saved,
Matchers.startsWith("2008-05-24 10:06:07")
);
Expand All @@ -123,30 +123,27 @@ void savesDateWithUtcTimezone() throws Exception {
*/
@Test
void loadsDateWithUtcTimezone() throws Exception {
final Connection conn = this.source.getConnection();
final Date loaded;
try {
final PreparedStatement ustmt = conn.prepareStatement(
try (Connection conn = this.source.getConnection();
PreparedStatement ustmt = conn.prepareStatement(
"INSERT INTO foo (date) VALUES (?) "
);
)) {
ustmt.setString(1, "2005-02-02 10:07:08.000");
ustmt.executeUpdate();
final PreparedStatement rstmt = conn.prepareStatement(
try (PreparedStatement rstmt = conn.prepareStatement(
"SELECT date FROM foo "
);
try (ResultSet rset = rstmt.executeQuery()) {
); ResultSet rset = rstmt.executeQuery()) {
if (!rset.next()) {
throw new IllegalArgumentException();
}
loaded = Utc.getTimestamp(rset, 1);
}
} finally {
conn.close();
}
this.fmt.setCalendar(
new GregorianCalendar(TimeZone.getTimeZone("GMT-3"))
);
MatcherAssert.assertThat(
"loaded date is 2005-02-02 07:07:08",
this.fmt.format(loaded),
Matchers.startsWith("2005-02-02 07:07:08")
);
Expand All @@ -163,24 +160,20 @@ void setsAndReadsDateWithDifferentTimezone() throws Exception {
.sql("INSERT INTO foo VALUES (?) ")
.set(new Utc(date))
.insert(Outcome.VOID);
final Connection conn = this.source.getConnection();
final String saved;
try {
final PreparedStatement stmt = conn.prepareStatement(
try (Connection conn = this.source.getConnection();
PreparedStatement stmt = conn.prepareStatement(
"SELECT date FROM foo "
);
try (ResultSet rset = stmt.executeQuery()) {
if (!rset.next()) {
throw new IllegalStateException();
}
saved = rset.getString(1);
); ResultSet rset = stmt.executeQuery()) {
if (!rset.next()) {
throw new IllegalStateException();
}
} finally {
conn.close();
saved = rset.getString(1);
}
this.fmt.setTimeZone(TimeZone.getTimeZone("GMT"));
final Date absolute = this.fmt.parse(saved);
MatcherAssert.assertThat(
"the received date is equal to the set date",
absolute.toString(),
Matchers.equalTo(date.toString())
);
Expand Down
Loading