feat: Adds checkstyle module. (#233)

* feat: Adds checkstyle module.
This commit is contained in:
Дамян Минков 2021-09-02 12:54:33 -05:00 committed by GitHub
parent adca67b17f
commit 9dc08bd299
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
82 changed files with 570 additions and 494 deletions

40
checkstyle.xml Normal file
View File

@ -0,0 +1,40 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="SuppressWithPlainTextCommentFilter"/>
<module name="LineLength">
<property name="fileExtensions" value="java"/>
<property name="max" value="120"/>
<property name="ignorePattern" value="http://|https://"/>
</module>
<module name="TreeWalker">
<module name="LeftCurly">
<property name="option" value="nl"/>
<property name="tokens" value="LITERAL_CATCH"/>
<property name="tokens" value="LITERAL_ELSE"/>
<property name="tokens" value="LITERAL_FINALLY"/>
<property name="tokens" value="LITERAL_IF"/>
<property name="tokens" value="LITERAL_TRY"/>
</module>
<!-- Skips empty blocks {}, to not skip them: value="alone" -->
<module name="RightCurly">
<property name="option" value="alone_or_singleline"/>
</module>
<module name="WhitespaceAfter">
<!-- Drops TYPECAST from default tokens -->
<property name="tokens" value="COMMA , SEMI , LITERAL_IF , LITERAL_ELSE , LITERAL_WHILE , LITERAL_DO , LITERAL_FOR , DO_WHILE"/>
</module>
</module>
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
</module>

15
pom.xml
View File

@ -191,6 +191,21 @@
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.gantsign.maven</groupId>
<artifactId>ktlint-maven-plugin</artifactId>

View File

@ -221,10 +221,12 @@ abstract class AddressAttribute extends Attribute
binValue[7] = (byte)(getPort() & 0x00FF);
//address
if(getFamily() == ADDRESS_FAMILY_IPV6){
if (getFamily() == ADDRESS_FAMILY_IPV6)
{
System.arraycopy(getAddressBytes(), 0, binValue, 8, 16);
}
else{
else
{
System.arraycopy(getAddressBytes(), 0, binValue, 8, 4);
}

View File

@ -468,15 +468,18 @@ public class Component
* since those candidates aren't added to the candidate list even
* though the pair is added to the check list).
*/
CandidatePair existingPair = streamCheckList.findPairMatching(pair.getLocalCandidate(), pair.getRemoteCandidate());
if (existingPair != null) {
CandidatePair existingPair
= streamCheckList.findPairMatching(pair.getLocalCandidate(), pair.getRemoteCandidate());
if (existingPair != null)
{
logger.info("existing Pair updated: " +
existingPair.toShortString() +
" to " + pair.toShortString() + ".");
existingPair.setRemoteCandidate(pair.getRemoteCandidate());
existingPair.computePriority();
}
else {
else
{
streamCheckList.add(pair);
logger.info("new Pair added: " + pair.toShortString()
+ ".");

View File

@ -255,7 +255,8 @@ class ConnectivityCheckServer
final boolean bothControlledConflict = !selfIceControlling &&
req.containsAttribute(Attribute.ICE_CONTROLLED);
if (!(bothControllingConflict || bothControlledConflict)) {
if (!(bothControllingConflict || bothControlledConflict))
{
// we don't have a role conflict
return true;
}

View File

@ -196,7 +196,8 @@ public class MappingCandidateHarvesters
for (MappingCandidateHarvester h : harvesters)
{
if (face.getAddress().equals(h.getFace().getAddress()) && mask.getAddress().equals(h.getMask().getAddress()))
if (face.getAddress().equals(h.getFace().getAddress())
&& mask.getAddress().equals(h.getMask().getAddress()))
{
logger.info("Discarding a mapping harvester with duplicate "
+ "addresses: " + harvester + ". Kept: " + h);

View File

@ -469,6 +469,7 @@ public abstract class Message
/* Old TURN attributes */
protected static final byte DESTINATION_ADDRESS_PRESENTITY_INDEX = 29;
// CHECKSTYLE:OFF
protected final static byte attributePresentities[][] = new byte[][]{
// Binding Shared Shared Shared Alloc Alloc Rfrsh Rfrsh ChnlBnd ChnlBnd Send Data
// Binding Binding Error Secret Secret Secret Req. Resp. Req. Resp. Req. Resp. Indic. Indic.
@ -509,6 +510,7 @@ public abstract class Message
/*USE-CANDIDATE*/ { O, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A},
/*DESTINATION-ADDRESS*/{N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, O, N_A, N_A, N_A, M, N_A},
};
// CHECKSTYLE:ON
/**
* Creates an empty STUN Message.

View File

@ -54,7 +54,8 @@ public class MessageFactory
try
{
bindingRequest.setMessageType(Message.BINDING_REQUEST);
} catch (IllegalArgumentException ex)
}
catch (IllegalArgumentException ex)
{
// there should be no exc here since we're the creators.
logger.log(Level.FINE, "Failed to set message type.", ex);
@ -122,7 +123,8 @@ public class MessageFactory
IceControllingAttribute iceControllingAttribute = AttributeFactory
.createIceControllingAttribute(tieBreaker);
bindingRequest.putAttribute(iceControllingAttribute);
} else
}
else
{
IceControlledAttribute iceControlledAttribute = AttributeFactory
.createIceControlledAttribute(tieBreaker);
@ -356,7 +358,8 @@ public class MessageFactory
try
{
allocateRequest.setMessageType(Message.ALLOCATE_REQUEST);
} catch (IllegalArgumentException ex)
}
catch (IllegalArgumentException ex)
{
// there should be no exc here since we're the creators.
logger.log(Level.FINE, "Failed to set message type.", ex);
@ -669,7 +672,8 @@ public class MessageFactory
LifetimeAttribute lifetimeReq = AttributeFactory
.createLifetimeAttribute(lifetime);
refreshRequest.putAttribute(lifetimeReq);
} catch (IllegalArgumentException ex)
}
catch (IllegalArgumentException ex)
{
logger.log(Level.FINE, "Failed to set message type.", ex);
}
@ -949,7 +953,8 @@ public class MessageFactory
.createDataAttribute(data);
sendIndication.putAttribute(dataAttribute);
}
} catch (IllegalArgumentException ex)
}
catch (IllegalArgumentException ex)
{
logger.log(Level.FINE, "Failed to set message type.", ex);
}

View File

@ -445,7 +445,8 @@ public class PseudoTCPBase
long nInFlight = m_snd_nxt - m_snd_una;
m_ssthresh = Math.max(nInFlight / 2, 2 * m_mss);
//Logger.Log(LS_INFO) << "m_ssthresh: " << m_ssthresh << " nInFlight: " << nInFlight << " m_mss: " << m_mss;
//Logger.Log(LS_INFO)
// << "m_ssthresh: " << m_ssthresh << " nInFlight: " << nInFlight << " m_mss: " << m_mss;
m_cwnd = m_mss;
// Back off retransmit timer. Note: the limit is lower when connecting.
@ -1252,7 +1253,8 @@ public class PseudoTCPBase
m_recover = m_snd_nxt;
long nInFlight = m_snd_nxt - m_snd_una;
m_ssthresh = Math.max(nInFlight / 2, 2 * m_mss);
//Logger.Log(LS_INFO) << "m_ssthresh: " << m_ssthresh << " nInFlight: " << nInFlight << " m_mss: " << m_mss;
//Logger.Log(LS_INFO)
// << "m_ssthresh: " << m_ssthresh << " nInFlight: " << nInFlight << " m_mss: " << m_mss;
m_cwnd = m_ssthresh + 3 * m_mss;
}
else

View File

@ -755,8 +755,9 @@ public class DelegatingDatagramSocket
p.setAddress(newAddr);
super.send(p);
} else if (ex instanceof IOException) {
}
else if (ex instanceof IOException)
{
throw((IOException)ex);
}
}

View File

@ -210,7 +210,8 @@ class Connector
if (!running)
return;
if (logger.isLoggable(Level.FINEST)){
if (logger.isLoggable(Level.FINEST))
{
logger.finest("received datagram packet - addr: "
+ packet.getAddress() + " port: " + packet.getPort());
}

View File

@ -301,7 +301,8 @@ class NetAccessManager
{
logger.log(Level.WARNING, "Removing connector:" + connector,
error);
} else if (logger.isLoggable(Level.FINE))
}
else if (logger.isLoggable(Level.FINE))
{
logger.fine("Removing connector " + connector);
}

View File

@ -165,7 +165,8 @@ public class StunServerTransaction
IOException,
IllegalArgumentException
{
if(!isRetransmitting){
if (!isRetransmitting)
{
this.response = response;
//the transaction id might already have been set, but its our job
//to make sure of that

View File

@ -409,7 +409,8 @@ public class NetworkConfigurationDiscoveryProcess
{
Request request = MessageFactory.createBindingRequest();
/* ChangeRequestAttribute changeRequest = (ChangeRequestAttribute)request.getAttribute(Attribute.CHANGE_REQUEST); */
/* ChangeRequestAttribute changeRequest
= (ChangeRequestAttribute)request.getAttribute(Attribute.CHANGE_REQUEST); */
/* add a change request attribute */
ChangeRequestAttribute changeRequest = AttributeFactory.createChangeRequestAttribute();
changeRequest.setChangeIpFlag(false);