rubinius/rubinius

View on GitHub
library/rubygems/test_case.rb

Summary

Maintainability
F
6 days
Test Coverage

File test_case.rb has 939 lines of code (exceeds 250 allowed). Consider refactoring.
Open

begin
  gem 'minitest', '~> 4.0'
rescue NoMethodError, Gem::LoadError
  # for ruby tests
end
Severity: Major
Found in library/rubygems/test_case.rb - About 2 days to fix

    Class TestCase has 71 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Gem::TestCase < MiniTest::Unit::TestCase
    
      attr_accessor :fetcher # :nodoc:
    
      attr_accessor :gem_repo # :nodoc:
    Severity: Major
    Found in library/rubygems/test_case.rb - About 1 day to fix

      Method setup has 100 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def setup
          super
      
          @orig_gem_home   = ENV['GEM_HOME']
          @orig_gem_path   = ENV['GEM_PATH']
      Severity: Major
      Found in library/rubygems/test_case.rb - About 4 hrs to fix

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

          def teardown
            $LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH
            if @orig_LOADED_FEATURES
              if @orig_LOAD_PATH
                paths = @orig_LOAD_PATH.map {|path| File.join(File.expand_path(path), "/")}
        Severity: Minor
        Found in library/rubygems/test_case.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 util_make_gems has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def util_make_gems(prerelease = false)
            @a1 = quick_gem 'a', '1' do |s|
              s.files = %w[lib/code.rb]
              s.require_paths = %w[lib]
              s.date = Gem::Specification::TODAY - 86400
        Severity: Major
        Found in library/rubygems/test_case.rb - About 2 hrs to fix

          Method setup has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

            def setup
              super
          
              @orig_gem_home   = ENV['GEM_HOME']
              @orig_gem_path   = ENV['GEM_PATH']
          Severity: Minor
          Found in library/rubygems/test_case.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 teardown has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def teardown
              $LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH
              if @orig_LOADED_FEATURES
                if @orig_LOAD_PATH
                  paths = @orig_LOAD_PATH.map {|path| File.join(File.expand_path(path), "/")}
          Severity: Minor
          Found in library/rubygems/test_case.rb - About 1 hr to fix

            Method util_setup_spec_fetcher has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def util_setup_spec_fetcher(*specs)
                all_specs = Gem::Specification.to_a + specs
                Gem::Specification._resort! all_specs
            
                spec_fetcher = Gem::SpecFetcher.fetcher
            Severity: Minor
            Found in library/rubygems/test_case.rb - About 1 hr to fix

              Method new_spec has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def new_spec name, version, deps = nil, *files # :nodoc:
                  require 'rubygems/specification'
              
                  spec = Gem::Specification.new do |s|
                    s.platform    = Gem::Platform::RUBY
              Severity: Minor
              Found in library/rubygems/test_case.rb - About 1 hr to fix

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

                  def new_spec name, version, deps = nil, *files # :nodoc:
                    require 'rubygems/specification'
                
                    spec = Gem::Specification.new do |s|
                      s.platform    = Gem::Platform::RUBY
                Severity: Minor
                Found in library/rubygems/test_case.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 assert_contains_make_command has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def assert_contains_make_command(target, output, msg = nil)
                    if output.match(/\n/)
                      msg = message(msg) {
                        'Expected output containing make command "%s": %s' % [
                          ('%s %s' % [make_command, target]).rstrip,
                Severity: Minor
                Found in library/rubygems/test_case.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 util_set_RUBY_VERSION has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def util_set_RUBY_VERSION(version, patchlevel = nil, revision = nil)
                    if Gem.instance_variables.include? :@ruby_version or
                       Gem.instance_variables.include? '@ruby_version' then
                      Gem.send :remove_instance_variable, :@ruby_version
                    end
                Severity: Minor
                Found in library/rubygems/test_case.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 rubybin has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def self.rubybin
                    ruby = ENV["RUBY"]
                    return ruby if ruby
                    ruby = "ruby"
                    rubyexe = "#{ruby}.exe"
                Severity: Minor
                Found in library/rubygems/test_case.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 util_spec has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def util_spec name, version = 2, deps = nil # :yields: specification
                    raise "deps or block, not both" if deps and block_given?
                
                    spec = Gem::Specification.new do |s|
                      s.platform    = Gem::Platform::RUBY
                Severity: Minor
                Found in library/rubygems/test_case.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 write_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def write_file(path)
                    path = File.join @gemhome, path unless Pathname.new(path).absolute?
                    dir = File.dirname path
                    FileUtils.mkdir_p dir unless File.directory? dir
                
                
                Severity: Minor
                Found in library/rubygems/test_case.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

                    spec = Gem::Specification.new do |s|
                      s.platform    = Gem::Platform::RUBY
                      s.name        = name
                      s.version     = version
                      s.author      = 'A User'
                Severity: Minor
                Found in library/rubygems/test_case.rb and 1 other location - About 40 mins to fix
                library/rubygems/test_case.rb on lines 833..844

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

                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

                    spec = Gem::Specification.new do |s|
                      s.platform    = Gem::Platform::RUBY
                      s.name        = name
                      s.version     = version
                      s.author      = 'A User'
                Severity: Minor
                Found in library/rubygems/test_case.rb and 1 other location - About 40 mins to fix
                library/rubygems/test_case.rb on lines 639..650

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

                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

                There are no issues that match your filters.

                Category
                Status