Skip to content

chore: add ErrorProne verification to catch bugs ealier#3493

Merged
vlsi merged 12 commits intopgjdbc:masterfrom
vlsi:errorprone
Jan 28, 2025
Merged

chore: add ErrorProne verification to catch bugs ealier#3493
vlsi merged 12 commits intopgjdbc:masterfrom
vlsi:errorprone

Conversation

@vlsi
Copy link
Member

@vlsi vlsi commented Jan 22, 2025

This adds verifications from error-prone so we could catch errors earlier.
I suggest we fail the build on javac warnings as well.

However, we could probably live with warnings in the test code. Otherwise there will be a lot of warnings when testing deprecated classes. As we deprecate method, the test code should better be intact so it ensures the behavior is kept.

@vlsi vlsi force-pushed the errorprone branch 2 times, most recently from 91c5e2c to 6290ef3 Compare January 22, 2025 12:58
@davecramer
Copy link
Member

cool, great idea

@vlsi vlsi force-pushed the errorprone branch 6 times, most recently from 55fd558 to 8e1d1d9 Compare January 24, 2025 13:14
@vlsi vlsi changed the title chore: add ErrorProne verification to detect unused variables chore: add ErrorProne verification to catch bugs ealier Jan 24, 2025
@vlsi
Copy link
Member Author

vlsi commented Jan 24, 2025

It looks like this is finalized.

In practice, errorprone does not significantly increase the build time, so it might be worth running it on every build. WDYT?

Currently, I configured it so it executes errorpone only when explicitly asked (e.g. ./gradlew -PenableErrorprone classes or ./gradlew style)

@davecramer
Copy link
Member

Thanks, this looks like it will clean up a lot of things.

@vlsi
Copy link
Member Author

vlsi commented Jan 24, 2025

it will clean up a lot of things.

Just for the reference, ErrorProne does not fix issues. It only reports them and suggests fixes.

For example:

> Task :postgresql:compileJava
pgjdbc/pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java:1741: Note: [MethodCanBeStatic] A private method that does not reference the enclosing instance can be static
  private void checkPermission(SQLPermission sqlPermissionNetworkTimeout) {
  ^
    (see https://errorprone.info/bugpattern/MethodCanBeStatic)
  Did you mean 'private static void checkPermission(SQLPermission sqlPermissionNetworkTimeout) {'?

@davecramer
Copy link
Member

That's a lot of work! Thanks

vlsi added 12 commits January 28, 2025 11:10
Even though we do not suggest using Fastpath, there's no rush to replace it with something else

Note: javac produces deprecation warnings when building with --release 8,
so we have to use fully-qualified imports when using deprecated classes/interfaces
Errorprone complains on empty catch blocks, and it looks it is worth
adding the relevant comments in such cases.
It is still useful (e.g. when parsing the version provided by the backend)
@vlsi vlsi merged commit 165cd26 into pgjdbc:master Jan 28, 2025
16 of 17 checks passed
@vlsi vlsi deleted the errorprone branch May 16, 2025 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments