cowbell/cordova-plugin-geofence

View on GitHub

Showing 112 of 112 total issues

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

            if status != SQLITE_OK {
                print("SwiftData Error -> During: Opening Database with Flags")
                print("                -> Code: \(status) - " + SDError.errorMessageFromCode(Int(status)))
                if let errMsg = String.fromCString(sqlite3_errmsg(SQLiteDB.sharedInstance.sqliteDB)) {
                    print("                -> Details: \(errMsg)")
Severity: Major
Found in src/ios/SwiftData.swift and 2 other locations - About 1 hr to fix
src/ios/SwiftData.swift on lines 1073..1080
src/ios/SwiftData.swift on lines 1193..1200

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

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

            if status != SQLITE_OK {
                print("SwiftData Error -> During: Closing Database with Flags")
                print("                -> Code: \(status) - " + SDError.errorMessageFromCode(Int(status)))
                if let errMsg = String.fromCString(sqlite3_errmsg(SQLiteDB.sharedInstance.sqliteDB)) {
                    print("                -> Details: \(errMsg)")
Severity: Major
Found in src/ios/SwiftData.swift and 2 other locations - About 1 hr to fix
src/ios/SwiftData.swift on lines 1073..1080
src/ios/SwiftData.swift on lines 1120..1127

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

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 openWithFlags has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        func openWithFlags(flags: Int32) -> Int? {

            //check if in transaction
            if inTransaction {
                print("SwiftData Error -> During: Opening Database with Flags")
Severity: Minor
Found in src/ios/SwiftData.swift - About 1 hr to fix

    Function executeChange has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            func executeChange(sqlStr: String, withArgs: [AnyObject]? = nil) -> Int? {
    
                var sql = sqlStr
                if let args = withArgs {
                    let result = bind(args, toSQL: sql)
    Severity: Minor
    Found in src/ios/SwiftData.swift - About 1 hr to fix

      Method execute has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          public boolean execute(final String action, final JSONArray args,
                                 final CallbackContext callbackContext) throws JSONException {
              Log.d(TAG, "GeofencePlugin execute action: " + action + " args: " + args.toString());
              executedAction = new Action(action, args, callbackContext);
      Severity: Minor
      Found in src/android/GeofencePlugin.java - About 1 hr to fix

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

                    if status != SQLITE_DONE && status != SQLITE_OK {
                        print("SwiftData Error -> During: SQL Step")
                        print("                -> Code: \(status) - " + SDError.errorMessageFromCode(Int(status)))
                        if let errMsg = String.fromCString(sqlite3_errmsg(SQLiteDB.sharedInstance.sqliteDB)) {
                            print("                -> Details: \(errMsg)")
        Severity: Major
        Found in src/ios/SwiftData.swift and 1 other location - About 1 hr to fix
        src/ios/SwiftData.swift on lines 1368..1376

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

        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 status != SQLITE_OK {
                        print("SwiftData Error -> During: SQL Prepare")
                        print("                -> Code: \(status) - " + SDError.errorMessageFromCode(Int(status)))
                        if let errMsg = String.fromCString(sqlite3_errmsg(SQLiteDB.sharedInstance.sqliteDB)) {
                            print("                -> Details: \(errMsg)")
        Severity: Major
        Found in src/ios/SwiftData.swift and 1 other location - About 1 hr to fix
        src/ios/SwiftData.swift on lines 1379..1387

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

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

                func executeChange(sqlStr: String, withArgs: [AnyObject]? = nil) -> Int? {
        
                    var sql = sqlStr
                    if let args = withArgs {
                        let result = bind(args, toSQL: sql)
        Severity: Minor
        Found in src/ios/SwiftData.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 getColumnValue has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

                func getColumnValue(statement: COpaquePointer, index: Int32, type: String) -> AnyObject? {
        
                    switch type {
                    case "INT", "INTEGER", "TINYINT", "SMALLINT", "MEDIUMINT", "BIGINT", "UNSIGNED BIG INT", "INT2", "INT8":
                        if sqlite3_column_type(statement, index) == SQLITE_NULL {
        Severity: Minor
        Found in src/ios/SwiftData.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

        Method notify has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public void notify(Notification notification) {
                notification.setContext(context);
                NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
                    .setVibrate(notification.getVibrate())
                    .setSmallIcon(notification.getSmallIcon())
        Severity: Minor
        Found in src/android/GeoNotificationNotifier.java - About 1 hr to fix

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

              public static func transaction(transactionClosure: ()->Bool) -> Int? {
          
                  //create the error variable
                  var error: Int? = nil
          
          
          Severity: Minor
          Found in src/ios/SwiftData.swift - About 1 hr to fix

            Method getUriForResourcePath has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private Uri getUriForResourcePath(String path) {
                    File dir = context.getExternalCacheDir();
            
                    if (dir == null) {
                        Log.e("Asset", "Missing external cache dir");
            Severity: Minor
            Found in src/android/AssetUtil.java - About 1 hr to fix

              Function closeCustomConnection has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      func closeCustomConnection() -> Int? {
              
                          //check if in trasaction
                          if inTransaction {
                              print("SwiftData Error -> During: Closing Database with Flags")
              Severity: Minor
              Found in src/ios/SwiftData.swift - About 1 hr to fix

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

                    if (typeof(value) !== "number") {
                        console.warn(name + " is not a number, trying to convert to number");
                        value = Number(value);
                
                        if (isNaN(value)) {
                Severity: Major
                Found in www/geofence.js and 1 other location - About 1 hr to fix
                www/geofence.js on lines 231..238

                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 (!isInt(value)) {
                        console.warn(name + " is not an integer, trying to convert to integer");
                        value = parseInt(value);
                
                        if (isNaN(value)) {
                Severity: Major
                Found in www/geofence.js and 1 other location - About 1 hr to fix
                www/geofence.js on lines 218..225

                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

                Function executeMultipleChanges has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static func executeMultipleChanges(sqlArr: [String]) -> Int? {
                
                        //create error variable
                        var error: Int? = nil
                
                
                Severity: Minor
                Found in src/ios/SwiftData.swift - About 1 hr to fix

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

                      func escapeStringIdentifier(str: String) -> String {
                          var escapedStr = ""
                          for char in str.characters {
                              if char == "\"" {
                                  escapedStr += "\""
                  Severity: Minor
                  Found in src/ios/SwiftData.swift and 1 other location - About 55 mins to fix
                  src/ios/SwiftData.swift on lines 1726..1736

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

                  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

                      func escapeStringValue(str: String) -> String {
                          var escapedStr = ""
                          for char in str.characters {
                              if char == "'" {
                                  escapedStr += "'"
                  Severity: Minor
                  Found in src/ios/SwiftData.swift and 1 other location - About 55 mins to fix
                  src/ios/SwiftData.swift on lines 1739..1749

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

                  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

                          try {
                              AssetManager assets = context.getAssets();
                              FileOutputStream outStream = new FileOutputStream(file);
                              InputStream inputStream = assets.open(resPath);
                  
                  
                  Severity: Minor
                  Found in src/android/AssetUtil.java and 1 other location - About 50 mins to fix
                  src/android/AssetUtil.java on lines 230..241

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

                  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

                          try {
                              Resources res = context.getResources();
                              FileOutputStream outStream = new FileOutputStream(file);
                              InputStream inputStream = res.openRawResource(resId);
                              copyFile(inputStream, outStream);
                  Severity: Minor
                  Found in src/android/AssetUtil.java and 1 other location - About 50 mins to fix
                  src/android/AssetUtil.java on lines 176..188

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language