]> source.dussan.org Git - poi.git/commitdiff
SonarCube fixes
authorAndreas Beeker <kiwiwings@apache.org>
Sat, 12 Nov 2016 00:52:10 +0000 (00:52 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sat, 12 Nov 2016 00:52:10 +0000 (00:52 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1769366 13f79535-47bb-0310-9956-ffa450edef68

src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java
src/examples/src/org/apache/poi/ss/examples/ToCSV.java
src/java/org/apache/poi/ss/formula/atp/NetworkdaysFunction.java
src/java/org/apache/poi/ss/formula/function/FunctionMetadata.java
src/java/org/apache/poi/ss/formula/function/FunctionMetadataRegistry.java
src/ooxml/java/org/apache/poi/util/OOXMLLite.java

index d6f846a6bb0c8756050cf1cedeb702ea185c5939..5ed404e2d3db2d1c82afba5317470b58c6d7064a 100644 (file)
@@ -318,9 +318,7 @@ public class ExcelComparator {
             \r
             if (!name1.equals(name2)) {\r
                 String str = String.format(Locale.ROOT, "%s\nworkbook1 -> %s [%d] != workbook2 -> %s [%d]",\r
-                    "Name of the sheets do not match ::",\r
-                    loc1.sheet.getSheetName(), name1, i+1,\r
-                    loc2.sheet.getSheetName(), name2, i+1\r
+                    "Name of the sheets do not match ::", name1, i+1, name2, i+1\r
                 );\r
                 listOfDifferences.add(str);\r
             }\r
index 532b89c0f7692363354c64db75647165d785d923..b6c5ea97298359e2baa53a2e6dc24ddf631c7d0f 100644 (file)
@@ -344,23 +344,25 @@ public class ToCSV {
         // (.xls) and the other a SpreadsheetML file (.xlsx), then the names
         // for both CSV files will be identical and one CSV file will,
         // therefore, over-write the other.
-        for(File excelFile : filesList) {
-            // Open the workbook
-            this.openWorkbook(excelFile);
-
-            // Convert it's contents into a CSV file
-            this.convertToCSV();
-
-            // Build the name of the csv folder from that of the Excel workbook.
-            // Simply replace the .xls or .xlsx file extension with .csv
-            destinationFilename = excelFile.getName();
-            destinationFilename = destinationFilename.substring(
-                    0, destinationFilename.lastIndexOf(".")) +
-                    ToCSV.CSV_FILE_EXTENSION;
-
-            // Save the CSV file away using the newly constricted file name
-            // and to the specified directory.
-            this.saveCSVFile(new File(destination, destinationFilename));
+        if (filesList != null) {
+            for(File excelFile : filesList) {
+                // Open the workbook
+                this.openWorkbook(excelFile);
+    
+                // Convert it's contents into a CSV file
+                this.convertToCSV();
+    
+                // Build the name of the csv folder from that of the Excel workbook.
+                // Simply replace the .xls or .xlsx file extension with .csv
+                destinationFilename = excelFile.getName();
+                destinationFilename = destinationFilename.substring(
+                        0, destinationFilename.lastIndexOf(".")) +
+                        ToCSV.CSV_FILE_EXTENSION;
+    
+                // Save the CSV file away using the newly constricted file name
+                // and to the specified directory.
+                this.saveCSVFile(new File(destination, destinationFilename));
+            }
         }
     }
 
index 6c07ed9d39dcd41f02d781e1f0693e580a9eec80..95e0548643f4cf71cd1676832107022d814dc553 100644 (file)
@@ -58,7 +58,7 @@ final class NetworkdaysFunction implements FreeRefFunction {
      * 
      * @return {@link ValueEval} for the number of days between two dates.
      */
-    public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
+    public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) { // NOSONAR
         if (args.length < 2 || args.length > 3) {
             return ErrorEval.VALUE_INVALID;
         }
index 0a72bba384720593a0716e9b710df6f4efb52a1c..6ab06f0ad8711ce264f4812c9fb98b8566d35556 100644 (file)
@@ -47,7 +47,7 @@ public final class FunctionMetadata {
                _minParams = minParams;
                _maxParams = maxParams;
                _returnClassCode = returnClassCode;
-               _parameterClassCodes = parameterClassCodes;
+               _parameterClassCodes = (parameterClassCodes == null) ? null : parameterClassCodes.clone();
        }
        public int getIndex() {
                return _index;
index bbe9ecfd80b0065dbe2d0964008caf2538a5d494..34317fe6d8f8448d140e3ba3105fc1441b6e8579 100644 (file)
@@ -49,7 +49,7 @@ public final class FunctionMetadataRegistry {
        }
 
        /* package */ FunctionMetadataRegistry(FunctionMetadata[] functionDataByIndex, Map<String, FunctionMetadata> functionDataByName) {
-               _functionDataByIndex = functionDataByIndex;
+               _functionDataByIndex = (functionDataByIndex == null) ? null : functionDataByIndex.clone();
                _functionDataByName = functionDataByName;
        }
 
index c8d3610498fd7ab8726ee119fe54a23777e2674f..c42ba5e03811d612ddb32b64579640db867a9c29 100644 (file)
@@ -207,8 +207,11 @@ public final class OOXMLLite {
     private static void collectTests(File root, File arg, List<Class<?>> out, String ptrn, String exclude)
     throws ClassNotFoundException {
         if (arg.isDirectory()) {
-            for (File f : arg.listFiles()) {
-                collectTests(root, f, out, ptrn, exclude);
+            File files[] = arg.listFiles();
+            if (files != null) {
+                for (File f : files) {
+                    collectTests(root, f, out, ptrn, exclude);
+                }
             }
         } else {
             String path = arg.getAbsolutePath();