XYOracleNetwork/sdk-ble-flutter

View on GitHub

Showing 312 of 312 total issues

Function decodeMessage has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    _ = _uniqueStorage()
    try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
      while let fieldNumber = try decoder.nextFieldNumber() {
        switch fieldNumber {
Severity: Minor
Found in ios/Classes/protos/gatt.pb.swift - About 3 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 decodeMessage has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    _ = _uniqueStorage()
    try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
      while let fieldNumber = try decoder.nextFieldNumber() {
        switch fieldNumber {
Severity: Minor
Found in ios/Classes/protos/gatt.pb.swift - About 3 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

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

  static func ==(lhs: GattResponse, rhs: GattResponse) -> 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: Major
Found in ios/Classes/protos/gatt.pb.swift and 1 other location - About 3 hrs to fix
ios/Classes/protos/gatt.pb.swift on lines 445..460

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

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: GattOperation, rhs: GattOperation) -> 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: Major
Found in ios/Classes/protos/gatt.pb.swift and 1 other location - About 3 hrs to fix
ios/Classes/protos/gatt.pb.swift on lines 611..626

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

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

  override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
    when (call.method) {
      "start" -> start(call, result)
      "stop" -> stop(call, result)
      "gattSingle" -> gattSingle(call, result)
android/src/main/kotlin/network/xyo/ble/xyo_ble/channels/bridge.kt on lines 48..58

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

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

    override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
        when (call.method) {
            "setArchivists" -> setArchivists(call, result)
            "getBlockCount" -> getBlockCount(call, result)
            "getLastBlock" -> getLastBlock(call, result)
android/src/main/kotlin/network/xyo/ble/xyo_ble/channels/device.kt on lines 112..122

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

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

IBeacon has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

  public  static final class IBeacon extends
      com.google.protobuf.GeneratedMessageLite<
          IBeacon, IBeacon.Builder> implements
      // @@protoc_insertion_point(message_implements:IBeacon)
      IBeaconOrBuilder {

    IBeacon has 28 methods (exceeds 20 allowed). Consider refactoring.
    Open

      public  static final class IBeacon extends
          com.google.protobuf.GeneratedMessageLite<
              IBeacon, IBeacon.Builder> implements
          // @@protoc_insertion_point(message_implements:IBeacon)
          IBeaconOrBuilder {

      GattCall has 27 methods (exceeds 20 allowed). Consider refactoring.
      Open

        public  static final class GattCall extends
            com.google.protobuf.GeneratedMessageLite<
                GattCall, GattCall.Builder> implements
            // @@protoc_insertion_point(message_implements:GattCall)
            GattCallOrBuilder {

        Builder has 27 methods (exceeds 20 allowed). Consider refactoring.
        Open

            public static final class Builder extends
                com.google.protobuf.GeneratedMessageLite.Builder<
                  network.xyo.ble.flutter.protobuf.Gatt.GattOperation, Builder> implements
                // @@protoc_insertion_point(builder_implements:GattOperation)
                network.xyo.ble.flutter.protobuf.Gatt.GattOperationOrBuilder {

          GattCall has 27 methods (exceeds 20 allowed). Consider refactoring.
          Open

            public  static final class GattCall extends
                com.google.protobuf.GeneratedMessageLite<
                    GattCall, GattCall.Builder> implements
                // @@protoc_insertion_point(message_implements:GattCall)
                GattCallOrBuilder {

            Builder has 27 methods (exceeds 20 allowed). Consider refactoring.
            Open

                public static final class Builder extends
                    com.google.protobuf.GeneratedMessageLite.Builder<
                      network.xyo.ble.flutter.protobuf.Gatt.GattOperation, Builder> implements
                    // @@protoc_insertion_point(builder_implements:GattOperation)
                    network.xyo.ble.flutter.protobuf.Gatt.GattOperationOrBuilder {

              Builder has 26 methods (exceeds 20 allowed). Consider refactoring.
              Open

                  public static final class Builder extends
                      com.google.protobuf.GeneratedMessageLite.Builder<
                        network.xyo.ble.flutter.protobuf.Gatt.GattResponse, Builder> implements
                      // @@protoc_insertion_point(builder_implements:GattResponse)
                      network.xyo.ble.flutter.protobuf.Gatt.GattResponseOrBuilder {

                Builder has 26 methods (exceeds 20 allowed). Consider refactoring.
                Open

                    public static final class Builder extends
                        com.google.protobuf.GeneratedMessageLite.Builder<
                          network.xyo.ble.flutter.protobuf.Gatt.GattResponse, Builder> implements
                        // @@protoc_insertion_point(builder_implements:GattResponse)
                        network.xyo.ble.flutter.protobuf.Gatt.GattResponseOrBuilder {

                  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

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

                    internal class AddDeviceEventChannel: NSObject, FlutterStreamHandler {
                    
                        var eventSink: FlutterEventSink?
                    
                        func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? {
                    Severity: Major
                    Found in ios/Classes/AddDeviceManager.swift and 1 other location - About 2 hrs to fix
                    ios/Classes/SmartScanChannel.swift on lines 65..90

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

                    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

                    internal class ScannerEventChannel: NSObject, FlutterStreamHandler {
                    
                        var eventSink: FlutterEventSink?
                    
                        func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? {
                    Severity: Major
                    Found in ios/Classes/SmartScanChannel.swift and 1 other location - About 2 hrs to fix
                    ios/Classes/AddDeviceManager.swift on lines 13..38

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

                    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

                    Write has 23 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                        public  static final class Write extends
                            com.google.protobuf.GeneratedMessageLite<
                                Write, Write.Builder> implements
                            // @@protoc_insertion_point(message_implements:GattOperation.Write)
                            WriteOrBuilder {

                      Range has 23 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                        public  static final class Range extends
                            com.google.protobuf.GeneratedMessageLite<
                                Range, Range.Builder> implements
                            // @@protoc_insertion_point(message_implements:Range)
                            RangeOrBuilder {

                        Write has 23 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                            public  static final class Write extends
                                com.google.protobuf.GeneratedMessageLite<
                                    Write, Write.Builder> implements
                                // @@protoc_insertion_point(message_implements:GattOperation.Write)
                                WriteOrBuilder {
                          Severity
                          Category
                          Status
                          Source
                          Language