XYOracleNetwork/sdk-xyo-swift

View on GitHub

Showing 189 of 674 total issues

Function build has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public func build() throws -> XyoNode {
    if (XyoSdk.nodes.count > 0) {
      throw XyoNodeBuilderError(kind: .alreadyNodes)
    }
    if (self.storage == nil) {
Severity: Minor
Found in Sources/sdk-xyo-swift/sdk/XyoNodeBuilder.swift - About 1 hr to fix

    Function wait has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        func wait(for device: XYBluetoothDevice) {
            // Quick escape if we already have the device and it is connected or it's already connecting
            guard !isConnectedOrConnecting(for: device) else { return }
    
            // We have lost contact with the device, so we'll do a non-expiring connectiong try

      Function notify has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          func notify(for device: XYBluetoothDevice, enabled: Bool) -> Promise<Void> {
              var operationPromise = Promise<Void>.pending()
              guard let peripheral = device.peripheral, peripheral.state == .connected else {
                  operationPromise.reject(XYBluetoothError.notConnected)
                  return operationPromise
      Severity: Minor
      Found in Carthage/Checkouts/sdk-ble-swift/Source/Gatt/GattRequest.swift - About 1 hr to fix

        Function base58FromBytes has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            static func base58FromBytes(_ bytes: [UInt8]) -> String {
                var bytes = bytes
                var zerosCount = 0
                var length = 0
        
        

          Function notify has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              func notify(for device: XYBluetoothDevice, enabled: Bool) -> Promise<Void> {
                  var operationPromise = Promise<Void>.pending()
                  guard let peripheral = device.peripheral, peripheral.state == .connected else {
                      operationPromise.reject(XYBluetoothError.notConnected)
                      return operationPromise

            Function base58FromBytes has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                static func base58FromBytes(_ bytes: [UInt8]) -> String {
                    var bytes = bytes
                    var zerosCount = 0
                    var length = 0
            
            

              Function updateStatus has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                public func updateStatus() {
                  #if os(iOS)
                  var newStatus = XYSmartScanStatus.enabled
                  let central = XYCentral.instance
                  if !XYLocation.instance.locationServicesEnabled {
              Severity: Minor
              Found in Carthage/Checkouts/sdk-ble-swift/Sources/XyBleSdk/XYSmartScan.swift - About 1 hr to fix

                Function set has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    func set(to device: XYBluetoothDevice, valueObj: XYBluetoothResult, withResponse: Bool = true) -> Promise<Void> {
                        var operationPromise = Promise<Void>.pending()
                        guard let peripheral = device.peripheral, peripheral.state == .connected else {
                            operationPromise.reject(XYBluetoothError.notConnected)
                            return operationPromise

                  Function get has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      func get(from device: XYBluetoothDevice) -> Promise<Data?> {
                          var operationPromise = Promise<Data?>.pending()
                          guard let peripheral = device.peripheral, peripheral.state == .connected else {
                              operationPromise.reject(XYBluetoothError.notConnected)
                              return operationPromise
                  Severity: Minor
                  Found in Carthage/Checkouts/sdk-ble-swift/Source/Gatt/GattRequest.swift - About 1 hr to fix

                    Function updateStatus has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      public func updateStatus() {
                        #if os(iOS)
                        var newStatus = XYSmartScanStatus.enabled
                        let central = XYCentral.instance
                        if !XYLocation.instance.locationServicesEnabled {
                    Severity: Minor
                    Found in Carthage/Checkouts/sdk-ble-swift/Source/XYSmartScan.swift - About 1 hr to fix

                      Function set has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          func set(to device: XYBluetoothDevice, valueObj: XYBluetoothResult, withResponse: Bool = true) -> Promise<Void> {
                              var operationPromise = Promise<Void>.pending()
                              guard let peripheral = device.peripheral, peripheral.state == .connected else {
                                  operationPromise.reject(XYBluetoothError.notConnected)
                                  return operationPromise
                      Severity: Minor
                      Found in Carthage/Checkouts/sdk-ble-swift/Source/Gatt/GattRequest.swift - About 1 hr to fix

                        Function get has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            func get(from device: XYBluetoothDevice) -> Promise<Data?> {
                                var operationPromise = Promise<Data?>.pending()
                                guard let peripheral = device.peripheral, peripheral.state == .connected else {
                                    operationPromise.reject(XYBluetoothError.notConnected)
                                    return operationPromise

                          Function testPromiseThen has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            func testPromiseThen() {
                              // Act.
                              let numberPromise = Promise { fulfill, _ in
                                fulfill(42)
                              }

                            Function detected has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                              public override func detected(_ rssi: Int) {
                                    guard self.isUpdatingFirmware == false else { return }
                            
                                    var events: [XYFinderEventNotification] = [.detected(device: self, powerLevel: Int(self.powerLevel), rssi: self.rssi, distance: 0)]
                            
                            

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

                                func getValues() {
                                    guard let device = rangedDevicesManager.selectedDevice else { return }
                                    var values = [XYBluetoothResult]()
                                    self.parent?.showRefreshing()
                                    device.connection {

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

                                func getValues() {
                                    guard let device = self.device else { return }
                                    self.characteristicValues.removeAll()
                                    var values = [XYBluetoothResult]()
                                    self.gattSpinner.startAnimation(self)

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

                                static func base58FromBytes(_ bytes: [UInt8]) -> String {
                                    var bytes = bytes
                                    var zerosCount = 0
                                    var length = 0
                            
                            

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

                              func bridge() throws {
                                guard semaphore == true, knownBridges.count > 0 else {
                                  if knownBridges.count == 0 {
                                    print("No known bridges")
                                  }
                            Severity: Minor
                            Found in Source/Clients/XyoTcpipClient.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 base58FromBytes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                                static func base58FromBytes(_ bytes: [UInt8]) -> String {
                                    var bytes = bytes
                                    var zerosCount = 0
                                    var length = 0
                            
                            

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

                                func disconnect(from device: XYBluetoothDevice) {
                                    print("STEP 1: Trying to DISCONNECT from \(device.id.shortId)...")
                            
                                    let disconnectQueue = DispatchQueue(label: "com.xyfindables.sdk.ConnectionManagerDisconnectQueueFor\(device.id)")
                            
                            

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language