Skip to content

Commit 0793324

Browse files
committed
refine conditions
1 parent 8fbe396 commit 0793324

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

poi-examples/src/main/java/org/apache/poi/examples/hsmf/Msg2txt.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void processAttachment(AttachmentChunks attachment,
141141
* @param args the list of MSG files to process
142142
*/
143143
public static void main(String[] args) {
144-
if(args.length <= 0) {
144+
if(args.length == 0) {
145145
System.err.println("No files names provided");
146146
} else {
147147
for (String arg : args) {

poi-ooxml/src/main/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public XWPFHeaderFooterPolicy(XWPFDocument doc, CTSectPr sectPr) {
110110
CTHdrFtrRef ref = sectPr.getHeaderReferenceArray(i);
111111
POIXMLDocumentPart relatedPart = doc.getRelationById(ref.getId());
112112
XWPFHeader hdr = null;
113-
if (relatedPart != null && relatedPart instanceof XWPFHeader) {
113+
if (relatedPart instanceof XWPFHeader) {
114114
hdr = (XWPFHeader) relatedPart;
115115
}
116116
// Assign it; treat invalid options as "default" POI-60293
@@ -128,7 +128,7 @@ public XWPFHeaderFooterPolicy(XWPFDocument doc, CTSectPr sectPr) {
128128
CTHdrFtrRef ref = sectPr.getFooterReferenceArray(i);
129129
POIXMLDocumentPart relatedPart = doc.getRelationById(ref.getId());
130130
XWPFFooter ftr = null;
131-
if (relatedPart != null && relatedPart instanceof XWPFFooter) {
131+
if (relatedPart instanceof XWPFFooter) {
132132
ftr = (XWPFFooter) relatedPart;
133133
}
134134
// Assign it; treat invalid options as "default" POI-60293

poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public String addPictureData(InputStream is, int format) throws InvalidFormatExc
290290
*/
291291
public XWPFPictureData getPictureDataByID(String blipID) {
292292
POIXMLDocumentPart relatedPart = getRelationById(blipID);
293-
if (relatedPart != null && relatedPart instanceof XWPFPictureData) {
293+
if (relatedPart instanceof XWPFPictureData) {
294294
return (XWPFPictureData) relatedPart;
295295
}
296296
return null;

poi/src/main/java/org/apache/poi/hpsf/TypedPropertyValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ static void skipPadding( LittleEndianByteArrayInputStream lei ) {
255255
for (int i=0; i<skipBytes; i++) {
256256
lei.mark(1);
257257
int b = lei.read();
258-
if (b == -1 || b != 0) {
258+
if (b != 0) {
259259
lei.reset();
260260
break;
261261
}

poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFSheet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2552,7 +2552,7 @@ private void setRepeatingRowsAndColumns(
25522552
if (rowDef != null) {
25532553
row1 = rowDef.getFirstRow();
25542554
row2 = rowDef.getLastRow();
2555-
if ((row1 == -1 && row2 != -1) || (row1 > row2)
2555+
if ((row1 > row2)
25562556
|| (row1 < 0 || row1 > maxRowIndex)
25572557
|| (row2 < 0 || row2 > maxRowIndex)) {
25582558
throw new IllegalArgumentException("Invalid row range specification");
@@ -2561,7 +2561,7 @@ private void setRepeatingRowsAndColumns(
25612561
if (colDef != null) {
25622562
col1 = colDef.getFirstColumn();
25632563
col2 = colDef.getLastColumn();
2564-
if ((col1 == -1 && col2 != -1) || (col1 > col2)
2564+
if ((col1 > col2)
25652565
|| (col1 < 0 || col1 > maxColIndex)
25662566
|| (col2 < 0 || col2 > maxColIndex)) {
25672567
throw new IllegalArgumentException("Invalid column range specification");

poi/src/main/java/org/apache/poi/ss/formula/eval/FunctionEval.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ public static Collection<String> getNotSupportedFunctionNames() {
428428
Collection<String> lst = new TreeSet<>();
429429
for (int i = 0; i < functions.length; i++) {
430430
Function func = functions[i];
431-
if (func != null && (func instanceof NotImplementedFunction)) {
431+
if ((func instanceof NotImplementedFunction)) {
432432
FunctionMetadata metaData = FunctionMetadataRegistry.getFunctionByIndex(i);
433433
lst.add(metaData.getName());
434434
}

poi/src/main/java/org/apache/poi/ss/formula/functions/MathX.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ public static double tanh(double d) {
414414
*/
415415
public static double nChooseK(int n, int k) {
416416
double d = 1;
417-
if (n<0 || k<0 || n<k) {
417+
if (k < 0 || n < k) {
418418
d= Double.NaN;
419419
}
420420
else {

0 commit comments

Comments
 (0)