Author: tilman
Date: Mon Dec 16 19:33:52 2019
New Revision: 1871679

URL: http://svn.apache.org/viewvc?rev=1871679&view=rev
Log:
PDFBOX-4071: Sonar fix: merge if statement / collapsible "if" statements

Modified:
    
pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/interactive/form/PrintFields.java
    
pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomPageDrawer.java
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java
    
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java
    
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationStamp.java
    
pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java

Modified: 
pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/interactive/form/PrintFields.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/interactive/form/PrintFields.java?rev=1871679&r1=1871678&r2=1871679&view=diff
==============================================================================
--- 
pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/interactive/form/PrintFields.java
 (original)
+++ 
pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/interactive/form/PrintFields.java
 Mon Dec 16 19:33:52 2019
@@ -61,12 +61,9 @@ public class PrintFields
         
         if (field instanceof PDNonTerminalField)
         {
-            if (!sParent.equals(field.getPartialName()))
+            if (!sParent.equals(field.getPartialName()) && partialName != null)
             {
-                if (partialName != null)
-                {
-                    sParent = sParent + "." + partialName;
-                }
+                sParent = sParent + "." + partialName;
             }
             System.out.println(sLevel + sParent);
 

Modified: 
pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomPageDrawer.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomPageDrawer.java?rev=1871679&r1=1871678&r2=1871679&view=diff
==============================================================================
--- 
pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomPageDrawer.java
 (original)
+++ 
pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomPageDrawer.java
 Mon Dec 16 19:33:52 2019
@@ -96,15 +96,12 @@ public class CustomPageDrawer
         @Override
         protected Paint getPaint(PDColor color) throws IOException
         {
-            // if this is the non-stroking color
-            if (getGraphicsState().getNonStrokingColor() == color)
+            // if this is the non-stroking color, find red, ignoring alpha 
channel
+            if (getGraphicsState().getNonStrokingColor() == color &&
+                color.toRGB() == (Color.RED.getRGB() & 0x00FFFFFF))
             {
-                // find red, ignoring alpha channel
-                if (color.toRGB() == (Color.RED.getRGB() & 0x00FFFFFF))
-                {
-                    // replace it with blue
-                    return Color.BLUE;
-                }
+                // replace it with blue
+                return Color.BLUE;
             }
             return super.getPaint(color);
         }

Modified: 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java?rev=1871679&r1=1871678&r2=1871679&view=diff
==============================================================================
--- 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java 
(original)
+++ 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java 
Mon Dec 16 19:33:52 2019
@@ -105,14 +105,11 @@ public class COSFloat extends COSNumber
             }
         }
         // check for very small values
-        else if (floatValue == 0 && doubleValue != 0)
+        else if (floatValue == 0 && doubleValue != 0 && Math.abs(doubleValue) 
< Float.MIN_NORMAL)
         {
-            if (Math.abs(doubleValue) < Float.MIN_NORMAL )
-            {
-                floatValue = Float.MIN_NORMAL;
-                floatValue *= doubleValue >= 0  ? 1 : -1;
-                valueReplaced = true;
-            }
+            floatValue = Float.MIN_NORMAL;
+            floatValue *= doubleValue >= 0 ? 1 : -1;
+            valueReplaced = true;
         }
         if (valueReplaced)
         {

Modified: 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java?rev=1871679&r1=1871678&r2=1871679&view=diff
==============================================================================
--- 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java 
(original)
+++ 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/io/ScratchFile.java 
Mon Dec 16 19:33:52 2019
@@ -509,15 +509,9 @@ public class ScratchFile implements Clos
                 }
             }
             
-            if (file != null)
+            if (file != null && !file.delete() && file.exists() && ioexc == 
null)
             {
-                if (!file.delete())
-                {
-                    if (file.exists() && (ioexc == null))
-                    {
-                        ioexc = new IOException("Error deleting scratch file: 
" + file.getAbsolutePath());
-                    }
-                }
+                ioexc = new IOException("Error deleting scratch file: " + 
file.getAbsolutePath());
             }
         }
         

Modified: 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationStamp.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationStamp.java?rev=1871679&r1=1871678&r2=1871679&view=diff
==============================================================================
--- 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationStamp.java
 (original)
+++ 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationStamp.java
 Mon Dec 16 19:33:52 2019
@@ -296,21 +296,15 @@ public class FDFAnnotationStamp extends
         NodeList nodeList = arrayEl.getChildNodes();
         String parentAttrKey = arrayEl.getAttribute("KEY");
 
-        if ("BBox".equals(parentAttrKey))
+        if ("BBox".equals(parentAttrKey) && nodeList.getLength() < 4)
         {
-            if (nodeList.getLength() < 4)
-            {
-                throw new IOException("BBox does not have enough coordinates, 
only has: " +
-                        nodeList.getLength());
-            }
+            throw new IOException("BBox does not have enough coordinates, only 
has: " +
+                    nodeList.getLength());
         }
-        else if ("Matrix".equals(parentAttrKey))
+        else if ("Matrix".equals(parentAttrKey) && nodeList.getLength() < 6)
         {
-            if (nodeList.getLength() < 6)
-            {
-                throw new IOException("Matrix does not have enough 
coordinates, only has: " + 
-                        nodeList.getLength());
-            }
+            throw new IOException("Matrix does not have enough coordinates, 
only has: " + 
+                    nodeList.getLength());
         }
 
         for (int i = 0; i < nodeList.getLength(); i++)

Modified: 
pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java?rev=1871679&r1=1871678&r2=1871679&view=diff
==============================================================================
--- 
pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
 (original)
+++ 
pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
 Mon Dec 16 19:33:52 2019
@@ -820,16 +820,13 @@ public class PreflightParser extends PDF
                     endObjectKey = readString();
 
                     // we have case with a second 'endstream' before endobj
-                    if (!endObjectKey.startsWith("endobj"))
+                    if (!endObjectKey.startsWith("endobj") && 
endObjectKey.startsWith("endstream"))
                     {
-                        if (endObjectKey.startsWith("endstream"))
+                        endObjectKey = endObjectKey.substring(9).trim();
+                        if (endObjectKey.length() == 0)
                         {
-                            endObjectKey = endObjectKey.substring(9).trim();
-                            if (endObjectKey.length() == 0)
-                            {
-                                // no other characters in extra endstream line
-                                endObjectKey = readString(); // read next line
-                            }
+                            // no other characters in extra endstream line
+                            endObjectKey = readString(); // read next line
                         }
                     }
                 }


Reply via email to