Lambda-School-Labs/community-calendar-ios

View on GitHub

Showing 94 of 254 total issues

Avoid too many return statements within this function.
Open

        return UICollectionViewCell()

    Avoid too many return statements within this function.
    Open

                return

      Avoid too many return statements within this function.
      Open

                  guard let resultsVC = segue.destination as? SearchResultViewController else { return }

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

            func populateDataSource() {
                
                if currentUser == nil || authController?.stateManager?.accessToken == nil {
                    createdCalDataSource.removeAll()
                    savedCalDataSource.removeAll()

        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 setDistrictList has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private func setDistrictList() {
                if let events = events {
                    var districtList = [String]()
                    for event in events {
                        if let location = event.location?.city {

        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 collectionView has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
                if collectionView == eventCollectionView {
                    guard let cell = eventCollectionView.dequeueReusableCell(withReuseIdentifier: "EventCollectionViewCell", for: indexPath) as? EventCollectionViewCell else { return UICollectionViewCell() }
                    
                    let event = filteredEvents?[indexPath.item]

        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 fetchAllEventData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            func fetchAllEventData() {
                apolloController.fetchEvents { _ in
                    
                }
                Apollo.shared.fetchTodaysEvents { _ in

        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 fetchTomorrowsEvents has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            func fetchTomorrowsEvents(completion: @escaping (Swift.Result<[FetchDateRangedEventsQuery.Data.Event], Error>) -> Void) {
                let dates = tomorrowsDateRange()
                guard let startDate = dates.first, let endDate = dates.last else {
                    print("Returned out of dates guard let in fetch tomorrow's events function")
                    return

        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 fetchTodaysEvents has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            func fetchTodaysEvents(completion: @escaping (Swift.Result<[FetchDateRangedEventsQuery.Data.Event], Error>) -> Void) {
                let dates = todaysDateRange()
                guard let startDate = dates.first, let endDate = dates.last else {
                    print("Returned out of dates guard let in fetch today's events function.")
                    return

        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 fetchWeekendEvents has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            func fetchWeekendEvents(completion: @escaping (Swift.Result<[FetchDateRangedEventsQuery.Data.Event], Error>) -> Void) {
                let dates = weekendDateRange()
                guard let startDate = dates.first, let endDate = dates.last else {
                    print("Returned out of dates guard let in fetch weekend events function.")
                    return

        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 fetchAllEvents has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            func fetchAllEvents(completion: @escaping (Swift.Result<[FetchDateRangedEventsQuery.Data.Event], Error>) -> Void) {
                let dates = allEventsRange()
                guard let startDate = dates.first, let endDate = dates.last else {
                    print("Returned out of dates guard let in fetch all events function.")
                    return

        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 fetchImage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            func fetchImage(for key: String) {
        //        if let image = cache.fetch(key: key) {
        //            NotificationCenter.default.post(name: .imageWasLoaded, object: ImageNotification(image: image, url: key))
        //            return
        //        }
        Severity: Minor
        Found in Community Calendar/Community Calendar/Model Controller/Controller.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

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

            func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
                if collectionView == selectedTagsCollectionView {
                    guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "SelectedFilterCell", for: indexPath) as? TagCollectionViewCell else { return UICollectionViewCell() }
                    cell.filterTag = selectedFilters[indexPath.row]
                    cell.isActive = true

        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 handleCellEvents has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            func handleCellEvents(cell: DateCell, cellState: CellState) {
                let dateString = jtCalCompareFormatter.string(from: cellState.date)
                if createdCalDataSource[dateString] == nil {
                    cell.createdDot.isHidden = true
                } else {

        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