fsaar/SASeatBooking

View on GitHub

Showing 2 of 2 total issues

Function animated has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    func animated(show : Bool,bodyOf node: SCNNode) {
        if let body =  node.childNode(withName: SASeatFactoryLabel.body.rawValue, recursively: true) {
            let action = show ? SCNAction.fadeOpacity(to: 1, duration: 1) : SCNAction.fadeOpacity(to: 0, duration: 1)
            body.runAction(action)
        }
Severity: Minor
Found in SASeatBooking/SASeatBookingView/SAViewController.swift - About 25 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

Constant should be lowerCamelCase
Open

            let unit_in_radian = CGFloat(Double.pi / 180) / 5

constant-naming

Global constants should follow either UpperCamelCase or lowerCamelCase naming conventions. Local constants should follow lowerCamelCase naming conventions.

Preferred

let MaxHeight = 42
let maxHeight = 42

Not Preferred

let max_height = 42
Severity
Category
Status
Source
Language