XYOracleNetwork/sdk-ble-flutter

View on GitHub

Showing 226 of 312 total issues

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

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

        static func execute(_ device: XYBluetoothDevice?, operations: GattOperationList) -> Promise<[GattResponse]> {
            guard let device = device else {
                return Promise([])
            }
    
    
    Severity: Minor
    Found in ios/Classes/GattGroupRequest.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 traverse has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
        try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
          if !_storage._id.isEmpty {
            try visitor.visitSingularStringField(value: _storage._id, fieldNumber: 1)
          }
    Severity: Minor
    Found in ios/Classes/protos/device.pb.swift - About 1 hr to fix

      Method sendMessage has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        fun sendMessage(device: XYBluetoothDevice) {
          val family = Device.Family.newBuilder()
          val range = Device.Range.newBuilder()
          val beacon = Device.IBeacon.newBuilder()
          val deviceData = Device.BluetoothDevice.newBuilder()

        Method toBase58String has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        /**
         * Encodes the bytes as a base58 string (no checksum is appended).
         *
         * @return the base58-encoded string
         */
        Severity: Minor
        Found in android/src/main/kotlin/network/xyo/ble/xyo_ble/Base58.kt - About 1 hr to fix

          Method sendMessage has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            fun sendMessage(device: XYBluetoothDevice) {
              val family = Device.Family.newBuilder()
              val range = Device.Range.newBuilder()
              val beacon = Device.IBeacon.newBuilder()
              val deviceData = Device.BluetoothDevice.newBuilder()

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

              override func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
                do {
                  switch (call.method) {
                  case "setArchivists":
                    setArchivists(call, result: result)
            Severity: Minor
            Found in ios/Classes/Channels/Bridge.swift - About 1 hr to fix

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

                  static func execute(_ device: XYBluetoothDevice?, operations: GattOperationList) -> Promise<[GattResponse]> {
                      guard let device = device else {
                          return Promise([])
                      }
              
              
              Severity: Minor
              Found in ios/Classes/GattGroupRequest.swift - About 1 hr to fix

                Function traverse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
                    try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
                      if !_storage._deviceID.isEmpty {
                        try visitor.visitSingularStringField(value: _storage._deviceID, fieldNumber: 1)
                      }
                Severity: Minor
                Found in ios/Classes/protos/gatt.pb.swift - About 55 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function process has a Cognitive Complexity of 9 (exceeds 5 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 55 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function traverse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
                    try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
                      if !_storage._deviceID.isEmpty {
                        try visitor.visitSingularStringField(value: _storage._deviceID, fieldNumber: 1)
                      }
                Severity: Minor
                Found in ios/Classes/protos/gatt.pb.swift - About 55 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Method getAllKeys has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                Open

                    override fun getAllKeys(): Deferred<Iterator<ByteArray>> = GlobalScope.async {
                        try {
                            val i = db.allKeysIterator()
                
                            return@async object : Iterator<ByteArray> {

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

                  static func ==(lhs: DeviceBoundWitness, rhs: DeviceBoundWitness) -> Bool {
                    if lhs.bytes != rhs.bytes {return false}
                    if lhs.byteHash != rhs.byteHash {return false}
                    if lhs.humanName != rhs.humanName {return false}
                    if lhs.huerestics != rhs.huerestics {return false}
                Severity: Minor
                Found in ios/Classes/protos/bound_witness.pb.swift - About 35 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function traverse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
                    if !self.bytes.isEmpty {
                      try visitor.visitSingularStringField(value: self.bytes, fieldNumber: 1)
                    }
                    if !self.byteHash.isEmpty {
                Severity: Minor
                Found in ios/Classes/protos/bound_witness.pb.swift - About 35 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Avoid too many return statements within this method.
                Open

                          return null;

                  Avoid too many return statements within this method.
                  Open

                          return null;

                    Avoid too many return statements within this method.
                    Open

                              return parser;

                      Avoid too many return statements within this method.
                      Open

                              return null;

                        Avoid too many return statements within this method.
                        Open

                                  return parser;

                          Avoid too many return statements within this method.
                          Open

                                  return null;
                            Severity
                            Category
                            Status
                            Source
                            Language