Skip to content
Permalink
Browse files

checkstyle: Enable more checks

  • Loading branch information...
Flowdalic committed Sep 14, 2019
1 parent f2f10ce commit ae5ae8e42e0ce4bfb450ffa18f02b1d5a55212f9
Showing with 295 additions and 194 deletions.
  1. +107 −3 config/checkstyle/checkstyle.xml
  2. +1 −1 minidns-async/src/main/java/org/minidns/source/async/AsyncDnsRequest.java
  3. +2 −2 minidns-client/src/main/java/org/minidns/DnsClient.java
  4. +1 −1 minidns-client/src/main/java/org/minidns/MiniDnsException.java
  5. +10 −10 minidns-client/src/main/java/org/minidns/MiniDnsFuture.java
  6. +1 −1 minidns-client/src/main/java/org/minidns/MiniDnsInitialization.java
  7. +4 −4 minidns-client/src/main/java/org/minidns/RrSet.java
  8. +3 −3 minidns-client/src/main/java/org/minidns/cache/ExtendedLruCache.java
  9. +1 −2 minidns-client/src/main/java/org/minidns/cache/LruCache.java
  10. +1 −1 minidns-client/src/main/java/org/minidns/dnsserverlookup/AbstractDnsServerLookupMechanism.java
  11. +1 −1 minidns-client/src/main/java/org/minidns/dnsserverlookup/AndroidUsingExec.java
  12. +1 −1 minidns-client/src/main/java/org/minidns/dnsserverlookup/AndroidUsingReflection.java
  13. +4 −4 minidns-client/src/main/java/org/minidns/dnsserverlookup/DnsServerLookupMechanism.java
  14. +1 −1 minidns-client/src/main/java/org/minidns/dnsserverlookup/UnixUsingEtcResolvConf.java
  15. +1 −1 minidns-client/src/main/java/org/minidns/source/DnsDataSource.java
  16. +2 −2 minidns-client/src/main/java/org/minidns/source/NetworkDataSource.java
  17. +1 −1 minidns-client/src/main/java/org/minidns/source/NetworkDataSourceWithAccounting.java
  18. +1 −1 minidns-client/src/test/java/org/minidns/DnsClientTest.java
  19. +1 −1 minidns-core/src/main/java/org/minidns/constants/DnsRootServer.java
  20. +2 −2 minidns-core/src/main/java/org/minidns/constants/DnssecConstants.java
  21. +1 −1 minidns-core/src/main/java/org/minidns/dnslabel/LdhLabel.java
  22. +1 −1 minidns-core/src/main/java/org/minidns/dnslabel/NonReservedLdhLabel.java
  23. +1 −1 minidns-core/src/main/java/org/minidns/dnslabel/ReservedLdhLabel.java
  24. +1 −1 minidns-core/src/main/java/org/minidns/dnslabel/XnLabel.java
  25. +8 −9 minidns-core/src/main/java/org/minidns/dnsmessage/DnsMessage.java
  26. +5 −5 minidns-core/src/main/java/org/minidns/dnsmessage/Question.java
  27. +5 −5 minidns-core/src/main/java/org/minidns/dnsname/DnsName.java
  28. +5 −5 minidns-core/src/main/java/org/minidns/edns/Edns.java
  29. +2 −2 minidns-core/src/main/java/org/minidns/idna/IdnaTransformator.java
  30. +1 −1 minidns-core/src/main/java/org/minidns/record/A.java
  31. +1 −1 minidns-core/src/main/java/org/minidns/record/AAAA.java
  32. +1 −1 minidns-core/src/main/java/org/minidns/record/Data.java
  33. +1 −1 minidns-core/src/main/java/org/minidns/record/DelegatingDnssecRR.java
  34. +1 −2 minidns-core/src/main/java/org/minidns/record/MX.java
  35. +2 −2 minidns-core/src/main/java/org/minidns/record/NSEC.java
  36. +2 −2 minidns-core/src/main/java/org/minidns/record/OPT.java
  37. +6 −4 minidns-core/src/main/java/org/minidns/record/RRSIG.java
  38. +11 −11 minidns-core/src/main/java/org/minidns/record/Record.java
  39. +1 −2 minidns-core/src/main/java/org/minidns/record/SRV.java
  40. +3 −3 minidns-core/src/main/java/org/minidns/record/TLSA.java
  41. +1 −1 minidns-core/src/main/java/org/minidns/record/UNKNOWN.java
  42. +1 −1 minidns-core/src/main/java/org/minidns/util/ExceptionCallback.java
  43. +3 −3 minidns-core/src/main/java/org/minidns/util/InetAddressUtil.java
  44. +2 −2 minidns-core/src/main/java/org/minidns/util/MultipleIoException.java
  45. +2 −2 minidns-core/src/main/java/org/minidns/util/SrvUtil.java
  46. +1 −1 minidns-core/src/main/java/org/minidns/util/SuccessCallback.java
  47. +9 −9 minidns-core/src/test/java/org/minidns/dnsmessage/DnsMessageTest.java
  48. +6 −6 minidns-core/src/test/java/org/minidns/dnsname/DnsNameTest.java
  49. +23 −23 minidns-core/src/test/java/org/minidns/record/RecordsTest.java
  50. +4 −4 minidns-core/src/test/java/org/minidns/util/Base32Test.java
  51. +4 −4 minidns-core/src/test/java/org/minidns/util/Base64Test.java
  52. +1 −1 minidns-core/src/test/java/org/minidns/util/SrvUtilTest.java
  53. +2 −2 minidns-dane-java7/src/main/java/org/minidns/dane/java7/DaneExtendedTrustManager.java
  54. +2 −2 minidns-dnssec/src/main/java/org/minidns/dane/DaneVerifier.java
  55. +1 −1 minidns-dnssec/src/main/java/org/minidns/dnssec/DnssecResultNotAuthenticException.java
  56. +1 −1 minidns-dnssec/src/main/java/org/minidns/dnssec/algorithms/AlgorithmMap.java
  57. +1 −1 minidns-dnssec/src/main/java/org/minidns/dnssec/algorithms/DsaSignatureVerifier.java
  58. +4 −4 minidns-dnssec/src/main/java/org/minidns/dnssec/algorithms/EcdsaSignatureVerifier.java
  59. +1 −1 minidns-dnssec/src/main/java/org/minidns/dnssec/algorithms/EcgostSignatureVerifier.java
  60. +1 −1 minidns-dnssec/src/main/java/org/minidns/dnssec/algorithms/RsaSignatureVerifier.java
  61. +2 −2 minidns-dnssec/src/test/java/org/minidns/dnssec/DnssecClientTest.java
  62. +2 −2 minidns-dnssec/src/test/java/org/minidns/dnssec/DnssecWorld.java
  63. +2 −2 minidns-dnssec/src/test/java/org/minidns/dnssec/VerifierTest.java
  64. +2 −2 minidns-dnssec/src/test/java/org/minidns/dnssec/algorithms/DsaSingatureVerifierTest.java
  65. +2 −2 minidns-dnssec/src/test/java/org/minidns/dnssec/algorithms/RsaSignatureVerifierTest.java
  66. +1 −1 minidns-hla/src/main/java/org/minidns/hla/ResolverApi.java
  67. +2 −2 minidns-hla/src/main/java/org/minidns/hla/SrvResolverResult.java
  68. +0 −1 minidns-integration-test/src/main/java/org/minidns/integrationtest/IntegrationTestHelper.java
  69. +4 −4 minidns-iterative-resolver/src/main/java/org/minidns/iterative/IterativeDnsClient.java
  70. +1 −1 minidns-iterative-resolver/src/main/java/org/minidns/iterative/ResolutionState.java
  71. +2 −2 minidns-iterative-resolver/src/test/java/org/minidns/iterative/IterativeDnsClientTest.java
@@ -51,20 +51,28 @@
<property name="format" value="^\s*[\S&amp;&amp;[^\*/]]+\s+$"/>
<property name="message" value="Line containing trailing whitespace character(s)"/>
</module>
<module name="RegexpSingleline">
<property name="format" value="^\s*//[^\s]"/>
<property name="message" value="Comment start ('//') followed by non-space character. You would not continue after a punctuation without a space, would you?"/>
</module>
<!-- <module name="JavadocPackage"/> -->
<module name="TreeWalker">
<!-- <module name="FinalClass"/> -->
<module name="SuppressionCommentFilter"/>
<module name="FinalClass"/>
<module name="UnusedImports">
<property name="processJavadoc" value="true"/>
</module>
<module name="AvoidStarImport"/>
<module name="IllegalImport"/>
<module name="RedundantImport"/>
<module name="RedundantModifier"/>
<module name="ModifierOrder"/>
<module name="UpperEll"/>
<!-- <module name="ArrayTypeStyle"/> -->
<module name="ArrayTypeStyle"/>
<module name="GenericWhitespace"/>
<module name="EmptyStatement"/>
<module name="PackageDeclaration"/>
<module name="LeftCurly"/>
<module name="RegexpSinglelineJava">
<property name="format" value="printStackTrace"/>
<property name="message" value="Usage of printStackTrace"/>
@@ -84,6 +92,102 @@
<property name="checkEmptyJavadoc" value="true"/>
<property name="checkHtml" value="false"/>
</module>
<module name="SuppressionCommentFilter"/>
<module name="ParenPad">
</module>
<module name="NoWhitespaceAfter">
<property name="tokens" value="INC
, DEC
, UNARY_MINUS
, UNARY_PLUS
, BNOT, LNOT
, DOT
, ARRAY_DECLARATOR
, INDEX_OP
"/>
</module>
<module name="WhitespaceAfter">
<property name="tokens" value="TYPECAST
, LITERAL_IF
, LITERAL_ELSE
, LITERAL_WHILE
, LITERAL_DO
, LITERAL_FOR
, DO_WHILE
, COMMA
"/>
</module>
<module name="WhitespaceAround">
<property
name="ignoreEnhancedForColon"
value="false"
/>
<!-- Currently disabled tokens: LCURLY, RCURLY, WILDCARD_TYPE, GENERIC_START, GENERIC_END -->
<property
name="tokens"
value="ASSIGN
, ARRAY_INIT
, BAND
, BAND_ASSIGN
, BOR
, BOR_ASSIGN
, BSR
, BSR_ASSIGN
, BXOR
, BXOR_ASSIGN
, COLON
, DIV
, DIV_ASSIGN
, DO_WHILE
, EQUAL
, GE
, GT
, LAMBDA
, LAND
, LE
, LITERAL_CATCH
, LITERAL_DO
, LITERAL_ELSE
, LITERAL_FINALLY
, LITERAL_FOR
, LITERAL_IF
, LITERAL_RETURN
, LITERAL_SWITCH
, LITERAL_SYNCHRONIZED
, LITERAL_TRY
, LITERAL_WHILE
, LOR
, LT
, MINUS
, MINUS_ASSIGN
, MOD
, MOD_ASSIGN
, NOT_EQUAL
, PLUS
, PLUS_ASSIGN
, QUESTION
, SL
, SLIST
, SL_ASSIGN
, SR
, SR_ASSIGN
, STAR
, STAR_ASSIGN
, LITERAL_ASSERT
, TYPE_EXTENSION_AND
"/>
</module>
<!-- TODO: Enable this check
<module name="CustomImportOrder">
<property name="customImportOrderRules"
value="STATIC###STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE"/>
<property name="specialImportsRegExp" value="^org\.minidns"/>
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="separateLineBetweenGroups" value="true"/>
</module>
-->
<module name="MissingJavadocPackage"/>
<module name="UnnecessaryParentheses"/>
<module name="UnnecessarySemicolonInEnumeration"/>
<module name="UnnecessarySemicolonInTryWithResources"/>
</module>
</module>
@@ -135,7 +135,7 @@ private void addException(IOException e) {
exceptions.add(e);
}

private final void gotResult(DnsQueryResult result) {
private void gotResult(DnsQueryResult result) {
if (onResponseCallback != null) {
onResponseCallback.onResponse(request, result);
}
@@ -283,7 +283,7 @@ public void processException(IOException exception) {
continue;
}

assert(!res.isEmpty());
assert !res.isEmpty();

// We could cache if res only contains IP addresses and avoid the verification in case. Not sure if its really that beneficial
// though, because the list returned by the server mechanism is rather short.
@@ -351,7 +351,7 @@ public void processException(IOException exception) {
// The following invariant must hold: "dnsServerString is a IP address". Therefore findDNS() must only return a List of Strings
// representing IP addresses. Otherwise the following call of getByName(String) may perform a DNS lookup without MiniDNS being
// involved. Something we want to avoid.
assert (InetAddressUtil.isIpAddress(dnsServerString));
assert InetAddressUtil.isIpAddress(dnsServerString);

InetAddress dnsServerAddress;
try {
@@ -37,7 +37,7 @@ protected MiniDnsException(String message) {

public IdMismatch(DnsMessage request, DnsMessage response) {
super(getString(request, response));
assert (request.id != response.id);
assert request.id != response.id;
this.request = request;
this.response = response;
}
@@ -54,20 +54,20 @@ public synchronized boolean cancel(boolean mayInterruptIfRunning) {
}

@Override
public synchronized final boolean isCancelled() {
public final synchronized boolean isCancelled() {
return cancelled;
}

@Override
public synchronized final boolean isDone() {
public final synchronized boolean isDone() {
return hasResult() || hasException();
}

public synchronized final boolean hasResult() {
public final synchronized boolean hasResult() {
return result != null;
}

public synchronized final boolean hasException() {
public final synchronized boolean hasException() {
return exception != null;
}

@@ -85,29 +85,29 @@ public synchronized final boolean hasException() {
return this;
}

private final V getOrThrowExecutionException() throws ExecutionException {
assert (result != null || exception != null || cancelled);
private V getOrThrowExecutionException() throws ExecutionException {
assert result != null || exception != null || cancelled;
if (result != null) {
return result;
}
if (exception != null) {
throw new ExecutionException(exception);
}

assert (cancelled);
assert cancelled;
throw new CancellationException();
}

@Override
public synchronized final V get() throws InterruptedException, ExecutionException {
public final synchronized V get() throws InterruptedException, ExecutionException {
while (result == null && exception == null && !cancelled) {
wait();
}

return getOrThrowExecutionException();
}

public synchronized final V getOrThrow() throws E {
public final synchronized V getOrThrow() throws E {
while (result == null && exception == null && !cancelled) {
try {
wait();
@@ -129,7 +129,7 @@ public synchronized final V getOrThrow() throws E {
}

@Override
public synchronized final V get(long timeout, TimeUnit unit)
public final synchronized V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
final long deadline = System.currentTimeMillis() + unit.toMillis(timeout);
while (result != null && exception != null && !cancelled) {
@@ -30,7 +30,7 @@
InputStream is = MiniDnsInitialization.class.getClassLoader().getResourceAsStream("org.minidns/version");
reader = new BufferedReader(new InputStreamReader(is));
miniDnsVersion = reader.readLine();
} catch(Exception e) {
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Could not determine MiniDNS version", e);
miniDnsVersion = "unkown";
} finally {
@@ -20,7 +20,7 @@
import org.minidns.record.Record.CLASS;
import org.minidns.record.Record.TYPE;

public class RrSet {
public final class RrSet {

public final DnsName name;
public final TYPE type;
@@ -35,7 +35,7 @@ private RrSet(DnsName name, TYPE type, CLASS clazz, Set<Record<? extends Data>>
}

@Override
public final String toString() {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(name).append('\t').append(clazz).append('\t').append(type).append('\n');
for (Record<?> record : records) {
@@ -48,7 +48,7 @@ public static Builder builder() {
return new Builder();
}

public static class Builder {
public static final class Builder {
private DnsName name;
private TYPE type;
private CLASS clazz;
@@ -68,7 +68,7 @@ public Builder addRecord(Record<? extends Data> record) {
}

boolean didNotExist = records.add(record);
assert (didNotExist);
assert didNotExist;

return this;
}
@@ -59,7 +59,7 @@ protected void putNormalized(DnsMessage q, DnsQueryResult result) {
public void offer(DnsMessage query, DnsQueryResult result, DnsName authoritativeZone) {
DnsMessage reply = result.response;
// The reply shouldn't be an authoritative answers when offer() is used. That would be a case for put().
assert(!reply.authoritativeAnswer);
assert !reply.authoritativeAnswer;

Map<DnsMessage, List<Record<? extends Data>>> extraCaches = new HashMap<>(reply.additionalSection.size());

@@ -70,7 +70,7 @@ public void offer(DnsMessage query, DnsQueryResult result, DnsName authoritative
putExtraCaches(result, extraCaches);
}

private final void gather(Map<DnsMessage, List<Record<?extends Data>>> extraCaches, DnsMessage q, List<Record<? extends Data>> records, DnsName authoritativeZone) {
private void gather(Map<DnsMessage, List<Record<?extends Data>>> extraCaches, DnsMessage q, List<Record<? extends Data>> records, DnsName authoritativeZone) {
for (Record<? extends Data> extraRecord : records) {
if (!shouldGather(extraRecord, q.getQuestion(), authoritativeZone))
continue;
@@ -98,7 +98,7 @@ private final void gather(Map<DnsMessage, List<Record<?extends Data>>> extraCach
}
}

private final void putExtraCaches(DnsQueryResult synthesynthesizationSource, Map<DnsMessage, List<Record<? extends Data>>> extraCaches) {
private void putExtraCaches(DnsQueryResult synthesynthesizationSource, Map<DnsMessage, List<Record<? extends Data>>> extraCaches) {
DnsMessage reply = synthesynthesizationSource.response;
for (Entry<DnsMessage, List<Record<? extends Data>>> entry : extraCaches.entrySet()) {
DnsMessage question = entry.getKey();
@@ -65,8 +65,7 @@ public LruCache(final int capacity, final long maxTTL) {
this.capacity = capacity;
this.maxTTL = maxTTL;
backend = new LinkedHashMap<DnsMessage, CachedDnsQueryResult>(
Math.min(capacity + (capacity + 3) / 4 + 2, 11), 0.75f, true)
{
Math.min(capacity + (capacity + 3) / 4 + 2, 11), 0.75f, true) {
@Override
protected boolean removeEldestEntry(
Entry<DnsMessage, CachedDnsQueryResult> eldest) {
@@ -18,7 +18,7 @@

public abstract class AbstractDnsServerLookupMechanism implements DnsServerLookupMechanism {

protected final static Logger LOGGER = Logger.getLogger(AbstractDnsServerLookupMechanism.class.getName());
protected static final Logger LOGGER = Logger.getLogger(AbstractDnsServerLookupMechanism.class.getName());

private final String name;
private final int priority;
@@ -28,7 +28,7 @@
/**
* Try to retrieve the list of DNS server by executing getprop.
*/
public class AndroidUsingExec extends AbstractDnsServerLookupMechanism {
public final class AndroidUsingExec extends AbstractDnsServerLookupMechanism {

public static final DnsServerLookupMechanism INSTANCE = new AndroidUsingExec();
public static final int PRIORITY = AndroidUsingReflection.PRIORITY - 1;
@@ -43,7 +43,7 @@ protected AndroidUsingReflection() {
for (String propKey : new String[] {
"net.dns1", "net.dns2", "net.dns3", "net.dns4"}) {

String value = (String)method.invoke(null, propKey);
String value = (String) method.invoke(null, propKey);

if (value == null) continue;
if (value.length() == 0) continue;
@@ -14,11 +14,11 @@

public interface DnsServerLookupMechanism extends Comparable<DnsServerLookupMechanism> {

public String getName();
String getName();

public int getPriority();
int getPriority();

public boolean isAvailable();
boolean isAvailable();

/**
* Returns a List of String representing ideally IP addresses. The list must be modifiable.
@@ -29,6 +29,6 @@
*
* @return a List of Strings presenting hopefully IP addresses.
*/
public List<String> getDnsServerAddresses();
List<String> getDnsServerAddresses();

}
@@ -24,7 +24,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class UnixUsingEtcResolvConf extends AbstractDnsServerLookupMechanism {
public final class UnixUsingEtcResolvConf extends AbstractDnsServerLookupMechanism {

public static final DnsServerLookupMechanism INSTANCE = new UnixUsingEtcResolvConf();
public static final int PRIORITY = 2000;
@@ -19,7 +19,7 @@

public interface DnsDataSource {

abstract DnsQueryResult query(DnsMessage message, InetAddress address, int port) throws IOException;
DnsQueryResult query(DnsMessage message, InetAddress address, int port) throws IOException;

MiniDnsFuture<DnsQueryResult, IOException> queryAsync(DnsMessage message, InetAddress address, int port, OnResponseCallback onResponseCallback);

0 comments on commit ae5ae8e

Please sign in to comment.
You can’t perform that action at this time.