From: PJ Fanning Date: Sat, 6 Aug 2022 21:06:50 +0000 (+0000) Subject: [github-366] remove unnecessary local vars. Thanks to Arturo Bernal. This closes... X-Git-Tag: REL_5_2_3~85 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=eaa27548fa4f1d374cfb68c9a3f51b6d0e6b8d3d;p=poi.git [github-366] remove unnecessary local vars. Thanks to Arturo Bernal. This closes #366 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1903257 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFChartAxis.java b/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFChartAxis.java index c04e066ed2..b565987f84 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFChartAxis.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFChartAxis.java @@ -408,11 +408,10 @@ public abstract class XDDFChartAxis implements HasShapeProperties { } protected long getNextAxId(CTPlotArea plotArea) { - long totalAxisCount = 0L + return 0L + plotArea.sizeOfValAxArray() + plotArea.sizeOfCatAxArray() + plotArea.sizeOfDateAxArray() + plotArea.sizeOfSerAxArray(); - return totalAxisCount; } } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java index 12e58207f0..4c7d4bdf56 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java @@ -492,8 +492,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo private boolean isCursorInHdrF(XmlCursor cursor) { try (XmlCursor verify = cursor.newCursor()) { verify.toParent(); - boolean result = (verify.getObject() == this.headerFooter); - return result; + return (verify.getObject() == this.headerFooter); } } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java index efe489ef9c..47ccb465c7 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java @@ -336,8 +336,7 @@ public class XWPFTableCell implements IBody, ICell { private boolean isCursorInTableCell(XmlCursor cursor) { try (XmlCursor verify = cursor.newCursor()) { verify.toParent(); - boolean result = (verify.getObject() == this.ctTc); - return result; + return (verify.getObject() == this.ctTc); } } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/MAPIMessage.java b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/MAPIMessage.java index 23c9bd770d..643463e191 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/MAPIMessage.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/MAPIMessage.java @@ -447,8 +447,7 @@ public class MAPIMessage extends POIReadOnlyDocument { if (val != null && !val.isEmpty()) { int codepage = ((LongPropertyValue) val.get(0)).getValue(); try { - String encoding = CodePageUtil.codepageToEncoding(codepage, true); - generalcodepage = encoding; + generalcodepage = CodePageUtil.codepageToEncoding(codepage, true); } catch (UnsupportedEncodingException e) { LOG.atWarn().log("Invalid codepage ID {} set for the message via {}, ignoring", box(codepage), MAPIProperty.MESSAGE_CODEPAGE); } @@ -463,8 +462,7 @@ public class MAPIMessage extends POIReadOnlyDocument { int codepage = LocaleUtil.getDefaultCodePageFromLCID(lcid); try { if (codepage != 0) { - String encoding = CodePageUtil.codepageToEncoding(codepage, true); - generalcodepage = encoding; + generalcodepage = CodePageUtil.codepageToEncoding(codepage, true); } } catch (UnsupportedEncodingException e) { LOG.atWarn().log("Invalid codepage ID {}from locale ID{} set for the message via {}, ignoring", box(codepage), box(lcid), MAPIProperty.MESSAGE_LOCALE_ID); @@ -482,8 +480,7 @@ public class MAPIMessage extends POIReadOnlyDocument { if (header.toLowerCase(LocaleUtil.getUserLocale()).startsWith("content-type")) { Matcher m = GUESS_7_BIT_ENCODING_PATTERN.matcher(header); if (m.matches()) { - String encoding = m.group(1); - generalcodepage = encoding; + generalcodepage = m.group(1); } } } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/GrfhicAbstractType.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/GrfhicAbstractType.java index e968f971fc..8304443080 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/GrfhicAbstractType.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/GrfhicAbstractType.java @@ -91,7 +91,7 @@ public abstract class GrfhicAbstractType public String toString() { - String builder = "[Grfhic]\n" + + return "[Grfhic]\n" + " .grfhic = " + " ( " + field_1_grfhic + " )\n" + " .fHtmlChecked = " + isFHtmlChecked() + '\n' + @@ -103,7 +103,6 @@ public abstract class GrfhicAbstractType " .fHtmlHangingIndentBeneathNumber = " + isFHtmlHangingIndentBeneathNumber() + '\n' + " .fHtmlBuiltInBullet = " + isFHtmlBuiltInBullet() + '\n' + "[/Grfhic]"; - return builder; } /** diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/Areas.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/Areas.java index f6034ef5a5..1a7ed187d4 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/functions/Areas.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/Areas.java @@ -40,8 +40,7 @@ public final class Areas implements Function { RefListEval refListEval = (RefListEval) valueEval; result = refListEval.getList().size(); } - NumberEval numberEval = new NumberEval(new NumberPtg(result)); - return numberEval; + return new NumberEval(new NumberPtg(result)); } catch (Exception e) { return ErrorEval.VALUE_INVALID; }