Lambda-School-Labs/community-calendar-ios

View on GitHub

Showing 254 of 254 total issues

Function signOut has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    func signOut(with options: OktaSignOutOptions,
                 failedOptions: OktaSignOutOptions,
                 progressHandler: @escaping ((OktaSignOutOptions) -> Void),
                 completionHandler: @escaping ((Bool, OktaSignOutOptions) -> Void)) {
        if options.isEmpty {

    Function configureViews has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        func configureViews() {
    
            imageBackgroundView.layer.cornerRadius = UIScreen.main.bounds.width / 4.2
            imageBackgroundView2.layer.cornerRadius = UIScreen.main.bounds.width / 4.2 - 10
            imageBackgroundView2.backgroundColor = UIColor.coral

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

          func weirdLineGradient(color1: UIColor, color2: UIColor, color3: UIColor) {
              let gradientlayer = CAGradientLayer()
              gradientlayer.colors = [color1.cgColor, color2.cgColor, color3.cgColor]
              gradientlayer.locations = [0.0, 0.5, 1.0]
              gradientlayer.frame = bounds
      Community Calendar/Community Calendar/Helpers/UIView+GradientLayer.swift on lines 32..40

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

      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

          func add3ColorGradient(color1: UIColor, color2: UIColor, color3: UIColor) {
              let gradientlayer = CAGradientLayer()
              gradientlayer.colors = [color1.cgColor, color2.cgColor, color3.cgColor]
              gradientlayer.locations = [0.15, 0.5, 0.85]
              gradientlayer.frame = bounds
      Community Calendar/Community Calendar/Helpers/UIView+GradientLayer.swift on lines 42..50

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

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

          func checkCurrentuser() {
              if let user = apolloController?.currentUser, let userEvents = user.userEvents {
                  if self.events.count != userEvents.count {
                      self.events = userEvents
                      self.noEventsLabel.isHidden = 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

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

              apollo.perform(mutation: UpdateProfileImageMutation(profileImage: urlString, id: graphQLID)) { result in
                  switch result {
                  case .failure(let error):
                      print("Error updating users profile picture on back end: \(error)")
                      completion(.failure(error))
      Community Calendar/Community Calendar/Model Controller/ApolloController.swift on lines 93..106

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

      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

              apollo.upload(operation: AddProfilePicMutation(image: image, id: graphQLID), files: [file]) { result in
                  switch result {
                  case .failure(let error):
                      print("Error updating users profile picture: \(error)")
                      completion(.failure(error))
      Community Calendar/Community Calendar/Model Controller/ApolloController.swift on lines 111..124

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

      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

          func getEventDate(date: Date) -> Date {
              var components = DateComponents()
              let calendar = Calendar.current
              let dateComponents = calendar.dateComponents([.year, .month, .day], from: date)
              components.year = dateComponents.year
      Community Calendar/Community Calendar/Views/FeaturedCollectionViewCell.swift on lines 74..83

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

      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

          func getEventTime(date: Date) -> Date {
              var components = DateComponents()
              let calendar = Calendar.current
              let dateComponents = calendar.dateComponents([.hour, .minute, .second], from: date)
              components.hour = dateComponents.hour
      Community Calendar/Community Calendar/Views/FeaturedCollectionViewCell.swift on lines 63..72

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

      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

              } else if let tags = filter.tags {
                  byFilterLabel.text = "By tag"
                  if tags.count != 1 {
                      byFilterLabel.text = "\(byFilterLabel.text ?? "")s"
                  }
      Community Calendar/Community Calendar/View Controllers/SearchResultViewController.swift on lines 97..117

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

      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

              } else if let tags = filter.tags {
                  filterLabel.text = "By tag"
                  if tags.count != 1 {
                      filterLabel.text = "\(filterLabel.text ?? "")s"
                  }
      Community Calendar/Community Calendar/Views/RecentSearchesTableViewCell.swift on lines 41..63

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

      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 13 (exceeds 5 allowed). Consider refactoring.
      Open

          func signOut(with options: OktaSignOutOptions,
                       failedOptions: OktaSignOutOptions,
                       progressHandler: @escaping ((OktaSignOutOptions) -> Void),
                       completionHandler: @escaping ((Bool, OktaSignOutOptions) -> Void)) {
              if options.isEmpty {

      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

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

          func addGradientToButton(color1: UIColor, color2: UIColor) {
              let gradientlayer = CAGradientLayer()
              gradientlayer.colors = [color1.cgColor, color2.cgColor]
              gradientlayer.locations = [0.0, 1.0]
              gradientlayer.frame = bounds
      Community Calendar/Community Calendar/Helpers/UIView+GradientLayer.swift on lines 12..20

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

      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

          func addGradient(color1: UIColor, color2: UIColor) {
              let gradientlayer = CAGradientLayer()
              gradientlayer.colors = [color1.cgColor, color2.cgColor]
              gradientlayer.locations = [0.0, 1.0]
              gradientlayer.frame = bounds
      Community Calendar/Community Calendar/Helpers/UIView+GradientLayer.swift on lines 22..30

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

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

          func updateViewsLogin(user: FetchUserIdQuery.Data.User) {
              guard
                  let urlString = user.profileImage,
                  let url = URL(string: urlString),
                  let data = try? Data(contentsOf: url),

        Function loginUser has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            func loginUser() {
                guard let tabBar = tabBarController as? EventTabBarController else { return }
                
                tabBar.authController.signIn(viewController: self) { _ in
                    if let accessToken = self.authController?.stateManager?.accessToken {

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

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

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

                func createAttrText(with title: String, color: UIColor, fontName: String) -> NSAttributedString {
                    guard let font = UIFont(name: fontName, size: 14) else { return NSAttributedString() }
                    let attrString = NSAttributedString(string: title,
                                                        attributes: [NSAttributedString.Key.foregroundColor: color, NSAttributedString.Key.font: font])
                    return attrString
            Community Calendar/Community Calendar/View Controllers/HomeViewController.swift on lines 246..251
            Community Calendar/Community Calendar/View Controllers/SettingsLauncher.swift on lines 177..182
            Community Calendar/Community Calendar/ViewControllerExtensions/EventVC+CollectionView.swift on lines 354..359

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

            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 4 locations. Consider refactoring.
            Open

                func createAttrText(with title: String, color: UIColor, fontName: String) -> NSAttributedString {
                    guard let font = UIFont(name: fontName, size: 14) else { return NSAttributedString() }
                    let attrString = NSAttributedString(string: title,
                                                        attributes: [NSAttributedString.Key.foregroundColor: color, NSAttributedString.Key.font: font])
                    return attrString
            Community Calendar/Community Calendar/Helpers/String+Extension.swift on lines 26..31
            Community Calendar/Community Calendar/View Controllers/HomeViewController.swift on lines 246..251
            Community Calendar/Community Calendar/View Controllers/SettingsLauncher.swift on lines 177..182

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

            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 4 locations. Consider refactoring.
            Open

                func createAttrText(with title: String, color: UIColor, fontName: String) -> NSAttributedString {
                    guard let font = UIFont(name: fontName, size: 17) else { return NSAttributedString() }
                    let attrString = NSAttributedString(string: title,
                                                        attributes: [NSAttributedString.Key.foregroundColor: color, NSAttributedString.Key.font: font])
                    return attrString
            Community Calendar/Community Calendar/Helpers/String+Extension.swift on lines 26..31
            Community Calendar/Community Calendar/View Controllers/HomeViewController.swift on lines 246..251
            Community Calendar/Community Calendar/ViewControllerExtensions/EventVC+CollectionView.swift on lines 354..359

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

            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