sonar issues

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1903686 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2022-08-25 18:52:27 +00:00
parent 8d9d916ecd
commit deffaacd0f
10 changed files with 21 additions and 25 deletions

View File

@ -25,9 +25,7 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.FreeRefFunction;
import org.apache.poi.ss.formula.udf.UDFFinder;
import org.apache.poi.ss.usermodel.Row;

View File

@ -4958,7 +4958,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet, OoxmlSheetEx
if (totalsRowCount == 1) { // never seen more than one totals row
XSSFRow totalsRow = sheet.getRow(clonedTable.getEndCellReference().getRow());
if (clonedTable.getCTTable().getTableColumns() != null
&& clonedTable.getCTTable().getTableColumns().getTableColumnList().size() > 0) {
&& !clonedTable.getCTTable().getTableColumns().getTableColumnList().isEmpty()) {
clonedTable.getCTTable().setTotalsRowCount(totalsRowCount);
for (int i = 0; i < clonedTable.getCTTable().getTableColumns().getTableColumnList().size(); i++) {
CTTableColumn tableCol = table.getCTTable().getTableColumns().getTableColumnList().get(i);
@ -4983,7 +4983,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet, OoxmlSheetEx
// clone calculated column formulas
if (clonedTable.getCTTable().getTableColumns() != null
&& clonedTable.getCTTable().getTableColumns().getTableColumnList().size() > 0) {
&& !clonedTable.getCTTable().getTableColumns().getTableColumnList().isEmpty()) {
clonedTable.getCTTable().setTotalsRowCount(totalsRowCount);
for (int i = 0; i < clonedTable.getCTTable().getTableColumns().getTableColumnList().size(); i++) {
CTTableColumn tableCol = table.getCTTable().getTableColumns().getTableColumnList().get(i);

View File

@ -31,11 +31,11 @@ import java.util.Objects;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
public class TestXSLFSlideCopy {
class TestXSLFSlideCopy {
private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
@Test
public void testCopySlide() throws IOException {
void testCopySlide() throws IOException {
final String shapeName = "title";
try (
InputStream stream = slTests.openResourceAsStream("copy-slide-demo.pptx");

View File

@ -49,9 +49,9 @@ import static org.apache.poi.POITestCase.assertEndsWith;
import static org.apache.poi.POITestCase.assertStartsWith;
import static org.junit.jupiter.api.Assertions.*;
public final class TestSXSSFWorkbookWithNullAutoSizeTracker extends BaseTestXWorkbook {
final class TestSXSSFWorkbookWithNullAutoSizeTracker extends BaseTestXWorkbook {
public TestSXSSFWorkbookWithNullAutoSizeTracker() {
TestSXSSFWorkbookWithNullAutoSizeTracker() {
super(SXSSFITestDataProviderWithNullAutoSizeTracker.instance);
}
@ -672,7 +672,7 @@ public final class TestSXSSFWorkbookWithNullAutoSizeTracker extends BaseTestXWor
}
@Test
public void disableAutoSizeTracker() throws IOException {
void disableAutoSizeTracker() throws IOException {
try (Workbook workbook = _testDataProvider.createWorkbook(10)) {
assertThrows(IllegalStateException.class, () -> {
Sheet sheet = workbook.createSheet("testSheet");

View File

@ -39,7 +39,7 @@ import java.util.Calendar;
/**
* Tests for XSSFBubbleChartData.
*/
public final class TestXSSFBubbleChartData {
final class TestXSSFBubbleChartData {
@Test
void testExample() throws IOException {

View File

@ -355,7 +355,7 @@ public class HemfPlusBrush {
size += LittleEndianConsts.INT_SIZE;
}
brushBytes = IOUtils.toByteArray(leis, (int)(dataSize-size), MAX_OBJECT_SIZE);
brushBytes = IOUtils.toByteArray(leis, Math.toIntExact(dataSize-size), MAX_OBJECT_SIZE);
return dataSize;
}
@ -542,7 +542,7 @@ public class HemfPlusBrush {
// gradient is repeated.
wrapMode = EmfPlusWrapMode.valueOf(leis.readInt());
int size = 2 * LittleEndianConsts.INT_SIZE;
long size = 2L * LittleEndianConsts.INT_SIZE;
size += readRectF(leis, rect);
// An EmfPlusARGB object that specifies the color at the starting/ending boundary point of the linear gradient brush.
@ -552,10 +552,11 @@ public class HemfPlusBrush {
// skip reserved1/2 fields
leis.skipFully(2 * LittleEndianConsts.INT_SIZE);
size += 4 * LittleEndianConsts.INT_SIZE;
size += 4L * LittleEndianConsts.INT_SIZE;
if (TRANSFORM.isSet(dataFlags)) {
size += readXForm(leis, (blendTransform = new AffineTransform()));
blendTransform = new AffineTransform();
size += readXForm(leis, blendTransform);
}
if (isPreset() && (isBlendH() || isBlendV())) {
@ -709,7 +710,7 @@ public class HemfPlusBrush {
// that appears at the center point of the brush. The color of the brush changes gradually from the
// boundary color to the center color as it moves from the boundary to the center point.
centerColor = readARGB(leis.readInt());
long size = 3*LittleEndianConsts.INT_SIZE;
long size = 3L * LittleEndianConsts.INT_SIZE;
if (wrapMode == null) {
return size;
@ -727,7 +728,7 @@ public class HemfPlusBrush {
for (int i = 0; i < colorCount; i++) {
surroundingColor[i] = readARGB(leis.readInt());
}
size += (colorCount + 1) * LittleEndianConsts.INT_SIZE;
size += (colorCount + 1L) * LittleEndianConsts.INT_SIZE;
// The boundary of the path gradient brush, which is specified by either a path or a closed cardinal spline.
// If the BrushDataPath flag is set in the BrushDataFlags field, this field MUST contain an
@ -785,7 +786,7 @@ public class HemfPlusBrush {
size += 3*LittleEndianConsts.INT_SIZE;
}
return Math.toIntExact(size);
return size;
}
@Override
@ -846,14 +847,16 @@ public class HemfPlusBrush {
// across a shape, when the image is smaller than the area being filled.
wrapMode = EmfPlusWrapMode.valueOf(leis.readInt());
long size = 2*LittleEndianConsts.INT_SIZE;
long size = 2L * LittleEndianConsts.INT_SIZE;
if (TRANSFORM.isSet(dataFlags)) {
size += readXForm(leis, (brushTransform = new AffineTransform()));
brushTransform = new AffineTransform();
size += readXForm(leis, brushTransform);
}
if (dataSize > size) {
size += (image = new EmfPlusImage()).init(leis, dataSize-size, EmfPlusObjectType.IMAGE, 0);
image = new EmfPlusImage();
size += image.init(leis, dataSize-size, EmfPlusObjectType.IMAGE, 0);
}
return Math.toIntExact(size);

View File

@ -19,7 +19,6 @@ package org.apache.poi.hsmf.dev;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Comparator;
import org.apache.poi.hsmf.datatypes.MAPIProperty;
import org.apache.poi.util.StringUtil;

View File

@ -24,8 +24,6 @@ import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.poifs.crypt.standard.EncryptionRecord;
import org.apache.poi.poifs.filesystem.DirectoryEntry;
import org.apache.poi.poifs.filesystem.DocumentEntry;
import org.apache.poi.poifs.filesystem.POIFSWriterEvent;
import org.apache.poi.poifs.filesystem.POIFSWriterListener;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndianByteArrayOutputStream;
import org.apache.poi.util.LittleEndianConsts;

View File

@ -36,7 +36,6 @@ import org.apache.poi.poifs.crypt.Encryptor;
import org.apache.poi.poifs.crypt.HashAlgorithm;
import org.apache.poi.poifs.crypt.standard.EncryptionRecord;
import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.util.LittleEndianByteArrayOutputStream;
import org.apache.poi.util.RandomSingleton;
public class BinaryRC4Encryptor extends Encryptor {

View File

@ -47,7 +47,6 @@ import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.POIFSWriterEvent;
import org.apache.poi.poifs.filesystem.POIFSWriterListener;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndianByteArrayOutputStream;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.LittleEndianOutputStream;
import org.apache.poi.util.RandomSingleton;