bundler/bundler

View on GitHub
lib/bundler/definition.rb

Summary

Maintainability
F
1 wk
Test Coverage

File definition.rb has 728 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative "lockfile_parser"
require "set"

module Bundler
  class Definition
Severity: Major
Found in lib/bundler/definition.rb - About 1 day to fix

    Class Definition has 67 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Definition
        include GemHelpers
    
        attr_reader(
          :dependencies,
    Severity: Major
    Found in lib/bundler/definition.rb - About 1 day to fix

      Method converge_locked_specs has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
      Open

          def converge_locked_specs
            deps = []
      
            # Build a list of dependencies that are the same in the Gemfile
            # and Gemfile.lock. If the Gemfile modified a dependency, but
      Severity: Minor
      Found in lib/bundler/definition.rb - About 1 day 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 ensure_equivalent_gemfile_and_lockfile has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

          def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
            msg = String.new
            msg << "You are trying to install in deployment mode after changing\n" \
                   "your Gemfile. Run `bundle install` elsewhere and add the\n" \
                   "updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."
      Severity: Minor
      Found in lib/bundler/definition.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

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

          def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, optional_groups = [], gemfiles = [])
            if [true, false].include?(unlock)
              @unlocking_bundler = false
              @unlocking = unlock
            else
      Severity: Major
      Found in lib/bundler/definition.rb - About 2 hrs to fix

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

            def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, optional_groups = [], gemfiles = [])
              if [true, false].include?(unlock)
                @unlocking_bundler = false
                @unlocking = unlock
              else
        Severity: Minor
        Found in lib/bundler/definition.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 ensure_equivalent_gemfile_and_lockfile has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
              msg = String.new
              msg << "You are trying to install in deployment mode after changing\n" \
                     "your Gemfile. Run `bundle install` elsewhere and add the\n" \
                     "updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."
        Severity: Major
        Found in lib/bundler/definition.rb - About 2 hrs to fix

          Method converge_locked_specs has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def converge_locked_specs
                deps = []
          
                # Build a list of dependencies that are the same in the Gemfile
                # and Gemfile.lock. If the Gemfile modified a dependency, but
          Severity: Major
          Found in lib/bundler/definition.rb - About 2 hrs to fix

            Consider simplifying this complex logical expression.
            Open

                  if (new_deps.empty? && deleted_deps.empty?) && (!new_sources.empty? && !deleted_sources.empty?)
                    new_sources.reject! {|source| (source.path? && source.path.exist?) || equivalent_rubygems_remotes?(source) }
                    deleted_sources.reject! {|source| (source.path? && source.path.exist?) || equivalent_rubygems_remotes?(source) }
                  end
            Severity: Critical
            Found in lib/bundler/definition.rb - About 1 hr to fix

              Method expand_dependencies has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def expand_dependencies(dependencies, remote = false)
                    sorted_platforms = Resolver.sort_platforms(@platforms)
                    deps = []
                    dependencies.each do |dep|
                      dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name)
              Severity: Minor
              Found in lib/bundler/definition.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 double_check_for_index has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def double_check_for_index(idx, dependency_names)
                    pinned_names = pinned_spec_names
                    loop do
                      idxcount = idx.size
              
              
              Severity: Minor
              Found in lib/bundler/definition.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 additional_base_requirements_for_resolve has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def additional_base_requirements_for_resolve
                    return [] unless @locked_gems && Bundler.feature_flag.only_update_to_newer_versions?
                    dependencies_by_name = dependencies.inject({}) {|memo, dep| memo.update(dep.name => dep) }
                    @locked_gems.specs.reduce({}) do |requirements, locked_spec|
                      name = locked_spec.name
              Severity: Minor
              Found in lib/bundler/definition.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 pinned_spec_names has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def pinned_spec_names(skip = nil)
                    pinned_names = []
                    default = Bundler.feature_flag.disable_multisource? && sources.default_source
                    @dependencies.each do |dep|
                      next unless dep_source = dep.source || default
              Severity: Minor
              Found in lib/bundler/definition.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 validate_ruby! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def validate_ruby!
                    return unless ruby_version
              
                    if diff = ruby_version.diff(Bundler::RubyVersion.system)
                      problem, expected, actual = diff
              Severity: Minor
              Found in lib/bundler/definition.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 converge_dependencies has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def converge_dependencies
                    frozen = Bundler.frozen_bundle?
                    (@dependencies + @locked_deps.values).each do |dep|
                      locked_source = @locked_deps[dep.name]
                      # This is to make sure that if bundler is installing in deployment mode and
              Severity: Minor
              Found in lib/bundler/definition.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 compute_requires has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def compute_requires
                    dependencies.reduce({}) do |requires, dep|
                      next requires unless dep.should_include?
                      requires[dep.name] = Array(dep.autorequire || dep.name).map do |file|
                        # Allow `require: true` as an alias for `require: <name>`
              Severity: Minor
              Found in lib/bundler/definition.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 initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, optional_groups = [], gemfiles = [])
              Severity: Major
              Found in lib/bundler/definition.rb - About 50 mins to fix

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

                    def concat_ruby_version_requirements(ruby_version, ruby_versions = [])
                      return ruby_versions unless ruby_version
                      if ruby_version.patchlevel
                        ruby_versions << ruby_version.to_gem_version_with_patchlevel
                      else
                Severity: Minor
                Found in lib/bundler/definition.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 lock has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def lock(file, preserve_unknown_sections = false)
                      contents = to_lock
                
                      # Convert to \r\n if the existing lock has them
                      # i.e., Windows with `git config core.autocrlf=true`
                Severity: Minor
                Found in lib/bundler/definition.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 source_requirements has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def source_requirements
                      # Load all specs from remote sources
                      index
                
                      # Record the specs available in each gem's source, so that those
                Severity: Minor
                Found in lib/bundler/definition.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 converge_locals has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def converge_locals
                      locals = []
                
                      Bundler.settings.local_overrides.map do |k, v|
                        spec   = @dependencies.find {|s| s.name == k }
                Severity: Minor
                Found in lib/bundler/definition.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

                TODO found
                Open

                        # TODO: delete in Bundler 2
                Severity: Minor
                Found in lib/bundler/definition.rb by fixme

                XXX found
                Open

                        # XXX This is a backwards-compatibility fix to preserve the ability to
                Severity: Minor
                Found in lib/bundler/definition.rb by fixme

                There are no issues that match your filters.

                Category
                Status