cowbell/cordova-plugin-geofence

View on GitHub

Showing 112 of 112 total issues

File SwiftData.swift has 1191 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Foundation
import UIKit


// MARK: - SwiftData
Severity: Major
Found in src/ios/SwiftData.swift - About 3 days to fix

    File GeofencePlugin.swift has 436 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import Foundation
    import AudioToolbox
    import WebKit
    
    let TAG = "GeofencePlugin"
    Severity: Minor
    Found in src/ios/GeofencePlugin.swift - About 6 hrs to fix

      Function executeQuery has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

              func executeQuery(sqlStr: String, withArgs: [AnyObject]? = nil) -> (result: [SDRow], error: Int?) {
      
                  var resultSet = [SDRow]()
      
                  var sql = sqlStr
      Severity: Minor
      Found in src/ios/SwiftData.swift - About 5 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 coerceProperties has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

      function coerceProperties(geofence) {
          if (geofence.id) {
              geofence.id = geofence.id.toString();
          } else {
              throw new Error("Geofence id is not provided");
      Severity: Minor
      Found in www/geofence.js - About 4 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 escapeValue has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          func escapeValue(obj: AnyObject?) -> String {
      
              if let obj: AnyObject = obj {
      
                  if obj is String {
      Severity: Minor
      Found in src/ios/SwiftData.swift - About 4 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 errorMessageFromCode has 96 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static func errorMessageFromCode(errorCode: Int) -> String {
      
              switch errorCode {
      
              //no error
      Severity: Major
      Found in src/ios/SwiftData.swift - About 3 hrs to fix

        Function checkRequirements has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        func checkRequirements() -> (Bool, [String], [[String:String]]) {
            var errors = [[String:String]]()
            var warnings = [String]()
            
            if (!CLLocationManager.isMonitoringAvailableForClass(CLRegion)) {
        Severity: Minor
        Found in src/ios/GeofencePlugin.swift - About 3 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

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

            public static func existingIndexesForTable(table: String) -> (result: [String], error: Int?) {
        
                //create the result and error variables
                var result = [String] ()
                var error: Int? = nil
        Severity: Major
        Found in src/ios/SwiftData.swift and 1 other location - About 3 hrs to fix
        src/ios/SwiftData.swift on lines 219..252

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

        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 static func executeQuery(sqlStr: String) -> (result: [SDRow], error: Int?) {
        
                //create result and error variables
                var result = [SDRow] ()
                var error: Int? = nil
        Severity: Major
        Found in src/ios/SwiftData.swift and 1 other location - About 3 hrs to fix
        src/ios/SwiftData.swift on lines 804..837

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

        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 static func existingIndexes() -> (result: [String], error: Int?) {
        
                //create the result and error variables
                var result = [String] ()
                var error: Int? = nil
        Severity: Major
        Found in src/ios/SwiftData.swift and 1 other location - About 2 hrs to fix
        src/ios/SwiftData.swift on lines 497..530

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

        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 static func existingTables() -> (result: [String], error: Int?) {
        
                //create result and error variables
                var result = [String] ()
                var error: Int? = nil
        Severity: Major
        Found in src/ios/SwiftData.swift and 1 other location - About 2 hrs to fix
        src/ios/SwiftData.swift on lines 757..790

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

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

            @Override
            protected void onHandleIntent(Intent intent) {
                Logger logger = Logger.getLogger();
                logger.log(Log.DEBUG, "ReceiveTransitionsIntentService - onHandleIntent");
                Intent broadcastIntent = new Intent(GeofenceTransitionIntent);
        Severity: Minor
        Found in src/android/ReceiveTransitionsIntentService.java - 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 executeQuery has 70 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                func executeQuery(sqlStr: String, withArgs: [AnyObject]? = nil) -> (result: [SDRow], error: Int?) {
        
                    var resultSet = [SDRow]()
        
                    var sql = sqlStr
        Severity: Major
        Found in src/ios/SwiftData.swift - About 2 hrs to fix

          Function bind has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              func bind(objects: [AnyObject], toSQL sql: String) -> (string: String, error: Int?) {
          
                  var newSql = ""
                  var bindIndex = 0
                  var i = false
          Severity: Minor
          Found in src/ios/SwiftData.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

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

              public static func lastInsertedRowID() -> (rowID: Int, error: Int?) {
          
                  //create result and error variables
                  var result = 0
                  var error: Int? = nil
          Severity: Major
          Found in src/ios/SwiftData.swift and 1 other location - About 2 hrs to fix
          src/ios/SwiftData.swift on lines 615..648

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

          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 static func numberOfRowsModified() -> (rowID: Int, error: Int?) {
          
                  //create result and error variables
                  var result = 0
                  var error: Int? = nil
          Severity: Major
          Found in src/ios/SwiftData.swift and 1 other location - About 2 hrs to fix
          src/ios/SwiftData.swift on lines 569..602

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

          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

          Function savepoint has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              public static func savepoint(savepointClosure: ()->Bool) -> Int? {
          
                  //create the error variable
                  var error: Int? = nil
          
          
          Severity: Minor
          Found in src/ios/SwiftData.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

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

              public static func executeChange(sqlStr: String) -> Int? {
          
                  //create error variable
                  var error: Int? = nil
          
          
          Severity: Major
          Found in src/ios/SwiftData.swift and 2 other locations - About 2 hrs to fix
          src/ios/SwiftData.swift on lines 453..485
          src/ios/SwiftData.swift on lines 713..745

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

          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 static func deleteTable(table: String) -> Int? {
          
                  //create the error variable
                  var error: Int? = nil
          
          
          Severity: Major
          Found in src/ios/SwiftData.swift and 2 other locations - About 2 hrs to fix
          src/ios/SwiftData.swift on lines 53..85
          src/ios/SwiftData.swift on lines 713..745

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

          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

          SwiftData has 23 methods (exceeds 20 allowed). Consider refactoring.
          Open

          public struct SwiftData {
          
          
              // MARK: - Public SwiftData Functions
          
          
          Severity: Minor
          Found in src/ios/SwiftData.swift - About 2 hrs to fix
            Severity
            Category
            Status
            Source
            Language