aboutsummaryrefslogtreecommitdiffstats
path: root/poi/src
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2021-10-17 20:44:36 +0000
committerAndreas Beeker <kiwiwings@apache.org>2021-10-17 20:44:36 +0000
commit87a764956c280960f6117eee1bfb351d94c3a23b (patch)
treec5518744cfb432bb519882f354fafba4921e38aa /poi/src
parentb20897a996059e6df7d651ff28361a0c22c7ef1d (diff)
downloadpoi-87a764956c280960f6117eee1bfb351d94c3a23b.tar.gz
poi-87a764956c280960f6117eee1bfb351d94c3a23b.zip
sonar fixes
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894331 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi/src')
-rw-r--r--poi/src/main/java/org/apache/poi/extractor/MainExtractorFactory.java1
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java3
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/record/DConRefRecord.java38
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFWorkbookFactory.java3
-rw-r--r--poi/src/main/java/org/apache/poi/sl/draw/geom/GuideIf.java12
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/WorkbookEvaluator.java9
-rw-r--r--poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java2
-rw-r--r--poi/src/test/java9/module-info.classbin4145 -> 4198 bytes
8 files changed, 37 insertions, 31 deletions
diff --git a/poi/src/main/java/org/apache/poi/extractor/MainExtractorFactory.java b/poi/src/main/java/org/apache/poi/extractor/MainExtractorFactory.java
index d485f864ff..89815bfd9e 100644
--- a/poi/src/main/java/org/apache/poi/extractor/MainExtractorFactory.java
+++ b/poi/src/main/java/org/apache/poi/extractor/MainExtractorFactory.java
@@ -52,6 +52,7 @@ public class MainExtractorFactory implements ExtractorProvider {
return create(new POIFSFileSystem(inputStream).getRoot(), password);
}
+ @SuppressWarnings("java:S2093")
@Override
public POITextExtractor create(DirectoryNode poifsDir, String password) throws IOException {
final String oldPW = Biff8EncryptionKey.getCurrentUserPassword();
diff --git a/poi/src/main/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java b/poi/src/main/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java
index 4bca11d9d5..7d359c228b 100644
--- a/poi/src/main/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java
+++ b/poi/src/main/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java
@@ -78,6 +78,7 @@ public class OldExcelExtractor implements POITextExtractor {
open(input);
}
+ @SuppressWarnings("java:S2093")
public OldExcelExtractor(File f) throws IOException {
POIFSFileSystem poifs = null;
try {
@@ -120,6 +121,7 @@ public class OldExcelExtractor implements POITextExtractor {
open(directory);
}
+ @SuppressWarnings("java:S2093")
private void open(InputStream biffStream) throws IOException {
BufferedInputStream bis = (biffStream instanceof BufferedInputStream)
? (BufferedInputStream)biffStream
@@ -230,6 +232,7 @@ public class OldExcelExtractor implements POITextExtractor {
*
* @return the text contents of the file
*/
+ @Override
public String getText() {
StringBuilder text = new StringBuilder();
diff --git a/poi/src/main/java/org/apache/poi/hssf/record/DConRefRecord.java b/poi/src/main/java/org/apache/poi/hssf/record/DConRefRecord.java
index d90aa2ed6c..98d3112e2d 100644
--- a/poi/src/main/java/org/apache/poi/hssf/record/DConRefRecord.java
+++ b/poi/src/main/java/org/apache/poi/hssf/record/DConRefRecord.java
@@ -33,11 +33,11 @@ import org.apache.poi.util.StringUtil;
* DConRef records specify a range in a workbook (internal or external) that serves as a data source
* for pivot tables or data consolidation.
*
- * Represents a <code>DConRef</code> Structure
+ * Represents a {@code DConRef} Structure
* <a href="http://msdn.microsoft.com/en-us/library/dd923854(office.12).aspx">[MS-XLS s.
- * 2.4.86]</a>, and the contained <code>DConFile</code> structure
+ * 2.4.86]</a>, and the contained {@code DConFile} structure
* <a href="http://msdn.microsoft.com/en-us/library/dd950157(office.12).aspx">
- * [MS-XLS s. 2.5.69]</a>. This in turn contains a <code>XLUnicodeStringNoCch</code>
+ * [MS-XLS s. 2.5.69]</a>. This in turn contains a {@code XLUnicodeStringNoCch}
* <a href="http://msdn.microsoft.com/en-us/library/dd910585(office.12).aspx">
* [MS-XLS s. 2.5.296]</a>.
*
@@ -56,16 +56,16 @@ import org.apache.poi.util.StringUtil;
* </pre>
* Where
* <ul>
- * <li><code>DConFile.h = 0x00</code> if the characters in<code>rgb</code> are single byte, and
- * <code>DConFile.h = 0x01</code> if they are double byte.<p>
+ * <li>{@code DConFile.h = 0x00} if the characters in{@code rgb} are single byte, and
+ * {@code DConFile.h = 0x01} if they are double byte.<p>
* If they are double byte, then
* <ul>
- * <li> If it exists, the length of <code>DConRef.un = 2</code>. Otherwise it is 1.
- * <li> The length of <code>DConFile.rgb = (2 * DConRef.cch)</code>. Otherwise it is equal to
- * <code>DConRef.cch</code>.
+ * <li> If it exists, the length of {@code DConRef.un = 2}. Otherwise it is 1.
+ * <li> The length of {@code DConFile.rgb = (2 * DConRef.cch)}. Otherwise it is equal to
+ * {@code DConRef.cch}.
* </ul>
- * <li><code>DConRef.rgb</code> starts with <code>0x01</code> if it is an external reference,
- * and with <code>0x02</code> if it is a self-reference.
+ * <li>{@code DConRef.rgb} starts with {@code 0x01} if it is an external reference,
+ * and with {@code 0x02} if it is a self-reference.
* </ul>
*
* At the moment this class is read-only.
@@ -85,26 +85,28 @@ public class DConRefRecord extends StandardRecord {
* <a href="http://msdn.microsoft.com/en-us/library/dd920420(office.12).aspx">
* [MS XLS s.2.5.211]</a>
*/
- private int firstRow, lastRow, firstCol, lastCol;
+ private final int firstRow;
+ private final int lastRow;
+ private final int firstCol;
+ private final int lastCol;
/**
* the number of chars in the link
*/
- private int charCount;
+ private final int charCount;
/**
* the type of characters (single or double byte)
*/
- private int charType;
+ private final int charType;
/**
- * The link's path string. This is the <code>rgb</code> field of a
- * <code>XLUnicodeStringNoCch</code>. Therefore it will contain at least one leading special
+ * The link's path string. This is the {@code rgb} field of a
+ * {@code XLUnicodeStringNoCch}. Therefore it will contain at least one leading special
* character (0x01 or 0x02) and probably other ones.<p>
* @see <A href="http://msdn.microsoft.com/en-us/library/dd923491(office.12).aspx">
* DConFile [MS-XLS s. 2.5.77]</A> and
* <A href="http://msdn.microsoft.com/en-us/library/dd950157(office.12).aspx">
* VirtualPath [MS-XLS s. 2.5.69]</a>
- * <p>
*/
- private byte[] path;
+ private final byte[] path;
/**
* unused bits at the end, must be set to 0.
*/
@@ -256,7 +258,7 @@ public class DConRefRecord extends StandardRecord {
}
String out = new String(Arrays.copyOfRange(path, offset, path.length), StringUtil.UTF8);
//UNC paths have \u0003 chars as path separators.
- out = out.replaceAll("\u0003", "/");
+ out = out.replace("\u0003", "/");
return out;
}
return null;
diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFWorkbookFactory.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFWorkbookFactory.java
index b9fdbb9727..bda0dd6e8d 100644
--- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFWorkbookFactory.java
+++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFWorkbookFactory.java
@@ -67,6 +67,7 @@ public class HSSFWorkbookFactory implements WorkbookProvider {
* Note that in order to properly release resources the
* Workbook should be closed after use.
*/
+ @SuppressWarnings("java:S2093")
@Override
public HSSFWorkbook create(final DirectoryNode root, String password) throws IOException {
boolean passwordSet = false;
@@ -95,7 +96,7 @@ public class HSSFWorkbookFactory implements WorkbookProvider {
}
@Override
- @SuppressWarnings("java:S2095")
+ @SuppressWarnings({"java:S2095","java:S2093"})
public Workbook create(File file, String password, boolean readOnly) throws IOException {
boolean passwordSet = false;
if (password != null) {
diff --git a/poi/src/main/java/org/apache/poi/sl/draw/geom/GuideIf.java b/poi/src/main/java/org/apache/poi/sl/draw/geom/GuideIf.java
index cd6e26d457..d813f0ca31 100644
--- a/poi/src/main/java/org/apache/poi/sl/draw/geom/GuideIf.java
+++ b/poi/src/main/java/org/apache/poi/sl/draw/geom/GuideIf.java
@@ -45,14 +45,14 @@ public interface GuideIf extends Formula {
}
default double evaluateGuide(Context ctx) {
- Guide.Op op;
+ Op op;
String[] operands = WHITESPACE.split(getFmla());
switch (operands[0]) {
- case "*/": op = Guide.Op.muldiv; break;
- case "+-": op = Guide.Op.addsub; break;
- case "+/": op = Guide.Op.adddiv; break;
- case "?:": op = Guide.Op.ifelse; break;
- default: op = Guide.Op.valueOf(operands[0]); break;
+ case "*/": op = Op.muldiv; break;
+ case "+-": op = Op.addsub; break;
+ case "+/": op = Op.adddiv; break;
+ case "?:": op = Op.ifelse; break;
+ default: op = Op.valueOf(operands[0]); break;
}
double x = (operands.length > 1) ? ctx.getValue(operands[1]) : 0;
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/WorkbookEvaluator.java b/poi/src/main/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
index dc06753f4a..f1beee7569 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
@@ -235,8 +235,7 @@ public final class WorkbookEvaluator {
int rowIndex, int columnIndex, EvaluationTracker tracker) {
// avoid tracking dependencies to cells that have constant definition
- boolean shouldCellDependencyBeRecorded = _stabilityClassifier == null ? true
- : !_stabilityClassifier.isCellFinal(sheetIndex, rowIndex, columnIndex);
+ boolean shouldCellDependencyBeRecorded = _stabilityClassifier == null || !_stabilityClassifier.isCellFinal(sheetIndex, rowIndex, columnIndex);
if (srcCell == null || srcCell.getCellType() != CellType.FORMULA) {
ValueEval result = getValueFromNonFormulaCell(srcCell);
if (shouldCellDependencyBeRecorded) {
@@ -389,7 +388,7 @@ public final class WorkbookEvaluator {
String message = finalDbgIndentStr
+ "- evaluateFormula('" + ec.getRefEvaluatorForCurrentSheet().getSheetNameRange()
+ "'/" + new CellReference(ec.getRowIndex(), ec.getColumnIndex()).formatAsString()
- + "): " + Arrays.toString(ptgs).replaceAll("\\Qorg.apache.poi.ss.formula.ptg.\\E", "");
+ + "): " + Arrays.toString(ptgs).replace("\\Qorg.apache.poi.ss.formula.ptg.\\E", "");
return new SimpleMessage(message);
});
dbgEvaluationOutputIndent++;
@@ -665,7 +664,7 @@ public final class WorkbookEvaluator {
/**
* returns an appropriate Eval impl instance for the Ptg. The Ptg must be
* one of: Area3DPtg, AreaPtg, ReferencePtg, Ref3DPtg, IntPtg, NumberPtg,
- * StringPtg, BoolPtg<p>
+ * StringPtg, BoolPtg
* <p>
* special Note: OperationPtg subtypes cannot be passed here!
*/
@@ -889,7 +888,7 @@ public final class WorkbookEvaluator {
* @throws IndexOutOfBoundsException if the resulting shifted row/column indexes are over the document format limits
* @throws IllegalArgumentException if target is not within region.
*/
- protected boolean adjustRegionRelativeReference(Ptg[] ptgs, CellReference target, CellRangeAddressBase region) {
+ private boolean adjustRegionRelativeReference(Ptg[] ptgs, CellReference target, CellRangeAddressBase region) {
// region may not be the one that contains the target, if a conditional formatting rule applies to multiple regions
int deltaRow = target.getRow() - region.getFirstRow();
diff --git a/poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java b/poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java
index b9bc149737..a448b905fa 100644
--- a/poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java
+++ b/poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java
@@ -433,7 +433,7 @@ public class DataFormatter {
if (formatStr.contains("#/") || formatStr.contains("?/")) {
String[] chunks = formatStr.split(";");
for (String chunk1 : chunks) {
- String chunk = chunk1.replaceAll("\\?", "#");
+ String chunk = chunk1.replace("?", "#");
Matcher matcher = fractionStripper.matcher(chunk);
chunk = matcher.replaceAll(" ");
chunk = chunk.replaceAll(" +", " ");
diff --git a/poi/src/test/java9/module-info.class b/poi/src/test/java9/module-info.class
index 028b943d0a..438e778ab5 100644
--- a/poi/src/test/java9/module-info.class
+++ b/poi/src/test/java9/module-info.class
Binary files differ