XYOracleNetwork/sdk-xyo-swift

View on GitHub

Showing 189 of 674 total issues

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

  fileprivate func checkExits() {
    XYSmartScan.queue.asyncAfter(deadline: DispatchTime.now() + TimeInterval(XYConstants.DEVICE_TUNING_SECONDS_EXIT_CHECK_INTERVAL)) {
      guard self.isCheckingExits else {
        return
      }
Severity: Minor
Found in Carthage/Checkouts/sdk-ble-swift/Sources/XyBleSdk/XYSmartScan.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 display has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    func display(for serviceCharacteristic: XYServiceCharacteristic) -> String? {
        switch serviceCharacteristic.characteristicType {
        case .string:
            guard let strVal = self.asString else { return "n/a" }
            return "\(strVal)"

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

    public static func unsubscribe(to events: [XYFinderEvent], referenceKey: UUID?) {
        managerQueue.async {
            guard let key = referenceKey else { return }
            for event in events {
                guard let eventsInRegistry = handlerRegistry[event] else { continue }

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

    func display(for serviceCharacteristic: XYServiceCharacteristic) -> String? {
        switch serviceCharacteristic.characteristicType {
        case .string:
            guard let strVal = self.asString else { return "n/a" }
            return "\(strVal)"

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

    func peripheral(_ peripheral: CBPeripheral, didUpdateNotificationStateFor 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 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 fromSignalStrength has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static func fromSignalStrength(_ strength: Int) -> XYDeviceProximity {
        if strength == -999 { return XYDeviceProximity.none }
        if strength >= -40 { return XYDeviceProximity.touching }
        if strength >= -60 { return XYDeviceProximity.veryNear }
        if strength >= -70 { return XYDeviceProximity.near }

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

   func enableHeursitics(heuristics: [XyoHeuristicEnum], enabled: Bool) {
    for heuristic in heuristics {
      let heuristicName = heuristic.rawValue + String(describing: self)
      if enabled {
        switch heuristic {
Severity: Minor
Found in Sources/sdk-xyo-swift/sdk/XyoBoundWitnessTarget.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 unsubscribe has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static func unsubscribe(to events: [XYFinderEvent], referenceKey: UUID?) {
        managerQueue.async {
            guard let key = referenceKey else { return }
            for event in events {
                guard let eventsInRegistry = handlerRegistry[event] else { continue }

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

    @discardableResult func connect(_ timeout: DispatchTimeInterval? = nil) -> Promise<Void> {
        guard self.device.peripheral?.state != .connected && self.device.peripheral?.state != .connecting else {
            return Promise(())
        }

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 function.
Open

        if strength >= -90 { return XYDeviceProximity.far }
Severity: Major
Found in Carthage/Checkouts/sdk-ble-swift/Source/Constants/XYConstants.swift - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                        return
    Severity: Major
    Found in Carthage/Checkouts/sdk-ble-swift/Source/XYDeviceConnectionManager.swift - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              if strength >= -80 { return XYDeviceProximity.medium }
      Severity: Major
      Found in Carthage/Checkouts/sdk-ble-swift/Source/Constants/XYConstants.swift - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                                return

          Avoid too many return statements within this function.
          Open

                      guard let byteVal = self.asByteArray else { return "n/a" }

            Avoid too many return statements within this function.
            Open

                        return byteVal.hexa

              Avoid too many return statements within this function.
              Open

                      return false
              Severity: Major
              Found in Source/BleInterface/devices/XyoDifferentiableDevice.swift - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return nil

                  Avoid too many return statements within this function.
                  Open

                                      return
                  Severity: Major
                  Found in Carthage/Checkouts/sdk-ble-swift/Source/Gatt/GattRequest.swift - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return XYIBeaconDefinition(uuid: uuid, major: major, minor: minor)

                      Avoid too many return statements within this function.
                      Open

                              return "\(latNumData), \(lngNumData)"
                      Severity: Major
                      Found in Source/Heuristics/GpsResolver.swift - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language