Skip to content
Permalink
Browse files
Add disallow multiple empty lines (#1427)
* style: Add allowMultipleEmptyLinesInsideClassMembers set to false

Adds a checkstyle rule to disallow multiple back to back empty newlines inside class members.
  • Loading branch information
sehrope authored and davecramer committed Dec 13, 2019
1 parent d10ab8d commit be5c9f434c3ce68b9140f3ff929023e69cb2f984
Showing with 2 additions and 125 deletions.
  1. +1 −1 pgjdbc/src/assembly/dist.xml
  2. +1 −1 pgjdbc/src/main/checkstyle/checks.xml
  3. +0 −2 pgjdbc/src/main/java/org/postgresql/PGConnection.java
  4. +0 −1 pgjdbc/src/main/java/org/postgresql/PGStatement.java
  5. +0 −1 pgjdbc/src/main/java/org/postgresql/core/PGStream.java
  6. +0 −1 pgjdbc/src/main/java/org/postgresql/core/ParameterList.java
  7. +0 −5 pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java
  8. +0 −1 pgjdbc/src/main/java/org/postgresql/core/v3/SimpleParameterList.java
  9. +0 −1 pgjdbc/src/main/java/org/postgresql/core/v3/replication/V3ReplicationProtocol.java
  10. +0 −1 pgjdbc/src/main/java/org/postgresql/gss/GssAction.java
  11. +0 −1 pgjdbc/src/main/java/org/postgresql/gss/MakeGSS.java
  12. +0 −2 pgjdbc/src/main/java/org/postgresql/jdbc/AbstractBlobClob.java
  13. +0 −2 pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java
  14. +0 −16 pgjdbc/src/main/java/org/postgresql/jdbc/PgResultSet.java
  15. +0 −1 pgjdbc/src/main/java/org/postgresql/jdbc/TimestampUtils.java
  16. +0 −1 pgjdbc/src/main/java/org/postgresql/ssl/LibPQFactory.java
  17. +0 −1 pgjdbc/src/main/java/org/postgresql/sspi/SSPIClient.java
  18. +0 −9 pgjdbc/src/main/java/org/postgresql/util/Base64.java
  19. +0 −2 pgjdbc/src/main/java/org/postgresql/util/PGtokenizer.java
  20. +0 −1 pgjdbc/src/main/java/org/postgresql/util/ServerErrorMessage.java
  21. +0 −3 pgjdbc/src/test/java/org/postgresql/core/ParserTest.java
  22. +0 −1 pgjdbc/src/test/java/org/postgresql/replication/LogicalReplicationStatusTest.java
  23. +0 −2 pgjdbc/src/test/java/org/postgresql/replication/LogicalReplicationTest.java
  24. +0 −1 pgjdbc/src/test/java/org/postgresql/test/TestUtil.java
  25. +0 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/ArrayTest.java
  26. +0 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/AutoRollbackTestSuite.java
  27. +0 −2 pgjdbc/src/test/java/org/postgresql/test/jdbc2/BlobTransactionTest.java
  28. +0 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/CopyTest.java
  29. +0 −2 pgjdbc/src/test/java/org/postgresql/test/jdbc2/CursorFetchTest.java
  30. +0 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/DatabaseEncodingTest.java
  31. +0 −19 pgjdbc/src/test/java/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
  32. +0 −2 pgjdbc/src/test/java/org/postgresql/test/jdbc2/DateTest.java
  33. +0 −9 pgjdbc/src/test/java/org/postgresql/test/jdbc2/DriverTest.java
  34. +0 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/IntervalTest.java
  35. +0 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/RefCursorTest.java
  36. +0 −2 pgjdbc/src/test/java/org/postgresql/test/jdbc2/ServerPreparedStmtTest.java
  37. +0 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/StatementTest.java
  38. +0 −2 pgjdbc/src/test/java/org/postgresql/test/jdbc2/TimeTest.java
  39. +0 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/TimestampTest.java
  40. +0 −3 pgjdbc/src/test/java/org/postgresql/test/jdbc2/UpdateableResultTest.java
  41. +0 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/UpsertTest.java
  42. +0 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc3/Jdbc3BlobTest.java
  43. +0 −2 pgjdbc/src/test/java/org/postgresql/test/jdbc3/Jdbc3CallableStatementTest.java
  44. +0 −2 pgjdbc/src/test/java/org/postgresql/test/jdbc3/SendRecvBufferSizeTest.java
  45. +0 −3 pgjdbc/src/test/java/org/postgresql/test/jdbc4/DatabaseMetaDataTest.java
  46. +0 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc42/Jdbc42CallableStatementTest.java
  47. +0 −6 pgjdbc/src/test/java/org/postgresql/test/jdbc42/PreparedStatementTest.java
  48. +0 −2 pgjdbc/src/test/java/org/postgresql/test/ssl/SslTest.java
@@ -40,4 +40,4 @@
<scope>runtime</scope>
</dependencySet>
</dependencySets>
</assembly>
</assembly>
@@ -22,7 +22,6 @@

<property name="fileExtensions" value="java, properties, xml"/>


<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="FileTabCharacter">
@@ -101,6 +100,7 @@
<module name="EmptyLineSeparator">
<property name="allowNoEmptyLineBetweenFields" value="true"/>
<property name="allowMultipleEmptyLines" value="false"/>
<property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
</module>
<module name="SeparatorWrap">
<property name="tokens" value="DOT"/>
@@ -167,7 +167,6 @@ public interface PGConnection {
*/
void setDefaultFetchSize(int fetchSize) throws SQLException;


/**
* Get the default fetch size for statements created from this connection.
*
@@ -224,7 +223,6 @@ public interface PGConnection {
*/
PreferQueryMode getPreferQueryMode();


/**
* Connection configuration regarding automatic per-query savepoints.
*
@@ -23,7 +23,6 @@ public interface PGStatement {
long DATE_POSITIVE_SMALLER_INFINITY = 185543533774800000L;
long DATE_NEGATIVE_SMALLER_INFINITY = -185543533774800000L;


/**
* Returns the Last inserted/updated oid.
*
@@ -540,7 +540,6 @@ public void sendStream(InputStream inStream, int remaining) throws IOException {
}
}


/**
* Flush any pending output to the backend.
*
@@ -23,7 +23,6 @@
* @author Oliver Jowett (oliver@opencloud.com)
*/
public interface ParameterList {

void registerOutParameter(int index, int sqlType) throws SQLException;

/**
@@ -674,7 +674,6 @@ private void sendFastpathCall(int fnid, SimpleParameterList params)
}
}


pgStream.sendChar('F');
pgStream.sendInteger4(4 + 4 + 2 + 2 * paramCount + 2 + encodedSize + 2);
pgStream.sendInteger4(fnid);
@@ -2026,7 +2025,6 @@ protected void processResults(ResultHandler handler, int flags) throws IOExcepti

LOGGER.log(Level.FINEST, " <=BE ParameterDescription");


DescribeRequest describeData = pendingDescribeStatementQueue.getFirst();
SimpleQuery query = describeData.query;
SimpleParameterList params = describeData.parameterList;
@@ -2101,7 +2099,6 @@ protected void processResults(ResultHandler handler, int flags) throws IOExcepti
pgStream.receiveInteger4(); // len, discarded
LOGGER.log(Level.FINEST, " <=BE PortalSuspended");


ExecuteRequest executeData = pendingExecuteQueue.removeFirst();
SimpleQuery currentQuery = executeData.query;
Portal currentPortal = executeData.portal;
@@ -2128,7 +2125,6 @@ protected void processResults(ResultHandler handler, int flags) throws IOExcepti

doneAfterRowDescNoData = false;


ExecuteRequest executeData = pendingExecuteQueue.peekFirst();
SimpleQuery currentQuery = executeData.query;
Portal currentPortal = executeData.portal;
@@ -2210,7 +2206,6 @@ protected void processResults(ResultHandler handler, int flags) throws IOExcepti
}
}


if (!noResults) {
if (tuples == null) {
tuples = new ArrayList<byte[][]>();
@@ -477,4 +477,3 @@ public String toString() {

private int pos = 0;
}

@@ -136,5 +136,4 @@ private void configureSocketTimeout(CommonOptions options) throws PSQLException
PSQLState.CONNECTION_UNABLE_TO_CONNECT, ioe);
}
}

}
@@ -92,7 +92,6 @@ public Exception run() {
while (!established) {
outToken = secContext.initSecContext(inToken, 0, inToken.length);


if (outToken != null) {
LOGGER.log(Level.FINEST, " FE=> Password(GSS Authentication Token)");

@@ -24,7 +24,6 @@
import javax.security.auth.login.LoginContext;

public class MakeGSS {

private static final Logger LOGGER = Logger.getLogger(MakeGSS.class.getName());

public static void authenticate(PGStream pgStream, String host, String user, String password,
@@ -246,8 +246,6 @@ protected void checkFreed() throws SQLException {
}

protected synchronized LargeObject getLo(boolean forWrite) throws SQLException {


if (this.currentLo != null) {
if (forWrite && !currentLoIsWriteable) {
// Reopen the stream in read-write, at the same pos.
@@ -1582,7 +1582,6 @@ public ResultSet getColumns(String catalog, String schemaPattern, String tableNa
tuple[5] = connection.encodeString(pgType); // Type name
tuple[7] = null; // Buffer length


String defval = rs.getString("adsrc");

if (defval != null) {
@@ -2552,7 +2551,6 @@ public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePa
+ "else null end as base_type "
+ "from pg_catalog.pg_type t, pg_catalog.pg_namespace n where t.typnamespace = n.oid and n.nspname != 'pg_catalog' and n.nspname != 'pg_toast'";


StringBuilder toAdd = new StringBuilder();
if (types != null) {
toAdd.append(" and (false ");
@@ -943,11 +943,8 @@ public synchronized void deleteRow() throws SQLException {
PSQLState.INVALID_CURSOR_STATE);
}


int numKeys = primaryKeys.size();
if (deleteStatement == null) {


StringBuilder deleteSQL =
new StringBuilder("DELETE FROM ").append(onlyTable).append(tableName).append(" where ");

@@ -967,7 +964,6 @@ public synchronized void deleteRow() throws SQLException {
deleteStatement.setObject(i + 1, primaryKeys.get(i).getValue());
}


deleteStatement.executeUpdate();

rows.remove(currentRow);
@@ -1040,8 +1036,6 @@ public synchronized void insertRow() throws SQLException {

// need to clear this in case of another insert
clearRowBuffer(false);


}
}

@@ -1068,13 +1062,11 @@ public synchronized void moveToInsertRow() throws SQLException {
insertStatement = null;
}


// make sure the underlying data is null
clearRowBuffer(false);

onInsertRow = true;
doingUpdates = false;

}

private synchronized void clearRowBuffer(boolean copyCurrentRow) throws SQLException {
@@ -1088,7 +1080,6 @@ private synchronized void clearRowBuffer(boolean copyCurrentRow) throws SQLExcep

// clear the updateValues hash map for the next set of updates
updateValues.clear();

}

public boolean rowDeleted() throws SQLException {
@@ -1252,7 +1243,6 @@ public synchronized void updateObject(int columnIndex, Object x) throws SQLExcep

public synchronized void updateObject(int columnIndex, Object x, int scale) throws SQLException {
this.updateObject(columnIndex, x);

}

@Override
@@ -1299,7 +1289,6 @@ public void refreshRow() throws SQLException {
selectStatement = connection.prepareStatement(sqlText,
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);


for (int j = 0, i = 1; j < numKeys; j++, i++) {
selectStatement.setObject(i, primaryKeys.get(j).getValue());
}
@@ -1318,7 +1307,6 @@ public void refreshRow() throws SQLException {
rs.close();
selectStatement.close();
selectStatement = null;

}

@Override
@@ -1500,7 +1488,6 @@ public synchronized void updateObject(String columnName, Object x) throws SQLExc
updateObject(findColumn(columnName), x);
}


/**
* Is this ResultSet updateable?
*/
@@ -1540,7 +1527,6 @@ boolean isUpdateable() throws SQLException {
// with oids has been removed in version 12
// FIXME: with oids does not automatically create an index, should check for primary keys first


usingOID = false;
int oidIndex = findColumnIndex("oid"); // 0 if not present

@@ -1578,7 +1564,6 @@ boolean isUpdateable() throws SQLException {

connection.getLogger().log(Level.FINE, "no of keys={0}", i);


if (i < 1) {
throw new PSQLException(GT.tr("No primary key found for table {0}.", tableName),
PSQLState.DATA_ERROR);
@@ -1679,7 +1664,6 @@ private void parseQuery() {
}

private void updateRowBuffer() throws SQLException {

for (Map.Entry<String, Object> entry : updateValues.entrySet()) {
int columnIndex = findColumn(entry.getKey()) - 1;

@@ -1107,7 +1107,6 @@ public LocalTime toLocalTimeBin(byte[] bytes) throws PSQLException {
micros = ByteConverter.int8(bytes, 0);
}


return LocalTime.ofNanoOfDay(micros * 1000);
}
//#endif
@@ -70,7 +70,6 @@ private void initPk8(String sslkeyfile, String defaultdir, Properties info) thro
sslcertfile = defaultdir + "postgresql.crt";
}


// If the properties are empty, give null to prevent client key selection
km = new LazyKeyManager(("".equals(sslcertfile) ? null : sslcertfile),
("".equals(sslkeyfile) ? null : sslkeyfile), getCallbackHandler(info), defaultfile);
@@ -111,7 +111,6 @@ private String makeSPN() throws PSQLException {
}
}


/**
* Respond to an authentication request from the back-end for SSPI authentication (AUTH_REQ_SSPI).
*
@@ -55,9 +55,7 @@
* @version 2.1
*/
public class Base64 {

/* ******** P U B L I C F I E L D S ******** */

/**
* No options specified. Value is zero.
*/
@@ -79,7 +77,6 @@ public class Base64 {
public static final int DONT_BREAK_LINES = 8;

/* ******** P R I V A T E F I E L D S ******** */

/**
* Maximum line length (76) of Base64 output.
*/
@@ -180,7 +177,6 @@ private Base64() {
}

/* ******** E N C O D I N G M E T H O D S ******** */

/**
* Encodes up to three bytes of the array <var>source</var> and writes the resulting four Base64
* bytes to <var>destination</var>. The source and destination arrays can be manipulated anywhere
@@ -348,20 +344,16 @@ public static String encodeBytes(byte[] source, int off, int len, int options) {
e += 4;
} // end if: some padding needed


// Return value according to relevant encoding.
try {
return new String(outBuff, 0, e, PREFERRED_ENCODING);
} catch (java.io.UnsupportedEncodingException uue) {
return new String(outBuff, 0, e);
}

}

}

/* ******** D E C O D I N G M E T H O D S ******** */

/**
* Decodes four bytes from array <var>source</var> and writes the resulting bytes (up to three of
* them) to <var>destination</var>. The source and destination arrays can be manipulated anywhere
@@ -415,7 +407,6 @@ private static int decode4to3(byte[] source, int srcOffset, byte[] destination,
| ((DECODABET[source[srcOffset + 2]] & 0xFF) << 6)
| ((DECODABET[source[srcOffset + 3]] & 0xFF));


destination[destOffset] = (byte) (outBuff >> 16);
destination[destOffset + 1] = (byte) (outBuff >> 8);
destination[destOffset + 2] = (byte) (outBuff);
@@ -89,8 +89,6 @@ public int tokenize(String string, char delim) {
}

// Don't forget the last token ;-)


if (s < string.length()) {
tokens.add(string.substring(s));
}
@@ -14,7 +14,6 @@
import java.util.logging.Logger;

public class ServerErrorMessage implements Serializable {

private static final Logger LOGGER = Logger.getLogger(ServerErrorMessage.class.getName());

private static final Character SEVERITY = 'S';
@@ -243,8 +243,5 @@ public void valuesTableParse() throws SQLException {
command = qry.get(0).getCommand();
Assert.assertEquals(43,command.getBatchRewriteValuesBraceOpenPosition());
Assert.assertEquals(49,command.getBatchRewriteValuesBraceClosePosition());



}
}
@@ -336,7 +336,6 @@ public void testApplyLocationDoNotDependOnFlushLocation() throws Exception {
receiveMessageWithoutBlock(stream, 1);
stream.forceUpdateStatus();


LogSequenceNumber flushed = getFlushLocationOnView();
LogSequenceNumber applied = getReplayLocationOnView();

@@ -166,7 +166,6 @@ public void testReceiveChangesAfterStartReplication() throws Exception {
.withSlotOption("skip-empty-xacts", true)
.start();


List<String> result = new ArrayList<String>();

Statement st = sqlConnection.createStatement();
@@ -731,7 +730,6 @@ public void testReplicationRestartFromLastFeedbackPosition() throws Exception {
consumedData.addAll(receiveMessageWithoutBlock(stream, 3));
String result = group(consumedData);


String wait = group(Arrays.asList(
"BEGIN",
"table public.test_logic_table: INSERT: pk[integer]:1 name[character varying]:'first tx changes'",
@@ -473,7 +473,6 @@ public static void createEnumType(Connection con, String name, String values)
try {
dropType(con, name);


// Now create the table
st.executeUpdate("create type " + name + " as enum (" + values + ")");
} finally {

0 comments on commit be5c9f4

Please sign in to comment.