mirror of
https://github.com/lightbend/config.git
synced 2025-01-15 14:50:23 +08:00
Update findbugs, add Xlint:unchecked, fix warnings discovered
Fix an == that should have been equals in ConfigBeanImpl.java Fix missing equals/hashCode on IgnoredWhitespace token Add some `<?>` that Xlint:unchecked wanted Make RenderComparator serializable just to silence findbugs findbugs still reports some "serializable without void constructors" but those are not accurate because we replace the instance with another class before serializing.
This commit is contained in:
parent
d73d11edb2
commit
7511e865a5
@ -68,13 +68,14 @@ doc in Compile := {
|
||||
|
||||
findbugsSettings
|
||||
findbugsReportType := Some(ReportType.Html)
|
||||
findbugsReportName := Some("findbugs.html")
|
||||
findbugsEffort := Effort.High
|
||||
findbugsMaxMemory := 1000
|
||||
findbugsReportPath := Some(crossTarget.value / "findbugs.html")
|
||||
findbugsEffort := Effort.Maximum
|
||||
findbugsMaxMemory := 2000
|
||||
|
||||
jacoco.settings
|
||||
|
||||
javacOptions in (Compile, compile) ++= Seq("-source", "1.6", "-target", "1.8", "-g")
|
||||
javacOptions in (Compile, compile) ++= Seq("-source", "1.6", "-target", "1.8",
|
||||
"-g", "-Xlint:unchecked")
|
||||
|
||||
// because we test some global state such as singleton caches,
|
||||
// we have to run tests in serial.
|
||||
|
@ -49,7 +49,7 @@ public class ConfigBeanImpl {
|
||||
String camelName = ConfigImplUtil.toCamelCase(originalName);
|
||||
// if a setting is in there both as some hyphen name and the camel name,
|
||||
// the camel one wins
|
||||
if (originalNames.containsKey(camelName) && originalName != camelName) {
|
||||
if (originalNames.containsKey(camelName) && !originalName.equals(camelName)) {
|
||||
// if we aren't a camel name to start with, we lose.
|
||||
// if we are or we are the first matching key, we win.
|
||||
} else {
|
||||
@ -105,7 +105,7 @@ public class ConfigBeanImpl {
|
||||
for (PropertyDescriptor beanProp : beanProps) {
|
||||
Method setter = beanProp.getWriteMethod();
|
||||
Type parameterType = setter.getGenericParameterTypes()[0];
|
||||
Class parameterClass = setter.getParameterTypes()[0];
|
||||
Class<?> parameterClass = setter.getParameterTypes()[0];
|
||||
Object unwrapped = getValue(clazz, parameterType, parameterClass, config, originalNames.get(beanProp.getName()));
|
||||
setter.invoke(bean, unwrapped);
|
||||
}
|
||||
@ -127,7 +127,7 @@ public class ConfigBeanImpl {
|
||||
// setting. So, instead, we only support a limited number of
|
||||
// types plus you can always use Object, ConfigValue, Config,
|
||||
// ConfigObject, etc. as an escape hatch.
|
||||
private static Object getValue(Class beanClass, Type parameterType, Class parameterClass, Config config, String configPropName) {
|
||||
private static Object getValue(Class beanClass, Type parameterType, Class<?> parameterClass, Config config, String configPropName) {
|
||||
if (parameterClass == Boolean.class || parameterClass == boolean.class) {
|
||||
return config.getBoolean(configPropName);
|
||||
} else if (parameterClass == Integer.class || parameterClass == int.class) {
|
||||
@ -168,7 +168,7 @@ public class ConfigBeanImpl {
|
||||
}
|
||||
}
|
||||
|
||||
private static Object getListValue(Class beanClass, Type parameterType, Class parameterClass, Config config, String configPropName) {
|
||||
private static Object getListValue(Class<?> beanClass, Type parameterType, Class<?> parameterClass, Config config, String configPropName) {
|
||||
Type elementType = ((ParameterizedType)parameterType).getActualTypeArguments()[0];
|
||||
|
||||
if (elementType == Boolean.class) {
|
||||
|
@ -110,9 +110,7 @@ final class DefaultTransformer {
|
||||
@Override
|
||||
public int compare(Map.Entry<Integer, AbstractConfigValue> a,
|
||||
Map.Entry<Integer, AbstractConfigValue> b) {
|
||||
// Integer.compare was added in 1.7 so not using
|
||||
// it here yet
|
||||
return Integer.valueOf(a.getKey()).compareTo(b.getKey());
|
||||
return Integer.compare(a.getKey(), b.getKey());
|
||||
}
|
||||
});
|
||||
// drop the indices (we allow gaps in the indices, for better or
|
||||
|
@ -418,7 +418,10 @@ final class SimpleConfigObject extends AbstractConfigObject implements Serializa
|
||||
});
|
||||
}
|
||||
|
||||
static final private class RenderComparator implements java.util.Comparator<String> {
|
||||
// this is only Serializable to chill out a findbugs warning
|
||||
static final private class RenderComparator implements java.util.Comparator<String>, Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static boolean isAllDigits(String s) {
|
||||
int length = s.length();
|
||||
|
||||
|
@ -136,6 +136,22 @@ final class Tokens {
|
||||
@Override
|
||||
public String toString() { return "'" + value + "' (WHITESPACE)"; }
|
||||
|
||||
@Override
|
||||
protected boolean canEqual(Object other) {
|
||||
return other instanceof IgnoredWhitespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return super.equals(other)
|
||||
&& ((IgnoredWhitespace) other).value.equals(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 41 * (41 + super.hashCode()) + value.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tokenText() {
|
||||
return value;
|
||||
|
@ -1,4 +1,4 @@
|
||||
addSbtPlugin("de.johoop" % "findbugs4sbt" % "1.2.1")
|
||||
addSbtPlugin("de.johoop" % "findbugs4sbt" % "1.4.0")
|
||||
addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.6")
|
||||
addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.1")
|
||||
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.6.0")
|
||||
|
Loading…
Reference in New Issue
Block a user