Lambda-School-Labs/community-calendar-ios

View on GitHub

Showing 254 of 254 total issues

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)
                

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              @objc func stopEditingTextInput() {
                  if let textField = self.textFieldBeingEdited {
                      
                      textField.resignFirstResponder()
                      
          Community Calendar/Community Calendar/Helpers/ShiftableViewController.swift on lines 29..47

          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 77.

          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

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              @objc func stopEditingTextInput() {
                  if let textField = self.textFieldBeingEdited {
                      
                      textField.resignFirstResponder()
                      
          Community Calendar/Community Calendar/Helpers/ShiftableView.swift on lines 43..61

          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 77.

          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

          Further Reading

          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

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

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

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

              func editViewConstraints() {
                  
                  let window = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
                  
                  if let window = window {

            Function loadImageFT has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

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

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

                Function setFilterLabel has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private func setFilterLabel() {
                        guard let filter = filter, let filterLabel = filterLabel else { return }
                        filterLabel.text = "All Events"
                        if let index = filter.index {
                            filterLabel.text = "By term \"\(index)\""

                  Function loadImageCV has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

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

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                            if let keyboardRect = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect,
                                keyboardRect.height != 0 {
                                keyboardSize = keyboardRect
                            } else if let keyboardRect = notification.userInfo?["UIKeyboardBoundsUserInfoKey"] as? CGRect {
                                keyboardSize = keyboardRect
                    Community Calendar/Community Calendar/Helpers/ShiftableView.swift on lines 95..100

                    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 74.

                    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

                    Further Reading

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                            if let keyboardRect = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect,
                                keyboardRect.height != 0 {
                                keyboardSize = keyboardRect
                            } else if let keyboardRect = notification.userInfo?["UIKeyboardBoundsUserInfoKey"] as? CGRect {
                                keyboardSize = keyboardRect
                    Community Calendar/Community Calendar/Helpers/ShiftableViewController.swift on lines 81..86

                    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 74.

                    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

                    Further Reading

                    Function buttonTapped has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        func buttonTapped(cell: TagCollectionViewCell) {
                            guard let tag = cell.filterTag else { return }
                            if cell.isActive {
                                guard let indexPath = selectedTagsCollectionView.indexPath(for: cell) else { return }
                                for tagFilter in selectedFilters {

                      Function saveTapped has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          func saveTapped() {
                              guard
                                  let firstName = firstNameTextField.text,
                                  let lastName = lastNameTextField.text,
                                  let apolloController = apolloController

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                                if tableView == eventTableView {
                                    guard let cell = eventTableView.dequeueReusableCell(withIdentifier: "EventTableViewCell", for: indexPath) as? EventTableViewCell
                                        else { return UITableViewCell() }
                                    
                                    let event = filteredEvents?[indexPath.row]
                        Community Calendar/Community Calendar/ViewControllerExtensions/HomeVC+Ext.swift on lines 27..43

                        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 72.

                        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

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                                if collectionView == eventCollectionView {
                                    guard let cell = eventCollectionView.dequeueReusableCell(withReuseIdentifier: "EventCollectionViewCell", for: indexPath) as? EventCollectionViewCell else { return UICollectionViewCell() }
                                    
                                    let event = filteredEvents?[indexPath.item]
                                    loadImageCV(forCell: cell, forItemAt: indexPath)
                        Community Calendar/Community Calendar/ViewControllerExtensions/HomeVC+Ext.swift on lines 58..67

                        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 72.

                        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

                        Further Reading

                        Severity
                        Category
                        Status
                        Source
                        Language