XYOracleNetwork/sdk-xyo-swift

View on GitHub

Showing 189 of 674 total issues

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

  private func setDefaultRelayNode() {
    if let br = blockRepository {
      if let sr = stateRepository {
        if let bq = bridgeQueueRepository {
          if let hp = hashingProvider {
Severity: Minor
Found in Source/sdk/XyoNodeBuilder.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 send has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public func send(data: [UInt8], waitForResponse: Bool, completion: ([UInt8]?) -> ()) {
        let dataWithSize = XyoBuffer()
            .put(bits: UInt32(data.count + 4))
            .put(bytes: data)
            .toByteArray()

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

    private func getBoundWitnessesOptionsForFlag (flag : [UInt8]) -> [XyoBoundWitnessOption] {
        var retunOptions = [XyoBoundWitnessOption]()
        
        for option in boundWitnessOptions.values {
            if (min(option.getFlag().count, flag.count) != 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 getBoundWitnessesOptionsForFlag has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private func getBoundWitnessesOptionsForFlag (flag : [UInt8]) -> [XyoBoundWitnessOption] {
        var retunOptions = [XyoBoundWitnessOption]()
        
        for option in boundWitnessOptions.values {
            if (min(option.getFlag().count, flag.count) != 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 send has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public func send(data: [UInt8], waitForResponse: Bool, completion: ([UInt8]?) -> ()) {
        let dataWithSize = XyoBuffer()
            .put(bits: UInt32(data.count + 4))
            .put(bytes: data)
            .toByteArray()

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

    @discardableResult public func inquire(for device: XYBluetoothDevice) -> Promise<GattDeviceDescriptor> {
        let operationPromise = Promise<GattDeviceDescriptor>.pending()
        guard
            let peripheral = device.peripheral,
            peripheral.state == .connected else {
Severity: Minor
Found in Carthage/Checkouts/sdk-ble-swift/Source/Gatt/GattInquisitor.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 doBoundWitness has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  func doBoundWitness(withDevice: XyoBluetoothDevice, withCompletion: BoundWitnessCallback) throws {
    
      self.delegate?.boundWitness(started: withDevice.id)

      withDevice.connection {
Severity: Minor
Found in Sources/sdk-xyo-swift/Clients/XyoBleClient.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 setDefaultRelayNode has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  private func setDefaultRelayNode() {
    if let br = blockRepository {
      if let sr = stateRepository {
        if let bq = bridgeQueueRepository {
          if let hp = hashingProvider {
Severity: Minor
Found in Sources/sdk-xyo-swift/sdk/XyoNodeBuilder.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 inquire has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    @discardableResult public func inquire(for device: XYBluetoothDevice) -> Promise<GattDeviceDescriptor> {
        let operationPromise = Promise<GattDeviceDescriptor>.pending()
        guard
            let peripheral = device.peripheral,
            peripheral.state == .connected else {

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

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

    func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
        operationsQueue.async {
            guard self.status != .disconnected || self.status != .timedOut else { return }

            guard error == nil else {

    Function updateStayAwakeAndConnectionButtonStates has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private func updateStayAwakeAndConnectionButtonStates() {
            guard
                let device = self.rangedDevicesManager.selectedDevice
                else { return }
    
    

      Function testPromiseAllHeterogeneous3 has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        func testPromiseAllHeterogeneous3() {
          // Arrange.
          let expectedValues = (42, "hello world", Int?.none)
          let promise1 = Promise<Int> { fulfill, _ in
            Test.delay(0.1) {

        Function testPromiseAnyHeterogeneous3 has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          func testPromiseAnyHeterogeneous3() {
            // Arrange.
            let expectedValues = (Maybe(42), Maybe("hello world"), Maybe(Int?.none))
            let promise1 = Promise<Int> { fulfill, _ in
              Test.delay(0.1) {

          Function peripheral has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
                  operationsQueue.async {
                      guard self.status != .disconnected || self.status != .timedOut else { return }
          
                      guard error == nil else {
          Severity: Minor
          Found in Carthage/Checkouts/sdk-ble-swift/Source/Gatt/GattRequest.swift - About 1 hr to fix

            Function testPromiseAnyHeterogeneous3Reject has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              func testPromiseAnyHeterogeneous3Reject() {
                // Arrange.
                let expectedValuesAndErrors = (Maybe(42), Maybe<String>(Test.Error.code42), Maybe(Int?.none))
                let promise1 = Promise { fulfill, _ in
                  Test.delay(0.1) {

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

                  func write(data: [UInt8], withIdentifier: String? = nil, callback: WriteCallback? = nil) {
                      let message = Message(data: data, identifier: withIdentifier ?? self.identifier)
              
                      var error: NSError?
                      self.opQueue.addOperation { [weak self] in

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

                public func retry<Value>(
                  on queue: DispatchQueue = .promises,
                  attempts count: Int = __FBLPromiseRetryDefaultAttemptsCount,
                  delay interval: TimeInterval = __FBLPromiseRetryDefaultDelayInterval,
                  condition predicate: ((_ count: Int, _ error: Error) -> Bool)? = nil,
                Severity: Minor
                Found in Carthage/Checkouts/promises/Sources/Promises/Promise+Retry.swift - About 1 hr to fix

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

                    func testPromiseRace() {
                      // Arrange.
                      let promise1 = Promise<Any?> { fulfill, _ in
                        Test.delay(0.1) {
                          fulfill(42)

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

                        func write(data: [UInt8], withIdentifier: String? = nil, callback: WriteCallback? = nil) {
                            let message = Message(data: data, identifier: withIdentifier ?? self.identifier)
                    
                            var error: NSError?
                            self.opQueue.addOperation { [weak self] in
                      Severity
                      Category
                      Status
                      Source
                      Language