XYOracleNetwork/sdk-ble-flutter

View on GitHub

Showing 312 of 312 total issues

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

  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      switch fieldNumber {
      case 1: try decoder.decodeSingularInt64Field(value: &self.major)
      case 2: try decoder.decodeSingularInt64Field(value: &self.minor)
Severity: Major
Found in ios/Classes/protos/device.pb.swift and 1 other location - About 1 hr to fix
ios/Classes/protos/gatt.pb.swift on lines 293..302

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

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

  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      switch fieldNumber {
      case 1: try decoder.decodeSingularStringField(value: &self.deviceID)
      case 2: try decoder.decodeRepeatedMessageField(value: &self.operations)
Severity: Major
Found in ios/Classes/protos/gatt.pb.swift and 1 other location - About 1 hr to fix
ios/Classes/protos/device.pb.swift on lines 226..235

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

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

    static func runCall(for device: XYBluetoothDevice, operation: GattOperation) -> XYBluetoothResult {
        var bleResult: XYBluetoothResult

        if let selectedOp = operation.operation {
            switch selectedOp {
Severity: Minor
Found in ios/Classes/GattRequestHandler.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

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

                      Manifest.permission.ACCESS_FINE_LOCATION)) {
        val alert = AlertDialog.Builder(this)
        alert.setTitle("Location Permission")
        alert.setMessage("Location is required for XYO to communicate with nearby devices.")
        alert.setPositiveButton("Ok"){dialog, which -> }
example/android/app/src/main/java/network/xyo/sdk/flutter/example/android/MainActivity.kt on lines 25..32

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

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

              Manifest.permission.BLUETOOTH)) {
        val alert = AlertDialog.Builder(this)
        alert.setTitle("Bluetooth Permission")
        alert.setMessage("Bluetooth is required for XYO to communicate with nearby devices.")
        alert.setPositiveButton("Ok"){dialog, which -> }
example/android/app/src/main/java/network/xyo/sdk/flutter/example/android/MainActivity.kt on lines 48..55

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

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

    static func process(for device: XYBluetoothDevice, operation: DefinedOperation) -> XYBluetoothResult {
        if let xyDevice = self.deviceAsFinder(device) {
            switch operation {
            case .song:
                _ = xyDevice.unlock()
Severity: Minor
Found in ios/Classes/GattDefinedOperationRequest.swift - About 1 hr to fix

    Method getHumanBoundWitnessName has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        // todo find way to localise strings with flutter
        fun getHumanBoundWitnessName(boundWitness: XyoBoundWitness, publicKey: ByteArray?): String {
            if (boundWitness.numberOfParties == 1) {
                if (getIndexForParty(boundWitness, 0) == 0) {
                    return "First block!"

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

          static func operations(_ arguments: Any?) -> GattOperationList? {
              guard
                  let args = self.argsAsDict(arguments),
                  let data = args[Argument.request.rawValue] as? FlutterStandardTypedData
                  else { return nil }
      Severity: Major
      Found in ios/Classes/GattRequestHandler.swift and 1 other location - About 1 hr to fix
      ios/Classes/GattRequestHandler.swift on lines 53..64

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

        static func ==(lhs: Range, rhs: Range) -> Bool {
          if lhs.min != rhs.min {return false}
          if lhs.max != rhs.max {return false}
          if lhs.unknownFields != rhs.unknownFields {return false}
          return true
      Severity: Major
      Found in ios/Classes/protos/device.pb.swift and 1 other location - About 1 hr to fix
      ios/Classes/protos/gatt.pb.swift on lines 353..358

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

        static func ==(lhs: GattCall, rhs: GattCall) -> Bool {
          if lhs.serviceUuid != rhs.serviceUuid {return false}
          if lhs.characteristicUuid != rhs.characteristicUuid {return false}
          if lhs.unknownFields != rhs.unknownFields {return false}
          return true
      Severity: Major
      Found in ios/Classes/protos/gatt.pb.swift and 1 other location - About 1 hr to fix
      ios/Classes/protos/device.pb.swift on lines 210..215

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

          static func operation(_ arguments: Any?) -> GattOperation? {
              guard
                  let args = self.argsAsDict(arguments),
                  let data = args[Argument.request.rawValue] as? FlutterStandardTypedData
                  else { return nil }
      Severity: Major
      Found in ios/Classes/GattRequestHandler.swift and 1 other location - About 1 hr to fix
      ios/Classes/GattRequestHandler.swift on lines 39..50

      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

        mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
          while let fieldNumber = try decoder.nextFieldNumber() {
            switch fieldNumber {
            case 1: try decoder.decodeSingularSInt64Field(value: &self.min)
            case 2: try decoder.decodeSingularSInt64Field(value: &self.max)
      Severity: Major
      Found in ios/Classes/protos/device.pb.swift and 2 other locations - About 1 hr to fix
      ios/Classes/protos/gatt.pb.swift on lines 333..341
      ios/Classes/protos/gatt.pb.swift on lines 470..478

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

      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

        mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
          while let fieldNumber = try decoder.nextFieldNumber() {
            switch fieldNumber {
            case 1: try decoder.decodeSingularBytesField(value: &self.request)
            case 2: try decoder.decodeSingularBoolField(value: &self.requiresResponse)
      Severity: Major
      Found in ios/Classes/protos/gatt.pb.swift and 2 other locations - About 1 hr to fix
      ios/Classes/protos/device.pb.swift on lines 190..198
      ios/Classes/protos/gatt.pb.swift on lines 333..341

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

      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

        mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
          while let fieldNumber = try decoder.nextFieldNumber() {
            switch fieldNumber {
            case 1: try decoder.decodeSingularStringField(value: &self.serviceUuid)
            case 2: try decoder.decodeSingularStringField(value: &self.characteristicUuid)
      Severity: Major
      Found in ios/Classes/protos/gatt.pb.swift and 2 other locations - About 1 hr to fix
      ios/Classes/protos/device.pb.swift on lines 190..198
      ios/Classes/protos/gatt.pb.swift on lines 470..478

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

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

          static func getHumanHeuristics(boundWitness: XyoBoundWitness) -> [String: String] {
              do {
                  var returnArray: [String: String] = [:]
                  guard let numberOfParties = try boundWitness.getNumberOfParties() else {
                      return [:]
      Severity: Minor
      Found in ios/Classes/XyoHumanHeuristics.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 fromBase58 has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      /**
       * Decodes the base58 string into a [ByteArray]
       *
       * @return the decoded data bytes
       * @throws NumberFormatException if the string is not a valid base58 string
      Severity: Minor
      Found in android/src/main/kotlin/network/xyo/ble/xyo_ble/Base58.kt - About 1 hr to fix

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

          private fun gattGroup(call: MethodCall, result: MethodChannel.Result) = GlobalScope.launch {
            sendResult(result,GattGroupRequest.process(smartScan, call.arguments, result))
          }
        android/src/main/kotlin/network/xyo/ble/xyo_ble/channels/device.kt on lines 140..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 103.

        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

          private fun gattList(call: MethodCall, result: MethodChannel.Result) = GlobalScope.launch {
            sendResult(result,GattGroupRequest.process(smartScan, call.arguments, result))
          }
        android/src/main/kotlin/network/xyo/ble/xyo_ble/channels/device.kt on lines 136..138

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

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

            public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
                guard let method = MethodRegistry(rawValue: call.method) else {
                    result(nil)
                    return
                }
        Severity: Minor
        Found in ios/Classes/SwiftXyoBlePlugin.swift - About 1 hr to fix

          Method buildDevice has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              fun buildDevice(device: XYBluetoothDevice): Device.BluetoothDevice {
                val builder = Device.BluetoothDevice.newBuilder()
          
                builder.setId(device.id)
                builder.setConnected(device.connected)
          Severity: Minor
          Found in android/src/main/kotlin/network/xyo/ble/xyo_ble/channels/device.kt - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language