mlaccetti/JavaPNS

View on GitHub

Showing 80 of 107 total issues

Avoid deeply nested control flow statements.
Open

            if (foundFirstFail) {
              notificationsToResend.add(notification);
            } else {
              foundFirstFail = true;
            }
Severity: Major
Found in src/main/java/javapns/notification/PushNotificationManager.java - About 45 mins to fix

    Method addDevice has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      public Device addDevice(final String id, String token) throws Exception {
        if ((id == null) || (id.trim().equals(""))) {
          throw new NullIdException();
        } else if ((token == null) || (token.trim().equals(""))) {
          throw new NullDeviceTokenException();

    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 put has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      void put(final String propertyName, final Object propertyValue, final JSONObject object, final boolean opt) throws JSONException {
        try {
          if (isPayloadSizeEstimatedWhenAdding()) {
            final int maximumPayloadSize = getMaximumPayloadSize();
            final int estimatedPayloadSize = estimatePayloadSizeAfterAdding(propertyName, propertyValue);
    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

    Method payload has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      public static PushedNotifications payload(final Payload payload, final Object keystore, final String password, final boolean production, final int numberOfThreads, final Object devices) throws Exception {
    Severity: Minor
    Found in src/main/java/javapns/Push.java - About 45 mins to fix

      Method validateKeystoreParameter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        public static void validateKeystoreParameter(Object keystore) throws InvalidKeystoreReferenceException {
          if (keystore == null) {
            throw new InvalidKeystoreReferenceException((Object) null);
          }
          if (keystore instanceof KeyStore) {
      Severity: Minor
      Found in src/main/java/javapns/communication/KeystoreManager.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

      Method wrapKeystoreException has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        static KeystoreException wrapKeystoreException(final Exception e) {
          if (e != null) {
            final String msg = e.toString();
            if (msg.contains("javax.crypto.BadPaddingException")) {
              return new InvalidKeystorePasswordException();
      Severity: Minor
      Found in src/main/java/javapns/communication/KeystoreManager.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

      Method payload has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        public static PushedNotifications payload(final Payload payload, final Object keystore, final String password, final boolean production, final Object devices) throws CommunicationException, KeystoreException {
      Severity: Minor
      Found in src/main/java/javapns/Push.java - About 35 mins to fix

        Method sendPayload has 5 arguments (exceeds 4 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 {
        Severity: Minor
        Found in src/main/java/javapns/Push.java - About 35 mins to fix

          Method payloads has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            public static PushedNotifications payloads(final Object keystore, final String password, final boolean production, final int numberOfThreads, final Object payloadDevicePairs) throws Exception {
          Severity: Minor
          Found in src/main/java/javapns/Push.java - About 35 mins to fix

            Method badge has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              public static PushedNotifications badge(final int badge, final Object keystore, final String password, final boolean production, final Object devices) throws CommunicationException, KeystoreException {
            Severity: Minor
            Found in src/main/java/javapns/Push.java - About 35 mins to fix

              Method sound has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                public static PushedNotifications sound(final String sound, final Object keystore, final String password, final boolean production, final Object devices) throws CommunicationException, KeystoreException {
              Severity: Minor
              Found in src/main/java/javapns/Push.java - About 35 mins to fix

                Method alert has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  public static PushedNotifications alert(final String message, final Object keystore, final String password, final boolean production, final Object devices) throws CommunicationException, KeystoreException {
                Severity: Minor
                Found in src/main/java/javapns/Push.java - About 35 mins to fix

                  Method streamKeystore has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    static InputStream streamKeystore(final Object keystore) throws InvalidKeystoreReferenceException {
                      validateKeystoreParameter(keystore);
                      try {
                        if (keystore instanceof InputStream) {
                          return (InputStream) keystore;
                  Severity: Minor
                  Found in src/main/java/javapns/communication/KeystoreManager.java - About 35 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

                  Method readResponses has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    private static List<ResponsePacket> readResponses(final Socket socket) {
                      final List<ResponsePacket> responses = new ArrayList<>();
                      int previousTimeout = 0;
                      try {
                        /* Set socket timeout to avoid getting stuck on read() */
                  Severity: Minor
                  Found in src/main/java/javapns/notification/ResponsePacketReader.java - About 35 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

                  Method start has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    public synchronized NotificationThreads start() {
                      if (started) {
                        return this;
                      }
                      started = true;
                  Severity: Minor
                  Found in src/main/java/javapns/notification/transmission/NotificationThreads.java - About 35 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

                  Method asPayloadsPerDevices has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    public static List<PayloadPerDevice> asPayloadsPerDevices(final Object rawList) {
                      final List<PayloadPerDevice> list = new ArrayList<>();
                      if (rawList == null) {
                        return list;
                      }
                  Severity: Minor
                  Found in src/main/java/javapns/devices/Devices.java - About 35 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

                  Method test_Issue102 has a Cognitive Complexity of 7 (exceeds 5 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 35 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

                  Avoid too many return statements within this method.
                  Open

                          return prefix + "None (unknown)";
                  Severity: Major
                  Found in src/main/java/javapns/notification/ResponsePacket.java - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                          return null;
                    Severity: Major
                    Found in src/main/java/javapns/notification/ResponsePacketReader.java - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                          return list;
                      Severity: Major
                      Found in src/main/java/javapns/devices/Devices.java - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language