KoLmafia's codebase has a ton of crufty code. Some of it is simply because Java has advanced a lot in the last 15 years and for a long time, we restricted the source to a very old version. We have upgraded a lot of code, but a lot remains untouched.
If we compile with "lint" checking, we get warnings for:
[rawtypes] not using generics on declarations
[unchecked] operating on such variables
[fallthrough] in switch statements
[cast] redundant casts
[serial] serializable classes with no definition of serialVersionUID
[deprecation] usage of methods or fields (eventually) to be removed
[static] calling a static method as if it were an instance method
For testing, I changed the "compile" target in build.xml to onclude this:
That is used for files in the "src" tree. I also tried it for the "lib" tree and saw a bunch of things I don't currently feel like fixing.
I ended up with over 2600 warnings.
I spend the afternoon grinding through some of the packages. It is super tedious. When I submit my changes, we'll be down to 2267 warnings.
I found at least one genuine bug: TravelingTraderRequest.java:
cname was a string, but the map key needed to be an integer.
I'll submit this cleaned up code and let it bake over night. Hopefully I didn't introduce any bugs, but we'll see soon enough, I expect.
If we compile with "lint" checking, we get warnings for:
[rawtypes] not using generics on declarations
[unchecked] operating on such variables
[fallthrough] in switch statements
[cast] redundant casts
[serial] serializable classes with no definition of serialVersionUID
[deprecation] usage of methods or fields (eventually) to be removed
[static] calling a static method as if it were an instance method
For testing, I changed the "compile" target in build.xml to onclude this:
Code:
<javac
compiler="modern"
source="14"
target="14"
srcdir="${src}"
destdir="${build}"
classpath="${build}"
failonerror="false"
debug="on"
debuglevel="lines,vars,source"
deprecation="on"
encoding="utf-8"
nowarn="off"
includeantruntime="false"
errorProperty="compile.failed">
<compilerarg value="-Xlint"/>
<compilerarg value="-Xmaxwarns"/>
<compilerarg value="5000"/>
</javac>
I ended up with over 2600 warnings.
I spend the afternoon grinding through some of the packages. It is super tedious. When I submit my changes, we'll be down to 2267 warnings.
I found at least one genuine bug: TravelingTraderRequest.java:
Code:
private static final Map<Integer, Integer> buyPrices = CoinmastersDatabase.getNewMap();
...
Map prices = TravelingTraderRequest.buyPrices;
...
prices.put( cname, price );
I'll submit this cleaned up code and let it bake over night. Hopefully I didn't introduce any bugs, but we'll see soon enough, I expect.