Skip to content

Commit

Permalink
Update checkstyle to 8.45.1 (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
jodastephen committed Sep 23, 2022
1 parent 7237e69 commit 536487d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 26 deletions.
5 changes: 2 additions & 3 deletions pom.xml
Expand Up @@ -804,8 +804,7 @@
<maven-assembly-plugin.version>3.4.2</maven-assembly-plugin.version>
<maven-bundle-plugin.version>5.1.8</maven-bundle-plugin.version>
<maven-changes-plugin.version>2.12.1</maven-changes-plugin.version>
<!-- v3.0.0 does not work with Eclipse -->
<maven-checkstyle-plugin.version>2.17</maven-checkstyle-plugin.version>
<maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version>
<maven-clean-plugin.version>3.2.0</maven-clean-plugin.version>
<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
<maven-deploy-plugin.version>3.0.0</maven-deploy-plugin.version>
Expand Down Expand Up @@ -847,7 +846,7 @@
<doclint>none</doclint>

<!-- Properties for maven-checkstyle-plugin -->
<checkstyle.version>8.14</checkstyle.version>
<checkstyle.version>8.45.1</checkstyle.version>
<checkstyle.config.location>src/main/checkstyle/checkstyle.xml</checkstyle.config.location>
<linkXRef>false</linkXRef>

Expand Down
22 changes: 9 additions & 13 deletions src/main/checkstyle/checkstyle.xml
Expand Up @@ -3,8 +3,8 @@

<module name="Checker">
<property name="severity" value="warning"/>
<property name="tabWidth" value="4"/>
<module name="TreeWalker">
<property name="tabWidth" value="4"/>
<module name="ConstantName">
<property name="format" value="^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$|^[a-z][a-zA-Z0-9]*$"/>
</module>
Expand All @@ -29,25 +29,14 @@
<property name="scope" value="protected"/>
</module>
<module name="JavadocMethod">
<property name="scope" value="protected"/>
<property name="allowUndeclaredRTE" value="true"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowMissingJavadoc" value="true"/>
<property name="allowMissingPropertyJavadoc" value="true"/>
<property name="logLoadErrors" value="true"/>
<property name="suppressLoadErrors" value="true"/>
<property name="accessModifiers" value="public,protected"/>
</module>
<module name="JavadocVariable">
<property name="scope" value="protected"/>
</module>
<module name="LeftCurly">
<property name="severity" value="error"/>
</module>
<module name="LineLength">
<property name="ignorePattern" value="^ *\* *[^ ]+$"/>
<property name="max" value="200"/>
<property name="tabWidth" value="2"/>
</module>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName">
Expand All @@ -57,6 +46,9 @@
<property name="max" value="300"/>
</module>
<module name="MethodName"/>
<module name="MissingJavadocMethodCheck">
<property name="allowMissingPropertyJavadoc" value="true"/>
</module>
<module name="ModifierOrder">
<property name="severity" value="error"/>
</module>
Expand Down Expand Up @@ -137,5 +129,9 @@
<property name="eachLine" value="true"/>
<property name="severity" value="error"/>
</module>
<module name="LineLength">
<property name="ignorePattern" value="^ *\* *[^ ]+$"/>
<property name="max" value="200"/>
</module>
<module name="NewlineAtEndOfFile"/>
</module>
13 changes: 7 additions & 6 deletions src/main/java/org/joda/money/BigMoney.java
Expand Up @@ -78,6 +78,7 @@ public final class BigMoney implements BigMoneyProvider, Comparable<BigMoneyProv
public static BigMoney of(CurrencyUnit currency, BigDecimal amount) {
MoneyUtils.checkNotNull(currency, "Currency must not be null");
MoneyUtils.checkNotNull(amount, "Amount must not be null");
BigDecimal checkedAmount = amount;
if (amount.getClass() != BigDecimal.class) {
BigInteger value = amount.unscaledValue();
if (value == null) {
Expand All @@ -86,9 +87,9 @@ public static BigMoney of(CurrencyUnit currency, BigDecimal amount) {
if (value.getClass() != BigInteger.class) {
value = new BigInteger(value.toString());
}
amount = new BigDecimal(value, amount.scale());
checkedAmount = new BigDecimal(value, amount.scale());
}
return new BigMoney(currency, amount);
return new BigMoney(currency, checkedAmount);
}

/**
Expand Down Expand Up @@ -152,8 +153,8 @@ public static BigMoney ofScale(CurrencyUnit currency, BigDecimal amount, int sca
MoneyUtils.checkNotNull(currency, "CurrencyUnit must not be null");
MoneyUtils.checkNotNull(amount, "Amount must not be null");
MoneyUtils.checkNotNull(roundingMode, "RoundingMode must not be null");
amount = amount.setScale(scale, roundingMode);
return BigMoney.of(currency, amount);
BigDecimal scaledAmount = amount.setScale(scale, roundingMode);
return BigMoney.of(currency, scaledAmount);
}

/**
Expand Down Expand Up @@ -701,8 +702,8 @@ public int getAmountMinorInt() {
public int getMinorPart() {
int cdp = getCurrencyUnit().getDecimalPlaces();
return amount.setScale(cdp, RoundingMode.DOWN)
.remainder(BigDecimal.ONE)
.movePointRight(cdp).intValueExact();
.remainder(BigDecimal.ONE)
.movePointRight(cdp).intValueExact();
}

//-----------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/joda/money/Money.java
Expand Up @@ -94,8 +94,8 @@ public static Money of(CurrencyUnit currency, BigDecimal amount, RoundingMode ro
MoneyUtils.checkNotNull(currency, "CurrencyUnit must not be null");
MoneyUtils.checkNotNull(amount, "Amount must not be null");
MoneyUtils.checkNotNull(roundingMode, "RoundingMode must not be null");
amount = amount.setScale(currency.getDecimalPlaces(), roundingMode);
return new Money(BigMoney.of(currency, amount));
BigDecimal scaledAmount = amount.setScale(currency.getDecimalPlaces(), roundingMode);
return new Money(BigMoney.of(currency, scaledAmount));
}

//-----------------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/joda/money/format/AmountPrinterParser.java
Expand Up @@ -46,13 +46,15 @@ final class AmountPrinterParser implements MoneyPrinter, MoneyParser, Serializab
@Override
public void print(MoneyPrintContext context, Appendable appendable, BigMoney money) throws IOException {
MoneyAmountStyle activeStyle = style.localize(context.getLocale());
String str;
if (money.isNegative()) {
money = money.negated();
if (!activeStyle.isAbsValue()) {
appendable.append(activeStyle.getNegativeSignCharacter());
}
str = money.negated().getAmount().toPlainString();
} else {
str = money.getAmount().toPlainString();
}
String str = money.getAmount().toPlainString();
char zeroChar = activeStyle.getZeroCharacter();
if (zeroChar != '0') {
int diff = zeroChar - '0';
Expand Down

0 comments on commit 536487d

Please sign in to comment.