Commit 5903cff6 authored by Heiko Bornholdt's avatar Heiko Bornholdt Committed by bornholdt
Browse files

let maven validate codestyle

parent e2ac8717
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2020-2021 Heiko Bornholdt and Kevin Röbert
~ Copyright (c) 2020-2022 Heiko Bornholdt and Kevin Röbert
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
......@@ -22,65 +22,186 @@
-->
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/>
<property name="fileExtensions" value="java, properties, xml"/>
<!-- Excludes all 'module-info.java' files -->
<!-- See https://checkstyle.org/config_filefilters.html -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>
<module name="LineLength">
<property name="fileExtensions" value="java"/>
<property name="max" value="160"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
<!-- Annotations -->
<module name="SuppressWarningsFilter"/>
<!-- Javadoc Comments -->
<!-- <module name="JavadocPackage"/>-->
<!-- Miscellaneous -->
<module name="NewlineAtEndOfFile"/>
<module name="UniqueProperties"/>
<!-- Regexp -->
<!-- Prohibit consecutive empty lines (except the lines after package/import) -->
<module name="RegexpMultiline">
<property name="format" value="\n *(?!package )(?!import )[^\n]+\n{3,}"/>
<property name="message" value="two or more consecutive empty lines"/>
</module>
<!-- Copyright headers -->
<module name="RegexpSingleline">
<property name="format" value="Copyright.+Heiko Bornholdt and Kevin Röbert$"/>
<property name="minimum" value="1"/>
<property name="maximum" value="1"/>
<property name="message" value="missing copyright header"/>
</module>
<!-- Trailing whitespace -->
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="message" value="trailing whitespace"/>
</module>
<module name="JavadocPackage"/>
<!-- Whitespace -->
<module name="FileTabCharacter"/>
<module name="TreeWalker">
<module name="AvoidEscapedUnicodeCharacters">
<property name="allowEscapesForControlCharacters" value="true"/>
<property name="allowByTailComment" value="true"/>
<property name="allowNonPrintableEscapes" value="true"/>
<!-- Block Checks -->
<module name="AvoidNestedBlocks">
<property name="allowInSwitchCase" value="true"/>
</module>
<module name="EmptyBlock">
<property name="option" value="text"/>
</module>
<module name="EmptyCatchBlock"/>
<module name="LeftCurly"/>
<module name="RightCurly">
<property name="option" value="alone"/>
</module>
<module name="AvoidStarImport"/>
<!-- Class Design -->
<!-- <module name="FinalClass"/>-->
<module name="InnerTypeLast"/>
<module name="InterfaceIsType"/>
<module name="MutableException"/>
<module name="OneTopLevelClass"/>
<!-- Coding -->
<module name="CovariantEquals"/>
<!-- <module name="DeclarationOrder"/>-->
<module name="DefaultComesLast"/>
<module name="EqualsAvoidNull"/>
<module name="EqualsHashCode"/>
<module name="ExplicitInitialization"/>
<module name="FinalLocalVariable"/>
<module name="ModifiedControlVariable"/>
<module name="MultipleVariableDeclarations"/>
<module name="Indentation"/>
<module name="NoFinalizer"/>
<module name="OneStatementPerLine"/>
<module name="PackageDeclaration"/>
<module name="RequireThis"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<module name="StringLiteralEquality"/>
<module name="SuperClone"/>
<module name="SuperFinalize"/>
<module name="UnnecessarySemicolonAfterTypeMemberDeclaration"/>
<module name="UnnecessarySemicolonInEnumeration"/>
<module name="UnnecessarySemicolonInTryWithResources"/>
<!-- Annotations -->
<module name="AnnotationLocation"/>
<!-- false positives -->
<!-- <module name="MissingDeprecated"/>-->
<module name="MissingOverride"/>
<module name="PackageAnnotation"/>
<module name="SuppressWarningsHolder"/>
<!-- Imports -->
<module name="AvoidStarImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports"/>
<!-- Javadoc -->
<!-- Javadoc Comments -->
<module name="InvalidJavadocPosition"/>
<module name="JavadocContentLocationCheck"/>
<module name="JavadocStyle">
<!-- false positives -->
<property name="checkFirstSentence" value="false"/>
<property name="checkHtml" value="false"/>
</module>
<module name="MissingJavadocPackage"/>
<!-- Miscellaneous -->
<module name="ArrayTypeStyle"/>
<!-- false positives -->
<!-- <module name="FinalParameters"/>-->
<module name="OuterTypeFilename"/>
<module name="UpperEll"/>
<!-- Modifiers -->
<module name="ModifierOrder"/>
<!-- false positives -->
<!-- <module name="RedundantModifier">-->
<!-- <property name="tokens"-->
<!-- value="METHOD_DEF, VARIABLE_DEF, ANNOTATION_FIELD_DEF, INTERFACE_DEF, CTOR_DEF, CLASS_DEF, ENUM_DEF"/>-->
<!-- </module>-->
<module name="JavadocMethod">
<property name="scope" value="public"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="allowedAnnotations" value="Override, Test"/>
<property name="tokens" value="METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF"/>
<!-- Naming Conventions -->
<module name="AbbreviationAsWordInName">
<property name="ignoreFinal" value="false"/>
</module>
<module name="MissingJavadocMethod">
<property name="scope" value="public"/>
<property name="minLineCount" value="2"/>
<property name="allowedAnnotations" value="Override, Test"/>
<property name="tokens" value="METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF"/>
<module name="CatchParameterName">
<property name="format" value="^(e|e[1-9][\d]*|[a-z][a-z][a-zA-Z]+)$"/>
</module>
<module name="ClassTypeParameterName"/>
<module name="ConstantName">
<property name="applyToPrivate" value="false"/>
</module>
<module name="InterfaceTypeParameterName"/>
<module name="LambdaParameterName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName">
<property name="applyToPrivate" value="false"/>
</module>
<module name="MethodTypeParameterName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<module name="NeedBraces">
<!-- Whitespace -->
<module name="EmptyForInitializerPad"/>
<module name="EmptyForIteratorPad">
<property name="option" value="space"/>
</module>
<module name="EmptyLineSeparator">
<property name="allowNoEmptyLineBetweenFields" value="true"/>
<property name="allowMultipleEmptyLines" value="false"/>
<property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
<property name="tokens"
value="LITERAL_DO, LITERAL_ELSE, LITERAL_FOR, LITERAL_IF, LITERAL_WHILE"/>
value="IMPORT, STATIC_IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF, STATIC_INIT, INSTANCE_INIT, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
</module>
<module name="FinalLocalVariable">
<property name="tokens" value="VARIABLE_DEF"/>
<property name="validateEnhancedForLoopVariable" value="true"/>
<module name="GenericWhitespace"/>
<module name="MethodParamPad"/>
<module name="NoLineWrap"/>
<module name="NoWhitespaceAfter">
<property name="tokens" value="AT, INC, DEC, UNARY_MINUS, UNARY_PLUS, BNOT, LNOT, DOT, ARRAY_DECLARATOR, INDEX_OP"/>
</module>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap">
<property name="option" value="eol"/>
</module>
<module name="ParenPad"/>
<module name="SeparatorWrap">
<property name="tokens" value="COMMA"/>
</module>
<module name="SingleSpaceSeparator"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround">
<property name="tokens"
value="ASSIGN, 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>
</module>
</module>
......@@ -55,7 +55,7 @@ import java.util.Queue;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import static org.drasyl.node.JSONUtil.JACKSON_MAPPER;
import static org.drasyl.node.JsonUtil.JACKSON_MAPPER;
/**
* Run a drasyl node.
......
......@@ -258,6 +258,30 @@ public class TunCommand extends ChannelOptions {
}
}
public static void printRoutingTable(final PrintStream out,
final Identity identity,
final InetAddress address,
final Map<InetAddress, DrasylAddress> routes) {
out.println("My routing table:");
final Map<InetAddress, DrasylAddress> routingTable = new HashMap<>(routes);
routingTable.put(address, identity.getAddress());
final List<InetAddress> inetAddresses = new ArrayList<>(routingTable.keySet());
inetAddresses.sort(new InetAddressComparator());
for (final InetAddress inetAddress : inetAddresses) {
out.print(" ");
out.printf("%1$-14s", inetAddress.getHostAddress());
out.print(" <-> ");
out.print(routingTable.get(inetAddress));
if (address.equals(inetAddress)) {
out.print(" (this is me)");
}
out.println();
}
out.println();
}
/**
* Assign IP address and subnet to the tun device.
*/
......@@ -436,28 +460,4 @@ public class TunCommand extends ChannelOptions {
this.publicKey = requireNonNull(publicKey);
}
}
public static void printRoutingTable(final PrintStream out,
final Identity identity,
final InetAddress address,
final Map<InetAddress, DrasylAddress> routes) {
out.println("My routing table:");
final Map<InetAddress, DrasylAddress> routingTable = new HashMap<>(routes);
routingTable.put(address, identity.getAddress());
final List<InetAddress> inetAddresses = new ArrayList<>(routingTable.keySet());
inetAddresses.sort(new InetAddressComparator());
for (final InetAddress inetAddress : inetAddresses) {
out.print(" ");
out.printf("%1$-14s", inetAddress.getHostAddress());
out.print(" <-> ");
out.print(routingTable.get(inetAddress));
if (address.equals(inetAddress)) {
out.print(" (this is me)");
}
out.println();
}
out.println();
}
}
......@@ -114,14 +114,14 @@ public class DrasylServerChannel extends AbstractServerChannel {
protected void doRegister() throws Exception {
super.doRegister();
pipeline().addLast((new ChannelInitializer<>() {
pipeline().addLast(new ChannelInitializer<>() {
@Override
public void initChannel(final Channel ch) {
ch.pipeline().addLast(new ChildChannelRouter(paths));
ch.pipeline().addLast(new DuplicateChannelFilter());
ch.pipeline().addLast(new PendingWritesFlusher());
}
}));
});
}
@Override
......
......@@ -83,7 +83,7 @@ public class UserEventAwareEmbeddedChannel extends EmbeddedChannel {
private static class UserEventAcceptor extends ChannelInboundHandlerAdapter {
private final Queue<Object> userEvents;
public UserEventAcceptor() {
UserEventAcceptor() {
this.userEvents = new ArrayDeque<>();
}
......
......@@ -38,7 +38,7 @@ import java.nio.file.StandardCopyOption;
* <p>
* Based on: <a href="https://github.com/adamheinrich/native-utils">native-utils</a>
*/
public class NativeLoader {
public final class NativeLoader {
public static final String NATIVE_FOLDER_PATH_PREFIX = "nativeloader";
/**
* The minimum length a prefix for a file has to have according to
......@@ -148,9 +148,9 @@ public class NativeLoader {
.supportedFileAttributeViews()
.contains("posix");
}
catch (final FileSystemNotFoundException
| ProviderNotFoundException
| SecurityException e) {
catch (final FileSystemNotFoundException |
ProviderNotFoundException |
SecurityException e) {
return false;
}
}
......
......@@ -34,9 +34,9 @@ import org.drasyl.identity.DrasylAddress;
@Sharable
public class LoopbackHandler extends ChannelOutboundHandlerAdapter {
@Override
public void write(ChannelHandlerContext ctx,
Object msg,
ChannelPromise promise) {
public void write(final ChannelHandlerContext ctx,
final Object msg,
final ChannelPromise promise) {
if (msg instanceof OverlayAddressedMessage && ctx.channel().localAddress().equals(((OverlayAddressedMessage<?>) msg).recipient())) {
promise.setSuccess();
ctx.fireChannelRead(new OverlayAddressedMessage<>(((OverlayAddressedMessage<?>) msg).content(), (DrasylAddress) ctx.channel().localAddress(), (DrasylAddress) ctx.channel().localAddress()));
......
/*
* Copyright (c) 2020-2021 Heiko Bornholdt and Kevin Röbert
* Copyright (c) 2020-2022 Heiko Bornholdt and Kevin Röbert
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
......@@ -19,7 +19,7 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/
package org.drasyl.node.plugin.groups.client.message;
import org.drasyl.node.plugin.groups.client.Group;
/**
* Handlers used to run a drasyl node.
*/
package org.drasyl.handler;
......@@ -235,7 +235,7 @@ public class LocalNetworkDiscovery extends ChannelDuplexHandler {
this.lastInboundPingTime = lastInboundPingTime;
}
public Peer(final InetSocketAddress address, final long pingTimeoutMillis) {
Peer(final InetSocketAddress address, final long pingTimeoutMillis) {
this(pingTimeoutMillis, address, 0L);
}
......
......@@ -150,7 +150,7 @@ public class UdpBroadcastServer extends ChannelInboundHandlerAdapter {
}
private class UdpBroadcastServerHandler extends SimpleChannelInboundHandler<DatagramPacket> {
public UdpBroadcastServerHandler() {
UdpBroadcastServerHandler() {
super(false);
}
......@@ -174,7 +174,7 @@ public class UdpBroadcastServer extends ChannelInboundHandlerAdapter {
private class UdpBroadcastServerFutureListener implements ChannelFutureListener {
private final ChannelHandlerContext ctx;
public UdpBroadcastServerFutureListener(final ChannelHandlerContext ctx) {
UdpBroadcastServerFutureListener(final ChannelHandlerContext ctx) {
this.ctx = ctx;
}
......
......@@ -184,7 +184,7 @@ public class UdpMulticastServer extends ChannelInboundHandlerAdapter {
}
private class UdpMulticastServerHandler extends SimpleChannelInboundHandler<DatagramPacket> {
public UdpMulticastServerHandler() {
UdpMulticastServerHandler() {
super(false);
}
......@@ -208,7 +208,7 @@ public class UdpMulticastServer extends ChannelInboundHandlerAdapter {
private class UdpMulticastServerFutureListener implements ChannelFutureListener {
private final ChannelHandlerContext ctx;
public UdpMulticastServerFutureListener(final ChannelHandlerContext ctx) {
UdpMulticastServerFutureListener(final ChannelHandlerContext ctx) {
this.ctx = ctx;
}
......
......@@ -202,7 +202,7 @@ public class UdpServer extends ChannelDuplexHandler {
private class UdpServerHandler extends SimpleChannelInboundHandler<DatagramPacket> {
private final ChannelHandlerContext drasylServerChannelCtx;
public UdpServerHandler(final ChannelHandlerContext drasylServerChannelCtx) {
UdpServerHandler(final ChannelHandlerContext drasylServerChannelCtx) {
super(false);
this.drasylServerChannelCtx = drasylServerChannelCtx;
}
......@@ -247,7 +247,7 @@ public class UdpServer extends ChannelDuplexHandler {
private class UdpServerBindListener implements ChannelFutureListener {
private final ChannelHandlerContext ctx;
public UdpServerBindListener(final ChannelHandlerContext ctx) {
UdpServerBindListener(final ChannelHandlerContext ctx) {
this.ctx = ctx;
}
......
......@@ -79,8 +79,8 @@ public class ProtocolArmHandler extends MessageToMessageCodec<InetAddressedMessa
if (msg instanceof InetAddressedMessage && ((InetAddressedMessage<?>) msg).content() instanceof ArmedProtocolMessage) {
final ArmedProtocolMessage armedMessage = ((InetAddressedMessage<ArmedProtocolMessage>) msg).content();
return Objects.equals(myIdentity.getIdentityPublicKey(), armedMessage.getRecipient())
&& !Objects.equals(myIdentity.getIdentityPublicKey(), armedMessage.getSender());
return Objects.equals(myIdentity.getIdentityPublicKey(), armedMessage.getRecipient()) &&
!Objects.equals(myIdentity.getIdentityPublicKey(), armedMessage.getSender());
}
return false;
}
......
......@@ -440,9 +440,9 @@ public class InternetDiscoveryChildrenHandler extends ChannelDuplexHandler {
this.rtt = rtt;
}
public SuperPeer(final LongSupplier currentTime,
final long pingTimeoutMillis,
final InetSocketAddress inetAddress) {
SuperPeer(final LongSupplier currentTime,
final long pingTimeoutMillis,
final InetSocketAddress inetAddress) {
this(currentTime, pingTimeoutMillis, inetAddress, 0L, 0L);
}
......
......@@ -336,10 +336,10 @@ public class InternetDiscoverySuperPeerHandler extends ChannelDuplexHandler {
this.lastHelloTime = lastHelloTime;
}
public ChildrenPeer(final LongSupplier currentTime,
final long pingTimeoutMillis,
final InetSocketAddress publicInetAddress,
final Set<InetSocketAddress> privateInetAddresses) {
ChildrenPeer(final LongSupplier currentTime,
final long pingTimeoutMillis,
final InetSocketAddress publicInetAddress,
final Set<InetSocketAddress> privateInetAddresses) {
this(currentTime, pingTimeoutMillis, publicInetAddress, privateInetAddresses, 0L);
}
......
......@@ -369,10 +369,10 @@ public class TraversingInternetDiscoveryChildrenHandler extends InternetDiscover
this.lastApplicationTime = lastApplicationTime;
}
public TraversingPeer(final LongSupplier currentTime,
final long pingTimeoutMillis,
final long pingCommunicationTimeoutMillis,
final Set<InetSocketAddress> inetAddressCandidates) {
TraversingPeer(final LongSupplier currentTime,
final long pingTimeoutMillis,
final long pingCommunicationTimeoutMillis,
final Set<InetSocketAddress> inetAddressCandidates) {
this(currentTime, pingTimeoutMillis, pingCommunicationTimeoutMillis, inetAddressCandidates, 0L, 0L, 0L);
}
......
......@@ -125,8 +125,8 @@ public class UpnpIgdPortMapping implements PortMapping {
@Override
public boolean acceptMessage(final InetSocketAddress sender,
final ByteBuf msg) {
return sender != null
&& sender.getPort() == SSDP_MULTICAST_ADDRESS.getPort();
return sender != null &&
sender.getPort() == SSDP_MULTICAST_ADDRESS.getPort();
}
@SuppressWarnings("java:S134")
......
......@@ -75,7 +75,7 @@ public abstract class PublicHeader {
final IdentityPublicKey sender;
final ProofOfWork proofOfWork;
byte flags = byteBuf.readByte();
final byte flags = byteBuf.readByte();
// 000. ....
hopCount = HopCount.of(flags >> 5);
// ...0 ....
......
......@@ -252,8 +252,7 @@ public class TcpClient extends ChannelDuplexHandler {
static class TcpClientHandler extends SimpleChannelInboundHandler<ByteBuf> {
private final ChannelHandlerContext drasylCtx;
public TcpClientHandler(
final ChannelHandlerContext drasylCtx) {
TcpClientHandler(final ChannelHandlerContext drasylCtx) {
super(false);
this.drasylCtx = requireNonNull(drasylCtx);
}
......
......@@ -164,7 +164,7 @@ public class TcpServer extends ChannelDuplexHandler {
private class TcpServerFutureListener implements ChannelFutureListener {
private final ChannelHandlerContext ctx;
public TcpServerFutureListener(final ChannelHandlerContext ctx) {
TcpServerFutureListener(final ChannelHandlerContext ctx) {
this.ctx = ctx;
}
......@@ -191,9 +191,9 @@ public class TcpServer extends ChannelDuplexHandler {
private final ChannelHandlerContext ctx;
private final Duration pingTimeout;
public TcpServerChannelInitializer(final Map<SocketAddress, Channel> clients,
final ChannelHandlerContext ctx,
final Duration pingTimeout) {
TcpServerChannelInitializer(final Map<SocketAddress, Channel> clients,
final ChannelHandlerContext ctx,
final Duration pingTimeout) {
this.clients = requireNonNull(clients);
this.ctx = requireNonNull(ctx);
this.pingTimeout = pingTimeout;
......@@ -214,8 +214,8 @@ public class TcpServer extends ChannelDuplexHandler {
private final Map<SocketAddress, Channel> clients;
private final ChannelHandlerContext ctx;
public TcpServerHandler(final Map<SocketAddress, Channel> clients,
final ChannelHandlerContext ctx) {
TcpServerHandler(final Map<SocketAddress, Channel> clients,
final ChannelHandlerContext ctx) {
super(false);
this.clients = requireNonNull(clients);
this.ctx = requireNonNull(ctx);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment