mlaccetti/JavaPNS

View on GitHub

Showing 107 of 107 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  public WebClipPayload(final int payloadVersion, final String payloadOrganization, final String payloadIdentifier, final String payloadDisplayName, final String url, final String label) throws JSONException {
    super(payloadVersion, "com.apple.webClip.managed", payloadOrganization, payloadIdentifier, payloadDisplayName);
    final JSONObject payload = getPayload();
    payload.put("URL", url);
    payload.put("Label", label);
src/main/java/javapns/notification/management/CalendarSubscriptionPayload.java on lines 13..18
src/main/java/javapns/notification/management/LDAPPayload.java on lines 12..17

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 51.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  public LDAPPayload(final int payloadVersion, final String payloadOrganization, final String payloadIdentifier, final String payloadDisplayName, final String ldapAccountHostName, final boolean ldapAccountUseSSL) throws JSONException {
    super(payloadVersion, "com.apple.webClip.managed", payloadOrganization, payloadIdentifier, payloadDisplayName);
    final JSONObject payload = getPayload();
    payload.put("LDAPAccountHostName", ldapAccountHostName);
    payload.put("LDAPAccountUseSSL", ldapAccountUseSSL);
Severity: Major
Found in src/main/java/javapns/notification/management/LDAPPayload.java and 2 other locations - About 40 mins to fix
src/main/java/javapns/notification/management/CalendarSubscriptionPayload.java on lines 13..18
src/main/java/javapns/notification/management/WebClipPayload.java on lines 12..17

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 51.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  public CalendarSubscriptionPayload(final int payloadVersion, final String payloadOrganization, final String payloadIdentifier, final String payloadDisplayName, final String subCalAccountHostName, final boolean subCalAccountUseSSL) throws JSONException {
    super(payloadVersion, "com.apple.caldav.account", payloadOrganization, payloadIdentifier, payloadDisplayName);
    final JSONObject payload = getPayload();
    payload.put("SubCalAccountHostName", subCalAccountHostName);
    payload.put("SubCalAccountUseSSL", subCalAccountUseSSL);
src/main/java/javapns/notification/management/LDAPPayload.java on lines 12..17
src/main/java/javapns/notification/management/WebClipPayload.java on lines 12..17

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 51.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    try {
      System.out.println("");
      System.out.println("TESTING 257-BYTES PAYLOAD WITH SIZE ESTIMATION ENABLED");
      /* Expected result: PayloadMaxSizeProbablyExceededException when the alert is added to the payload */
      pushSpecificPayloadSize(keystore, password, token, production, true, 257);
Severity: Major
Found in src/test/java/javapns/test/SpecificNotificationTests.java and 2 other locations - About 40 mins to fix
src/test/java/javapns/test/SpecificNotificationTests.java on lines 84..91
src/test/java/javapns/test/SpecificNotificationTests.java on lines 92..99

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 50.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    try {
      System.out.println("");
      System.out.println("TESTING 257-BYTES PAYLOAD WITH SIZE ESTIMATION DISABLED");
      /* Expected result: PayloadMaxSizeExceededException when the payload is pushed */
      pushSpecificPayloadSize(keystore, password, token, production, false, 257);
Severity: Major
Found in src/test/java/javapns/test/SpecificNotificationTests.java and 2 other locations - About 40 mins to fix
src/test/java/javapns/test/SpecificNotificationTests.java on lines 76..83
src/test/java/javapns/test/SpecificNotificationTests.java on lines 92..99

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 50.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    try {
      System.out.println("");
      System.out.println("TESTING 256-BYTES PAYLOAD");
      /* Expected result: no exception */
      pushSpecificPayloadSize(keystore, password, token, production, false, 256);
Severity: Major
Found in src/test/java/javapns/test/SpecificNotificationTests.java and 2 other locations - About 40 mins to fix
src/test/java/javapns/test/SpecificNotificationTests.java on lines 76..83
src/test/java/javapns/test/SpecificNotificationTests.java on lines 84..91

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 50.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

          if (notificationsPushed != 0 && notificationsPushed % maxNotificationsPerConnection == 0) {
            if (listener != null) {
              listener.eventConnectionRestarted(this);
            }
            notificationManager.restartConnection(server);
src/main/java/javapns/notification/transmission/NotificationThread.java on lines 221..226

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 48.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        if (i != 0 && i % maxNotificationsPerConnection == 0) {
          if (listener != null) {
            listener.eventConnectionRestarted(this);
          }
          notificationManager.restartConnection(server);
src/main/java/javapns/notification/transmission/NotificationThread.java on lines 268..273

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 48.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                public PushedNotifications sendNotifications(final Payload payload, final List<Device> devices) throws CommunicationException, KeystoreException {
                  final PushedNotifications notifications = new PushedNotifications();
                  for (final Device device : devices) {
                    notifications.add(sendNotification(device, payload, false, SEQUENTIAL_IDENTIFIER));
                  }
              Severity: Minor
              Found in src/main/java/javapns/notification/PushNotificationManager.java and 1 other location - About 35 mins to fix
              src/main/java/javapns/notification/PushNotificationManager.java on lines 337..344

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 47.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                public PushedNotifications sendNotifications(final Payload payload, final Device... devices) throws CommunicationException, KeystoreException {
                  final PushedNotifications notifications = new PushedNotifications();
                  for (final Device device : devices) {
                    notifications.add(sendNotification(device, payload, false, SEQUENTIAL_IDENTIFIER));
                  }
              Severity: Minor
              Found in src/main/java/javapns/notification/PushNotificationManager.java and 1 other location - About 35 mins to fix
              src/main/java/javapns/notification/PushNotificationManager.java on lines 319..326

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 47.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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

              Severity
              Category
              Status
              Source
              Language