oauth-xx/oauth2

View on GitHub
lib/oauth2/client.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method get_token has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def get_token(params, access_token_opts = {}, extract_access_token = nil, &block)
      warn('OAuth2::Client#get_token argument `extract_access_token` will be removed in oauth2 v3. Refactor to use `access_token_class` on #initialize.') if extract_access_token
      extract_access_token ||= options[:extract_access_token]
      params = params.map do |key, value|
        if RESERVED_PARAM_KEYS.include?(key)
Severity: Minor
Found in lib/oauth2/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 request has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def request(verb, url, opts = {}, &block)
      response = execute_request(verb, url, opts, &block)

      case response.status
      when 301, 302, 303, 307
Severity: Minor
Found in lib/oauth2/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 get_token has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def get_token(params, access_token_opts = {}, extract_access_token = nil, &block)
      warn('OAuth2::Client#get_token argument `extract_access_token` will be removed in oauth2 v3. Refactor to use `access_token_class` on #initialize.') if extract_access_token
      extract_access_token ||= options[:extract_access_token]
      params = params.map do |key, value|
        if RESERVED_PARAM_KEYS.include?(key)
Severity: Minor
Found in lib/oauth2/client.rb - About 1 hr to fix

Method request has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def request(verb, url, opts = {}, &block)
      response = execute_request(verb, url, opts, &block)

      case response.status
      when 301, 302, 303, 307
Severity: Minor
Found in lib/oauth2/client.rb - About 1 hr to fix

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

    def execute_request(verb, url, opts = {})
      url = connection.build_url(url).to_s

      begin
        response = connection.run_request(verb, url, opts[:body], opts[:headers]) do |req|
Severity: Minor
Found in lib/oauth2/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 parse_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_response(response, access_token_opts)
      access_token_class = options[:access_token_class]
      data = response.parsed

      unless data.is_a?(Hash) && !data.empty?
Severity: Minor
Found in lib/oauth2/client.rb - 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

There are no issues that match your filters.

Category
Status