Skip to content

Commit 4491dd7

Browse files
committed
SonarQube fixes
1 parent c60d340 commit 4491dd7

File tree

4 files changed

+49
-36
lines changed

4 files changed

+49
-36
lines changed

fxcalc/src/main/java/net/objectlab/kit/fxcalc/FxRateCalculatorImpl.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,26 @@ public Optional<FxRate> findFx(final CurrencyPair ccyPair) {
7171
rates.put(ccyPair, fxRate);
7272
}
7373
} else {
74-
for (final String crossCcy : orderedCurrenciesForCross) {
75-
fxRate = findViaCrossCcy(ccyPair, crossCcy);
76-
if (fxRate != null) {
77-
if (cacheResults) {
78-
rates.put(ccyPair, fxRate);
79-
}
80-
break;
81-
}
82-
}
74+
fxRate = tryFindViaCrossCcy(ccyPair, fxRate);
8375
}
8476
}
8577

8678
return Optional.ofNullable(fxRate);
8779
}
8880

81+
private FxRate tryFindViaCrossCcy(final CurrencyPair ccyPair, FxRate fxRate) {
82+
for (final String crossCcy : orderedCurrenciesForCross) {
83+
fxRate = findViaCrossCcy(ccyPair, crossCcy);
84+
if (fxRate != null) {
85+
if (cacheResults) {
86+
rates.put(ccyPair, fxRate);
87+
}
88+
break;
89+
}
90+
}
91+
return fxRate;
92+
}
93+
8994
private FxRate findViaCrossCcy(final CurrencyPair ccyPair, final String crossCcy) {
9095
final CurrencyPair xCcyPair = CurrencyPair.of(crossCcy, ccyPair.getCcy1());
9196
FxRate xCcy1 = getBaseRate(xCcyPair);

portfolio/src/main/java/net/objectlab/kit/pf/package.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<!-- Copyright ObjectLab Kit: http://objectlabkit.sf.net -->
22
<!DOCTYPE html>
33
<html>
4+
<head><title>Portfolio Validation</title></head>
45
<body>
56
<p>New to 1.5.0: Portfolio Validation framework.</p>
67
</body>

utils/src/main/java/net/objectlab/kit/console/ConsoleMenu.java

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -130,33 +130,40 @@ public void displayMenu() {
130130
} while ((opt <= 0 || opt > methods.size()) && opt != EXIT_CODE);
131131

132132
if (opt == EXIT_CODE) {
133-
ConsoleMenu.println("Exiting menu");
134-
try {
135-
final Method meth = target.getClass().getMethod("tearDown", new Class[0]);
136-
if (meth != null) {
137-
meth.invoke(target, new Object());
138-
}
139-
} catch (final Exception e) {
140-
log(e);
141-
}
142-
133+
callTearDownIfRequired();
143134
return;
144135
}
145136

146-
// now call the method
147-
final String method = methods.get(opt - 1);
148-
final Boolean repeat = askForRepeat.get(opt - 1);
137+
callMenuOption(opt);
138+
}
139+
}
149140

150-
try {
151-
final Method meth = target.getClass().getMethod(method, new Class[0]);
152-
if (repeat) {
153-
target.repeat(meth);
154-
} else {
155-
meth.invoke(target, new Object[0]);
156-
}
157-
} catch (final Exception e) {
158-
log(e);
141+
private void callMenuOption(int opt) {
142+
// now call the method
143+
final String method = methods.get(opt - 1);
144+
final Boolean repeat = askForRepeat.get(opt - 1);
145+
146+
try {
147+
final Method meth = target.getClass().getMethod(method, new Class[0]);
148+
if (repeat) {
149+
target.repeat(meth);
150+
} else {
151+
meth.invoke(target, new Object[0]);
159152
}
153+
} catch (final Exception e) {
154+
log(e);
155+
}
156+
}
157+
158+
private void callTearDownIfRequired() {
159+
ConsoleMenu.println("Exiting menu");
160+
try {
161+
final Method meth = target.getClass().getMethod("tearDown", new Class[0]);
162+
if (meth != null) {
163+
meth.invoke(target, new Object());
164+
}
165+
} catch (final Exception e) {
166+
log(e);
160167
}
161168
}
162169

utils/src/main/java/net/objectlab/kit/util/FrequencyBucketDistribution.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,27 @@ public class FrequencyBucketDistribution {
1717
private final List<Bucket> orderedBuckets;
1818

1919
public static class Bucket {
20-
private final BigDecimal bucket;
20+
private final BigDecimal bucketValue;
2121
private long count;
2222

2323
public Bucket(final BigDecimal bucket) {
24-
this.bucket = bucket;
24+
this.bucketValue = bucket;
2525
}
2626

2727
public void incrementCount() {
2828
count++;
2929
}
3030

3131
public BigDecimal getBucket() {
32-
return bucket;
32+
return bucketValue;
3333
}
3434

3535
public long getCount() {
3636
return count;
3737
}
3838

3939
public boolean isUpperLimit() {
40-
return bucket == null;
40+
return bucketValue == null;
4141
}
4242
}
4343

@@ -47,7 +47,7 @@ public boolean isUpperLimit() {
4747
*/
4848
public FrequencyBucketDistribution(final List<BigDecimal> buckets) {
4949
if (buckets != null) {
50-
orderedBuckets = buckets.stream().map(t -> new Bucket(t)).sorted((o1, o2) -> o1.bucket.compareTo(o2.bucket)).collect(Collectors.toList());
50+
orderedBuckets = buckets.stream().map(t -> new Bucket(t)).sorted((o1, o2) -> o1.bucketValue.compareTo(o2.bucketValue)).collect(Collectors.toList());
5151
orderedBuckets.add(new Bucket(null)); // upper limit
5252
} else {
5353
orderedBuckets = Collections.emptyList();

0 commit comments

Comments
 (0)