Showing 92 of 122 total issues
Function tableView
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard let foodLog = foodLog, !foodLogIsEmpty() else { return }
var foodEntry: FoodLogEntry?
- Read upRead up
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 searchForFoodItemWithUPC
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
func searchForFoodItemWithUPC(searchTerm: String, completion: @escaping (Error?) -> Void) {
var urlComponents = URLComponents(url: baseURL, resolvingAgainstBaseURL: true)
let appIdQueryItem = URLQueryItem(name: "app_id", value: appId)
let appKeyQueryItem = URLQueryItem(name: "app_key", value: appKey)
let searchTermQueryItem = URLQueryItem(name: "upc", value: searchTerm)
- Read upRead up
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 updateAllValues
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
func updateAllValues() {
if let weightSampleType = HKSampleType.quantityType(forIdentifier: .bodyMass) {
if !weightIsLoading {
getBodyCompStatsForLast30Days(using: weightSampleType)
- Read upRead up
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 searchForFoodItemWithKeyword
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
func searchForFoodItemWithKeyword(searchTerm: String, completion: @escaping (Error?) -> Void) {
var urlComponents = URLComponents(url: baseURL, resolvingAgainstBaseURL: true)
let appIdQueryItem = URLQueryItem(name: "app_id", value: appId)
let appKeyQueryItem = URLQueryItem(name: "app_key", value: appKey)
let searchTermQueryItem = URLQueryItem(name: "ingr", value: searchTerm)
- Read upRead up
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 searchForNutrients
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
func searchForNutrients(qty: Double, measureURI: String, foodId: String, completion: @escaping (Nutrients?) -> Void) {
let json: [String: Any] = ["ingredients": [["quantity": qty, "measureURI": measureURI, "foodId": foodId]]]
let jsonData = try? JSONSerialization.data(withJSONObject: json)
var urlComponents = URLComponents(url: nutritionURL, resolvingAgainstBaseURL: true)
- Read upRead up
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 getBodyCompStatsForLast30Days
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
private func getBodyCompStatsForLast30Days(using sampleType: HKSampleType) {
let endDate = Date()
guard let startDate = Calendar.current.date(byAdding: .day, value: -29, to: endDate) else {
print("error getting start date for statistics collection")
Function getFoodLogEntriesForDate
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
func getFoodLogEntriesForDate(date: String, completion: @escaping (Result<FoodLog?, NetworkError>) -> Void) {
guard let token = getUserToken() else {
print("No token found for user")
DispatchQueue.main.async {
completion(.failure(.noAuth))
Function editFoodLogEntry
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func editFoodLogEntry(entry: FoodLogEntry, completion: @escaping (Result<Bool, NetworkError>) -> Void) {
guard let token = getUserToken() else {
print("No token found for user")
DispatchQueue.main.async {
completion(.failure(.noAuth))
Function setUpCameraLiveView
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
private func setUpCameraLiveView() {
// Ensure we have appropriate permissions before a capture session is established
guard permissionGranted != false else {
return
}
Function tableView
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
guard let foodLog = foodLog else { return nil }
let label = MealTypeHeaderLabel()
var macrosByMealModel: DailyMacros?
- Read upRead up
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 setUpCameraLiveView
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private func setUpCameraLiveView() {
// Ensure we have appropriate permissions before a capture session is established
guard permissionGranted != false else {
return
}
- Read upRead up
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 11 (exceeds 5 allowed). Consider refactoring. Open
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "ToActivityLevel" {
guard let profileController = profileController,
let apVC = segue.destination as? ActivityLevelViewController else { return }
- Read upRead up
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 editFoodLogEntry
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
func editFoodLogEntry(entry: FoodLogEntry, completion: @escaping (Result<Bool, NetworkError>) -> Void) {
guard let token = getUserToken() else {
print("No token found for user")
DispatchQueue.main.async {
completion(.failure(.noAuth))
- Read upRead up
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 updateFoodLog
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
@objc private func updateFoodLog() {
guard let date = selectedDateAsString else { return }
FoodLogController.shared.getFoodLogEntriesForDate(date: date) { (result) in
switch result {
- Read upRead up
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 searchForNutrients
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
func searchForNutrients(qty: Double, measureURI: String, foodId: String, completion: @escaping (Nutrients?) -> Void) {
let json: [String: Any] = ["ingredients": [["quantity": qty, "measureURI": measureURI, "foodId": foodId]]]
let jsonData = try? JSONSerialization.data(withJSONObject: json)
var urlComponents = URLComponents(url: nutritionURL, resolvingAgainstBaseURL: true)
Function tableView
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
guard let foodLog = foodLog else { return 0 }
switch section {
case 0:
- Read upRead up
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 getFoodImage
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
func getFoodImage(urlString: String, completion: @escaping (Data?) -> Void) {
guard let url = URL(string: urlString) else {
print("Error getting image url from string")
DispatchQueue.main.async {
completion(nil)
- Read upRead up
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 createFoodLogEntry
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
func createFoodLogEntry(entry: FoodLogEntry, completion: @escaping (Result<Bool, NetworkError>) -> Void) {
guard let token = getUserToken() else {
print("No token found for user")
DispatchQueue.main.async {
completion(.failure(.noAuth))
- Read upRead up
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 checkPermissions
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private func checkPermissions() {
let mediaType = AVMediaType.video
let status = AVCaptureDevice.authorizationStatus(for: mediaType)
switch status {
- Read upRead up
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 tableView
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "foodLogCell", for: indexPath)
guard let foodLog = foodLog else { return cell }
- Read upRead up
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"