kylegrantlucas/takeout

View on GitHub

Showing 3 of 3 total issues

Method perform_curl_request has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def perform_curl_request(request_type, request_url, options=nil, headers=nil)
      body = JSON_REQUEST_BODY.include?(request_type.to_sym) ? Oj.dump(options.deep_stringify_keys!) : options
      curl = Curl.send(request_type, request_url.to_s, body) do |curl|
        curl.verbose = true if @debug
        curl.headers = headers if headers
Severity: Minor
Found in lib/takeout/client.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 generate_request_url has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def generate_request_url(endpoint_name, request_type=nil, options=nil)
      # Generate custom templated path string and update options hash
      custom_schema, options = substitute_template_values(endpoint_name, request_type, options) unless schemas.empty?

      # Generate URL based on if the custom schema exists, and if there is a given object_id
Severity: Minor
Found in lib/takeout/client.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

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

    def method_missing(method_sym, *attributes, &block)
      request_type = method_sym.to_s.scan(/^(?:get|post|put|delete|patch|update)/).first
      request_name = method_sym.to_s.scan(/(?<=_{1}).*/).first
      if (request_type && request_name)
        self.define_singleton_method(method_sym) do |options={}, &block|
Severity: Minor
Found in lib/takeout/client.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