XYOracleNetwork/sdk-xyo-swift

View on GitHub

Showing 189 of 674 total issues

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

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

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

    public func all<A, B, C, D>(
      on queue: DispatchQueue = .promises,
      _ promiseA: Promise<A>,
      _ promiseB: Promise<B>,
      _ promiseC: Promise<C>,
    Severity: Minor
    Found in Carthage/Checkouts/promises/Sources/Promises/Promise+All.swift - About 1 hr to fix

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

          func peripheral(_ peripheral: CBPeripheral, didWriteValueFor 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/Sources/XyBleSdk/Gatt/GattRequest.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 write has a Cognitive Complexity of 9 (exceeds 5 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

      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 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public class func build(from iBeacon: XYIBeaconDefinition, rssi: Int? = nil, updateRssiAndPower: Bool = false) -> XYBluetoothDevice? {
              guard let family = XYDeviceFamily.build(iBeacon: iBeacon) else {
                  return nil
              }
              

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

          func peripheral(_ peripheral: CBPeripheral, didWriteValueFor 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 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 write has a Cognitive Complexity of 9 (exceeds 5 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

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

          public func boundWitness (handler : XyoNetworkHandler,
                                    procedureCatalogue: XyoProcedureCatalog,
                                    completion: @escaping (_: XyoBoundWitness?, _: XyoError?)->()) {
              
              if (currentBoundWitnessSession != nil) {

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

          public func boundWitness (handler : XyoNetworkHandler,
                                    procedureCatalogue: XyoProcedureCatalog,
                                    completion: @escaping (_: XyoBoundWitness?, _: XyoError?)->()) {
              
              if (currentBoundWitnessSession != nil) {

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

        public func update(_ rssi: Int, powerLevel: UInt8) {
          if rssi != XYDeviceProximity.defaultProximity {
            self.rssi = rssi
          }
          

      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 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public class func build(from iBeacon: XYIBeaconDefinition, rssi: Int? = nil, updateRssiAndPower: Bool = false) -> XYBluetoothDevice? {
              guard let family = XYDeviceFamily.build(iBeacon: iBeacon) else {
                  return nil
              }
              

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

        public func update(_ rssi: Int, powerLevel: UInt8) {
          if rssi != XYDeviceProximity.defaultProximity {
            self.rssi = rssi
          }
          

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

          public func restoreQueue () {
              var items = [XyoBridgeQueueItem]()
              
              do {
                  guard let encodedIndex = try store.read(key: XyoStorageBridgeQueueRepository.QUEUE_ARRAY_INDEX_KEY) 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 testRemoveIdFromBoundWitness has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          func testRemoveIdFromBoundWitness() throws {
              let rawBoundWitness = "600201A22015CB2019C8000C41170F9302323929FD3FD8A72851F73866A0BFC6D488040E9D921689E01B9E25E4393B0984576763DD9C5DA95E609A80B4CC12064758C1AEEE28AE264015BF474F000D8200AEB335766EC511499DDE566579B4ED1562079AA543388B2EDED68ED68363AE9DAE25E7E29B9A5607E676A5F50CC6EB5CBCEBDEE30FB3F1CB9DA0074D4D3CA29B8BFD42AEEE44CA7C26134F4401FF67332C549AD72B36FBF9211D07B0B825C137D6A0DD13EE35FE446B55D22E66CE751216DC4BB823A3A62C3D0208CAC0DF68AB2017D1201ACA00094421009A0FF234B98891EE3FF99365A3CA6AB804173F1A8619934134A68F59FBDCA92E200C04A196D4A39C987C984E18B79D3EE81667DD92E962E6C630DB5D7BDCDB1988000A81713AB83E5D8B4EF6D2EAB4D70B61AADCA01E733CB0B3D072DE307CDBCD09F46D528A7159EB73DEBB018871E30D182F5BBB426689E758A7BFD4C51D0AD116CA621BF1C39DA49A837D525905D22BAB7C1874F6C7E6B4D56139A15C3BE1D1DC8E061C241C060A24B588217E37D6206AFE5D71F4698D42E25C4FCE996EECCF7690B900130200".hexStringToBytes()
              let boundWitness = XyoBoundWitness(value: XyoBuffer(data: rawBoundWitness))
              let removedRssiBoundWitness = try XyoBoundWitnessUtil.removeIdFromUnsignedPayload(id: XyoSchemas.RSSI.id, boundWitness: boundWitness)
              let witnesses = try removedRssiBoundWitness.get(id: XyoSchemas.WITNESS.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

      Function wrapper has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          private func wrapper(_ button: CommonButton, unlock: Bool, operation: @escaping () -> XYBluetoothResult, completion: (() -> Void)? = nil) {
              guard
                  let device = self.rangedDevicesManager.selectedDevice
                  else { return }
      
      

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

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

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

          public func startMonitorTimer() {
              if monitorTimer == nil {
                  self.monitorTimer = DispatchSource.singleTimer(interval: XYFinderDeviceBase.monitorTimeout, queue: XYFinderDeviceBase.monitorTimerQueue) { [weak self] in
                      guard let strong = self else { return }
                      strong.monitorTimer = nil

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

          public func restoreQueue () {
              var items = [XyoBridgeQueueItem]()
              
              do {
                  guard let encodedIndex = try store.read(key: XyoStorageBridgeQueueRepository.QUEUE_ARRAY_INDEX_KEY) 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 beacon has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public static func beacon(from xyId: String) -> XYIBeaconDefinition? {
              let parts = xyId.components(separatedBy: ":")
      
              if parts[safe: 1] == "near" {
                  guard let uuid = UUID(uuidString: "00000000-0000-0000-0000-000000000000") else { return nil }

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

        func onPipe(pipe: XyoNetworkPipe) {
          print("On Pipe Called")
          delegate?.boundWitness(started: "From an XYO Device")
          
          let handler = XyoNetworkHandler(pipe: pipe)
      Severity: Minor
      Found in Source/Servers/XyoBleServer.swift - About 45 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

      Severity
      Category
      Status
      Source
      Language