Permalink
Browse files

style: update checkstyle + turn on some rules (#847)

1. Update checkstyle to 7.8.2
2. Add checkstyle module "RedundantModifier"
3. Uncomment checkstyle modules "ArrayTypeStyle", "ModifierOrder"
  • Loading branch information...
AlexElin authored and vlsi committed Jul 23, 2017
1 parent 0221f93 commit 246b759cdc264c2732717dbd6ff9f8f472024196
Showing with 332 additions and 327 deletions.
  1. +1 −1 pgjdbc/pom.xml
  2. +3 −2 pgjdbc/src/main/checkstyle/checks.xml
  3. +3 −3 pgjdbc/src/main/java/org/postgresql/PGProperty.java
  4. +1 −1 pgjdbc/src/main/java/org/postgresql/copy/CopyManager.java
  5. +2 −2 pgjdbc/src/main/java/org/postgresql/core/CachedQueryCreateAction.java
  6. +2 −1 pgjdbc/src/main/java/org/postgresql/core/CallableQueryKey.java
  7. +1 −1 pgjdbc/src/main/java/org/postgresql/core/EncodingPredictor.java
  8. +3 −3 pgjdbc/src/main/java/org/postgresql/core/NativeQuery.java
  9. +3 −3 pgjdbc/src/main/java/org/postgresql/core/PGStream.java
  10. +3 −3 pgjdbc/src/main/java/org/postgresql/core/Parser.java
  11. +1 −1 pgjdbc/src/main/java/org/postgresql/core/QueryWithReturningColumnsKey.java
  12. +1 −1 pgjdbc/src/main/java/org/postgresql/core/ServerVersion.java
  13. +1 −1 pgjdbc/src/main/java/org/postgresql/core/Utils.java
  14. +1 −1 pgjdbc/src/main/java/org/postgresql/core/VisibleBufferedInputStream.java
  15. +2 −2 pgjdbc/src/main/java/org/postgresql/core/v3/CompositeParameterList.java
  16. +1 −1 pgjdbc/src/main/java/org/postgresql/core/v3/DescribeRequest.java
  17. +1 −1 pgjdbc/src/main/java/org/postgresql/core/v3/ExecuteRequest.java
  18. +4 −4 pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java
  19. +6 −6 pgjdbc/src/main/java/org/postgresql/core/v3/SimpleParameterList.java
  20. +1 −1 pgjdbc/src/main/java/org/postgresql/core/v3/SimpleQuery.java
  21. +4 −2 pgjdbc/src/main/java/org/postgresql/ds/PGPooledConnection.java
  22. +1 −1 pgjdbc/src/main/java/org/postgresql/fastpath/Fastpath.java
  23. +2 −2 pgjdbc/src/main/java/org/postgresql/fastpath/FastpathArg.java
  24. +1 −1 pgjdbc/src/main/java/org/postgresql/geometric/PGbox.java
  25. +1 −1 pgjdbc/src/main/java/org/postgresql/geometric/PGlseg.java
  26. +1 −1 pgjdbc/src/main/java/org/postgresql/geometric/PGpath.java
  27. +1 −1 pgjdbc/src/main/java/org/postgresql/geometric/PGpolygon.java
  28. +5 −6 pgjdbc/src/main/java/org/postgresql/gss/GssAction.java
  29. +3 −3 pgjdbc/src/main/java/org/postgresql/jdbc/AbstractBlobClob.java
  30. +70 −70 pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions.java
  31. +1 −1 pgjdbc/src/main/java/org/postgresql/jdbc/PgCallableStatement.java
  32. +4 −2 pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java
  33. +39 −41 pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java
  34. +2 −2 pgjdbc/src/main/java/org/postgresql/jdbc/PgParameterMetaData.java
  35. +2 −2 pgjdbc/src/main/java/org/postgresql/jdbc/PgPreparedStatement.java
  36. +9 −9 pgjdbc/src/main/java/org/postgresql/jdbc/PgResultSet.java
  37. +6 −6 pgjdbc/src/main/java/org/postgresql/jdbc/PgStatement.java
  38. +2 −2 pgjdbc/src/main/java/org/postgresql/jdbc/TypeInfoCache.java
  39. +1 −1 pgjdbc/src/main/java/org/postgresql/largeobject/BlobOutputStream.java
  40. +15 −15 pgjdbc/src/main/java/org/postgresql/largeobject/LargeObject.java
  41. +2 −2 pgjdbc/src/main/java/org/postgresql/largeobject/LargeObjectManager.java
  42. +1 −1 pgjdbc/src/main/java/org/postgresql/osgi/PGDataSourceFactory.java
  43. +3 −3 pgjdbc/src/main/java/org/postgresql/ssl/DbKeyStoreSocketFactory.java
  44. +2 −1 pgjdbc/src/main/java/org/postgresql/ssl/jdbc4/LibPQFactory.java
  45. +13 −13 pgjdbc/src/main/java/org/postgresql/util/Base64.java
  46. +3 −3 pgjdbc/src/main/java/org/postgresql/util/GT.java
  47. +2 −2 pgjdbc/src/main/java/org/postgresql/util/LruCache.java
  48. +2 −2 pgjdbc/src/main/java/org/postgresql/util/MD5Digest.java
  49. +1 −1 pgjdbc/src/main/java/org/postgresql/util/PGInterval.java
  50. +1 −1 pgjdbc/src/main/java/org/postgresql/util/ReaderInputStream.java
  51. +23 −23 pgjdbc/src/main/java/org/postgresql/util/UnixCrypt.java
  52. +2 −1 pgjdbc/src/main/java/org/postgresql/xa/PGXAConnection.java
  53. +12 −12 pgjdbc/src/test/java/org/postgresql/test/jdbc2/ArrayTest.java
  54. +2 −2 pgjdbc/src/test/java/org/postgresql/test/jdbc2/AutoRollbackTestSuite.java
  55. +3 −3 pgjdbc/src/test/java/org/postgresql/test/jdbc2/BlobTest.java
  56. +2 −2 pgjdbc/src/test/java/org/postgresql/test/jdbc2/CopyTest.java
  57. +8 −8 pgjdbc/src/test/java/org/postgresql/test/jdbc2/NotifyTest.java
  58. +2 −2 pgjdbc/src/test/java/org/postgresql/test/jdbc2/PreparedStatementTest.java
  59. +1 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/TypeCacheDLLStressTest.java
  60. +1 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/UpdateableResultTest.java
  61. +1 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/optional/PoolingDataSourceTest.java
  62. +4 −4 pgjdbc/src/test/java/org/postgresql/test/jdbc3/Jdbc3BlobTest.java
  63. +1 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc3/StringTypeParameterTest.java
  64. +15 −15 pgjdbc/src/test/java/org/postgresql/test/jdbc4/ArrayTest.java
  65. +3 −3 pgjdbc/src/test/java/org/postgresql/test/jdbc4/XmlTest.java
  66. +1 −1 pgjdbc/src/test/java/org/postgresql/test/util/BufferGenerator.java
  67. +10 −10 pgjdbc/src/test/java/org/postgresql/util/ReaderInputStreamTest.java
@@ -33,7 +33,7 @@
<jdbc.specification.version>4.2</jdbc.specification.version>
<jdbc.specification.version.nodot>42</jdbc.specification.version.nodot>
<skip.assembly>false</skip.assembly>
<checkstyle.version>7.4</checkstyle.version>
<checkstyle.version>7.8.2</checkstyle.version>
</properties>
<profiles>
@@ -94,11 +94,12 @@
</module>
<module name="OneStatementPerLine"/>
<module name="MultipleVariableDeclarations"/>
<!--<module name="ArrayTypeStyle"/>-->
<module name="ArrayTypeStyle"/>
<!--<module name="MissingSwitchDefault"/>-->
<!--<module name="FallThrough"/>-->
<module name="UpperEll"/>
<!--<module name="ModifierOrder"/>-->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<module name="EmptyLineSeparator">
<property name="allowNoEmptyLineBetweenFields" value="true"/>
</module>
@@ -419,15 +419,15 @@
private String _description;
private String[] _choices;
private PGProperty(String name, String defaultValue, String description) {
PGProperty(String name, String defaultValue, String description) {
this(name, defaultValue, description, false);
}
private PGProperty(String name, String defaultValue, String description, boolean required) {
PGProperty(String name, String defaultValue, String description, boolean required) {
this(name, defaultValue, description, required, (String[]) null);
}
private PGProperty(String name, String defaultValue, String description, boolean required,
PGProperty(String name, String defaultValue, String description, boolean required,
String... choices) {
_name = name;
_defaultValue = defaultValue;
@@ -32,7 +32,7 @@
// do figure it out we can just set it here and they reap the rewards.
// Note that this is currently being used for both a number of bytes and a number
// of characters.
final static int DEFAULT_BUFFER_SIZE = 65536;
static final int DEFAULT_BUFFER_SIZE = 65536;
private final Encoding encoding;
private final QueryExecutor queryExecutor;
@@ -15,10 +15,10 @@
* Creates an instance of {@link CachedQuery} for a given connection.
*/
class CachedQueryCreateAction implements LruCache.CreateAction<Object, CachedQuery> {
private final static String[] EMPTY_RETURNING = new String[0];
private static final String[] EMPTY_RETURNING = new String[0];
private final QueryExecutor queryExecutor;
public CachedQueryCreateAction(QueryExecutor queryExecutor) {
CachedQueryCreateAction(QueryExecutor queryExecutor) {
this.queryExecutor = queryExecutor;
}
@@ -11,7 +11,8 @@
* syntax, thus a special cache key class is used to trigger proper parsing for callable statements.
*/
class CallableQueryKey extends BaseQueryKey {
public CallableQueryKey(String sql) {
CallableQueryKey(String sql) {
super(sql, true, true);
}
@@ -43,7 +43,7 @@
}
}
private final static Translation[] FATAL_TRANSLATIONS =
private static final Translation[] FATAL_TRANSLATIONS =
new Translation[]{
new Translation("ВАЖНО", null, "ru", "WIN", "ALT", "KOI8"),
new Translation("致命错误", null, "zh_CN", "EUC_CN", "GBK", "BIG5"),
@@ -11,8 +11,8 @@
* replaced with $1, $2, etc.
*/
public class NativeQuery {
private final static String[] BIND_NAMES = new String[128 * 10];
private final static int[] NO_BINDS = new int[0];
private static final String[] BIND_NAMES = new String[128 * 10];
private static final int[] NO_BINDS = new int[0];
public final String nativeSql;
public final int[] bindPositions;
@@ -42,7 +42,7 @@ public NativeQuery(String nativeSql, int[] bindPositions, boolean multiStatement
* parameter placeholders.
*
* @param parameters a ParameterList returned by this Query's {@link Query#createParameterList}
* method, or <code>null</code> to leave the parameter placeholders unsubstituted.
* method, or {@code null} to leave the parameter placeholders unsubstituted.
* @return a human-readable representation of this query
*/
public String toString(ParameterList parameters) {
@@ -230,7 +230,7 @@ public void sendInteger2(int val) throws IOException {
* @param buf The array of bytes to be sent
* @throws IOException if an I/O error occurs
*/
public void send(byte buf[]) throws IOException {
public void send(byte[] buf) throws IOException {
pg_output.write(buf);
}
@@ -242,7 +242,7 @@ public void send(byte buf[]) throws IOException {
* @param siz the number of bytes to be sent
* @throws IOException if an I/O error occurs
*/
public void send(byte buf[], int siz) throws IOException {
public void send(byte[] buf, int siz) throws IOException {
send(buf, 0, siz);
}
@@ -255,7 +255,7 @@ public void send(byte buf[], int siz) throws IOException {
* @param siz the number of bytes to be sent
* @throws IOException if an I/O error occurs
*/
public void send(byte buf[], int off, int siz) throws IOException {
public void send(byte[] buf, int off, int siz) throws IOException {
int bufamt = buf.length - off;
pg_output.write(buf, off, bufamt < siz ? bufamt : siz);
for (int i = bufamt; i < siz; ++i) {
@@ -25,7 +25,7 @@
* @author Christopher Deckers (chrriis@gmail.com)
*/
public class Parser {
private final static int[] NO_BINDS = new int[0];
private static final int[] NO_BINDS = new int[0];
/**
* Parses JDBC query into PostgreSQL's native format. Several queries might be given if separated
@@ -1197,8 +1197,8 @@ private static String escapeFunction(String functionName, String args, boolean s
}
}
private final static char[] QUOTE_OR_ALPHABETIC_MARKER = new char[]{'\"', '0'};
private final static char[] SINGLE_QUOTE = new char[]{'\''};
private static final char[] QUOTE_OR_ALPHABETIC_MARKER = {'\"', '0'};
private static final char[] SINGLE_QUOTE = {'\''};
// Static variables for parsing SQL when replaceProcessing is true.
private enum SqlParseState {
@@ -17,7 +17,7 @@
class QueryWithReturningColumnsKey extends BaseQueryKey {
public final String[] columnNames;
public QueryWithReturningColumnsKey(String sql, boolean isParameterized, boolean escapeProcessing,
QueryWithReturningColumnsKey(String sql, boolean isParameterized, boolean escapeProcessing,
String[] columnNames) {
super(sql, isParameterized, escapeProcessing);
if (columnNames == null) {
@@ -29,7 +29,7 @@
private final int version;
private ServerVersion(String version) {
ServerVersion(String version) {
this.version = parseServerVersionStr(version);
}
@@ -37,7 +37,7 @@ public static String toHexString(byte[] data) {
* Keep a local copy of the UTF-8 Charset so we can avoid synchronization overhead from looking up
* the Charset by name as String.getBytes(String) requires.
*/
private final static Charset utf8Charset = Charset.forName("UTF-8");
private static final Charset utf8Charset = Charset.forName("UTF-8");
/**
* Encode a string as UTF-8.
@@ -177,7 +177,7 @@ private void moveBufferTo(byte[] dest) {
/**
* {@inheritDoc}
*/
public int read(byte to[], int off, int len) throws IOException {
public int read(byte[] to, int off, int len) throws IOException {
if ((off | len | (off + len) | (to.length - (off + len))) < 0) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
@@ -64,9 +64,9 @@ public int getOutParameterCount() {
}
public int[] getTypeOIDs() {
int oids[] = new int[total];
int[] oids = new int[total];
for (int i = 0; i < offsets.length; i++) {
int subOids[] = subparams[i].getTypeOIDs();
int[] subOids = subparams[i].getTypeOIDs();
System.arraycopy(subOids, 0, oids, offsets[i], subOids.length);
}
return oids;
@@ -16,7 +16,7 @@
public final boolean describeOnly;
public final String statementName;
public DescribeRequest(SimpleQuery query, SimpleParameterList parameterList,
DescribeRequest(SimpleQuery query, SimpleParameterList parameterList,
boolean describeOnly, String statementName) {
this.query = query;
this.parameterList = parameterList;
@@ -15,7 +15,7 @@
public final Portal portal;
public final boolean asSimple;
public ExecuteRequest(SimpleQuery query, Portal portal, boolean asSimple) {
ExecuteRequest(SimpleQuery query, Portal portal, boolean asSimple) {
this.query = query;
this.portal = portal;
this.asSimple = asSimple;
@@ -780,7 +780,7 @@ private void setSocketTimeout(int millis) throws PSQLException {
LOGGER.log(Level.FINEST, " <=BE FunctionCallResponse({0} bytes)", valueLen);
if (valueLen != -1) {
byte buf[] = new byte[valueLen];
byte[] buf = new byte[valueLen];
pgStream.receive(buf, 0, valueLen);
returnValue = buf;
}
@@ -819,7 +819,7 @@ public synchronized CopyOperation startCopy(String sql, boolean suppressBegin)
if (!suppressBegin) {
doSubprotocolBegin();
}
byte buf[] = Utils.encodeUTF8(sql);
byte[] buf = Utils.encodeUTF8(sql);
try {
LOGGER.log(Level.FINEST, " FE=> Query(CopyStart)");
@@ -1786,8 +1786,8 @@ private void sendOneQuery(SimpleQuery query, SimpleParameterList params, int max
|| (!oneShot && paramsHasUnknown && queryHasUnknown && !query.isStatementDescribed());
if (!describeStatement && paramsHasUnknown && !queryHasUnknown) {
int queryOIDs[] = query.getStatementTypes();
int paramOIDs[] = params.getTypeOIDs();
int[] queryOIDs = query.getStatementTypes();
int[] paramOIDs = params.getTypeOIDs();
for (int i = 0; i < paramOIDs.length; i++) {
// Only supply type information when there isn't any
// already, don't arbitrarily overwrite user supplied
@@ -32,12 +32,12 @@
*/
class SimpleParameterList implements V3ParameterList {
private final static byte IN = 1;
private final static byte OUT = 2;
private final static byte INOUT = IN | OUT;
private static final byte IN = 1;
private static final byte OUT = 2;
private static final byte INOUT = IN | OUT;
private final static byte TEXT = 0;
private final static byte BINARY = 4;
private static final byte TEXT = 0;
private static final byte BINARY = 4;
SimpleParameterList(int paramCount, TypeTransferModeRegistry transferModeRegistry) {
this.paramValues = new Object[paramCount];
@@ -467,7 +467,7 @@ public String toString() {
* Marker object representing NULL; this distinguishes "parameter never set" from "parameter set
* to null".
*/
private final static Object NULL_OBJECT = new Object();
private static final Object NULL_OBJECT = new Object();
private int pos = 0;
}
@@ -316,5 +316,5 @@ public SqlCommand getSqlCommand() {
private Integer cachedMaxResultRowSize;
final static SimpleParameterList NO_PARAMETERS = new SimpleParameterList(0, null);
static final SimpleParameterList NO_PARAMETERS = new SimpleParameterList(0, null);
}
@@ -248,10 +248,11 @@ private void fireConnectionError(SQLException e) {
private Connection proxy; // the Connection the client is currently using, which is a proxy
private boolean automatic = false;
public ConnectionHandler(Connection con) {
ConnectionHandler(Connection con) {
this.con = con;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
final String methodName = method.getName();
// From Object
@@ -375,11 +376,12 @@ public boolean isClosed() {
private ConnectionHandler con;
private Statement st;
public StatementHandler(ConnectionHandler con, Statement st) {
StatementHandler(ConnectionHandler con, Statement st) {
this.con = con;
this.st = st;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
final String methodName = method.getName();
// From Object
@@ -32,7 +32,7 @@
// Java passes oids around as longs, but in the backend
// it's an unsigned int, so we use this to make the conversion
// of long -> signed int which the backend interprets as unsigned.
private final static long NUM_OIDS = 4294967296L; // 2^32
private static final long NUM_OIDS = 4294967296L; // 2^32
// This maps the functions names to their id's (possible unique just
// to a connection).
@@ -65,7 +65,7 @@ public FastpathArg(long value) {
*
* @param bytes array to store
*/
public FastpathArg(byte bytes[]) {
public FastpathArg(byte[] bytes) {
this(bytes, 0, bytes.length);
}
@@ -76,7 +76,7 @@ public FastpathArg(byte bytes[]) {
* @param off offset within array
* @param len length of data to include
*/
public FastpathArg(byte buf[], int off, int len) {
public FastpathArg(byte[] buf, int off, int len) {
this.bytes = buf;
this.bytesStart = off;
this.bytesLength = len;
@@ -22,7 +22,7 @@
/**
* These are the two points.
*/
public PGpoint point[] = new PGpoint[2];
public PGpoint[] point = new PGpoint[2];
/**
* @param x1 first x coordinate
@@ -21,7 +21,7 @@
/**
* These are the two points.
*/
public PGpoint point[] = new PGpoint[2];
public PGpoint[] point = new PGpoint[2];
/**
* @param x1 coordinate for first point
@@ -26,7 +26,7 @@
/**
* The points defining this path
*/
public PGpoint points[];
public PGpoint[] points;
/**
* @param points the PGpoints that define the path
@@ -18,7 +18,7 @@
/**
* The points defining the polygon
*/
public PGpoint points[];
public PGpoint[] points;
/**
* Creates a polygon using an array of PGpoints
Oops, something went wrong.

0 comments on commit 246b759

Please sign in to comment.