Skip to content

Commit

Permalink
Merge pull request #470 from JamieMagee/redundant-if-statement
Browse files Browse the repository at this point in the history
Remove redundant if/else statements
  • Loading branch information
cheenamalhotra authored Sep 21, 2017
2 parents 8b261f9 + 6291ec0 commit f56f198
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ public final class SQLServerColumnEncryptionCertificateStoreProvider extends SQL
static final String myCertificateStore = "My";

static {
if (System.getProperty("os.name").toLowerCase(Locale.ENGLISH).startsWith("windows")) {
isWindows = true;
}
else {
isWindows = false;
}
isWindows = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).startsWith("windows");
}
private Path keyStoreDirectoryPath = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1968,10 +1968,7 @@ else if (name.equals(SQLServerDriverIntProperty.PORT_NUMBER.toString())) {
case ResultSet.TYPE_SCROLL_INSENSITIVE:
// case SQLServerResultSet.TYPE_SS_SCROLL_STATIC: sensitive synonym
case SQLServerResultSet.TYPE_SS_DIRECT_FORWARD_ONLY:
if (ResultSet.CONCUR_READ_ONLY == concurrency)
return true;
else
return false;
return ResultSet.CONCUR_READ_ONLY == concurrency;
}
// per spec if we do not know we do not support.
return false;
Expand All @@ -1980,60 +1977,48 @@ else if (name.equals(SQLServerDriverIntProperty.PORT_NUMBER.toString())) {
/* L0 */ public boolean ownUpdatesAreVisible(int type) throws SQLServerException {
checkClosed();
checkResultType(type);
if (type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
return type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
|| SQLServerResultSet.TYPE_SCROLL_SENSITIVE == type || SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type)
return true;
return false;
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type;
}

/* L0 */ public boolean ownDeletesAreVisible(int type) throws SQLServerException {
checkClosed();
checkResultType(type);
if (type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
return type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
|| SQLServerResultSet.TYPE_SCROLL_SENSITIVE == type || SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type)
return true;
return false;
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type;
}

/* L0 */ public boolean ownInsertsAreVisible(int type) throws SQLServerException {
checkClosed();
checkResultType(type);
if (type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
return type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
|| SQLServerResultSet.TYPE_SCROLL_SENSITIVE == type || SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type)
return true;
return false;
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type;
}

/* L0 */ public boolean othersUpdatesAreVisible(int type) throws SQLServerException {
checkClosed();
checkResultType(type);
if (type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
return type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
|| SQLServerResultSet.TYPE_SCROLL_SENSITIVE == type || SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type)
return true;
return false;
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type;
}

/* L0 */ public boolean othersDeletesAreVisible(int type) throws SQLServerException {
checkClosed();
checkResultType(type);
if (type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
return type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
|| SQLServerResultSet.TYPE_SCROLL_SENSITIVE == type || SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type)
return true;
return false;
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type;
}

/* L0 */ public boolean othersInsertsAreVisible(int type) throws SQLServerException {
checkClosed();
checkResultType(type);
if (type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type)
return true;
return false;
return type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type;
}

/* L0 */ public boolean updatesAreDetected(int type) throws SQLServerException {
Expand All @@ -2045,10 +2030,7 @@ else if (name.equals(SQLServerDriverIntProperty.PORT_NUMBER.toString())) {
/* L0 */ public boolean deletesAreDetected(int type) throws SQLServerException {
checkClosed();
checkResultType(type);
if (SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type)
return true;
else
return false;
return SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type;
}

// Check the result types to make sure the user does not pass a bad value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,12 +581,7 @@ private void checkClosed() throws SQLServerException {
rsProcedureMeta = s.executeQueryInternal("exec sp_sproc_columns " + sProc + ", @ODBCVer=3");

// if rsProcedureMeta has next row, it means the stored procedure is found
if (rsProcedureMeta.next()) {
procedureIsFound = true;
}
else {
procedureIsFound = false;
}
procedureIsFound = rsProcedureMeta.next();
rsProcedureMeta.beforeFirst();

// Sixth is DATA_TYPE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6280,8 +6280,7 @@ boolean onRow(TDSReader tdsReader) throws SQLServerException {

// Consume the ROW token, leaving tdsReader at the start of
// this row's column values.
if (TDS.TDS_ROW != tdsReader.readUnsignedByte())
assert false;
assert TDS.TDS_ROW == tdsReader.readUnsignedByte();
fetchBufferCurrentRowType = RowType.ROW;
return false;
}
Expand All @@ -6291,8 +6290,7 @@ boolean onNBCRow(TDSReader tdsReader) throws SQLServerException {

// Consume the NBCROW token, leaving tdsReader at the start of
// nullbitmap.
if (TDS.TDS_NBCROW != tdsReader.readUnsignedByte())
assert false;
assert TDS.TDS_NBCROW == tdsReader.readUnsignedByte();

fetchBufferCurrentRowType = RowType.NBCROW;
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ final class StreamColInfo extends StreamPacket {
}

void setFromTDS(TDSReader tdsReader) throws SQLServerException {
if (TDS.TDS_COLINFO != tdsReader.readUnsignedByte())
assert false : "Not a COLINFO token";
assert TDS.TDS_COLINFO == tdsReader.readUnsignedByte() : "Not a COLINFO token";

this.tdsReader = tdsReader;
int tokenLength = tdsReader.readUnsignedShort();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ CryptoMetadata readCryptoMetadata(TDSReader tdsReader) throws SQLServerException
* @throws SQLServerException
*/
void setFromTDS(TDSReader tdsReader) throws SQLServerException {
if (TDS.TDS_COLMETADATA != tdsReader.readUnsignedByte())
assert false;
assert TDS.TDS_COLMETADATA == tdsReader.readUnsignedByte();

int nTotColumns = tdsReader.readUnsignedShort();

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/microsoft/sqlserver/jdbc/StreamError.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ final int getErrorSeverity() {
}

void setFromTDS(TDSReader tdsReader) throws SQLServerException {
if (TDS.TDS_ERR != tdsReader.readUnsignedByte())
assert false;
assert TDS.TDS_ERR == tdsReader.readUnsignedByte();
setContentsFromTDS(tdsReader);
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/microsoft/sqlserver/jdbc/StreamInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ final class StreamInfo extends StreamPacket {
}

void setFromTDS(TDSReader tdsReader) throws SQLServerException {
if (TDS.TDS_MSG != tdsReader.readUnsignedByte())
assert false;
assert TDS.TDS_MSG == tdsReader.readUnsignedByte();
msg.setContentsFromTDS(tdsReader);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ final class StreamLoginAck extends StreamPacket {
}

void setFromTDS(TDSReader tdsReader) throws SQLServerException {
if (TDS.TDS_LOGIN_ACK != tdsReader.readUnsignedByte())
assert false;
assert TDS.TDS_LOGIN_ACK == tdsReader.readUnsignedByte();
tdsReader.readUnsignedShort(); // length of this token stream
tdsReader.readUnsignedByte(); // SQL version accepted by the server
tdsVersion = tdsReader.readIntBigEndian(); // TDS version accepted by the server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ final int getStatus() {
}

void setFromTDS(TDSReader tdsReader) throws SQLServerException {
if (TDS.TDS_RET_STAT != tdsReader.readUnsignedByte())
assert false;
assert TDS.TDS_RET_STAT == tdsReader.readUnsignedByte();
status = tdsReader.readInt();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ final int getOrdinalOrLength() {
}

void setFromTDS(TDSReader tdsReader) throws SQLServerException {
if (TDS.TDS_RETURN_VALUE != tdsReader.readUnsignedByte())
assert false;
assert TDS.TDS_RETURN_VALUE == tdsReader.readUnsignedByte();
ordinalOrLength = tdsReader.readUnsignedShort();
paramName = tdsReader.readUnicodeString(tdsReader.readUnsignedByte());
status = tdsReader.readUnsignedByte();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/microsoft/sqlserver/jdbc/StreamSSPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ final class StreamSSPI extends StreamPacket {
}

void setFromTDS(TDSReader tdsReader) throws SQLServerException {
if (TDS.TDS_SSPI != tdsReader.readUnsignedByte())
assert false;
assert TDS.TDS_SSPI == tdsReader.readUnsignedByte();
int blobLength = tdsReader.readUnsignedShort();
sspiBlob = new byte[blobLength];
tdsReader.readBytes(sspiBlob, 0, blobLength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ final class StreamTabName extends StreamPacket {
}

void setFromTDS(TDSReader tdsReader) throws SQLServerException {
if (TDS.TDS_TABNAME != tdsReader.readUnsignedByte())
assert false : "Not a TABNAME token";
assert TDS.TDS_TABNAME == tdsReader.readUnsignedByte() : "Not a TABNAME token";

this.tdsReader = tdsReader;
int tokenLength = tdsReader.readUnsignedShort();
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/com/microsoft/sqlserver/jdbc/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -790,10 +790,7 @@ static final String readGUID(byte[] inputGUID) throws SQLServerException {
static boolean IsActivityTraceOn() {
LogManager lm = LogManager.getLogManager();
String activityTrace = lm.getProperty(ActivityIdTraceProperty);
if ("on".equalsIgnoreCase(activityTrace))
return true;
else
return false;
return "on".equalsIgnoreCase(activityTrace);
}

/**
Expand Down

0 comments on commit f56f198

Please sign in to comment.