XYOracleNetwork/sdk-xyo-client-swift

View on GitHub

Showing 24 of 24 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

import Foundation

open class XyoBasicWitness: XyoWitness {
    
    public init(_ observer: @escaping ObserverClosure) {
Severity: Major
Found in Sources/XyoClient/XyoWitness/Basic/BasicWitness.swift and 1 other location - About 2 hrs to fix
Sources/XyoClient/XyoWitness/Event/EventWitness.swift on lines 1..24

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 148.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

import Foundation

open class XyoEventWitness: XyoWitness {
    
    public init(_ observer: @escaping ObserverClosure) {
Severity: Major
Found in Sources/XyoClient/XyoWitness/Event/EventWitness.swift and 1 other location - About 2 hrs to fix
Sources/XyoClient/XyoWitness/Basic/BasicWitness.swift on lines 1..24

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 148.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function start has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    func start() {
        monitor.start(queue: queue)
        monitor.pathUpdateHandler = { path in
            //bail if shutting down
            if (self.shuttingDown) {
Severity: Minor
Found in Sources/XyoClient/XyoWitness/SystemInfo/PathMonitorManager.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 security has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    func security() -> String? {
        let client = CWWiFiClient.shared()
        let interface = client.interface(withName: nil)
        guard let security = interface?.security() else {return nil}
        switch(security) {
Severity: Minor
Found in Sources/XyoClient/XyoWitness/SystemInfo/WifiInformation.swift - About 1 hr to fix

    Function start has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        func start() {
            monitor.start(queue: queue)
            monitor.pathUpdateHandler = { path in
                //bail if shutting down
                if (self.shuttingDown) {
    Severity: Minor
    Found in Sources/XyoClient/XyoWitness/SystemInfo/PathMonitorManager.swift - About 1 hr to fix

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

          func encodeBodyFields(_ container: inout KeyedEncodingContainer<CodingKeys>) throws {
              try container.encode(addresses, forKey: .addresses)
              try container.encode(payload_hashes, forKey: .payload_hashes)
              try container.encode(payload_schemas, forKey: .payload_schemas)
              try container.encode(previous_hashes, forKey: .previous_hashes)
      Severity: Major
      Found in Sources/XyoClient/BoundWitness/BoundWitnessJson.swift and 1 other location - About 1 hr to fix
      Sources/XyoClient/BoundWitness/Body/BoundWitnessBodyJson.swift on lines 39..45

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 90.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

          func encodeBodyFields(_ container: inout KeyedEncodingContainer<CodingKeys>) throws {
              try container.encode(addresses, forKey: .addresses)
              try container.encode(payload_hashes, forKey: .payload_hashes)
              try container.encode(payload_schemas, forKey: .payload_schemas)
              try container.encode(previous_hashes, forKey: .previous_hashes)
      Sources/XyoClient/BoundWitness/BoundWitnessJson.swift on lines 30..36

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 90.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 5 locations. Consider refactoring.
      Open

              model = withUnsafePointer(to: &systemInfo.machine) {
                  $0.withMemoryRebound(to: CChar.self, capacity: 1) {
                      ptr in String.init(validatingUTF8: ptr)
                  }
              }?.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 18..22
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 24..28
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 30..34
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 36..40

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 56.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 5 locations. Consider refactoring.
      Open

              sysname = withUnsafePointer(to: &systemInfo.sysname) {
                  $0.withMemoryRebound(to: CChar.self, capacity: 1) {
                      ptr in String.init(validatingUTF8: ptr)
                  }
              }?.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 12..16
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 24..28
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 30..34
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 36..40

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 56.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 5 locations. Consider refactoring.
      Open

              nodename = withUnsafePointer(to: &systemInfo.nodename) {
                  $0.withMemoryRebound(to: CChar.self, capacity: 1) {
                      ptr in String.init(validatingUTF8: ptr)
                  }
              }?.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 12..16
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 18..22
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 30..34
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 36..40

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 56.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 5 locations. Consider refactoring.
      Open

              version = withUnsafePointer(to: &systemInfo.version) {
                  $0.withMemoryRebound(to: CChar.self, capacity: 1) {
                      ptr in String.init(validatingUTF8: ptr)
                  }
              }?.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 12..16
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 18..22
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 24..28
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 30..34

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 56.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 5 locations. Consider refactoring.
      Open

              release = withUnsafePointer(to: &systemInfo.release) {
                  $0.withMemoryRebound(to: CChar.self, capacity: 1) {
                      ptr in String.init(validatingUTF8: ptr)
                  }
              }?.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 12..16
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 18..22
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 24..28
      Sources/XyoClient/XyoWitness/SystemInfo/SystemInfoDevicePayloadStruct.swift on lines 36..40

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 56.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

          func data(using encoding:ExtendedEncoding) -> Data? {
              let hexStr = self.dropFirst(self.hasPrefix("0x") ? 2 : 0)
              
              guard hexStr.count % 2 == 0 else { return nil }
              
      Severity: Minor
      Found in Sources/XyoClient/extensions/String.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

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

          func mac() -> String? {
              let client = CWWiFiClient.shared()
              let interface = client.interface(withName: nil)
              return interface?.hardwareAddress()
          }
      Severity: Major
      Found in Sources/XyoClient/XyoWitness/SystemInfo/WifiInformation.swift and 3 other locations - About 40 mins to fix
      Sources/XyoClient/XyoWitness/SystemInfo/WifiInformation.swift on lines 37..41
      Sources/XyoClient/XyoWitness/SystemInfo/WifiInformation.swift on lines 128..132
      Sources/XyoClient/XyoWitness/SystemInfo/WifiInformation.swift on lines 140..144

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 49.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

          func rssi() -> Int? {
              let client = CWWiFiClient.shared()
              let interface = client.interface(withName: nil)
              return interface?.rssiValue()
          }
      Severity: Major
      Found in Sources/XyoClient/XyoWitness/SystemInfo/WifiInformation.swift and 3 other locations - About 40 mins to fix
      Sources/XyoClient/XyoWitness/SystemInfo/WifiInformation.swift on lines 37..41
      Sources/XyoClient/XyoWitness/SystemInfo/WifiInformation.swift on lines 58..62
      Sources/XyoClient/XyoWitness/SystemInfo/WifiInformation.swift on lines 140..144

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 49.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

          func txPower() -> Int? {
              let client = CWWiFiClient.shared()
              let interface = client.interface(withName: nil)
              return interface?.transmitPower()
          }
      Severity: Major
      Found in Sources/XyoClient/XyoWitness/SystemInfo/WifiInformation.swift and 3 other locations - About 40 mins to fix
      Sources/XyoClient/XyoWitness/SystemInfo/WifiInformation.swift on lines 37..41
      Sources/XyoClient/XyoWitness/SystemInfo/WifiInformation.swift on lines 58..62
      Sources/XyoClient/XyoWitness/SystemInfo/WifiInformation.swift on lines 128..132

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 49.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

          func ssid() -> String? {
              let client = CWWiFiClient.shared()
              let interface = client.interface(withName: nil)
              return interface?.ssid()
          }
      Severity: Major
      Found in Sources/XyoClient/XyoWitness/SystemInfo/WifiInformation.swift and 3 other locations - About 40 mins to fix
      Sources/XyoClient/XyoWitness/SystemInfo/WifiInformation.swift on lines 58..62
      Sources/XyoClient/XyoWitness/SystemInfo/WifiInformation.swift on lines 128..132
      Sources/XyoClient/XyoWitness/SystemInfo/WifiInformation.swift on lines 140..144

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 49.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

          public func postBoundWitnesses (
              _ entries: [XyoBoundWitnessJson],
              _ closure: @escaping (_ error: String?) -> Void
          ) throws {
              let body = entries
      Severity: Minor
      Found in Sources/XyoClient/ArchivistApi/ArchivistApiClient.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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          public var keccakHex: String? {
              get {
                  guard let bytes = keccakBytes else { return nil }
                      return bytes.toHex(64)
              }
      Severity: Minor
      Found in Sources/XyoClient/Address/XyoAddress.swift and 1 other location - About 30 mins to fix
      Sources/XyoClient/Address/XyoAddress.swift on lines 72..77

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 41.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          public var addressHex: String? {
              get {
                  guard let bytes = addressBytes else { return nil }
                      return bytes.toHex(40)
              }
      Severity: Minor
      Found in Sources/XyoClient/Address/XyoAddress.swift and 1 other location - About 30 mins to fix
      Sources/XyoClient/Address/XyoAddress.swift on lines 58..63

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 41.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Severity
      Category
      Status
      Source
      Language