ePages-de/beyond_api-ruby_client

View on GitHub

Showing 13 of 13 total issues

Class Orders has 33 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Orders < Base
    include BeyondApi::Utils

    #
    # A +GET+ request is used to retrieve the active payment processes. There is only one active payment process. See {Show payment process details}[http://docs.beyondshop.cloud/#resources-payment-process-get] for more information about the request and response structure.
Severity: Minor
Found in lib/beyond_api/resources/orders.rb - About 4 hrs to fix

    Class Session has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Session
        class InvalidUriProtocolError < StandardError; end
    
        attr_reader :api_url
        attr_accessor :access_token, :refresh_token
    Severity: Minor
    Found in lib/beyond_api/session.rb - About 2 hrs to fix

      Class Carts has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Carts < Base
          include BeyondApi::Utils
      
          #
          # A +POST+ request is used to add a line item to the cart. Currently only product line items are supported.
      Severity: Minor
      Found in lib/beyond_api/resources/carts.rb - About 2 hrs to fix

        Method upload_by_form has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.upload_by_form(session, path, files, params)
              response = BeyondApi::Connection.multipart.post do |request|
                request.url(session.api_url + path)
                request.headers["Authorization"] = "Bearer #{session.access_token}" unless session.access_token.nil?
                request.options[:params_encoder] = Faraday::FlatParamsEncoder
        Severity: Minor
        Found in lib/beyond_api/request.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 sanitize_response has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def sanitize_response(hash)
              {}.tap do |h|
                hash.each do |key, value|
                  next if key == "_links" && BeyondApi.configuration.remove_response_links
        
        
        Severity: Minor
        Found in lib/beyond_api/utils.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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        module BeyondApi
          class OrderSettings < Base
            include BeyondApi::Utils
        
            #
        Severity: Minor
        Found in lib/beyond_api/resources/order_settings.rb and 1 other location - About 40 mins to fix
        lib/beyond_api/resources/checkout_settings.rb on lines 5..60

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 37.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        module BeyondApi
          class CheckoutSettings < Base
            include BeyondApi::Utils
        
            #
        Severity: Minor
        Found in lib/beyond_api/resources/checkout_settings.rb and 1 other location - About 40 mins to fix
        lib/beyond_api/resources/order_settings.rb on lines 5..94

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 37.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Method upload has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def self.upload(session, path, file_binary, content_type, params)
        Severity: Minor
        Found in lib/beyond_api/request.rb - About 35 mins to fix

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

              def handle_response(response, status, respond_with_true: false)
                if status.between?(200, 299)
                  return true if respond_with_true
          
                  response = sanitize_response(response)
          Severity: Minor
          Found in lib/beyond_api/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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              def sort(payment_method_ids)
                body = payment_method_ids.map { |id| "#{@session.api_url}/payment-methods/#{id}" }
                response, status = BeyondApi::Request.put(@session, "/payment-methods", body)
          
                handle_response(response, status, respond_with_true: true)
          Severity: Minor
          Found in lib/beyond_api/resources/payment_methods.rb and 1 other location - About 25 mins to fix
          lib/beyond_api/resources/pickup_options.rb on lines 152..156

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 31.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              def sort(pickup_option_ids)
                body = pickup_option_ids.map { |id| "#{@session.api_url}/pickup-options/#{id}" }
                response, status = BeyondApi::Request.put(@session, "/pickup-options", body)
          
                handle_response(response, status, respond_with_true: true)
          Severity: Minor
          Found in lib/beyond_api/resources/pickup_options.rb and 1 other location - About 25 mins to fix
          lib/beyond_api/resources/payment_methods.rb on lines 126..130

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 31.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              def change_username(user_id, new_username, current_password)
                path = "/users/#{user_id}/change-username"
          
                response, status = BeyondApi::Request.post(@session,
                                                           path,
          Severity: Minor
          Found in lib/beyond_api/resources/users.rb and 1 other location - About 15 mins to fix
          lib/beyond_api/resources/users.rb on lines 85..93

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 25.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              def change_password(user_id, current_password, new_password)
                path = "/users/#{user_id}/change-password"
          
                response, status = BeyondApi::Request.post(@session,
                                                           path,
          Severity: Minor
          Found in lib/beyond_api/resources/users.rb and 1 other location - About 15 mins to fix
          lib/beyond_api/resources/users.rb on lines 117..125

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 25.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language