Dariusch/plenty_client

View on GitHub

Showing 33 of 33 total issues

File constants.rb has 354 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module PlentyClient
  class Constants
    AVAILABLE_LANGS = %w(de en bg fr it es tr nl pl pt nn ro da se cz ru sk cn vn).freeze

    PAYMENT_STATUS_IDS = [
Severity: Minor
Found in lib/plenty_client/constants.rb - About 4 hrs to fix

    Method build_endpoint has 82 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def build_endpoint(api_endpoint_template, arguments = {})
            # Duplicate constant to temporary endpoint string
            api_endpoint_result = api_endpoint_template.dup
            # Endpoint parameters hash that links symbols to regex
            endpoint_parameters = {
    Severity: Major
    Found in lib/plenty_client/endpoint.rb - About 3 hrs to fix

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

            def parse_body(response)
              return nil if response.body.strip == ""
              content_type = response.env.response_headers['Content-Type']
              case content_type
              when %r{(?:application|text)/json}
      Severity: Minor
      Found in lib/plenty_client/request.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 find_by_language has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

                  def find_by_language(item_id, variation_id, property_id, lang, headers = {}, &block)
      Severity: Minor
      Found in lib/plenty_client/item/variation/property/text.rb - About 45 mins to fix

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

                  def find(item_id, variation_id, supplier_id, headers = {}, &block)
        Severity: Minor
        Found in lib/plenty_client/item/variation/supplier.rb - About 35 mins to fix

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

                    def find(item_id, variation_id, price_id, headers = {}, &block)
          Severity: Minor
          Found in lib/plenty_client/item/variation/sales_price.rb - About 35 mins to fix

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

                      def find(item_id, image_id, lang, headers = {}, &block)
            Severity: Minor
            Found in lib/plenty_client/item/image/name.rb - About 35 mins to fix

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

                        def find(item_id, variation_id, plenty_id, headers = {}, &block)
              Severity: Minor
              Found in lib/plenty_client/item/variation/default_category.rb - About 35 mins to fix

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

                          def find(item_id, variation_id, property_id, headers = {}, &block)
                Severity: Minor
                Found in lib/plenty_client/item/variation/property.rb - About 35 mins to fix

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

                            def find(item_id, variation_id, category_id, headers = {}, &block)
                  Severity: Minor
                  Found in lib/plenty_client/item/variation/category.rb - About 35 mins to fix

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

                              def find(item_id, variation_id, sku_id, headers = {}, &block)
                    Severity: Minor
                    Found in lib/plenty_client/item/variation/sku.rb - About 35 mins to fix

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

                                  def find(item_id, variation_id, property_id, headers = {}, &block)
                      Severity: Minor
                      Found in lib/plenty_client/item/variation/property/text.rb - About 35 mins to fix

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

                                  def find(item_id, variation_id, warehouse_id, headers = {}, &block)
                        Severity: Minor
                        Found in lib/plenty_client/item/variation/warehouse.rb - About 35 mins to fix

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

                                    def find(item_id, variation_id, bundle_id, headers = {}, &block)
                          Severity: Minor
                          Found in lib/plenty_client/item/variation/bundle.rb - About 35 mins to fix

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

                                        def update(item_id, variation_id, property_id, lang, headers = {})
                            Severity: Minor
                            Found in lib/plenty_client/item/variation/property/text.rb - About 35 mins to fix

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

                                    def request(http_method, path, params = {})
                                      raise ArgumentError, "http_method or path is missing" if http_method.nil? || path.nil?
                                      unless %w[post put patch delete get].include?(http_method.to_s)
                                        raise ArgumentError, "unsupported http_method: #{http_method}"
                                      end
                              Severity: Minor
                              Found in lib/plenty_client/request.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 get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                    def get(path, params = {})
                                      page = 1
                                      rval_array = []
                                      if block_given?
                                        loop do
                              Severity: Minor
                              Found in lib/plenty_client/request.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 extract_message has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                    def extract_message(response)
                                      if response.key?('validation_errors') && response['validation_errors'] && !response['validation_errors']&.empty?
                                        errors = response['validation_errors']
                                        rval = errors.values         if response['validation_errors'].is_a?(Hash)
                                        rval = errors.flatten.values if response['validation_errors'].is_a?(Array)
                              Severity: Minor
                              Found in lib/plenty_client/request.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

                              Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency faraday should appear before json.
                              Open

                                spec.add_runtime_dependency 'faraday', '>= 0.9'
                              Severity: Minor
                              Found in plenty_client.gemspec by rubocop

                              Dependencies in the gemspec should be alphabetically sorted.

                              Example:

                              # bad
                              spec.add_dependency 'rubocop'
                              spec.add_dependency 'rspec'
                              
                              # good
                              spec.add_dependency 'rspec'
                              spec.add_dependency 'rubocop'
                              
                              # good
                              spec.add_dependency 'rubocop'
                              
                              spec.add_dependency 'rspec'
                              
                              # bad
                              spec.add_development_dependency 'rubocop'
                              spec.add_development_dependency 'rspec'
                              
                              # good
                              spec.add_development_dependency 'rspec'
                              spec.add_development_dependency 'rubocop'
                              
                              # good
                              spec.add_development_dependency 'rubocop'
                              
                              spec.add_development_dependency 'rspec'
                              
                              # bad
                              spec.add_runtime_dependency 'rubocop'
                              spec.add_runtime_dependency 'rspec'
                              
                              # good
                              spec.add_runtime_dependency 'rspec'
                              spec.add_runtime_dependency 'rubocop'
                              
                              # good
                              spec.add_runtime_dependency 'rubocop'
                              
                              spec.add_runtime_dependency 'rspec'
                              
                              # good only if TreatCommentsAsGroupSeparators is true
                              # For code quality
                              spec.add_dependency 'rubocop'
                              # For tests
                              spec.add_dependency 'rspec'

                              Inconsistent indentation detected.
                              Open

                                      faraday.request :retry, max: PlentyClient::Config.attempt_count
                              Severity: Minor
                              Found in lib/plenty_client/request.rb by rubocop

                              This cops checks for inconsistent indentation.

                              Example:

                              class A
                                def test
                                  puts 'hello'
                                   puts 'world'
                                end
                              end
                              Severity
                              Category
                              Status
                              Source
                              Language