Skip to content
Permalink
Browse files

style: enable checkstyle modules for name checking (#1411)

enable MemberName, ParameterName, TypeName and LocalVariableName checkstyle modules
  • Loading branch information...
AlexElin authored and davecramer committed Feb 17, 2019
1 parent 61cc275 commit 6b124a054074e3aa85787314390b633adfe073ca
Showing with 1,261 additions and 1,207 deletions.
  1. +6 −21 pgjdbc/src/main/checkstyle/checks.xml
  2. +18 −18 pgjdbc/src/main/java/org/postgresql/Driver.java
  3. +23 −23 pgjdbc/src/main/java/org/postgresql/PGProperty.java
  4. +2 −2 pgjdbc/src/main/java/org/postgresql/core/BaseStatement.java
  5. +14 −13 pgjdbc/src/main/java/org/postgresql/core/Notification.java
  6. +3 −3 pgjdbc/src/main/java/org/postgresql/core/PGBindException.java
  7. +57 −57 pgjdbc/src/main/java/org/postgresql/core/PGStream.java
  8. +50 −50 pgjdbc/src/main/java/org/postgresql/core/Parser.java
  9. +6 −6 pgjdbc/src/main/java/org/postgresql/core/v3/ConnectionFactoryImpl.java
  10. +12 −12 pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java
  11. +6 −7 pgjdbc/src/main/java/org/postgresql/gss/GssAction.java
  12. +23 −21 pgjdbc/src/main/java/org/postgresql/jdbc/PSQLSavepoint.java
  13. +15 −15 pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java
  14. +8 −8 pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java
  15. +16 −11 pgjdbc/src/main/java/org/postgresql/jdbc/PgParameterMetaData.java
  16. +35 −25 pgjdbc/src/main/java/org/postgresql/jdbc/PgPreparedStatement.java
  17. +128 −101 pgjdbc/src/main/java/org/postgresql/jdbc/PgResultSet.java
  18. +6 −3 pgjdbc/src/main/java/org/postgresql/jdbc/PgResultSetMetaData.java
  19. +71 −62 pgjdbc/src/main/java/org/postgresql/jdbc/PgSQLXML.java
  20. +29 −17 pgjdbc/src/main/java/org/postgresql/jdbc/PgStatement.java
  21. +4 −4 pgjdbc/src/main/java/org/postgresql/jdbc/TimestampUtils.java
  22. +106 −106 pgjdbc/src/main/java/org/postgresql/jdbc/TypeInfoCache.java
  23. +5 −5 pgjdbc/src/main/java/org/postgresql/osgi/PGBundleActivator.java
  24. +2 −2 pgjdbc/src/main/java/org/postgresql/ssl/DbKeyStoreSocketFactory.java
  25. +1 −1 pgjdbc/src/main/java/org/postgresql/ssl/DefaultJavaSSLFactory.java
  26. +1 −1 pgjdbc/src/main/java/org/postgresql/ssl/LibPQFactory.java
  27. +1 −1 pgjdbc/src/main/java/org/postgresql/ssl/NonValidatingFactory.java
  28. +3 −3 pgjdbc/src/main/java/org/postgresql/ssl/PGjdbcHostnameVerifier.java
  29. +1 −1 pgjdbc/src/main/java/org/postgresql/ssl/SingleCertValidatingFactory.java
  30. +8 −8 pgjdbc/src/main/java/org/postgresql/ssl/WrappedFactory.java
  31. +4 −4 pgjdbc/src/main/java/org/postgresql/util/Base64.java
  32. +6 −6 pgjdbc/src/main/java/org/postgresql/util/GT.java
  33. +12 −12 pgjdbc/src/main/java/org/postgresql/util/MD5Digest.java
  34. +18 −18 pgjdbc/src/main/java/org/postgresql/util/PGbytea.java
  35. +3 −3 pgjdbc/src/main/java/org/postgresql/util/PSQLException.java
  36. +66 −66 pgjdbc/src/main/java/org/postgresql/util/ServerErrorMessage.java
  37. +8 −8 pgjdbc/src/main/java/org/postgresql/util/StreamWrapper.java
  38. +2 −2 pgjdbc/src/test/java/org/postgresql/jdbc/InsertRewriteWithAlternatingTypesIssue584.java
  39. +3 −3 pgjdbc/src/test/java/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
  40. +6 −6 pgjdbc/src/test/java/org/postgresql/test/jdbc2/SearchPathLookupTest.java
  41. +2 −2 pgjdbc/src/test/java/org/postgresql/test/jdbc2/TestACL.java
  42. +54 −54 pgjdbc/src/test/java/org/postgresql/test/jdbc2/TimestampTest.java
  43. +9 −9 pgjdbc/src/test/java/org/postgresql/test/jdbc2/TimezoneTest.java
  44. +30 −30 pgjdbc/src/test/java/org/postgresql/test/jdbc3/CompositeTest.java
  45. +6 −6 pgjdbc/src/test/java/org/postgresql/test/jdbc3/DatabaseMetaDataTest.java
  46. +19 −19 pgjdbc/src/test/java/org/postgresql/test/jdbc3/Jdbc3BlobTest.java
  47. +39 −39 pgjdbc/src/test/java/org/postgresql/test/jdbc3/Jdbc3SavepointTest.java
  48. +8 −8 pgjdbc/src/test/java/org/postgresql/test/jdbc3/ResultSetTest.java
  49. +6 −6 pgjdbc/src/test/java/org/postgresql/test/jdbc3/SendRecvBufferSizeTest.java
  50. +8 −8 pgjdbc/src/test/java/org/postgresql/test/jdbc3/TypesTest.java
  51. +63 −63 pgjdbc/src/test/java/org/postgresql/test/jdbc4/ArrayTest.java
  52. +6 −6 pgjdbc/src/test/java/org/postgresql/test/jdbc4/BinaryStreamTest.java
  53. +15 −15 pgjdbc/src/test/java/org/postgresql/test/jdbc4/BlobTest.java
  54. +16 −16 pgjdbc/src/test/java/org/postgresql/test/jdbc4/DatabaseMetaDataTest.java
  55. +10 −10 pgjdbc/src/test/java/org/postgresql/test/jdbc4/PGCopyInputStreamTest.java
  56. +18 −18 pgjdbc/src/test/java/org/postgresql/test/jdbc4/WrapperTest.java
  57. +7 −7 pgjdbc/src/test/java/org/postgresql/test/jdbc4/XmlTest.java
  58. +9 −9 pgjdbc/src/test/java/org/postgresql/test/jdbc4/jdbc41/CloseOnCompletionTest.java
  59. +57 −57 pgjdbc/src/test/java/org/postgresql/test/jdbc4/jdbc41/GetObjectTest.java
  60. +15 −15 pgjdbc/src/test/java/org/postgresql/test/jdbc4/jdbc41/NetworkTimeoutTest.java
  61. +35 −35 pgjdbc/src/test/java/org/postgresql/test/jdbc4/jdbc41/SchemaTest.java
  62. +10 −10 pgjdbc/src/test/java/org/postgresql/test/osgi/PGDataSourceFactoryTest.java
  63. +3 −3 pgjdbc/src/test/java/org/postgresql/test/socketfactory/SocketFactoryTestSuite.java
  64. +10 −9 pgjdbc/src/test/java/org/postgresql/test/util/BrokenInputStream.java
  65. +18 −18 pgjdbc/src/test/java/org/postgresql/test/xa/XADataSourceTest.java
@@ -115,33 +115,18 @@
value="Package name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="EqualsHashCode"/>
<!--<module name="TypeName">
<message key="name.invalidPattern"
value="Type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="MemberName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
<message key="name.invalidPattern"
value="Member name ''{0}'' must match pattern ''{1}''."/>
<module name="MemberName"/>
<module name="ParameterName"/>
<module name="TypeName"/>
<module name="LocalVariableName">
<property name="allowOneCharVarInForLoop" value="true"/>
</module>
<module name="ParameterName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
<message key="name.invalidPattern"
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
</module>-->
<!-- Not yet supported by Checkstyle-IDEA <module name="CatchParameterName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
<message key="name.invalidPattern"
value="Catch parameter name ''{0}'' must match pattern ''{1}''."/>
</module> -->
<!-- <module name="LocalVariableName">
<property name="tokens" value="VARIABLE_DEF"/>
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
<property name="allowOneCharVarInForLoop" value="true"/>
<message key="name.invalidPattern"
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ClassTypeParameterName">
<!-- <module name="ClassTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<message key="name.invalidPattern"
value="Class type name ''{0}'' must match pattern ''{1}''."/>
@@ -541,31 +541,31 @@ public boolean jdbcCompliant() {
public static Properties parseURL(String url, Properties defaults) {
Properties urlProps = new Properties(defaults);

String l_urlServer = url;
String l_urlArgs = "";
String urlServer = url;
String urlArgs = "";

int l_qPos = url.indexOf('?');
if (l_qPos != -1) {
l_urlServer = url.substring(0, l_qPos);
l_urlArgs = url.substring(l_qPos + 1);
int qPos = url.indexOf('?');
if (qPos != -1) {
urlServer = url.substring(0, qPos);
urlArgs = url.substring(qPos + 1);
}

if (!l_urlServer.startsWith("jdbc:postgresql:")) {
if (!urlServer.startsWith("jdbc:postgresql:")) {
LOGGER.log(Level.FINE, "JDBC URL must start with \"jdbc:postgresql:\" but was: {0}", url);
return null;
}
l_urlServer = l_urlServer.substring("jdbc:postgresql:".length());
urlServer = urlServer.substring("jdbc:postgresql:".length());

if (l_urlServer.startsWith("//")) {
l_urlServer = l_urlServer.substring(2);
int slash = l_urlServer.indexOf('/');
if (urlServer.startsWith("//")) {
urlServer = urlServer.substring(2);
int slash = urlServer.indexOf('/');
if (slash == -1) {
LOGGER.log(Level.WARNING, "JDBC URL must contain a / at the end of the host or port: {0}", url);
return null;
}
urlProps.setProperty("PGDBNAME", URLCoder.decode(l_urlServer.substring(slash + 1)));
urlProps.setProperty("PGDBNAME", URLCoder.decode(urlServer.substring(slash + 1)));

String[] addresses = l_urlServer.substring(0, slash).split(",");
String[] addresses = urlServer.substring(0, slash).split(",");
StringBuilder hosts = new StringBuilder();
StringBuilder ports = new StringBuilder();
for (String address : addresses) {
@@ -607,21 +607,21 @@ public static Properties parseURL(String url, Properties defaults) {
urlProps.setProperty("PGHOST", "localhost");
}
if (defaults == null || !defaults.containsKey("PGDBNAME")) {
urlProps.setProperty("PGDBNAME", URLCoder.decode(l_urlServer));
urlProps.setProperty("PGDBNAME", URLCoder.decode(urlServer));
}
}

// parse the args part of the url
String[] args = l_urlArgs.split("&");
String[] args = urlArgs.split("&");
for (String token : args) {
if (token.isEmpty()) {
continue;
}
int l_pos = token.indexOf('=');
if (l_pos == -1) {
int pos = token.indexOf('=');
if (pos == -1) {
urlProps.setProperty(token, "");
} else {
urlProps.setProperty(token.substring(0, l_pos), URLCoder.decode(token.substring(l_pos + 1)));
urlProps.setProperty(token.substring(0, pos), URLCoder.decode(token.substring(pos + 1)));
}
}

@@ -434,11 +434,11 @@
+ "from that database. "
+ "(backend >= 9.4)");

private String _name;
private String _defaultValue;
private boolean _required;
private String _description;
private String[] _choices;
private final String name;
private final String defaultValue;
private final boolean required;
private final String description;
private final String[] choices;

PGProperty(String name, String defaultValue, String description) {
this(name, defaultValue, description, false);
@@ -450,11 +450,11 @@

PGProperty(String name, String defaultValue, String description, boolean required,
String... choices) {
_name = name;
_defaultValue = defaultValue;
_required = required;
_description = description;
_choices = choices;
this.name = name;
this.defaultValue = defaultValue;
this.required = required;
this.description = description;
this.choices = choices;
}

/**
@@ -464,7 +464,7 @@
* @return the name of the connection parameter
*/
public String getName() {
return _name;
return name;
}

/**
@@ -473,7 +473,7 @@ public String getName() {
* @return the default value for this connection parameter or null
*/
public String getDefaultValue() {
return _defaultValue;
return defaultValue;
}

/**
@@ -482,7 +482,7 @@ public String getDefaultValue() {
* @return the available values for this connection parameter or null
*/
public String[] getChoices() {
return _choices;
return choices;
}

/**
@@ -493,7 +493,7 @@ public String getDefaultValue() {
* @return evaluated value for this connection parameter
*/
public String get(Properties properties) {
return properties.getProperty(_name, _defaultValue);
return properties.getProperty(name, defaultValue);
}

/**
@@ -504,9 +504,9 @@ public String get(Properties properties) {
*/
public void set(Properties properties, String value) {
if (value == null) {
properties.remove(_name);
properties.remove(name);
} else {
properties.setProperty(_name, value);
properties.setProperty(name, value);
}
}

@@ -577,7 +577,7 @@ public Integer getInteger(Properties properties) throws PSQLException {
* @param value boolean value for this connection parameter
*/
public void set(Properties properties, boolean value) {
properties.setProperty(_name, Boolean.toString(value));
properties.setProperty(name, Boolean.toString(value));
}

/**
@@ -587,7 +587,7 @@ public void set(Properties properties, boolean value) {
* @param value int value for this connection parameter
*/
public void set(Properties properties, int value) {
properties.setProperty(_name, Integer.toString(value));
properties.setProperty(name, Integer.toString(value));
}

/**
@@ -608,10 +608,10 @@ public boolean isPresent(Properties properties) {
* @return a DriverPropertyInfo representing this connection parameter
*/
public DriverPropertyInfo toDriverPropertyInfo(Properties properties) {
DriverPropertyInfo propertyInfo = new DriverPropertyInfo(_name, get(properties));
propertyInfo.required = _required;
propertyInfo.description = _description;
propertyInfo.choices = _choices;
DriverPropertyInfo propertyInfo = new DriverPropertyInfo(name, get(properties));
propertyInfo.required = required;
propertyInfo.description = description;
propertyInfo.choices = choices;
return propertyInfo;
}

@@ -632,7 +632,7 @@ public static PGProperty forName(String name) {
* @return the value of a set property
*/
public String getSetString(Properties properties) {
Object o = properties.get(_name);
Object o = properties.get(name);
if (o instanceof String) {
return (String) o;
}
@@ -44,13 +44,13 @@ ResultSet createResultSet(Query originalQuery, Field[] fields, List<byte[][]> tu
/**
* Execute a query, passing additional query flags.
*
* @param p_sql the query to execute (JDBC-style query)
* @param sql the query to execute (JDBC-style query)
* @param flags additional {@link QueryExecutor} flags for execution; these are bitwise-ORed into
* the default flags.
* @return true if there is a result set
* @throws SQLException if something goes wrong.
*/
boolean executeWithFlags(String p_sql, int flags) throws SQLException;
boolean executeWithFlags(String sql, int flags) throws SQLException;

/**
* Execute a query, passing additional query flags.
@@ -8,37 +8,38 @@
import org.postgresql.PGNotification;

public class Notification implements PGNotification {
public Notification(String p_name, int p_pid) {
this(p_name, p_pid, "");

private final String name;
private final String parameter;
private final int pid;

public Notification(String name, int pid) {
this(name, pid, "");
}

public Notification(String p_name, int p_pid, String p_parameter) {
m_name = p_name;
m_pid = p_pid;
m_parameter = p_parameter;
public Notification(String name, int pid, String parameter) {
this.name = name;
this.pid = pid;
this.parameter = parameter;
}

/*
* Returns name of this notification
*/
public String getName() {
return m_name;
return name;
}

/*
* Returns the process id of the backend process making this notification
*/
public int getPID() {
return m_pid;
return pid;
}

public String getParameter() {
return m_parameter;
return parameter;
}

private String m_name;
private String m_parameter;
private int m_pid;

}

@@ -9,13 +9,13 @@

public class PGBindException extends IOException {

private IOException _ioe;
private final IOException ioe;

public PGBindException(IOException ioe) {
_ioe = ioe;
this.ioe = ioe;
}

public IOException getIOException() {
return _ioe;
return ioe;
}
}

0 comments on commit 6b124a0

Please sign in to comment.
You can’t perform that action at this time.