ysiadf/AllIncomeFoods

View on GitHub

Showing 6 of 12 total issues

Function sendFarmersMarketRequestForCoordinate has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    func sendFarmersMarketRequestForCoordinate(coordinate: CLLocationCoordinate2D) {
        if CLLocationCoordinate2DIsValid(coordinate) {
            let urlString = NSString(format: "%@%@y=%f&x=%f&SNAP=1", Constants.kUSDABaseURL, Constants.kUSDAFarmersMarketSearchEndpoint, coordinate.latitude, coordinate.longitude)
            let url = NSURL(string: urlString as String)
            let request = NSURLRequest(URL: url!)
Severity: Minor
Found in iOS/SnapFresh/Controllers/RequestController.swift - About 4 hrs 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 sendFarmersMarketDetailRequest has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    func sendFarmersMarketDetailRequest(markets: NSArray, completionHandler: (farmersMarkets: NSArray?, error: NSError?) -> Void) {
        if (markets.count == 0) {
            let error = NSError(domain: "com.shrtlist.snapfresh", code:100, userInfo: [NSLocalizedFailureReasonErrorKey : "Empty array"])
            
            completionHandler(farmersMarkets: nil, error: error)
Severity: Minor
Found in iOS/SnapFresh/Controllers/RequestController.swift - About 2 hrs 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 sendFarmersMarketRequestForCoordinate has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    func sendFarmersMarketRequestForCoordinate(coordinate: CLLocationCoordinate2D) {
        if CLLocationCoordinate2DIsValid(coordinate) {
            let urlString = NSString(format: "%@%@y=%f&x=%f&SNAP=1", Constants.kUSDABaseURL, Constants.kUSDAFarmersMarketSearchEndpoint, coordinate.latitude, coordinate.longitude)
            let url = NSURL(string: urlString as String)
            let request = NSURLRequest(URL: url!)
Severity: Major
Found in iOS/SnapFresh/Controllers/RequestController.swift - About 2 hrs to fix

    Function sendFarmersMarketDetailRequest has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        func sendFarmersMarketDetailRequest(markets: NSArray, completionHandler: (farmersMarkets: NSArray?, error: NSError?) -> Void) {
            if (markets.count == 0) {
                let error = NSError(domain: "com.shrtlist.snapfresh", code:100, userInfo: [NSLocalizedFailureReasonErrorKey : "Empty array"])
                
                completionHandler(farmersMarkets: nil, error: error)
    Severity: Minor
    Found in iOS/SnapFresh/Controllers/RequestController.swift - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                                  if (index == self.kMaxFarmersMarkets) {
                                      break
                                  }
      Severity: Major
      Found in iOS/SnapFresh/Controllers/RequestController.swift - About 45 mins to fix

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

            func sendSNAPRequestForCoordinate(coordinate: CLLocationCoordinate2D) {
                if CLLocationCoordinate2DIsValid(coordinate) {
                    let coordinateString = NSString(format: "%f,%f", coordinate.latitude, coordinate.longitude)
                    let urlString = NSString(format: "%@%@?address=%@", Constants.kSnapFreshBaseURL, Constants.kSnapFreshEndpoint, coordinateString)
                    let url = NSURL(string: urlString as String)
        Severity: Minor
        Found in iOS/SnapFresh/Controllers/RequestController.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