Showing 80 of 107 total issues
File PushNotificationManager.java
has 420 lines of code (exceeds 250 allowed). Consider refactoring. Open
package javapns.notification;
import javapns.communication.ConnectionToAppleServer;
import javapns.communication.exceptions.CommunicationException;
import javapns.communication.exceptions.InvalidCertificateChainException;
Method sendNotification
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
private void sendNotification(final PushedNotification notification, final boolean closeAfter) throws CommunicationException {
try {
final Device device = notification.getDevice();
final Payload payload = notification.getPayload();
try {
- 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
PushNotificationManager
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
public class PushNotificationManager {
private static final Logger logger = LoggerFactory.getLogger(PushNotificationManager.class);
/* Default retries for a connection */
private static final int DEFAULT_RETRIES = 3;
Method processedFailedNotifications
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
private int processedFailedNotifications() throws CommunicationException, KeystoreException {
if (useEnhancedNotificationFormat) {
logger.debug("Reading responses");
int responsesReceived = ResponsePacketReader.processResponses(this);
while (responsesReceived > 0) {
- 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
NotificationThread
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
public class NotificationThread implements Runnable, PushQueue {
private static final int DEFAULT_MAXNOTIFICATIONSPERCONNECTION = 200;
private static final String JAVA_PNS = "JavaPNS";
private static final String STANDALONE = " standalone";
private static final String GROUPED = " grouped";
Method runQueue
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
private void runQueue() {
if (listener != null) {
listener.eventThreadStarted(this);
}
try {
- 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 sendNotification
has 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void sendNotification(final PushedNotification notification, final boolean closeAfter) throws CommunicationException {
try {
final Device device = notification.getDevice();
final Payload payload = notification.getPayload();
try {
Payload
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
public abstract class Payload {
static final Logger logger = LoggerFactory.getLogger(Payload.class);
/* Character encoding specified by Apple documentation */
private static final String DEFAULT_CHARACTER_ENCODING = "UTF-8";
Method getMessage
has a Cognitive Complexity of 21 (exceeds 5 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";
- 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
File NotificationThread.java
has 282 lines of code (exceeds 250 allowed). Consider refactoring. Open
package javapns.notification.transmission;
import javapns.communication.exceptions.CommunicationException;
import javapns.communication.exceptions.KeystoreException;
import javapns.devices.Device;
Method runList
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private void runList() {
if (listener != null) {
listener.eventThreadStarted(this);
}
busy = true;
- 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
NotificationThreads
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
public class NotificationThreads extends ThreadGroup implements PushQueue {
private static final long DEFAULT_DELAY_BETWEEN_THREADS = 500; // the number of milliseconds to wait between each thread startup
private static final String JAVAPNS_NOTIFICATION_THREADS = "javapns notification threads (";
private static final String THREADS = " threads)";
PushedNotification
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
public class PushedNotification {
private Payload payload;
private Device device;
private ResponsePacket response;
Method getMessage
has 57 lines of code (exceeds 25 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*/
Method asDevices
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public static List<Device> asDevices(final Object rawList) {
final List<Device> list = new ArrayList<>();
if (rawList == null) {
return list;
}
- 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
File SpecificNotificationTests.java
has 256 lines of code (exceeds 250 allowed). Consider refactoring. Open
package javapns.test;
import javapns.Push;
import javapns.communication.exceptions.CommunicationException;
import javapns.communication.exceptions.KeystoreException;
Method getDevices
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
private LinkedList<Device> getDevices(final SSLSocket socket) throws CommunicationException {
// Compute
LinkedList<Device> listDev = null;
try {
Method runList
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void runList() {
if (listener != null) {
listener.eventThreadStarted(this);
}
busy = true;
Method verifyKeystoreContent
has a Cognitive Complexity of 15 (exceeds 5 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()) {
- 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 runQueue
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void runQueue() {
if (listener != null) {
listener.eventThreadStarted(this);
}
try {