]> source.dussan.org Git - poi.git/commitdiff
Sonar fix - Suppress "Make sure that command line arguments are used safely here...
authorAndreas Beeker <kiwiwings@apache.org>
Mon, 20 Apr 2020 20:57:37 +0000 (20:57 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Mon, 20 Apr 2020 20:57:37 +0000 (20:57 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1876766 13f79535-47bb-0310-9956-ffa450edef68

35 files changed:
src/examples/src/org/apache/poi/hssf/usermodel/examples/EmbeddedObjects.java
src/examples/src/org/apache/poi/hwpf/Word2Forrest.java
src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java
src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java
src/examples/src/org/apache/poi/ss/examples/CalendarDemo.java
src/examples/src/org/apache/poi/ss/examples/CellStyleDetails.java
src/examples/src/org/apache/poi/ss/examples/ConditionalFormats.java
src/examples/src/org/apache/poi/ss/examples/DrawingBorders.java
src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java
src/examples/src/org/apache/poi/ss/examples/LoadEmbedded.java
src/examples/src/org/apache/poi/ss/examples/LoanCalculator.java
src/examples/src/org/apache/poi/ss/examples/SSPerformanceTest.java
src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
src/examples/src/org/apache/poi/ss/examples/ToCSV.java
src/examples/src/org/apache/poi/ss/examples/formula/CheckFunctionsSupported.java
src/examples/src/org/apache/poi/ss/examples/formula/UserDefinedFunctionExample.java
src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java
src/examples/src/org/apache/poi/xslf/usermodel/BarChartDemo.java
src/examples/src/org/apache/poi/xslf/usermodel/ChartFromScratch.java
src/examples/src/org/apache/poi/xslf/usermodel/DataExtraction.java
src/examples/src/org/apache/poi/xslf/usermodel/MergePresentations.java
src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java
src/examples/src/org/apache/poi/xslf/usermodel/tutorial/Step1.java
src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java
src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java
src/examples/src/org/apache/poi/xssf/eventusermodel/examples/LoadPasswordProtectedXlsxStreaming.java
src/examples/src/org/apache/poi/xssf/streaming/examples/SavePasswordProtectedXlsx.java
src/examples/src/org/apache/poi/xssf/usermodel/examples/CustomXMLMapping.java
src/examples/src/org/apache/poi/xssf/usermodel/examples/IterateCells.java
src/examples/src/org/apache/poi/xssf/usermodel/examples/LoadPasswordProtectedXlsx.java
src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java
src/examples/src/org/apache/poi/xwpf/usermodel/examples/BarChartExample.java
src/examples/src/org/apache/poi/xwpf/usermodel/examples/ChartFromScratch.java
src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleImages.java
src/examples/src/org/apache/poi/xwpf/usermodel/examples/UpdateEmbeddedDoc.java

index 7cfedc11529ef3278b7ff570209de2efcf2069db..9c9d0bce6f7732cd5abfe8119afc574244e66aec 100644 (file)
@@ -30,7 +30,7 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 /**
  * Demonstrates how you can extract embedded data from a .xls file
  */
-@SuppressWarnings({"java:S106","java:S4823"})
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
 public final class EmbeddedObjects {
     private EmbeddedObjects() {}
 
index e773efb5d1de4e5f809d2b27497c5c6e4039545f..b26f3c1675ee5a278159236d7c338cebd668958b 100644 (file)
@@ -32,6 +32,7 @@ import org.apache.poi.hwpf.usermodel.CharacterRun;
 import org.apache.poi.hwpf.usermodel.Paragraph;
 import org.apache.poi.hwpf.usermodel.Range;
 
+@SuppressWarnings({"java:S106","java:S4823"})
 public final class Word2Forrest
 {
   Writer _out;
index a9f259233116ece9611ac143037993183397353f..05a8a781216219f75e6f3d7721cddfb23877d72e 100644 (file)
@@ -199,6 +199,7 @@ import org.apache.poi.util.IOUtils;
  *               2mm have been noted in testing. Further investigation will
  *               continue to rectify this issue.
  */
+@SuppressWarnings({"java:S106","java:S4823"})
 public class AddDimensionedImage {
 
     // Four constants that determine how - and indeed whether - the rows
index fbbcab895dc09fafb55d6f5a63719bd6a0ebb53c..0e35509e2840f77f4e794770a51761f2e601baf8 100644 (file)
@@ -45,8 +45,8 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  *
  * @author Yegor Kozlov
  */
-@SuppressWarnings("java:S1192")
-public class BusinessPlan {
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
+public final class BusinessPlan {
 
     private static final String[] titles = {
             "ID", "Project Name", "Owner", "Days", "Start", "End"};
@@ -88,6 +88,8 @@ public class BusinessPlan {
                 null, null, null, null,  null, "x", null, null, null, null, null},
     };
 
+    private BusinessPlan() {}
+
     public static void main(String[] args) throws Exception {
         Workbook wb;
 
index bd7a95d05f8e94f66eb5caecd1300574ec00597e..108cc2596219a166dc266d818835b3781364de00 100644 (file)
 
 package org.apache.poi.ss.examples;
 
-import org.apache.poi.xssf.usermodel.*;
-import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.ss.usermodel.Font;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-
 import java.io.FileOutputStream;
 import java.util.Calendar;
-import java.util.Map;
 import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.FillPatternType;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.usermodel.PrintSetup;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 /**
  * A  monthly calendar created using Apache POI. Each month is on a separate sheet.
@@ -37,7 +47,8 @@ import java.util.HashMap;
  *
  * @author Yegor Kozlov
  */
-public class CalendarDemo {
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
+public final class CalendarDemo {
 
     private static final String[] days = {
             "Sunday", "Monday", "Tuesday",
@@ -47,6 +58,8 @@ public class CalendarDemo {
             "January", "February", "March","April", "May", "June","July", "August",
             "September","October", "November", "December"};
 
+    private CalendarDemo() {}
+
     public static void main(String[] args) throws Exception {
 
         Calendar calendar = Calendar.getInstance();
index e66e6b4c56a77c4450d3f6bf3691c13f9ff0a21d..4729c9fb531f9fad2df16b96362bbd89435e7f8d 100644 (file)
@@ -37,12 +37,15 @@ import org.apache.poi.xssf.usermodel.XSSFFont;
 /**
  * Demonstrates how to read excel styles for cells
  */
-public class CellStyleDetails {
+@SuppressWarnings({"java:S106","java:S4823"})
+public final class CellStyleDetails {
+    private CellStyleDetails() {}
+
     public static void main(String[] args) throws Exception {
         if(args.length == 0) {
            throw new IllegalArgumentException("Filename must be given");
         }
-        
+
         try (Workbook wb = WorkbookFactory.create(new File(args[0]))) {
             DataFormatter formatter = new DataFormatter();
 
@@ -82,7 +85,7 @@ public class CellStyleDetails {
             }
         }
     }
-    
+
     private static String renderColor(Color color) {
        if(color instanceof HSSFColor) {
           return ((HSSFColor)color).getHexString();
index 28a861b6c2e484cf6b081adde35807ae037dea14..ff26f9d17d9a003def1476386a9467ef9ba44399 100644 (file)
@@ -57,8 +57,10 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  *   http://www.contextures.com/xlcondformat03.html
  * </p>
  */
-@SuppressWarnings("java:S1192")
-public class ConditionalFormats {
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
+public final class ConditionalFormats {
+
+    private ConditionalFormats() {}
 
     /**
      * generates a sample workbook with conditional formatting,
index e23fdb73609bc36d91fe62507647d1d5acff08f9..8a4ad94e1ef4654dcf78c8fdd0c674df5e26fd1b 100644 (file)
@@ -36,13 +36,16 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 /**
  * Excel Border Drawing - examples
- * 
+ *
  * <p>
  * Partly based on the code snippets from
  * org.apache.poi.ss.examples.ConditionalFormats
  * </p>
  */
-public class DrawingBorders {
+@SuppressWarnings({"java:S106","java:S4823"})
+public final class DrawingBorders {
+
+    private DrawingBorders() {}
 
     public static void main(String[] args) throws IOException {
         try (Workbook wb = (args.length > 0 && args[0].equals("-xls"))
index 4dfd6f530222d96bf88379b8bf977112400b1d3d..f2cd249ef4547a951106874cc7251771e6435c96 100644 (file)
@@ -80,7 +80,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  *  }
  * </pre>
  */
-@SuppressWarnings("java:S1192")
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
 public class ExcelComparator {
 
     private static final String CELL_DATA_DOES_NOT_MATCH = "Cell Data does not Match ::";
index 4fd640ca70a4cd00e4759ec29892c4fc6e7c0741..34313b07b9077fdf211f66c5305cac3c2c192da5 100644 (file)
@@ -43,12 +43,15 @@ import org.apache.xmlbeans.XmlException;
  * Loads embedded resources from Workbooks. Code taken from the website:
  *  https://poi.apache.org/spreadsheet/quick-guide.html#Embedded
  */
-public class LoadEmbedded {
-   public static void main(String[] args) throws IOException, EncryptedDocumentException, OpenXML4JException, XmlException {
+@SuppressWarnings({"java:S106","java:S4823"})
+public final class LoadEmbedded {
+    private LoadEmbedded() {}
+
+    public static void main(String[] args) throws IOException, EncryptedDocumentException, OpenXML4JException, XmlException {
        Workbook wb = WorkbookFactory.create(new File(args[0]));
        loadEmbedded(wb);
    }
-   
+
    public static void loadEmbedded(Workbook wb) throws IOException, InvalidFormatException, OpenXML4JException, XmlException {
        if (wb instanceof HSSFWorkbook) {
            loadEmbedded((HSSFWorkbook)wb);
@@ -60,7 +63,7 @@ public class LoadEmbedded {
            throw new IllegalArgumentException(wb.getClass().getName());
        }
    }
-   
+
    public static void loadEmbedded(HSSFWorkbook workbook) throws IOException {
        for (HSSFObjectData obj : workbook.getAllEmbeddedObjects()) {
            //the OLE2 Class Name of the object
@@ -92,7 +95,7 @@ public class LoadEmbedded {
            }
        }
    }
-   
+
    public static void loadEmbedded(XSSFWorkbook workbook) throws IOException, InvalidFormatException, OpenXML4JException, XmlException {
        for (PackagePart pPart : workbook.getAllEmbeddedParts()) {
            String contentType = pPart.getContentType();
index 4714090bf11ef29babf2b08868609316515ebad7..079b782b14b1113b5addb2040471fa6b16dbc1b7 100644 (file)
@@ -45,8 +45,10 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  *
  * @author Yegor Kozlov
  */
-@SuppressWarnings("java:S1192")
-public class LoanCalculator {
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
+public final class LoanCalculator {
+
+    private LoanCalculator() {}
 
     public static void main(String[] args) throws Exception {
         Workbook wb;
index 8484c0998c3d62b60391d6d4263e6023d5add9f9..05776bee3e1fdab59927d5273c3792842600c456 100644 (file)
@@ -42,8 +42,10 @@ import org.apache.poi.ss.util.CellReference;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
-@SuppressWarnings("java:S1192")
-public class SSPerformanceTest {
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
+public final class SSPerformanceTest {
+    private SSPerformanceTest() {}
+
     public static void main(String[] args) throws IOException {
         if (args.length < 4) {
             usage("need at least four command arguments");
index 5d65bd353981323c39aab8578254492c63f4c280..5829454ec226e1bda85a9dadea554d4f15656932 100644 (file)
@@ -44,18 +44,20 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  *
  * @author Yegor Kozlov
  */
-@SuppressWarnings("java:S1192")
-public class TimesheetDemo {
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
+public final class TimesheetDemo {
     private static final String[] titles = {
             "Person",  "ID", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",
             "Total\nHrs", "Overtime\nHrs", "Regular\nHrs"
     };
 
-    private static Object[][] sample_data = {
+    private static final Object[][] sample_data = {
             {"Yegor Kozlov", "YK", 5.0, 8.0, 10.0, 5.0, 5.0, 7.0, 6.0},
             {"Gisella Bronzetti", "GB", 4.0, 3.0, 1.0, 3.5, null, null, 4.0},
     };
 
+    private TimesheetDemo() {}
+
     public static void main(String[] args) throws Exception {
         Workbook wb;
 
index 408a6a3ff378297e79176c7d268ce2a069c3a476..a5f8bf5421d5b0116528b1a3342261cd678dadc6 100644 (file)
@@ -129,6 +129,7 @@ import org.apache.poi.ss.usermodel.WorkbookFactory;
  *                                 either obeying Excel's or UNIX formatting
  *                                 conventions.
  */
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
 public class ToCSV {
 
     private Workbook workbook;
index 0e32c29116909b4d6a89b65e32f23e3a9df67226..d2291f009db18c646e7470f64ed90b23cca32125 100644 (file)
@@ -45,6 +45,7 @@ import org.apache.poi.ss.util.CellReference;
  *  files using Apache POI, along with how to handle errors whilst
  *  doing so.
  */
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
 public class CheckFunctionsSupported {
     public static void main(String[] args) throws Exception {
         if (args.length < 1) {
@@ -96,8 +97,8 @@ public class CheckFunctionsSupported {
         }
     }
 
-    private Workbook workbook;
-    private FormulaEvaluator evaluator;
+    private final Workbook workbook;
+    private final FormulaEvaluator evaluator;
     public CheckFunctionsSupported(Workbook workbook) {
         this.workbook = workbook;
         this.evaluator = workbook.getCreationHelper().createFormulaEvaluator();
index a76dbebf1d3f08f5df70b9b20860733e3a2a5add..7f5922b02a9d7fd3c0f386a4a5ba29a6c03f2120 100644 (file)
 ==================================================================== */
 package org.apache.poi.ss.examples.formula;
 
-import java.io.File ;
+import java.io.File;
 
-import org.apache.poi.ss.formula.functions.FreeRefFunction ;
-import org.apache.poi.ss.formula.udf.DefaultUDFFinder ;
-import org.apache.poi.ss.formula.udf.UDFFinder ;
+import org.apache.poi.ss.formula.functions.FreeRefFunction;
+import org.apache.poi.ss.formula.udf.DefaultUDFFinder;
+import org.apache.poi.ss.formula.udf.UDFFinder;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellValue;
 import org.apache.poi.ss.usermodel.FormulaEvaluator;
@@ -28,26 +28,29 @@ import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.usermodel.WorkbookFactory;
-import org.apache.poi.ss.util.CellReference ;
+import org.apache.poi.ss.util.CellReference;
 
 
 /**
  * An example class of how to invoke a User Defined Function for a given
  * XLS instance using POI's UDFFinder implementation.
  */
-public class UserDefinedFunctionExample {
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
+public final class UserDefinedFunctionExample {
+
+    private UserDefinedFunctionExample() {}
+
+    public static void main(String[] args ) throws Exception {
 
-    public static void main( String[] args ) throws Exception {
-        
         if(  args.length != 2 ) {
             // e.g. src/examples/src/org/apache/poi/ss/examples/formula/mortgage-calculation.xls Sheet1!B4
             System.out.println( "usage: UserDefinedFunctionExample fileName cellId" ) ;
             return;
         }
-        
+
         System.out.println( "fileName: " + args[0] ) ;
         System.out.println( "cell: " + args[1] ) ;
-        
+
         File workbookFile = new File( args[0] ) ;
 
         try (Workbook workbook = WorkbookFactory.create(workbookFile, null, true)) {
index 874bce4d7650f677d7f190a437fda4fae2a3c8cc..15fdc2af580e28e5e493943eab0c43803845b69c 100644 (file)
@@ -53,8 +53,8 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  * This example shows how to display a spreadsheet in HTML using the classes for
  * spreadsheet display.
  */
-@SuppressWarnings("java:S1192")
-public class ToHtml {
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
+public final class ToHtml {
     private final Workbook wb;
     private final Appendable output;
     private boolean completeHTML;
index ce17c668cb913d060789aa8f7ffc6a441ae3720e..d717e37ab09dae6ca7dec6116adedc77a172d583 100644 (file)
@@ -41,6 +41,7 @@ import org.apache.poi.xddf.usermodel.chart.XDDFNumericalDataSource;
 /**
  * Build a bar chart from a template pptx
  */
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
 public final class BarChartDemo {
     private BarChartDemo() {}
 
index 5fee24e363d74cbeaf7da36f75e00dd78d1136ef..eb007fc09b7f95841686f51da8c684d79a822406 100644 (file)
@@ -49,6 +49,7 @@ import org.apache.poi.xddf.usermodel.chart.XDDFValueAxis;
 /**
  * Build a chart without reading template file
  */
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
 public final class ChartFromScratch {
     private ChartFromScratch() {}
 
index 806735c4a8cb5c4f1bb6b5dfd58957129078c518..543726a48bebd8503d903d24c3b1c4e3456c2730 100644 (file)
@@ -14,7 +14,7 @@
  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
- * ==================================================================== 
+ * ====================================================================
  */
 
 package org.apache.poi.xslf.usermodel;
@@ -25,16 +25,16 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintStream;
 
-import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.openxml4j.opc.PackagePart;
 
 /**
  * Demonstrates how you can extract data from a .pptx file
  */
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
 public final class DataExtraction {
     private DataExtraction() {}
 
-    public static void main(String[] args) throws IOException, OpenXML4JException {
+    public static void main(String[] args) throws IOException {
 
         PrintStream out = System.out;
 
@@ -42,7 +42,7 @@ public final class DataExtraction {
            out.println("Input file is required");
            return;
         }
-        
+
         FileInputStream is = new FileInputStream(args[0]);
         try (XMLSlideShow ppt = new XMLSlideShow(is)) {
             is.close();
index a4c241e30c5ee389e1401c36f9cdd2807d4dde9b..e295ffd1eefbf1d355f49dde468a89b82be36f6d 100644 (file)
@@ -14,7 +14,7 @@
  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
- * ==================================================================== 
+ * ====================================================================
  */
 
 package org.apache.poi.xslf.usermodel;
@@ -25,6 +25,7 @@ import java.io.FileOutputStream;
 /**
  * Merge multiple pptx presentations together
  */
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
 public final class MergePresentations {
     private MergePresentations() {}
 
index ce920709e61be1b25fac3bf3a70b5d5d9f639e0e..15036a874fba34281c96e8548ca1ef08fad706fa 100644 (file)
@@ -38,6 +38,7 @@ import org.apache.poi.xddf.usermodel.chart.XDDFPieChartData;
 /**
  * Build a pie chart from a template pptx
  */
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
 public final class PieChartDemo {
     private PieChartDemo() {}
 
index c74046b45da7357329f89c46a22b1083646b72a9..6651bcc4f83c243ffd3166fd82842bf9b70fbfbe 100644 (file)
@@ -31,6 +31,7 @@ import org.apache.poi.xslf.usermodel.XSLFTextShape;
 /**
  * Reading a .pptx presentation and printing basic shape properties
  */
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
 public final class Step1 {
     private Step1() {}
 
index 85300de6f4d982b173e48117cbf992674a1ef2a1..8540cb237bd6ae0daef2dbf423160de80dfc20e6 100644 (file)
@@ -61,10 +61,11 @@ import org.xml.sax.XMLReader;
  * For a more advanced implementation of SAX event parsing
  * of XLSX files, see {@link XSSFEventBasedExcelExtractor}
  * and {@link XSSFSheetXMLHandler}. Note that for many cases,
- * it may be possible to simply use those with a custom 
+ * it may be possible to simply use those with a custom
  * {@link SheetContentsHandler} and no SAX code needed of
  * your own!
  */
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
 public class XLSX2CSV {
     /**
      * Uses the XSSF Event SAX helpers to do most of the work
@@ -75,7 +76,7 @@ public class XLSX2CSV {
         private boolean firstCellOfRow;
         private int currentRow = -1;
         private int currentCol = -1;
-        
+
         private void outputMissingRows(int number) {
             for (int i=0; i<number; i++) {
                 for (int j=0; j<minColumns; j++) {
@@ -125,7 +126,7 @@ public class XLSX2CSV {
                 output.append(',');
             }
             currentCol = thisCol;
-            
+
             // Number or string?
             try {
                 //noinspection ResultOfMethodCallIgnored
@@ -183,7 +184,7 @@ public class XLSX2CSV {
     public void processSheet(
             Styles styles,
             SharedStrings strings,
-            SheetContentsHandler sheetHandler, 
+            SheetContentsHandler sheetHandler,
             InputStream sheetInputStream) throws IOException, SAXException {
         DataFormatter formatter = new DataFormatter();
         InputSource sheetSource = new InputSource(sheetInputStream);
index f45cac0a917c4fb98e97bb5aa956a2696b4246af..154a5a80ae2db798567d61eb75cd229e9331c097 100644 (file)
@@ -42,6 +42,7 @@ import org.xml.sax.helpers.DefaultHandler;
  * See {@link XLSX2CSV} for a fuller example of doing
  *  XSLX processing with the XSSF Event code.
  */
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
 public class FromHowTo {
     public void processFirstSheet(String filename) throws Exception {
         try (OPCPackage pkg = OPCPackage.open(filename, PackageAccess.READ)) {
index 2e7df6c4412ac8c7fb9875e7c616714dd8dcd6fe..7a3ad6b02237cf2ab650240393d5b5e38ccbf5a7 100644 (file)
@@ -35,10 +35,10 @@ import org.apache.poi.xssf.usermodel.examples.LoadPasswordProtectedXlsx;
  * <li><code>AesZipFileZipEntrySource</code> is used to ensure that temp files are encrypted.
  * </ul><p>
  */
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
 public final class LoadPasswordProtectedXlsxStreaming {
 
-    private LoadPasswordProtectedXlsxStreaming() {
-    }
+    private LoadPasswordProtectedXlsxStreaming() {}
 
     public static void main(String[] args) throws Exception {
         LoadPasswordProtectedXlsx.execute(args, LoadPasswordProtectedXlsxStreaming::printSheetCount);
index f91141c78f7bbab02c7331b12c752aa06ad3c61a..a20c87e825bd94fa069860aa748953a860af8881 100644 (file)
@@ -46,7 +46,10 @@ import org.apache.poi.xssf.streaming.SXSSFSheet;
  * <li><code>SXSSFWorkbookWithCustomZipEntrySource</code> extends SXSSFWorkbook to ensure temp files are encrypted.
  * </ul><p>
  */
-public class SavePasswordProtectedXlsx {
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
+public final class SavePasswordProtectedXlsx {
+
+    private SavePasswordProtectedXlsx() {}
 
     public static void main(String[] args) throws Exception {
         if(args.length != 2) {
@@ -81,7 +84,7 @@ public class SavePasswordProtectedXlsx {
         }
         TempFileUtils.checkTempFiles();
     }
-    
+
     public static void save(final InputStream inputStream, final String filename, final String pwd)
             throws InvalidFormatException, IOException, GeneralSecurityException {
 
index 70b235413ff03a300c1de9bf5dc4408d0878344d..9f2ab3d4b7e61b5aae87665f324c9c036324d8c5 100644 (file)
 ==================================================================== */
 package org.apache.poi.xssf.usermodel.examples;
 
+import java.io.ByteArrayOutputStream;
+
 import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.xssf.extractor.XSSFExportToXml;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.apache.poi.xssf.usermodel.XSSFMap;
-
-import java.io.ByteArrayOutputStream;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 /**
  * Print all custom XML mappings registered in the given workbook
  */
-public class CustomXMLMapping {
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
+public final class CustomXMLMapping {
+
+    private CustomXMLMapping() {}
 
     public static void main(String[] args) throws Exception {
         try (OPCPackage pkg = OPCPackage.open(args[0]);
index 0d30923852565815ed7456f37e104a280a6b3505..b7f2930ffc6aeb4968f92fd23504d12ffd659e75 100644 (file)
@@ -29,7 +29,10 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 /**
  *  Iterate over rows and cells
  */
-public class IterateCells {
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
+public final class IterateCells {
+
+    private IterateCells() {}
 
     public static void main(String[] args) throws IOException {
         try (
index 50149bdae77fc4910f23980103b77f7cab7cef71..7afe88f00e0c72dea6bd4888763b382655f4a54e 100644 (file)
@@ -37,8 +37,11 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  * <li><code>AesZipFileZipEntrySource</code> is used to ensure that temp files are encrypted.
  * </ul><p>
  */
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
 public final class LoadPasswordProtectedXlsx {
 
+    private LoadPasswordProtectedXlsx() {}
+
     public interface EncryptionHandler {
         void handle(final InputStream inputStream) throws Exception;
     }
index f0d9ebde3765deb2d9dc721056a39c038beed780..0bee5e73e9c883a32b9409ceeccf34fd6260284f 100644 (file)
@@ -35,7 +35,10 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 /**
  * Demonstrates how to insert pictures in a SpreadsheetML document
  */
-public class WorkingWithPictures {
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
+public final class WorkingWithPictures {
+    private WorkingWithPictures() {}
+
     public static void main(String[] args) throws IOException {
 
         //create a new workbook
index 2b2d176f12109e8008c1da1a5b59304e10c5b450..2301687c471e14e71f8717b88b42c15b33e11fb8 100644 (file)
@@ -43,6 +43,7 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument;
 /**
  * Build a bar chart from a template docx
  */
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
 public final class BarChartExample {
     private BarChartExample() {}
 
index 6e4418f816c3698a262f937bd4d7edececacba6c..266466c1416c1bb60539893d4464ef99eff3e3ff 100644 (file)
@@ -49,6 +49,7 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument;
 /**
  * Build a chart without reading template file
  */
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
 public final class ChartFromScratch {
     private ChartFromScratch() {}
 
index 2ebcb354bf3a472ed7abacde0c88252cc6709da3..9e379955e25739589de1182504ed916590417b21 100644 (file)
@@ -33,6 +33,7 @@ import org.apache.poi.xwpf.usermodel.XWPFRun;
 /**
  * Demonstrates how to add pictures in a .docx document
  */
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
 public final class SimpleImages {
 
     private SimpleImages() {}
index c21f595d130eced7fb82c4c8abdf6fe198966f10..af0eefde463403d3203f787e65c886760653bf70 100644 (file)
@@ -42,10 +42,11 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument;
  * embedded into a WordprocessingML document. Note that the test has currently
  * only been conducted with a binary Excel workbook and NOT yet with a
  * SpreadsheetML workbook embedded into the document.<p>
- * 
+ *
  * This code was successfully tested with the following file from the POI test collection:
  * http://svn.apache.org/repos/asf/poi/trunk/test-data/document/EmbeddedDocument.docx
  */
+@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
 public class UpdateEmbeddedDoc {
 
     private XWPFDocument doc;