kaiwren/wrest

View on GitHub

Showing 21 of 21 total issues

Class HashWithIndifferentAccess has 43 methods (exceeds 20 allowed). Consider refactoring.
Open

  class HashWithIndifferentAccess < Hash
    # Returns +true+ so that <tt>Array#extract_options!</tt> finds members of
    # this class.
    def extractable_options?
      true
Severity: Minor
Found in lib/wrest/hash_with_indifferent_access.rb - About 5 hrs to fix

    Class Response has 34 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Response
          attr_reader :http_response
          attr_accessor :deserialised_body
    
          include HttpCodes
    Severity: Minor
    Found in lib/wrest/native/response.rb - About 4 hrs to fix

      Class Uri has 34 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Uri
          attr_reader :uri, :username, :password, :uri_string, :uri_path, :query, :default_headers
      
          # Valid tuples for the options are:
          #   :asynchronous_backend => Can currently be set to either Wrest::AsyncRequest::EventMachineBackend.new
      Severity: Minor
      Found in lib/wrest/uri.rb - About 4 hrs to fix

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

            def initialize(constructor = nil)
              if constructor.respond_to?(:to_hash)
                super()
                update(constructor)
        
        
        Severity: Minor
        Found in lib/wrest/hash_with_indifferent_access.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 build_request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def build_request(request_klass, uri, parameters, headers)
                if uri.query.empty?
                  request_klass.new(parameters.empty? ? uri.uri_path.to_s : "#{uri.uri_path}?#{Utils.hash_to_param(parameters)}", headers)
                else
                  request_klass.new(
        Severity: Minor
        Found in lib/wrest/native/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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def initialize(wrest_uri, http_request_klass, parameters = {}, body = nil, headers = {}, options = {}) # rubocop:disable Metrics/ParameterLists
        Severity: Minor
        Found in lib/wrest/native/request.rb - About 45 mins to fix

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

                      def to_hash(hash = {})
                        node_hash = {}
          
                        # Insert node hash into parent hash correctly.
                        case hash[name]
          Severity: Minor
          Found in lib/wrest/components/translators/xml/conversions.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                def initialize(wrest_uri, body = '', headers = {}, parameters = {}, options = {})
          Severity: Minor
          Found in lib/wrest/native/post.rb - About 35 mins to fix

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

                  def initialize(wrest_uri, body = '', headers = {}, parameters = {}, options = {})
            Severity: Minor
            Found in lib/wrest/native/patch.rb - About 35 mins to fix

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

                    def initialize(wrest_uri, body = '', headers = {}, parameters = {}, options = {})
              Severity: Minor
              Found in lib/wrest/native/put.rb - About 35 mins to fix

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

                module Wrest
                  module Native
                    class PutMultipart < Request
                      def initialize(wrest_uri, parameters = {}, headers = {}, options = {})
                        super(
                Severity: Minor
                Found in lib/wrest/native/put_multipart.rb and 1 other location - About 35 mins to fix
                lib/wrest/native/post_multipart.rb on lines 13..32

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

                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 Wrest
                  module Native
                    class PostMultipart < Request
                      def initialize(wrest_uri, parameters = {}, headers = {}, options = {})
                        super(
                Severity: Minor
                Found in lib/wrest/native/post_multipart.rb and 1 other location - About 35 mins to fix
                lib/wrest/native/put_multipart.rb on lines 13..32

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

                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 update_with_single_argument has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def update_with_single_argument(other_hash, block)
                      if other_hash.is_a? HashWithIndifferentAccess
                        regular_update(other_hash, &block)
                      else
                        other_hash.to_hash.each_pair do |key, value|
                Severity: Minor
                Found in lib/wrest/hash_with_indifferent_access.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

                  module Components
                    module Translators
                      module Html
                        module_function
                
                
                Severity: Minor
                Found in lib/wrest/components/translators/html.rb and 1 other location - About 25 mins to fix
                lib/wrest/components/translators/txt.rb on lines 12..30

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

                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 Components
                    module Translators
                      module Txt
                        module_function
                
                
                Severity: Minor
                Found in lib/wrest/components/translators/txt.rb and 1 other location - About 25 mins to fix
                lib/wrest/components/translators/html.rb on lines 12..30

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

                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 deserialise has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                        def deserialise(response, options = {})
                          data = response.body
                          data = StringIO.new(data || '') unless data.respond_to?(:read)
                          return {} if data.eof?
                
                
                Severity: Minor
                Found in lib/wrest/components/translators/xml.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 these_fields_are_equal(other)
                        (code == other.code) &&
                          (headers == other.headers) &&
                          (http_version == other.http_version) &&
                          (message == other.message) &&
                Severity: Minor
                Found in lib/wrest/native/response.rb and 1 other location - About 15 mins to fix
                lib/wrest/native/get.rb on lines 70..76

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

                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 these_fields_are_equal(other)
                        (uri == other.uri) &&
                          (parameters == other.parameters) &&
                          (username == other.username) &&
                          (password == other.password) &&
                Severity: Minor
                Found in lib/wrest/native/get.rb and 1 other location - About 15 mins to fix
                lib/wrest/native/response.rb on lines 269..275

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

                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 build_put(body = '', headers = {}, parameters = {}, &block)
                      Http::Put.new(self, body.to_s, default_headers.merge(headers), parameters,
                                    block ? @options.merge(callback_block: block) : @options)
                Severity: Minor
                Found in lib/wrest/uri.rb and 2 other locations - About 15 mins to fix
                lib/wrest/uri.rb on lines 117..119
                lib/wrest/uri.rb on lines 123..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 26.

                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 build_post(body = '', headers = {}, parameters = {}, &block)
                      Http::Post.new(self, body.to_s, default_headers.merge(headers), parameters,
                                     block ? @options.merge(callback_block: block) : @options)
                Severity: Minor
                Found in lib/wrest/uri.rb and 2 other locations - About 15 mins to fix
                lib/wrest/uri.rb on lines 111..113
                lib/wrest/uri.rb on lines 117..119

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

                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