error-prone icon indicating copy to clipboard operation
error-prone copied to clipboard

Rule request: redundant type cast

Open delanym opened this issue 2 years ago • 1 comments

Be nice to a have a rule against redundant type casts, and a patch to remove them.

delanym avatar Jan 04 '23 08:01 delanym

Here's a case for it:

  • https://github.com/pgjdbc/pgjdbc/pull/3631

The problematic case was calling a method that was already available on the base java.sql.Statement:

          try (Statement checkConnectionQuery = createStatement()) {
            // The cast to PgStatement is redundant here:
            ((PgStatement)checkConnectionQuery).execute("", QueryExecutor.QUERY_EXECUTE_AS_SIMPLE);
          }

vlsi avatar May 13 '25 10:05 vlsi