pioneerworks/yelp-business

View on GitHub

Showing 2 of 2 total issues

Method exec_api_call has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def exec_api_call
      raise ::Yelp::MissingAccessTokenError unless access_token
      response = api_fetch
      if response['error']
        raise ::Yelp::AuthenticationError, 'Invalid access token' if response['error']['code'] == 'TOKEN_INVALID'
Severity: Minor
Found in lib/yelp/business.rb - About 1 hr 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

Method fetch has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def fetch
      unless self.data
        raise ::Yelp::MissingAccessTokenError, 'please specify authentication token as class variable' unless access_token
        self.data = OpenStruct.new(exec_api_call)
        raise ::Yelp::BusinessNotFoundError "Can't find business #{business_id}" unless data
Severity: Minor
Found in lib/yelp/business.rb - About 55 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