coding-chimp/onesignal

View on GitHub
lib/onesignal/api_client.rb

Summary

Maintainability
C
1 day
Test Coverage

Method build_request has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def build_request(http_method, path, opts = {})
      url = build_request_url(path, opts)
      http_method = http_method.to_sym.downcase

      opts[:header_params]['OS-Usage-Data'] = 'kind=sdk, sdk-name=onesignal-ruby, version=1.2.2'
Severity: Minor
Found in lib/onesignal/api_client.rb - About 1 hr to fix

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

        def convert_to_type(data, return_type)
          return nil if data.nil?
          case return_type
          when 'String'
            data.to_s
    Severity: Minor
    Found in lib/onesignal/api_client.rb - About 1 hr to fix

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

          def download_file(request)
            tempfile = nil
            encoding = nil
            request.on_headers do |response|
              content_disposition = response.headers['Content-Disposition']
      Severity: Minor
      Found in lib/onesignal/api_client.rb - About 1 hr to fix

        Method build_request_body has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def build_request_body(header_params, form_params, body)
              # http form
              if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
                  header_params['Content-Type'] == 'multipart/form-data'
                data = {}
        Severity: Minor
        Found in lib/onesignal/api_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 deserialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def deserialize(response, return_type)
              body = response.body
        
              # handle file downloading - return the File instance processed in request callbacks
              # note that response body is empty when the file is written in chunks in request on_body callback
        Severity: Minor
        Found in lib/onesignal/api_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 download_file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def download_file(request)
              tempfile = nil
              encoding = nil
              request.on_headers do |response|
                content_disposition = response.headers['Content-Disposition']
        Severity: Minor
        Found in lib/onesignal/api_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 build_request has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def build_request(http_method, path, opts = {})
              url = build_request_url(path, opts)
              http_method = http_method.to_sym.downcase
        
              opts[:header_params]['OS-Usage-Data'] = 'kind=sdk, sdk-name=onesignal-ruby, version=1.2.2'
        Severity: Minor
        Found in lib/onesignal/api_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 call_api has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def call_api(http_method, path, opts = {})
              request = build_request(http_method, path, opts)
              response = request.run
        
              if @config.debugging
        Severity: Minor
        Found in lib/onesignal/api_client.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 convert_to_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def convert_to_type(data, return_type)
              return nil if data.nil?
              case return_type
              when 'String'
                data.to_s
        Severity: Minor
        Found in lib/onesignal/api_client.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 update_params_for_auth! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_params_for_auth!(header_params, query_params, auth_names)
              Array(auth_names).each do |auth_name|
                auth_setting = @config.auth_settings[auth_name]
                next unless auth_setting
                case auth_setting[:in]
        Severity: Minor
        Found in lib/onesignal/api_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