Lambda-School-Labs/nutrition-tracker-ios-pt7

View on GitHub

Showing 113 of 122 total issues

Avoid too many return statements within this function.
Open

        return 1
Severity: Major
Found in Nutrivurv/Nutrivurv/UserDefaults.swift - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                    return
    Severity: Major
    Found in Nutrivurv/Nutrivurv/FoodSearchController.swift - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                      return
      Severity: Major
      Found in Nutrivurv/Nutrivurv/UserController.swift - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                        return
        Severity: Major
        Found in Nutrivurv/Nutrivurv/FoodSearchController.swift - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                          return
          Severity: Major
          Found in Nutrivurv/Nutrivurv/UserController.swift - About 30 mins to fix

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

                @IBAction func signupButtonTapped(_ sender: Any) {
                    guard let user = profileController?.userProfile else {
                        print("User profile missing from registration process")
                        return
                    }
            Severity: Minor
            Found in Nutrivurv/Nutrivurv/ActivityLevelViewController.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 getMostRecentSamples has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                func getMostRecentSamples(for sampleType: HKSampleType, withStart date: Date = Date.distantPast, limit: Int = 1, sortDescriptor: NSSortDescriptor = NSSortDescriptor(key: HKSampleSortIdentifierStartDate, ascending: true), completion: @escaping ([HKQuantitySample]?, Error?) -> Swift.Void) {
                    
                    let mostRecentPredicate = HKQuery.predicateForSamples(withStart: date, end: Date(), options: .strictEndDate)
                    
                    let sampleQuery = HKSampleQuery(sampleType: sampleType,
            Severity: Minor
            Found in Nutrivurv/Nutrivurv/HealthKitController.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 viewWillAppear has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                override func viewWillAppear(_ animated: Bool) {
                    super.viewWillAppear(animated)
                    self.tabBarController?.tabBar.isHidden = false
                    foodSearchBar.searchTextField.text = foodSearchKeyword
                    tableView.reloadData()
            Severity: Minor
            Found in Nutrivurv/Nutrivurv/FoodSearchTableViewController.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 prepare has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
                    if segue.identifier == "FoodDetail" {
                        guard let indexPath = self.tableView.indexPathForSelectedRow,
                            let fdVC = segue.destination as? SwiftUIDetailViewController else { return }
                        
            Severity: Minor
            Found in Nutrivurv/Nutrivurv/FoodSearchTableViewController.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 reload has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                func reload() {
                    removeAll()
                    guard let tabBarItems = self.items else {
                        TabBarController.printError("empty items")
                        return
            Severity: Minor
            Found in Nutrivurv/Nutrivurv/TabBar.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 viewWillAppear has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                override func viewWillAppear(_ animated: Bool) {
                    super.viewWillAppear(animated)
                    guard let profileController = profileController else { return }
                    // If user has already completed information and is returning to a previous screen, this will set the info in view
                    if let birthDate = profileController.userProfile?.birthDate {
            Severity: Minor
            Found in Nutrivurv/Nutrivurv/GettingPersonalViewController.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 reselect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                internal final func reselect(animated: Bool, completion: (() -> ())?) {
                    if selected == false {
                        select(animated: animated, completion: completion)
                    } else {
                        if highlightEnabled && highlighted {
            Severity: Minor
            Found in Nutrivurv/Nutrivurv/TabBarItemContentView.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 viewDidLoad has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                override func viewDidLoad() {
                    super.viewDidLoad()
                    
                    // Removes the "back" text from navigation bar
                    self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
            Severity: Minor
            Found in Nutrivurv/Nutrivurv/DashboardViewController.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

            Severity
            Category
            Status
            Source
            Language