brightdigit/MistKit

View on GitHub
Sources/MistKit/Models/MKLocation.swift

Summary

Maintainability
A
45 mins
Test Coverage

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

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    try container.encode(coordinate.latitude, forKey: .latitude)
    try container.encode(coordinate.longitude, forKey: .longitude)
    try container.encode(altitude, forKey: .altitude)
Severity: Minor
Found in Sources/MistKit/Models/MKLocation.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

All declarations should specify Access Control Level keywords explicitly.
Open

  enum CodingKeys: String, CodingKey {

All declarations should specify Access Control Level keywords explicitly.
Open

  var course: MKLocationDirection?

All declarations should specify Access Control Level keywords explicitly.
Open

  var horizontalAccuracy: MKLocationAccuracy?

All declarations should specify Access Control Level keywords explicitly.
Open

  var speed: MKLocationSpeed?

All declarations should specify Access Control Level keywords explicitly.
Open

  var longitude: MKLocationDegrees

All declarations should specify Access Control Level keywords explicitly.
Open

  var coordinate: MKLocationCoordinate2D

All declarations should specify Access Control Level keywords explicitly.
Open

  var latitude: MKLocationDegrees

All declarations should specify Access Control Level keywords explicitly.
Open

  var altitude: MKLocationDistance?

All declarations should specify Access Control Level keywords explicitly.
Open

  var verticalAccuracy: MKLocationAccuracy?

All declarations should specify Access Control Level keywords explicitly.
Open

  var timestamp: Date?

public declarations should be documented.
Open

public typealias MKLocationDistance = Double

public declarations should be documented.
Open

public typealias MKLocationAccuracy = Double

public declarations should be documented.
Open

public typealias MKLocationSpeed = Double

public declarations should be documented.
Open

public typealias MKLocationDegrees = Double

public declarations should be documented.
Open

public typealias MKLocationDirection = Double

Function should have at least one blank line after it
Open

  }

function-whitespace

Every function and method declaration should have one blank line before and after itself. An exception to this rule are functions that are declared at the start of a file (only need one blank line after their declaration) or at the end of a file (only need one blank line before their declaration). Comments immediately before a function declaration (no blank lines between them and the function) are considered to be part of the declaration.

Preferred

func function1() {
  var text = 1
  var text = 2
}

function1()

// a comment
func function2() {
  // something goes here
}

struct SomeStruct {

  func function3() {
    // something goes here
  }

  func function4() {
    // something else goes here
  };

}

func function5() {
  // something goes here
}

Not Preferred

func function1() {
  var text = 1
  var text = 2
}
function1()
// a comment
func function2() {
  // something goes here
}

struct SomeStruct {
  func function3() {
    // something goes here
  }

  func function4() {
    // something else goes here
  };
}
func function5() {
  // something goes here
}

An 'instance_property' should not be placed amongst the type content(s) 'subtype'.
Open

  var speed: MKLocationSpeed?

An 'instance_property' should not be placed amongst the type content(s) 'subtype'.
Open

  var verticalAccuracy: MKLocationAccuracy?

An 'initializer' should not be placed amongst the type content(s) 'subtype'.
Open

  internal init(

An 'instance_property' should not be placed amongst the type content(s) 'subtype'.
Open

  var altitude: MKLocationDistance?

An 'instance_property' should not be placed amongst the type content(s) 'subtype'.
Open

  var timestamp: Date?

An 'instance_property' should not be placed amongst the type content(s) 'subtype'.
Open

  var horizontalAccuracy: MKLocationAccuracy?

An 'instance_property' should not be placed amongst the type content(s) 'subtype'.
Open

  var coordinate: MKLocationCoordinate2D

An 'instance_property' should not be placed amongst the type content(s) 'subtype'.
Open

  var course: MKLocationDirection?

There are no issues that match your filters.

Category
Status