XYOracleNetwork/sdk-ble-flutter

View on GitHub
ios/Classes/protos/device.pb.swift

Summary

Maintainability
D
2 days
Test Coverage

Function == has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

  static func ==(lhs: BluetoothDevice, rhs: BluetoothDevice) -> Bool {
    if lhs._storage !== rhs._storage {
      let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in
        let _storage = _args.0
        let rhs_storage = _args.1
Severity: Minor
Found in ios/Classes/protos/device.pb.swift - About 4 hrs 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

File device.pb.swift has 289 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Foundation
import SwiftProtobuf

// If the compiler emits an error on this type, it is because this file
// was generated by a version of the `protoc` Swift plug-in that is
Severity: Minor
Found in ios/Classes/protos/device.pb.swift - About 2 hrs to fix

    Function traverse has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
        try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
          if !_storage._id.isEmpty {
            try visitor.visitSingularStringField(value: _storage._id, fieldNumber: 1)
          }
    Severity: Minor
    Found in ios/Classes/protos/device.pb.swift - About 2 hrs 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 traverse has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
        try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
          if !_storage._id.isEmpty {
            try visitor.visitSingularStringField(value: _storage._id, fieldNumber: 1)
          }
    Severity: Minor
    Found in ios/Classes/protos/device.pb.swift - About 1 hr to fix

      Avoid too many return statements within this function.
      Open

              if _storage._address != rhs_storage._address {return false}
      Severity: Major
      Found in ios/Classes/protos/device.pb.swift - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            if lhs.unknownFields != rhs.unknownFields {return false}
        Severity: Major
        Found in ios/Classes/protos/device.pb.swift - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  if _storage._range != rhs_storage._range {return false}
          Severity: Major
          Found in ios/Classes/protos/device.pb.swift - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    if _storage._connected != rhs_storage._connected {return false}
            Severity: Major
            Found in ios/Classes/protos/device.pb.swift - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return true
              Severity: Major
              Found in ios/Classes/protos/device.pb.swift - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return true
                Severity: Major
                Found in ios/Classes/protos/device.pb.swift - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      if lhs.unknownFields != rhs.unknownFields {return false}
                  Severity: Major
                  Found in ios/Classes/protos/device.pb.swift - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            if _storage._name != rhs_storage._name {return false}
                    Severity: Major
                    Found in ios/Classes/protos/device.pb.swift - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return true
                      Severity: Major
                      Found in ios/Classes/protos/device.pb.swift - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            return true
                        Severity: Major
                        Found in ios/Classes/protos/device.pb.swift - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                if !storagesAreEqual {return false}
                          Severity: Major
                          Found in ios/Classes/protos/device.pb.swift - About 30 mins to fix

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

                              static func ==(lhs: IBeacon, rhs: IBeacon) -> Bool {
                                if lhs.major != rhs.major {return false}
                                if lhs.minor != rhs.minor {return false}
                                if lhs.uuid != rhs.uuid {return false}
                                if lhs.unknownFields != rhs.unknownFields {return false}
                            Severity: Major
                            Found in ios/Classes/protos/device.pb.swift and 1 other location - About 1 hr to fix
                            ios/Classes/protos/gatt.pb.swift on lines 317..323

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

                            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

                              mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
                                while let fieldNumber = try decoder.nextFieldNumber() {
                                  switch fieldNumber {
                                  case 1: try decoder.decodeSingularInt64Field(value: &self.major)
                                  case 2: try decoder.decodeSingularInt64Field(value: &self.minor)
                            Severity: Major
                            Found in ios/Classes/protos/device.pb.swift and 1 other location - About 1 hr to fix
                            ios/Classes/protos/gatt.pb.swift on lines 293..302

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

                            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

                              static func ==(lhs: Range, rhs: Range) -> Bool {
                                if lhs.min != rhs.min {return false}
                                if lhs.max != rhs.max {return false}
                                if lhs.unknownFields != rhs.unknownFields {return false}
                                return true
                            Severity: Major
                            Found in ios/Classes/protos/device.pb.swift and 1 other location - About 1 hr to fix
                            ios/Classes/protos/gatt.pb.swift on lines 353..358

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

                            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 3 locations. Consider refactoring.
                            Open

                              mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
                                while let fieldNumber = try decoder.nextFieldNumber() {
                                  switch fieldNumber {
                                  case 1: try decoder.decodeSingularSInt64Field(value: &self.min)
                                  case 2: try decoder.decodeSingularSInt64Field(value: &self.max)
                            Severity: Major
                            Found in ios/Classes/protos/device.pb.swift and 2 other locations - About 1 hr to fix
                            ios/Classes/protos/gatt.pb.swift on lines 333..341
                            ios/Classes/protos/gatt.pb.swift on lines 470..478

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

                            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

                              static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
                                1: .same(proto: "major"),
                                2: .same(proto: "minor"),
                                3: .same(proto: "uuid"),
                              ]
                            Severity: Minor
                            Found in ios/Classes/protos/device.pb.swift and 1 other location - About 40 mins to fix
                            ios/Classes/protos/gatt.pb.swift on lines 287..291

                            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

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

                              fileprivate mutating func _uniqueStorage() -> _StorageClass {
                                if !isKnownUniquelyReferenced(&_storage) {
                                  _storage = _StorageClass(copying: _storage)
                                }
                                return _storage
                            Severity: Minor
                            Found in ios/Classes/protos/device.pb.swift and 2 other locations - About 35 mins to fix
                            ios/Classes/protos/gatt.pb.swift on lines 389..394
                            ios/Classes/protos/gatt.pb.swift on lines 555..560

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

                            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

                            There are no issues that match your filters.

                            Category
                            Status