Lambda-School-Labs/community-calendar-ios

View on GitHub

Showing 94 of 254 total issues

Function setupSubView has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    func setupSubView() {
        
        //MARK: - Constraints
        cameraButton.translatesAutoresizingMaskIntoConstraints = false
        imageBackgroundView.translatesAutoresizingMaskIntoConstraints = false

    Function showInCalendar has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @IBAction func showInCalendar(_ sender: Any) {
            eventStore.requestAccess(to: .event) { (granted, error) in
                if let error = error {
                    NSLog("\(#file):L\(#line): Unable to request access to calendar in \(#function) with error: \(error)")
                    return

      Function updateViews has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          func updateViews() {
              guard let filter = filter, let filterUsedLabel = filterUsedLabel else { return }
              imageButton.backgroundColor = UIColor(red: 0.84, green: 0.84, blue: 0.84, alpha: 1.0)
              imageButton.layer.cornerRadius = 5
              imageButton.layer.borderWidth = 1

        Function prepare has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
                if segue.identifier == "ShowFeaturedDetailSegue" {
                    guard let detailVC = segue.destination as? EventDetailViewController,
                        let indexPath = featuredCollectionView.indexPathsForSelectedItems?.first else { return }
                    detailVC.indexPath = indexPath

          Function editingUserProfile has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              func editingUserProfile() {
                  guard let apolloController = apolloController else { return }
                  if isEditingUser {
                      firstNameTextField.text = apolloController.currentUser?.firstName
                      lastNameTextField.text = apolloController.currentUser?.lastName

            Function perform has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                static func perform(authRequest: OIDAuthorizationRequest, callback: @escaping OIDAuthorizationCallback) {
                    var urlRequest = URLRequest(url: authRequest.externalUserAgentRequestURL())
                    urlRequest.httpMethod = "GET"
                    urlRequest.allHTTPHeaderFields = [
                        "Accept": "application/json",

              Function animateTransition has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
                      guard let fromViewController = transitionContext.viewController(forKey: .from),
                          let toViewController = transitionContext.viewController(forKey: .to) as? FilterViewController, let toView = toViewController.view, let fromView = fromViewController.view else { return }
                      transitionContext.containerView.addSubview(toView)
                      toView.layer.cornerRadius = backgroundViewCornerRad

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

                    func isUserLoggedIn() {
                        guard let apolloController = apolloController else { return }
                        if let user = apolloController.currentUser, let email = apolloController.defaults.string(forKey: UserDefaults.Keys.oktaEmail.rawValue) {
                            profileImageView.image = user.userImage
                            emailLabel.text = email

                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 updateViews has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    func updateViews() {
                        guard
                            let event = event,
                            let urlString = event.image,
                            let url = URL(string: urlString),

                  Function setUpPickerViews has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private func setUpPickerViews() {
                          districtPickerView.delegate = self
                          districtPickerView.dataSource = self
                          
                          firstDatePickerView.datePickerMode = .date

                    Function signIn has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        func signIn(callback: @escaping ((OIDAuthState?, OktaOidcError?) -> Void)) {
                            self.downloadOidcConfiguration() { oidConfig, error in
                                guard let oidConfiguration = oidConfig else {
                                    callback(nil, error)
                                    return

                      Function checkAuthStatus has 30 lines of code (exceeds 25 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

                        Function updateViewsHomeVC has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private func updateViewsHomeVC() {
                                guard
                                    let event = event,
                        //            let urlCreatorString = event.creator.profileImage,
                        //            let urlCreator = URL(string: urlCreatorString),

                          Function signOutWithIdToken has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              func signOutWithIdToken(idToken: String,
                                                      callback: @escaping (Void?, OktaOidcError?) -> Void) {
                                  self.downloadOidcConfiguration() { oidConfig, error in
                                      guard let oidConfig = oidConfig else {
                                          callback(nil, error)

                            Function fetchUserID has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                func fetchUserID(oktaID: String, completion: @escaping (Swift.Result<FetchUserIdQuery.Data.User, Error>) -> Void) {
                                    apollo.fetch(query: FetchUserIdQuery(oktaId: oktaID), cachePolicy: .returnCacheDataElseFetch) { result in
                                        switch result {
                                        case .failure(let error):
                                            print("Error getting user ID: \(error)")

                              Function authenticateWithSessionToken has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  func authenticateWithSessionToken(sessionToken: String,
                                                                    callback: @escaping (OIDAuthState?, OktaOidcError?) -> Void) {
                                      self.downloadOidcConfiguration() { oidConfig, error in
                                          guard let oidConfig = oidConfig else {
                                              callback(nil, error)

                                Function constraint has 28 lines of code (exceeds 25 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 1 hr to fix

                                  Function setupSubviews has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      func setupSubviews() {
                                          editProfileView.backgroundColor = #colorLiteral(red: 0.1721869707, green: 0.1871494651, blue: 0.2290506661, alpha: 1)
                                          editProfileView.layer.cornerRadius = 12
                                          imageBackgroundView.backgroundColor = #colorLiteral(red: 0.7410163879, green: 0.4183317125, blue: 0.4147843719, alpha: 1)
                                          

                                    Function signOut has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        func signOut(viewController: UIViewController, completion: @escaping () -> Void) {
                                            guard let stateManager = stateManager, let oktaOidc = oktaOidc else { return }
                                            let options: OktaSignOutOptions = [.revokeAccessToken, .revokeRefreshToken, .removeTokensFromStorage]
                                            oktaOidc.signOut(with: options, authStateManager: stateManager, from: viewController, progressHandler: { currentOption in
                                                if currentOption.contains(.revokeAccessToken) {

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

                                        func updateViews() {
                                            guard
                                                let event = event,
                                                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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language