XYOracleNetwork/sdk-core-swift

View on GitHub

Showing 31 of 235 total issues

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: Minor
Found in sdk-core-swift/network/appGroup/XyoSharedFileManager.swift - About 1 hr to fix

    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: Minor
    Found in Sources/sdk-core-swift/network/appGroup/XyoSharedFileManager.swift - About 1 hr to fix

      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) {
      Severity: Minor
      Found in sdk-core-swift/node/XyoOriginChainCreator.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
      Severity: Minor
      Found in Sources/sdk-core-swift/network/appGroup/XyoSharedFileManager.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
      Severity: Minor
      Found in sdk-core-swift/network/appGroup/XyoSharedFileManager.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 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) {
      Severity: Minor
      Found in Sources/sdk-core-swift/node/XyoOriginChainCreator.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 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)
      Severity: Minor
      Found in sdk-core-swiftTests/boundWitness/XyoBoundWitnessUtilTest.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

      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 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

      Avoid too many return statements within this function.
      Open

                              return
      Severity: Major
      Found in sdk-core-swift/boundWitness/XyoZigZagBoundWitnessSession.swift - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                                return
        Severity: Major
        Found in Sources/sdk-core-swift/boundWitness/XyoZigZagBoundWitnessSession.swift - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language