Showing 231 of 231 total issues
File EventViewController.swift
has 477 lines of code (exceeds 250 allowed). Consider refactoring. Open
import UIKit
import EventKit
import MapKit
File MonthsViewController.swift
has 394 lines of code (exceeds 250 allowed). Consider refactoring. Open
import UIKit
import EventKit
final class MonthsViewController: UICollectionViewController, MonthsScreen,
CollectionViewTraitDelegate {
File ZoomTransition.swift
has 391 lines of code (exceeds 250 allowed). Consider refactoring. Open
import UIKit
import QuartzCore
enum ZoomTransitionFrameFitting: String {
case zoomedInAspectFittingZoomedOut
Function sync
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
@objc private func sync(_ sender: CADisplayLink) {
guard collectionView.contentOffset.y >= 0,
collectionView.contentOffset.y != collectionView.previousContentOffset?.y
else { return }
- 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
File TitleScrollView.swift
has 319 lines of code (exceeds 250 allowed). Consider refactoring. Open
import UIKit
import QuartzCore
enum TitleItemType {
Function transitionFocus
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
override func transitionFocus(to view: UIView?, from currentView: UIView? = nil,
completion: (() -> Void)? = nil) {
let isPicker = (from: currentView is UIDatePicker, to: view is UIDatePicker)
let shouldToggleDrawer = isPicker.from || isPicker.to && !(isPicker.from && isPicker.to)
var toggleDrawerDelay: TimeInterval?
- 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
FormViewController
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class FormViewController: UIViewController, FormDataSourceDelegate, FormFocusStateDelegate {
// MARK: - UIViewController
override func viewDidLoad() {
EventViewController
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
final class EventViewController: FormViewController, EventScreen {
// MARK: CoordinatedViewController
weak var currentSegue: UIStoryboardSegue?
Function indexPathUpdatesForEvent
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
func indexPathUpdatesForEvent(newInfo: EventWithChangeInfo,
oldInfo: EventWithChangeInfo) -> SelectiveUpdatingInfo {
var paths = (deletions: [IndexPath](), insertions: [IndexPath](), reloads: [IndexPath](),
sectionDeletions: IndexSet(), sectionInsertions: IndexSet())
- 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
File DayViewController.swift
has 292 lines of code (exceeds 250 allowed). Consider refactoring. Open
import UIKit
import EventKit
final class DayViewController: UICollectionViewController, DayScreen {
Function handleLongPress
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
@objc private func handleLongPress(_ sender: UILongPressGestureRecognizer) {
guard sender === longPressRecognizer else { preconditionFailure() }
let location = longPressRecognizer.location(in: collectionView)
let handleReattach = { (cell: UICollectionViewCell, indexPath: IndexPath) in
- 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 sync
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
@objc private func sync(_ sender: CADisplayLink) {
guard collectionView.contentOffset.y >= 0,
collectionView.contentOffset.y != collectionView.previousContentOffset?.y
else { return }
Function handleLongPress
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
@objc private func handleLongPress(_ sender: UILongPressGestureRecognizer) {
guard sender === longPressRecognizer else { preconditionFailure() }
let location = longPressRecognizer.location(in: collectionView)
let handleReattach = { (cell: UICollectionViewCell, indexPath: IndexPath) in
Function handlePan
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
@objc private func handlePan(_ sender: UIPanGestureRecognizer) {
let translation = sender.translation(in: sender.view!.superview!)
let velocity = sender.velocity(in: sender.view!)
switch sender.state {
case .began:
- 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 prepareSegueForDescendant
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
override func prepareSegueForDescendant(_ sender: Any?) {
super.prepareSegueForDescendant(sender)
let viewController = sender as! CoordinatedViewController
let (type, destination, source, destinationContainer, sourceContainer) =
EventCollectionsTests
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
final class EventCollectionsTests: XCTestCase {
lazy var tomorrowEvents: [TestEvent] = [
TestEvent(identifier: "Tomorrow-0", startDate: tomorrow),
TestEvent(identifier: "Tomorrow-1", startDate: tomorrow),
Function prepareSegueForDescendant
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
override func prepareSegueForDescendant(_ sender: Any?) {
super.prepareSegueForDescendant(sender)
let viewController = sender as! CoordinatedViewController
let (type, destination, source, destinationContainer, sourceContainer) =
- 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 indexPathUpdatesForEvent
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
func indexPathUpdatesForEvent(newInfo: EventWithChangeInfo,
oldInfo: EventWithChangeInfo) -> SelectiveUpdatingInfo {
var paths = (deletions: [IndexPath](), insertions: [IndexPath](), reloads: [IndexPath](),
sectionDeletions: IndexSet(), sectionInsertions: IndexSet())
Function transitionFocus
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
override func transitionFocus(to view: UIView?, from currentView: UIView? = nil,
completion: (() -> Void)? = nil) {
let isPicker = (from: currentView is UIDatePicker, to: view is UIDatePicker)
let shouldToggleDrawer = isPicker.from || isPicker.to && !(isPicker.from && isPicker.to)
var toggleDrawerDelay: TimeInterval?
Similar blocks of code found in 2 locations. Consider refactoring. Open
override func fetch(completion: (() -> Void)? = nil) {
guard beginFetch() else { return }
let endDate = isInvalid ? Date() : fetchCursor!
let startDate = Calendar.current.date(byAdding: fetchRangeComponents, to: endDate)!
- Read upRead up
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 113.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76