whichdigital/active-rest-client

View on GitHub

Showing 33 of 42 total issues

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

      def _filter_request(type, name, param)
        _handle_super_class_filters(type, name, param)
        filters = (type == :before ? @before_filters : @after_filters)
        filters ||= []
        filters.each do |filter|
Severity: Minor
Found in lib/active_rest_client/request_filtering.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 handle_hal_links_embedded has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def handle_hal_links_embedded(object, attributes)
      attributes["_links"] = attributes[:_links] if attributes[:_links]
      attributes["_embedded"] = attributes[:_embedded] if attributes[:_embedded]
      if attributes["_links"]
        attributes["_links"].each do |key, value|
Severity: Minor
Found in lib/active_rest_client/request.rb - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

              elsif type == :maximum && !value.nil?
                @errors[validation[:field_name]] << "must be no more than #{options}" unless value.to_f <= options.to_f
    Severity: Major
    Found in lib/active_rest_client/validation.rb - About 45 mins to fix

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

            def password(value = nil)
              if value.nil?
                if @password.nil?
                  @@password
                else
      Severity: Minor
      Found in lib/active_rest_client/configuration.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 cache_store= has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def cache_store=(value)
              @@cache_store = nil if value.nil? and return
              raise InvalidCacheStoreException.new("Cache store does not implement #read") unless value.respond_to?(:read)
              raise InvalidCacheStoreException.new("Cache store does not implement #write") unless value.respond_to?(:write)
              raise InvalidCacheStoreException.new("Cache store does not implement #fetch") unless value.respond_to?(:fetch)
      Severity: Minor
      Found in lib/active_rest_client/caching.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 username has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def username(value = nil)
              if value.nil?
                if @username.nil?
                  @@username
                else
      Severity: Minor
      Found in lib/active_rest_client/configuration.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

      Avoid deeply nested control flow statements.
      Open

                  @errors[validation[:field_name]] << "must be at least #{options}" unless value.to_f >= options.to_f
      Severity: Major
      Found in lib/active_rest_client/validation.rb - About 45 mins to fix

        Consider simplifying this complex logical expression.
        Open

              if @forced_url && @forced_url.present?
                @url = @forced_url
              else
                @url = @method[:url].dup
                matches = @url.scan(/(:[a-z_-]+)/)
        Severity: Major
        Found in lib/active_rest_client/request.rb - About 40 mins to fix

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

                def translate(result, options = {})
                  incoming_content_type = result.headers['Content-Type']
                  if result_is_json_or_unspecified?(result)
                    result.headers["content-type"] = "application/hal+json"
                  end
          Severity: Minor
          Found in lib/active_rest_client/proxy_base.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 parallelise has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def parallelise(method=nil)
                collected_responses = []
                threads = []
                @items.each do |item|
                  threads << Thread.new do
          Severity: Minor
          Found in lib/active_rest_client/result_iterator.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 prepare_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def prepare_url
                if @forced_url && @forced_url.present?
                  @url = @forced_url
                else
                  @url = @method[:url].dup
          Severity: Minor
          Found in lib/active_rest_client/request.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 prepare_request_body has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def prepare_request_body(params = nil)
                if request_body_type == :form_encoded
                  @body ||= (params || @post_params || {}).to_query
                  headers["Content-Type"] ||= "application/x-www-form-urlencoded"
                elsif request_body_type == :json
          Severity: Minor
          Found in lib/active_rest_client/request.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 prepare_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def prepare_params
                params = @params || @object._attributes rescue {}
                if params.is_a?(String) || params.is_a?(Fixnum)
                  params = {id:params}
                end
          Severity: Minor
          Found in lib/active_rest_client/request.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