rubinius/rubinius

View on GitHub
library/rubygems/dependency_installer.rb

Summary

Maintainability
F
3 days
Test Coverage

Method find_gems_with_sources has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

  def find_gems_with_sources dep, best_only=false # :nodoc:
    set = Gem::AvailableSet.new

    if consider_local?
      sl = Gem::Source::Local.new
Severity: Minor
Found in library/rubygems/dependency_installer.rb - About 4 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

File dependency_installer.rb has 319 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rubygems'
require 'rubygems/dependency_list'
require 'rubygems/package'
require 'rubygems/installer'
require 'rubygems/spec_fetcher'
Severity: Minor
Found in library/rubygems/dependency_installer.rb - About 3 hrs to fix

    Method add_found_dependencies has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      def add_found_dependencies to_do, dependency_list # :nodoc:
        seen = {}
        dependencies = Hash.new { |h, name| h[name] = Gem::Dependency.new name }
    
        until to_do.empty? do
    Severity: Minor
    Found in library/rubygems/dependency_installer.rb - About 3 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 resolve_dependencies has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

      def resolve_dependencies dep_or_name, version # :nodoc:
        request_set = Gem::RequestSet.new
        request_set.development         = @development
        request_set.development_shallow = @dev_shallow
        request_set.soft_missing = @force
    Severity: Minor
    Found in library/rubygems/dependency_installer.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 find_spec_by_name_and_version has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      def find_spec_by_name_and_version gem_name,
                                        version = Gem::Requirement.default,
                                        prerelease = false
        set = Gem::AvailableSet.new
    
    
    Severity: Minor
    Found in library/rubygems/dependency_installer.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 find_gems_with_sources has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def find_gems_with_sources dep, best_only=false # :nodoc:
        set = Gem::AvailableSet.new
    
        if consider_local?
          sl = Gem::Source::Local.new
    Severity: Major
    Found in library/rubygems/dependency_installer.rb - About 2 hrs to fix

      Method resolve_dependencies has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def resolve_dependencies dep_or_name, version # :nodoc:
          request_set = Gem::RequestSet.new
          request_set.development         = @development
          request_set.development_shallow = @dev_shallow
          request_set.soft_missing = @force
      Severity: Minor
      Found in library/rubygems/dependency_installer.rb - About 1 hr to fix

        Method add_found_dependencies has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def add_found_dependencies to_do, dependency_list # :nodoc:
            seen = {}
            dependencies = Hash.new { |h, name| h[name] = Gem::Dependency.new name }
        
            until to_do.empty? do
        Severity: Minor
        Found in library/rubygems/dependency_installer.rb - About 1 hr to fix

          Method find_spec_by_name_and_version has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def find_spec_by_name_and_version gem_name,
                                              version = Gem::Requirement.default,
                                              prerelease = false
              set = Gem::AvailableSet.new
          
          
          Severity: Minor
          Found in library/rubygems/dependency_installer.rb - About 1 hr to fix

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

              def install dep_or_name, version = Gem::Requirement.default
                request_set = resolve_dependencies dep_or_name, version
            
                @installed_gems = []
            
            
            Severity: Minor
            Found in library/rubygems/dependency_installer.rb - About 1 hr to fix

              Method initialize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def initialize options = {}
                  @only_install_dir = !!options[:install_dir]
                  @install_dir = options[:install_dir] || Gem.dir
                  @build_root = options[:build_root]
              
              
              Severity: Minor
              Found in library/rubygems/dependency_installer.rb - About 1 hr to fix

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

                  def gather_dependencies # :nodoc:
                    specs = @available.all_specs
                
                    # these gems were listed by the user, always install them
                    keep_names = specs.map { |spec| spec.full_name }
                Severity: Minor
                Found in library/rubygems/dependency_installer.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 in_background has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def in_background what # :nodoc:
                    fork_happened = false
                    if @build_docs_in_background and Process.respond_to?(:fork)
                      begin
                        Process.fork do
                Severity: Minor
                Found in library/rubygems/dependency_installer.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

                        tuples.each do |tup, source|
                          begin
                            spec = source.fetch_spec(tup)
                          rescue Gem::RemoteFetcher::FetchError => e
                            errors << Gem::SourceFetchProblem.new(source, e)
                Severity: Minor
                Found in library/rubygems/dependency_installer.rb and 1 other location - About 20 mins to fix
                library/rubygems/spec_fetcher.rb on lines 170..176

                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

                There are no issues that match your filters.

                Category
                Status