Lambda-School-Labs/community-calendar-ios

View on GitHub

Showing 94 of 254 total issues

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

    func loadImageTV(forCell cell: EventTableViewCell, forItemAt indexPath: IndexPath) {
        guard let event = filteredEvents?[indexPath.item] else { return }
        
        if let cachedImage = cache.value(for: event.id) {
            cell.eventImageView?.image = cachedImage

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

    func getUser(completion: @escaping (Swift.Result<[String], Error>) -> Void) {
        self.stateManager?.getUser({ [weak self] response, error in
            if let error = error {
                print("Error retrieving user info: \(error)")
                completion(.failure(error))

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

    private func setUpWithFilters() {
        if let dateRange = filter.dateRange {
            dateTextField.text = "\(filterDateFormatter.string(from: dateRange.min)) - \(filterDateFormatter.string(from: dateRange.max))"
            firstDatePickerView.date = dateRange.min
            secondDatePickerView.date = dateRange.max

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

    func checkAuthStatus(completion: @escaping () -> Void) {
        guard let stateManager = authController.stateManager, let accessToken = authController.stateManager?.accessToken else {
            print("No state manager or access token. State Manager at load of Tab Bar Controller")
            completion()
            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 anchor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    func anchor(top: NSLayoutYAxisAnchor?, leading: NSLayoutXAxisAnchor?, trailing: NSLayoutXAxisAnchor?, bottom: NSLayoutYAxisAnchor?, centerX: NSLayoutXAxisAnchor?, centerY: NSLayoutYAxisAnchor?, padding: UIEdgeInsets = .zero, size: CGSize = .zero) {
        translatesAutoresizingMaskIntoConstraints = false
        
        if let top = top {
            topAnchor.constraint(equalTo: top, constant: padding.top).isActive = true
Severity: Minor
Found in Community Calendar/Community Calendar/Helpers/UIVIew+Constraints.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 constraint has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

@discardableResult func constraint(firstView: UIView, to secondView: UIView, top: NSLayoutConstraint? = nil, bot: NSLayoutConstraint? = nil, left: NSLayoutConstraint? = nil, right: NSLayoutConstraint? = nil) -> [NSLayoutConstraint] {
    let topConst: NSLayoutConstraint
    let botConst: NSLayoutConstraint
    let leftConst: NSLayoutConstraint
    let rightConst: NSLayoutConstraint
Severity: Minor
Found in Community Calendar/Community Calendar/Helpers/Functions.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 keyboardWillShow has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    @objc func keyboardWillShow(notification: Notification) {
        
        keyboardDismissTapGestureRecognizer.isEnabled = true
        
        var keyboardSize: CGRect = .zero

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 urlSession has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        public func urlSession(_ session: URLSession, task: URLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse, newRequest request: URLRequest, completionHandler: @escaping (URLRequest?) -> Void) {
Severity: Minor
Found in Community Calendar/Pods/OktaOidc/Okta/OktaOidc/OktaOidcConfig.swift - About 35 mins to fix

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

        public func signOut(with options: OktaSignOutOptions,
                            authStateManager: OktaOidcStateManager,
                            from presenter: UIViewController,
                            progressHandler: @escaping ((OktaSignOutOptions) -> Void),
                            completionHandler: @escaping ((Bool, OktaSignOutOptions) -> Void)) {

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

          func updateProfilePic(image: String, graphQLID: String, accessToken: String, file: GraphQLFile, completion: @escaping (Swift.Result<AddProfilePicMutation.Data.UpdateUser, Error>) -> Void) {

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

            func calendar(_ calendar: JTACMonthView, willDisplay cell: JTACDayCell, forItemAt date: Date, cellState: CellState, indexPath: IndexPath) {

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

              func calendar(_ calendar: JTACMonthView, didDeselectDate date: Date, cell: JTACDayCell?, cellState: CellState, indexPath: IndexPath) {

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

                func calendar(_ calendar: JTACMonthView, didSelectDate date: Date, cell: JTACDayCell?, cellState: CellState, indexPath: IndexPath) {

              Function navigationController has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
                      guard let view = self.navigationController?.view else { return nil }
                      // This function calls a custom segue animation when transitioning to an instance of FilterViewController
                      switch operation {
                      case .push:

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

                  override func start() {
                      state = .isExecuting
                      guard
                          let urlString = (event.image),
                          let url = URL(string: urlString)

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

                  override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
                      guard let detailVC = segue.destination as? EventDetailViewController else { return }
              //        detailVC.controller = controller
                      if segue.identifier == "ShowDetailFromTable" {
                          guard let indexPath = eventResultsTableView.indexPathForSelectedRow else { 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 getState has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  static func getState(withAuthRequest authRequest: OIDAuthorizationRequest, callback: @escaping (OIDAuthState?, OktaOidcError?) -> Void ) {
                      
                      let finalize: ((OIDAuthState?, OktaOidcError?) -> Void) = { state, error in
                          callback(state, error)
                      }

              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

              Avoid too many return statements within this function.
              Open

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

                Avoid too many return statements within this function.
                Open

                        return UICollectionViewCell()

                  Avoid too many return statements within this function.
                  Open

                              return nil
                    Severity
                    Category
                    Status
                    Source
                    Language