whichdigital/active-rest-client

View on GitHub

Showing 42 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

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

              def post(path, data, options={})
                set_defaults(options)
                make_safe_request(path) do
                  @session.post(path) do |req|
                    req.headers = req.headers.merge(options[:headers])
          Severity: Minor
          Found in lib/active_rest_client/connection.rb and 1 other location - About 25 mins to fix
          lib/active_rest_client/connection.rb on lines 47..53

          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 3 locations. Consider refactoring.
          Open

              def self.debug(message)
                if defined?(Rails) && Rails.respond_to?(:logger)
                  Rails.logger.debug(message)
                elsif @logfile
                  File.open(@logfile, "a") do |f|
          Severity: Minor
          Found in lib/active_rest_client/logger.rb and 2 other locations - About 25 mins to fix
          lib/active_rest_client/logger.rb on lines 43..52
          lib/active_rest_client/logger.rb on lines 55..64

          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 put(path, data, options={})
                set_defaults(options)
                make_safe_request(path) do
                  @session.put(path) do |req|
                    req.headers = req.headers.merge(options[:headers])
          Severity: Minor
          Found in lib/active_rest_client/connection.rb and 1 other location - About 25 mins to fix
          lib/active_rest_client/connection.rb on lines 58..64

          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 3 locations. Consider refactoring.
          Open

              def self.warn(message)
                if defined?(Rails) && Rails.respond_to?(:logger)
                  Rails.logger.warn(message)
                elsif @logfile
                  File.open(@logfile, "a") do |f|
          Severity: Minor
          Found in lib/active_rest_client/logger.rb and 2 other locations - About 25 mins to fix
          lib/active_rest_client/logger.rb on lines 19..28
          lib/active_rest_client/logger.rb on lines 55..64

          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 3 locations. Consider refactoring.
          Open

              def self.error(message)
                if defined?(Rails) && Rails.respond_to?(:logger)
                  Rails.logger.error(message)
                elsif @logfile
                  File.open(@logfile, "a") do |f|
          Severity: Minor
          Found in lib/active_rest_client/logger.rb and 2 other locations - About 25 mins to fix
          lib/active_rest_client/logger.rb on lines 19..28
          lib/active_rest_client/logger.rb on lines 43..52

          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

          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

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

              def delete(path, options={})
                set_defaults(options)
                make_safe_request(path) do
                  @session.delete(path) do |req|
                    req.headers = req.headers.merge(options[:headers])
          Severity: Minor
          Found in lib/active_rest_client/connection.rb and 1 other location - About 20 mins to fix
          lib/active_rest_client/connection.rb on lines 37..42

          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 28.

          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 get(path, options={})
                set_defaults(options)
                make_safe_request(path) do
                  @session.get(path) do |req|
                    req.headers = req.headers.merge(options[:headers])
          Severity: Minor
          Found in lib/active_rest_client/connection.rb and 1 other location - About 20 mins to fix
          lib/active_rest_client/connection.rb on lines 69..74

          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 28.

          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