Skip to content

Commit 0fc00ef

Browse files
committed
SonarQube fixes
1 parent 16e1db7 commit 0fc00ef

File tree

6 files changed

+29
-26
lines changed

6 files changed

+29
-26
lines changed

datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/Tenor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public boolean equals(final Object obj) {
156156
} else if (!code.equals(other.code)) {
157157
return false;
158158
}
159-
return units != other.units;
159+
return units == other.units;
160160
}
161161
}
162162

datecalc-common/src/test/java/net/objectlab/kit/datecalc/common/TenorTest.java

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import java.util.HashSet;
3636
import java.util.Set;
3737

38-
import junit.framework.Assert;
3938
import junit.framework.Test;
4039
import junit.framework.TestCase;
4140
import junit.framework.TestSuite;
@@ -99,24 +98,24 @@ public void testHashcode() {
9998
set.add(StandardTenor.OVERNIGHT);
10099
set.add(StandardTenor.T_1D);
101100
set.add(StandardTenor.T_15Y);
102-
Assert.assertEquals("size", 3, set.size());
103-
Assert.assertTrue("Contains " + StandardTenor.T_1D, set.contains(StandardTenor.T_1D));
104-
Assert.assertTrue("Contains " + StandardTenor.OVERNIGHT, set.contains(StandardTenor.OVERNIGHT));
105-
Assert.assertTrue("Contains " + StandardTenor.T_15Y, set.contains(StandardTenor.T_15Y));
106-
Assert.assertEquals("Equals ", StandardTenor.T_15Y, StandardTenor.T_15Y);
101+
assertEquals("size", 3, set.size());
102+
assertTrue("Contains " + StandardTenor.T_1D, set.contains(StandardTenor.T_1D));
103+
assertTrue("Contains " + StandardTenor.OVERNIGHT, set.contains(StandardTenor.OVERNIGHT));
104+
assertTrue("Contains " + StandardTenor.T_15Y, set.contains(StandardTenor.T_15Y));
105+
assertEquals("Equals ", StandardTenor.T_15Y, StandardTenor.T_15Y);
107106
}
108107

109108
public void testEquals() {
110-
Assert.assertEquals("Equals ", StandardTenor.T_15Y, StandardTenor.T_15Y);
111-
Assert.assertTrue("same", StandardTenor.OVERNIGHT.equals(StandardTenor.OVERNIGHT));
112-
Assert.assertFalse("not same", StandardTenor.OVERNIGHT.equals(StandardTenor.SPOT));
113-
Assert.assertFalse("Different class", StandardTenor.OVERNIGHT.equals("Hello"));
114-
Assert.assertFalse("Null", StandardTenor.OVERNIGHT.equals(null));
115-
Assert.assertTrue("same", StandardTenor.T_10Y.equals(StandardTenor.T_10Y));
116-
Assert.assertFalse("diff unit", StandardTenor.T_10Y.equals(StandardTenor.T_15Y));
117-
Assert.assertTrue("same", StandardTenor.T_10Y.equals(new Tenor(10, TenorCode.YEAR)));
118-
Assert.assertFalse("same", new Tenor(10, null).equals(new Tenor(10, TenorCode.YEAR)));
119-
Assert.assertTrue("same", new Tenor(10, null).equals(new Tenor(10, null)));
109+
assertEquals("Equals ", StandardTenor.T_15Y, StandardTenor.T_15Y);
110+
assertTrue("same", StandardTenor.OVERNIGHT.equals(StandardTenor.OVERNIGHT));
111+
assertFalse("not same", StandardTenor.OVERNIGHT.equals(StandardTenor.SPOT));
112+
assertFalse("Different class", StandardTenor.OVERNIGHT.equals("Hello"));
113+
assertFalse("Null", StandardTenor.OVERNIGHT.equals(null));
114+
assertTrue("same", StandardTenor.T_10Y.equals(StandardTenor.T_10Y));
115+
assertFalse("diff unit", StandardTenor.T_10Y.equals(StandardTenor.T_15Y));
116+
assertTrue("same", StandardTenor.T_10Y.equals(new Tenor(10, TenorCode.YEAR)));
117+
assertFalse("same", new Tenor(10, null).equals(new Tenor(10, TenorCode.YEAR)));
118+
assertTrue("same", new Tenor(10, null).equals(new Tenor(10, null)));
120119
}
121120

122121
// -----------------------------------------------------------------------
@@ -147,32 +146,32 @@ public void testInvalidTenors() {
147146
private void checkToString(final String string) {
148147
try {
149148
final Tenor t = Tenor.valueOf(string);
150-
Assert.assertEquals(string, t.toString());
149+
assertEquals(string, t.toString());
151150
} catch (final IllegalArgumentException e) {
152-
Assert.fail(e.toString());
151+
fail(e.toString());
153152
}
154153
}
155154

156155
private void checkInvalidTenor(final String str) {
157156
try {
158157
Tenor.valueOf(str);
159-
Assert.fail(str + " is invalid and should have thrown an exception!");
158+
fail(str + " is invalid and should have thrown an exception!");
160159
} catch (final IllegalArgumentException e) {
161-
Assert.assertTrue(true);
160+
assertTrue(true);
162161
}
163162
}
164163

165164
private Tenor checkValidTenor(final String str, final boolean acceptUnits, final TenorCode tenorCode, final int units) {
166165
Tenor tenor = null;
167166
try {
168167
tenor = Tenor.valueOf(str);
169-
Assert.assertEquals(str + " Accept Units", acceptUnits, tenor.getCode().acceptUnits());
170-
Assert.assertEquals(str + " Accept Units", acceptUnits, tenor.hasUnits());
171-
Assert.assertSame(str + " right tenor ", tenorCode, tenor.getCode());
172-
Assert.assertEquals(str + " Units", units, tenor.getUnits());
168+
assertEquals(str + " Accept Units", acceptUnits, tenor.getCode().acceptUnits());
169+
assertEquals(str + " Accept Units", acceptUnits, tenor.hasUnits());
170+
assertSame(str + " right tenor ", tenorCode, tenor.getCode());
171+
assertEquals(str + " Units", units, tenor.getUnits());
173172
} catch (final IllegalArgumentException e) {
174173
e.printStackTrace();
175-
Assert.fail("[" + str + "] should be valid!");
174+
fail("[" + str + "] should be valid!");
176175
}
177176
return tenor;
178177
}

fxcalc/src/main/java/net/objectlab/kit/fxcalc/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>FX</title></head>
45
<body>
56
<p>New to 1.4.0: FX Market Convention and FX Rates, including cross currency calculations.</p>
67
</body>

utils/src/main/java/net/objectlab/kit/collections/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>Kit collections</title></head>
45
<body>
56
<p>This package is inspired by Guava BUT instead of loading one key at a time in an expiring cache, the whole dataset
67
can be loaded in one go; of course use this ONLY if your dataset is small.</p>

utils/src/main/java/net/objectlab/kit/console/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>Quick menu</title></head>
45
<body>
56
<p>This package provides a way to easily create console menus that facilitates interaction with a user.</p>
67
</body>

utils/src/main/java/net/objectlab/kit/util/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>BigDecimal Calculators</title></head>
45
<body>
56
<p>This package provides a series of utilities for manipulating BigDecimal and other that can be null.</p>
67
</body>

0 commit comments

Comments
 (0)