Showing 19 of 19 total issues

File structs.rb has 372 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 Cassette has 32 methods (exceeds 20 allowed). Consider refactoring.
    Open

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

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

        class Configuration
          include Hooks
          include VariableArgsBlockCaller
          include Logger::Mixin
      
      
      Severity: Minor
      Found in lib/vcr/configuration.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 tags has 37 lines of code (exceeds 25 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 1 hr to fix

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

                def configure!
                  ::RSpec.configure do |config|
          
                    when_tagged_with_vcr = { :vcr => lambda { |v| !!v } }
          
          
          Severity: Minor
          Found in lib/vcr/test_frameworks/rspec.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 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 should_re_record? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def should_re_record?(record_mode)
                return false unless @re_record_interval
                return false unless originally_recorded_at
                return false if record_mode == :none
          
          
          Severity: Minor
          Found in lib/vcr/cassette.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 start_new_fiber_for has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def start_new_fiber_for(request, fibers, fiber_errors, hook_declaration, proc)
          Severity: Minor
          Found in lib/vcr/configuration.rb - About 35 mins to fix

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

                    def vcr_cassette_name_for(metadata)
                      description = 
                        if metadata[:description].empty?
                          # we have an "it { is_expected.to be something }" block
                          metadata[:scoped_id]
              Severity: Minor
              Found in lib/vcr/test_frameworks/rspec.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

              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 35 mins to fix
              lib/vcr/cassette/serializers/psych.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 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 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 35 mins to fix
              lib/vcr/cassette/serializers/yaml.rb on lines 3..45

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

                  def create_fiber_for(fiber_errors, hook_declaration, proc)
                    current_thread = Thread.current
                    Fiber.new do |*args, &block|
                      begin
                        # JRuby Fiber runs in a separate thread, so we need to make this Fiber
              Severity: Minor
              Found in lib/vcr/configuration.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

              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

              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 64..70

              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