motionauth/oauth2

View on GitHub

Showing 10 of 10 total issues

Method run_request has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run_request(method, url, body, headers, parse)
      unless METHODS.include?(method)
        fail ArgumentError, "unknown http method: #{method}"
      end

Severity: Minor
Found in lib/oauth2-cocoa/connection.rb - About 1 hr to fix

    Method run_request has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def run_request(method, url, body, headers, parse)
          unless METHODS.include?(method)
            fail ArgumentError, "unknown http method: #{method}"
          end
    
    
    Severity: Minor
    Found in lib/oauth2-cocoa/connection.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 initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(url = nil, options = {})
          if url.is_a?(Hash)
            options = url.with_indifferent_access
            url = options[:url]
          else
    Severity: Minor
    Found in lib/oauth2-cocoa/connection.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 request has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def request(verb, url, opts = {}) # rubocop:disable CyclomaticComplexity, MethodLength
          # connection.response :logger, ::Logger.new($stdout) if ENV["OAUTH_DEBUG"] == "true"
    
          url = connection.build_url(url, opts[:params]).to_s
          response = connection.run_request(verb, url, opts[:body], opts[:headers], opts[:parse])
    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 signature has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def signature(timestamp, nonce, verb, url)
          nsurl = NSURL.URLWithString(url.to_s)
          fail(ArgumentError, "could not parse \"#{url}\" into NSURL") unless nsurl.host
    
          path = nsurl.path
    Severity: Minor
    Found in lib/oauth2-cocoa/mac_token.rb - About 45 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 run_request has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def run_request(method, url, body, headers, parse)
    Severity: Minor
    Found in lib/oauth2-cocoa/connection.rb - About 35 mins to fix

      Method token= has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def token=(opts) # rubocop:disable MethodLength
            case options[:mode]
            when :header
              opts[:headers] ||= {}
              opts[:headers].merge!(headers)
      Severity: Minor
      Found in lib/oauth2/access_token.rb - About 35 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_json has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.parse_json(str_data, &block)
            return nil unless str_data
            data = str_data.respond_to?("dataUsingEncoding:") ? str_data.dataUsingEncoding(NSUTF8StringEncoding) : str_data
            opts = NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves | NSJSONReadingAllowFragments
            error = Pointer.new(:id)
      Severity: Minor
      Found in lib/oauth2-cocoa/utils.rb - About 35 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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(client, token, opts = {})
            @client = client
            @token = token.to_s
            [:refresh_token, :expires_in, :expires_at].each do |arg|
              instance_variable_set("@#{arg}", opts.delete(arg) || opts.delete(arg.to_s))
      Severity: Minor
      Found in lib/oauth2/access_token.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

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

          def get_token(params, access_token_opts = {}, access_token_class = AccessToken)
            opts = { raise_errors: options[:raise_errors], parse: params.delete(:parse) }
            if options[:token_method] == :post
              headers = params.delete(:headers)
              opts[:body] = params
      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

      Severity
      Category
      Status
      Source
      Language