Kinvey/swift-sdk

View on GitHub
Kinvey/Kinvey/Push.swift

Summary

Maintainability
D
2 days
Test Coverage

File Push.swift has 315 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Foundation
import PromiseKit
import ObjectiveC

#if os(OSX)
Severity: Minor
Found in Kinvey/Kinvey/Push.swift - About 3 hrs to fix

    Function replaceAppDelegateMethods has 69 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private func replaceAppDelegateMethods(
            options: Options?,
            completionHandler: ((Swift.Result<Bool, Swift.Error>) -> Void)?
        ) {
            func replaceAppDelegateMethods(_ completionHandler: ((Swift.Result<Bool, Swift.Error>) -> Void)?) {
    Severity: Major
    Found in Kinvey/Kinvey/Push.swift - About 2 hrs to fix

      Function replaceAppDelegateMethods has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          private func replaceAppDelegateMethods(
              options: Options?,
              completionHandler: ((Swift.Result<Bool, Swift.Error>) -> Void)?
          ) {
              func replaceAppDelegateMethods(_ completionHandler: ((Swift.Result<Bool, Swift.Error>) -> Void)?) {
      Severity: Minor
      Found in Kinvey/Kinvey/Push.swift - About 2 hrs 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

      Function application has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          fileprivate func application(
              _ application: UIApplication,
              didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data,
              options: Options?,
              completionHandler: ((Swift.Result<Bool, Swift.Error>) -> Void)? = nil
      Severity: Minor
      Found in Kinvey/Kinvey/Push.swift - About 1 hr to fix

        Function registerForNotifications has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            @available(iOS 10.0, *)
            open func registerForNotifications(
                authorizationOptions: UNAuthorizationOptions = [.badge, .sound, .alert, .carPlay],
                categories: Set<UNNotificationCategory>? = nil,
                options: Options? = nil,
        Severity: Minor
        Found in Kinvey/Kinvey/Push.swift - 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

        Function application has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            fileprivate func application(
                _ application: UIApplication,
                didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data,
                options: Options?,
                completionHandler: ((Swift.Result<Bool, Swift.Error>) -> Void)? = nil
        Severity: Minor
        Found in Kinvey/Kinvey/Push.swift - 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

        Function unRegisterDeviceToken has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            open func unRegisterDeviceToken(
                options: Options? = nil,
                completionHandler: ((Swift.Result<Void, Swift.Error>) -> Void)? = nil
            ) {
                Promise<Void> { resolver in
        Severity: Minor
        Found in Kinvey/Kinvey/Push.swift - About 25 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

        Function replaceAppDelegateMethods has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                func replaceAppDelegateMethods(_ completionHandler: ((Swift.Result<Bool, Swift.Error>) -> Void)?) {
                    let app = UIApplication.shared
                    let appDelegate = app.delegate!
                    let appDelegateType = type(of: appDelegate)
                    
        Severity: Minor
        Found in Kinvey/Kinvey/Push.swift - About 25 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

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

                registerForNotifications(
                    authorizationOptions: authorizationOptions,
                    categories: categories,
                    options: try! Options(client: client)
                ) { (result: Swift.Result<Bool, Swift.Error>) in
        Severity: Major
        Found in Kinvey/Kinvey/Push.swift and 1 other location - About 1 hr to fix
        Kinvey/Kinvey/User.swift on lines 406..417

        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 101.

        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

        //
        //  Push.swift
        //  Kinvey
        //
        //  Created by Victor Barros on 2016-02-01.
        Severity: Minor
        Found in Kinvey/Kinvey/Push.swift and 1 other location - About 50 mins to fix
        Kinvey/Kinvey/FileStore.swift on lines 1..1342

        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 59.

        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

                    request.execute { (data, response, error) -> Void in
                        if let response = response,
                            response.isOK
                        {
                            self.deviceToken = nil
        Severity: Minor
        Found in Kinvey/Kinvey/Push.swift and 1 other location - About 45 mins to fix
        Kinvey/Kinvey/User.swift on lines 1176..1183

        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 57.

        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

                    if let originalApplicationDidFailToRegisterForRemoteNotificationsWithErrorMethod = originalApplicationDidFailToRegisterForRemoteNotificationsWithErrorMethod {
                        self.originalApplicationDidFailToRegisterForRemoteNotificationsWithErrorImplementation = method_setImplementation(
                            originalApplicationDidFailToRegisterForRemoteNotificationsWithErrorMethod,
                            applicationDidFailToRegisterForRemoteNotificationsWithErrorImplementation
                        )
        Severity: Minor
        Found in Kinvey/Kinvey/Push.swift and 1 other location - About 45 mins to fix
        Kinvey/Kinvey/Push.swift on lines 111..124

        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 56.

        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

                    if let originalApplicationDidRegisterForRemoteNotificationsWithDeviceTokenMethod = originalApplicationDidRegisterForRemoteNotificationsWithDeviceTokenMethod {
                        self.originalApplicationDidRegisterForRemoteNotificationsWithDeviceTokenImplementation = method_setImplementation(
                            originalApplicationDidRegisterForRemoteNotificationsWithDeviceTokenMethod,
                            applicationDidRegisterForRemoteNotificationsWithDeviceTokenImplementation
                        )
        Severity: Minor
        Found in Kinvey/Kinvey/Push.swift and 1 other location - About 45 mins to fix
        Kinvey/Kinvey/Push.swift on lines 126..139

        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 56.

        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

                        if let originalApplicationDidRegisterForRemoteNotificationsWithDeviceTokenImplementation = self.originalApplicationDidRegisterForRemoteNotificationsWithDeviceTokenImplementation {
                            let implementation = unsafeBitCast(originalApplicationDidRegisterForRemoteNotificationsWithDeviceTokenImplementation, to: ApplicationDidRegisterForRemoteNotificationsWithDeviceTokenImplementation.self)
                            implementation(obj, applicationDidRegisterForRemoteNotificationsWithDeviceTokenSelector, application, deviceToken)
                        }
        Severity: Minor
        Found in Kinvey/Kinvey/Push.swift and 1 other location - About 35 mins to fix
        Kinvey/Kinvey/Push.swift on lines 102..105

        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 44.

        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

                        if let originalApplicationDidFailToRegisterForRemoteNotificationsWithErrorImplementation = self.originalApplicationDidFailToRegisterForRemoteNotificationsWithErrorImplementation {
                            let implementation = unsafeBitCast(originalApplicationDidFailToRegisterForRemoteNotificationsWithErrorImplementation, to: ApplicationDidFailToRegisterForRemoteNotificationsWithErrorImplementation.self)
                            implementation(obj, applicationDidFailToRegisterForRemoteNotificationsWithErrorSelector, application, error)
                        }
        Severity: Minor
        Found in Kinvey/Kinvey/Push.swift and 1 other location - About 35 mins to fix
        Kinvey/Kinvey/Push.swift on lines 95..98

        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 44.

        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

        There are no issues that match your filters.

        Category
        Status