fsaar/TicTacToe

View on GitHub

Showing 8 of 26 total issues

Function merge has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    func merge(highscores : [[String : Any]]) {
        let fetchRequest = NSFetchRequest<TTTHighscore>(entityName:String(describing:TTTHighscore.self))
        let context = TTTCoreDataStack.sharedDataStack.privateQueueManagedObjectContext
        defer {
            context.perform {
Severity: Minor
Found in TicTacToe/TicTacToe/TTTBackendClient.swift - About 1 hr to fix

    Function merge has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        func merge(highscores : [[String : Any]]) {
            let fetchRequest = NSFetchRequest<TTTHighscore>(entityName:String(describing:TTTHighscore.self))
            let context = TTTCoreDataStack.sharedDataStack.privateQueueManagedObjectContext
            defer {
                context.perform {
    Severity: Minor
    Found in TicTacToe/TicTacToe/TTTBackendClient.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 controller has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
            switch type {
            case .insert:
                if let newIndexPath = newIndexPath {
                    self.tableView.insertRows(at: [newIndexPath], with: .automatic)
    Severity: Minor
    Found in TicTacToe/TicTacToe/Highscore/TTTHighscoreTableViewController.swift - About 55 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

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

        func attackMove(forPartySelectingRed selectingRed : Bool) -> TTTBoardPosition? {
            if (self.redCount == 0) && selectingRed  {
                if self[TTTBoardPosition(column:1, row: 1)] == .undefined {
                    return TTTBoardPosition(column:1, row: 1)
                }
    Severity: Minor
    Found in TicTacToe/TicTacToe/TTTBoardConfig.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

    Function controller has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
    Severity: Minor
    Found in TicTacToe/TicTacToe/Highscore/TTTHighscoreTableViewController.swift - About 35 mins to fix

      Function postHigscore has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          func postHigscore(with name : String,moves : Int, time : Float,callBack onQueue: OperationQueue = .main,using completionBlock: ((_ error : Error?) -> ())? = nil) {
      Severity: Minor
      Found in TicTacToe/TicTacToe/TTTBackendClient.swift - About 35 mins to fix

        Avoid too many return statements within this function.
        Open

                return positionToSelect
        Severity: Major
        Found in TicTacToe/TicTacToe/TTTBoardConfig.swift - About 30 mins to fix

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

              private func consecutiveCellStateCount(_ row : [TTTBoardPosition],state : TTTState) -> Int {
                  var count = 0
                  var previousPosition : TTTBoardPosition? = nil
                  let invalidState : TTTState = state == .greenSelected ? .redSelected :  .greenSelected
                  for position in row {
          Severity: Minor
          Found in TicTacToe/TicTacToe/TTTBoardConfig.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

          Severity
          Category
          Status
          Source
          Language