mlaccetti/JavaPNS

View on GitHub

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 {
Severity: Minor
Found in src/main/java/javapns/communication/ProxyManager.java - About 1 hr to fix

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 {
Severity: Minor
Found in src/main/java/javapns/communication/ProxyManager.java - About 1 hr to fix

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;
Severity: Minor
Found in src/test/java/javapns/test/SpecificNotificationTests.java - About 1 hr to fix

    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";
    Severity: Minor
    Found in src/main/java/javapns/communication/ConnectionToAppleServer.java - About 1 hr to fix

    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";
    Severity: Minor
    Found in src/main/java/javapns/communication/ConnectionToAppleServer.java - About 1 hr to fix

      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;
          }
      Severity: Minor
      Found in src/main/java/javapns/devices/Devices.java - About 1 hr to fix

        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) {
        Severity: Minor
        Found in src/main/java/javapns/notification/PushNotificationManager.java - About 1 hr to fix

          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*/
          
          
          Severity: Minor
          Found in src/main/java/javapns/notification/PushNotificationManager.java - About 1 hr to fix

          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";
          Severity: Minor
          Found in src/main/java/javapns/notification/ResponsePacket.java - About 1 hr to fix

            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()) {
            Severity: Minor
            Found in src/main/java/javapns/communication/KeystoreManager.java - About 1 hr to fix

              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();
              Severity: Minor
              Found in src/test/java/javapns/test/NotificationTest.java - About 1 hr to fix

              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);
              Severity: Minor
              Found in src/test/java/javapns/test/NotificationTest.java - About 1 hr to fix

                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;
                    }
                Severity: Minor
                Found in src/main/java/javapns/Push.java - About 1 hr to fix

                  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");
                  Severity: Minor
                  Found in src/test/java/javapns/test/NotificationTest.java - About 1 hr to fix

                  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;
                      }
                  Severity: Minor
                  Found in src/main/java/javapns/Push.java - About 1 hr to fix

                    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;
                        }
                    Severity: Minor
                    Found in src/main/java/javapns/notification/ResponsePacketReader.java - About 1 hr to fix

                      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) {
                      Severity: Major
                      Found in src/test/java/javapns/test/NotificationTest.java - About 50 mins to fix

                        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 {
                        Severity: Major
                        Found in src/main/java/javapns/Push.java - About 50 mins to fix

                          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 {
                          Severity: Minor
                          Found in src/test/java/javapns/test/SpecificNotificationTests.java - About 45 mins to fix

                            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; // ,"":""
                            Severity: Minor
                            Found in src/main/java/javapns/notification/Payload.java - About 45 mins to fix

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language