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 {
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 {
- Read upRead up
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)
- Read upRead up
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)
}
- Read upRead up
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?) {
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) {
Avoid too many return
statements within this function. Open
return positionToSelect
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 {
- Read upRead up
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"