myronmarston/vcr

View on GitHub

Showing 20 of 20 total issues

File structs.rb has 350 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'base64'
require 'delegate'
require 'time'

module VCR
Severity: Minor
Found in lib/vcr/structs.rb - About 4 hrs to fix

    Class Configuration has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Configuration
        include Hooks
        include VariableArgsBlockCaller
        include Logger
    
    
    Severity: Minor
    Found in lib/vcr/configuration.rb - About 3 hrs to fix

      Class Cassette has 26 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Cassette
          include Logger
      
          # The supported record modes.
          #
      Severity: Minor
      Found in lib/vcr/cassette.rb - About 3 hrs to fix

        Method tags has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def tags(*tag_names)
              original_options = tag_names.last.is_a?(::Hash) ? tag_names.pop : {}
              tag_names.each do |tag_name|
                tag_name = "@#{tag_name}" unless tag_name =~ /\A@/
        
        
        Severity: Minor
        Found in lib/vcr/test_frameworks/cucumber.rb - About 2 hrs 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 migrate_cassette has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def migrate_cassette(cassette)
                unless http_interactions = load_yaml(cassette)
                  @out.puts "  - Ignored #{relative_casssette_name(cassette)} since it could not be parsed as YAML (does it have some ERB?)"
                  return
                end
        Severity: Minor
        Found in lib/vcr/cassette/migrator.rb - About 1 hr to fix

          Method configure! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def configure!
                  ::RSpec.configure do |config|
                    vcr_cassette_name_for = lambda do |metadata|
                      description = metadata[:description]
          
          
          Severity: Minor
          Found in lib/vcr/test_frameworks/rspec.rb - About 55 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 try_encode_string has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                    def try_encode_string(string, encoding)
                      return string if encoding.nil? || string.encoding.name == encoding
          
                      # ASCII-8BIT just means binary, so encoding to it is nonsensical
                      # and yet "\u00f6".encode("ASCII-8BIT") raises an error.
          Severity: Minor
          Found in lib/vcr/structs.rb - About 55 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 request_with_vcr has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def request_with_vcr(request, *args, &block)
                  if VCR.turned_on?
                    handler = request.instance_eval do
                      remove_instance_variable(:@__vcr_request_handler) if defined?(@__vcr_request_handler)
                    end || VCR::LibraryHooks::FakeWeb::RequestHandler.new(self, request, *args, &block)
          Severity: Minor
          Found in lib/vcr/library_hooks/fakeweb.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 should_re_record? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def should_re_record?
                return false unless @re_record_interval
                previously_recorded_at = earliest_interaction_recorded_at
                return false unless previously_recorded_at
          
          
          Severity: Minor
          Found in lib/vcr/cassette.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(interactions, request_matchers, allow_playback_repeats = false, parent_list = NullList, log_prefix = '')
          Severity: Minor
          Found in lib/vcr/cassette/http_interaction_list.rb - About 35 mins to fix

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

                    def initialize(request_type, stubbed_response, vcr_request, *args, &response_block)
            Severity: Minor
            Found in lib/vcr/library_hooks/fakeweb.rb - About 35 mins to fix

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

                    def read_body(dest = nil, &block)
                      return super if @__read_body_previously_called
                      return @body if dest.nil? && block.nil?
                      raise ArgumentError.new("both arg and block given for HTTP method") if dest && block
              
              
              Severity: Minor
              Found in lib/vcr/extensions/net_http_response.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 render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def render
                      return @raw_template if @raw_template.nil? || !use_erb?
                      binding = binding_for_variables if erb_variables
                      template.result(binding)
                    rescue NameError => e
              Severity: Minor
              Found in lib/vcr/cassette/erb_renderer.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 filter_object! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def filter_object!(object, text, replacement_text)
                      if object.respond_to?(:gsub)
                        object.gsub!(text, replacement_text) if object.include?(text)
                      elsif Hash === object
                        filter_hash!(object, text, replacement_text)
              Severity: Minor
              Found in lib/vcr/structs.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 perform_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                      def perform_request(started, record_interaction = false)
                        # Net::HTTP calls #request recursively in certain circumstances.
                        # We only want to record the request when the request is started, as
                        # that is the final time through #request.
                        unless started
              Severity: Minor
              Found in lib/vcr/library_hooks/fakeweb.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 remove_unnecessary_standard_port has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def remove_unnecessary_standard_port(interaction)
                      uri = VCR.configuration.uri_parser.parse(interaction.request.uri)
                      if uri.scheme == 'http'  && uri.port == 80 ||
                         uri.scheme == 'https' && uri.port == 443
                        uri.port = nil
              Severity: Minor
              Found in lib/vcr/cassette/migrator.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

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

                        def stubbed_response_headers
                          @stubbed_response_headers ||= {}.tap do |hash|
                            stubbed_response.headers.each do |key, values|
                              hash[key] = values.size == 1 ? values.first : values
                            end if stubbed_response.headers
              Severity: Minor
              Found in lib/vcr/library_hooks/typhoeus.rb and 1 other location - About 20 mins to fix
              lib/vcr/library_hooks/typhoeus_0.4.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 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

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

                      def stubbed_response_headers
                        @stubbed_response_headers ||= {}.tap do |hash|
                          stubbed_response.headers.each do |key, values|
                            hash[key] = values.size == 1 ? values.first : values
                          end if stubbed_response.headers
              Severity: Minor
              Found in lib/vcr/library_hooks/typhoeus_0.4.rb and 1 other location - About 20 mins to fix
              lib/vcr/library_hooks/typhoeus.rb on lines 56..62

              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

              module VCR
                class Cassette
                  class Serializers
                    # The YAML serializer. This will use either Psych or Syck, which ever your
                    # ruby interpreter defaults to. You can also force VCR to use Psych or Syck by
              Severity: Minor
              Found in lib/vcr/cassette/serializers/yaml.rb and 1 other location - About 20 mins to fix
              lib/vcr/cassette/serializers/psych.rb on lines 3..41

              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

              module VCR
                class Cassette
                  class Serializers
                    # The Psych serializer. Psych is the new YAML engine in ruby 1.9.
                    #
              Severity: Minor
              Found in lib/vcr/cassette/serializers/psych.rb and 1 other location - About 20 mins to fix
              lib/vcr/cassette/serializers/yaml.rb on lines 3..43

              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