cowbell/cordova-plugin-geofence

View on GitHub

Showing 112 of 112 total issues

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

    public static func removeIndex(indexName: 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 453..485

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 2 locations. Consider refactoring.
Open

    public static func executeChange(sqlStr: String, withArgs: [AnyObject]) -> Int? {

        //create success variable
        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 408..440

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

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 createTable(table: String, withColumnNamesAndTypes values: [String: SwiftData.DataType]) -> Int? {

        //create the error variable
        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 110..142

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

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 transaction has a Cognitive Complexity of 16 (exceeds 5 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 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

    func existingIndexesForTable(table: String) -> (result: [String], error: Int?) {

        let sqlStr = "SELECT name FROM sqlite_master WHERE type = 'index' AND tbl_name = '\(table)'"

        var indexArr = [String]()
Severity: Major
Found in src/ios/SwiftData.swift and 1 other location - About 2 hrs to fix
src/ios/SwiftData.swift on lines 1864..1882

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

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 existingTables() -> (result: [String], error: Int?) {
        let sqlStr = "SELECT name FROM sqlite_master WHERE type = 'table'"
        var tableArr = [String]()
        let results = executeQuery(sqlStr)
        if let err = results.error {
Severity: Major
Found in src/ios/SwiftData.swift and 1 other location - About 2 hrs to fix
src/ios/SwiftData.swift on lines 1945..1964

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

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 coerceProperties has 51 lines of code (exceeds 25 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: Major
Found in www/geofence.js - About 2 hrs to fix

    Function checkRequirements has 48 lines of code (exceeds 25 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 1 hr to fix

      Function executeMultipleChanges has a Cognitive Complexity of 14 (exceeds 5 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

      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 onHandleIntent has 43 lines of code (exceeds 25 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 1 hr to fix

        Function escapeValue has 41 lines of code (exceeds 25 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 1 hr to fix

          Function bind has 40 lines of code (exceeds 25 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 1 hr to fix

            Function getColumnValue has 39 lines of code (exceeds 25 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

              Function savepoint has 37 lines of code (exceeds 25 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 1 hr to fix

                Method ExecuteCustomCode has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    @Override
                    public void ExecuteCustomCode() {
                        logger.log(Log.DEBUG, "Adding new geofences...");
                        if (geofencesToAdd != null && geofencesToAdd.size() > 0) try {
                            LocationServices.GeofencingApi
                Severity: Minor
                Found in src/android/AddGeofenceCommand.java - About 1 hr to fix

                  Method getUriFromRemote has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private Uri getUriFromRemote(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

                    Method onCommandExecuted has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        @Override
                        public void onCommandExecuted(Object error) {
                            if (error != null) try {
                                if (error instanceof Throwable) {
                                    JSONObject errorObject = new JSONObject();
                    Severity: Minor
                    Found in src/android/CommandExecutionHandler.java - 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

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

                                    } else {
                                        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 1411..1419

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

                    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 1459..1467

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

                    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: Opening Database")
                                    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 1120..1127
                    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

                    Severity
                    Category
                    Status
                    Source
                    Language