Showing 80 of 107 total issues
Method getProxyHost
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
static String getProxyHost(final AppleServer server) {
String host = server != null ? server.getProxyHost() : null;
if (host != null && host.length() > 0) {
return host;
} else {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method getProxyPort
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
static int getProxyPort(final AppleServer server) {
String host = server != null ? server.getProxyHost() : null;
if (host != null && host.length() > 0) {
return server.getProxyPort();
} else {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method test_Issue102
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static void test_Issue102(final String keystore, final String password, String token, final boolean production) {
try {
System.out.println("");
System.out.println("TESTING ISSUE #102");
final int devices = 10000;
Method doTunnelHandshake
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private void doTunnelHandshake(final Socket tunnel, final String host, final int port) throws IOException {
final OutputStream out = tunnel.getOutputStream();
final String msg = "CONNECT " + host + ":" + port + " HTTP/1.0\n" + "User-Agent: BoardPad Server" + "\r\n\r\n";
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method doTunnelHandshake
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void doTunnelHandshake(final Socket tunnel, final String host, final int port) throws IOException {
final OutputStream out = tunnel.getOutputStream();
final String msg = "CONNECT " + host + ":" + port + " HTTP/1.0\n" + "User-Agent: BoardPad Server" + "\r\n\r\n";
Method asDevices
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static List<Device> asDevices(final Object rawList) {
final List<Device> list = new ArrayList<>();
if (rawList == null) {
return list;
}
Method processedFailedNotifications
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private int processedFailedNotifications() throws CommunicationException, KeystoreException {
if (useEnhancedNotificationFormat) {
logger.debug("Reading responses");
int responsesReceived = ResponsePacketReader.processResponses(this);
while (responsesReceived > 0) {
Method getMessage
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private byte[] getMessage(String deviceToken, final Payload payload, final int identifier, final PushedNotification message) throws IOException, Exception {
logger.debug("Building Raw message from deviceToken and payload");
/* To test with a corrupted or invalid token, uncomment following line*/
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method getMessage
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public String getMessage() {
if (command == 8) {
final String prefix = "APNS: [" + identifier + "] "; //APNS ERROR FOR MESSAGE ID #" + identifier + ": ";
if (status == 0) {
return prefix + "No errors encountered";
Method verifyKeystoreContent
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static void verifyKeystoreContent(final KeyStore keystore) throws KeystoreException {
try {
int numberOfCertificates = 0;
final Enumeration<String> aliases = keystore.aliases();
while (aliases.hasMoreElements()) {
Method printPushedNotifications
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
static void printPushedNotifications(final List<PushedNotification> notifications) {
final List<PushedNotification> failedNotifications = PushedNotification.findFailedNotifications(notifications);
final List<PushedNotification> successfulNotifications = PushedNotification.findSuccessfulNotifications(notifications);
final int failed = failedNotifications.size();
final int successful = successfulNotifications.size();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method pushSimplePayloadUsingThreads
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static void pushSimplePayloadUsingThreads(final String keystore, final String password, final boolean production, final String token, final boolean simulation, final int devices, final int threads) {
try {
System.out.println("Creating PushNotificationManager and AppleNotificationServer");
final AppleNotificationServer server = new AppleNotificationServerBasicImpl(keystore, password, production);
Method sendPayloads
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static PushedNotifications sendPayloads(final Object keystore, final String password, final boolean production, final Object payloadDevicePairs) throws CommunicationException, KeystoreException {
final PushedNotifications notifications = new PushedNotifications();
if (payloadDevicePairs == null) {
return notifications;
}
Method pushTest
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private static void pushTest(final String[] args) throws CommunicationException, KeystoreException {
final String keystore = args[0];
final String password = args[1];
final String token = args[2];
final boolean production = args.length >= 4 && args[3].equalsIgnoreCase("production");
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method sendPayload
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static PushedNotifications sendPayload(final Payload payload, final Object keystore, final String password, final boolean production, final Object devices) throws CommunicationException, KeystoreException {
final PushedNotifications notifications = new PushedNotifications();
if (payload == null) {
return notifications;
}
Method readResponsePacketData
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static ResponsePacket readResponsePacketData(final InputStream input) throws IOException {
final int command = input.read();
if (command < 0) {
return null;
}
Method pushSimplePayloadUsingThreads
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
private static void pushSimplePayloadUsingThreads(final String keystore, final String password, final boolean production, final String token, final boolean simulation, final int devices, final int threads) {
Method combined
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public static PushedNotifications combined(final String message, final int badge, final String sound, final Object keystore, final String password, final boolean production, final Object devices) throws CommunicationException, KeystoreException {
Method pushSpecificPayloadSize
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private static void pushSpecificPayloadSize(final String keystore, final String password, final String token, final boolean production, final boolean checkWhenAdding, final int targetPayloadSize) throws CommunicationException, KeystoreException, JSONException {
Method estimatePayloadSizeAfterAdding
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private int estimatePayloadSizeAfterAdding(final String propertyName, final Object propertyValue) {
try {
int estimatedSize = getPayloadAsBytesUnchecked().length;
if (propertyName != null && propertyValue != null) {
estimatedSize += 6; // ,"":""
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"