rubygems/rubygems

View on GitHub
bundler/lib/bundler/definition.rb

Summary

Maintainability
F
1 wk
Test Coverage

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

require_relative "lockfile_parser"

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

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

      class Definition
        include GemHelpers
    
        class << self
          # Do not create or modify a lockfile (Makes #lock a noop)
    Severity: Major
    Found in bundler/lib/bundler/definition.rb - About 1 day to fix

      Method converge_specs has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

          def converge_specs(specs)
            converged = []
            deps = []
      
            @specs_that_changed_sources = []
      Severity: Minor
      Found in bundler/lib/bundler/definition.rb - About 5 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 a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
            added =   []
            deleted = []
            changed = []
      
      
      Severity: Minor
      Found in bundler/lib/bundler/definition.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 initialize has 83 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 bundler/lib/bundler/definition.rb - About 3 hrs to fix

        Method initialize has a Cognitive Complexity of 22 (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 bundler/lib/bundler/definition.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 converge_specs has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def converge_specs(specs)
              converged = []
              deps = []
        
              @specs_that_changed_sources = []
        Severity: Minor
        Found in bundler/lib/bundler/definition.rb - About 1 hr to fix

          Method ensure_equivalent_gemfile_and_lockfile has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
                added =   []
                deleted = []
                changed = []
          
          
          Severity: Minor
          Found in bundler/lib/bundler/definition.rb - About 1 hr to fix

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

                def materialize(dependencies)
                  specs = resolve.materialize(dependencies)
                  missing_specs = specs.missing_specs
            
                  if missing_specs.any?
            Severity: Minor
            Found in bundler/lib/bundler/definition.rb - About 1 hr to fix

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

                  def materialize(dependencies)
                    specs = resolve.materialize(dependencies)
                    missing_specs = specs.missing_specs
              
                    if missing_specs.any?
              Severity: Minor
              Found in bundler/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 converge_locked_specs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def converge_locked_specs
                    converged = converge_specs(@locked_specs)
              
                    resolve = SpecSet.new(converged.reject {|s| @gems_to_unlock.include?(s.name) })
              
              
              Severity: Minor
              Found in bundler/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 source_requirements has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def source_requirements
                    # Record the specs available in each gem's source, so that those
                    # specs will be available later when the resolver knows where to
                    # look for that gemspec (or its dependencies)
                    source_requirements = if precompute_source_requirements_for_indirect_dependencies?
              Severity: Minor
              Found in bundler/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 remove_invalid_platforms! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def remove_invalid_platforms!(dependencies)
                    return if Bundler.frozen_bundle?
              
                    platforms.reverse_each do |platform|
                      next if local_platform == platform ||
              Severity: Minor
              Found in bundler/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 bundler/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 write_lock has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def write_lock(file, preserve_unknown_sections)
                    return if Definition.no_lock
              
                    contents = to_lock
              
              
              Severity: Minor
              Found in bundler/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 bundler/lib/bundler/definition.rb - About 50 mins to fix

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

                    def change_reason
                      if unlocking?
                        unlock_targets = if @gems_to_unlock.any?
                          ["gems", @gems_to_unlock]
                        elsif @sources_to_unlock.any?
                Severity: Minor
                Found in bundler/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 check_lockfile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def check_lockfile
                      @missing_lockfile_dep = nil
                
                      @locked_spec_with_invalid_deps = nil
                      @locked_spec_with_missing_deps = nil
                Severity: Minor
                Found in bundler/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

                Consider simplifying this complex logical expression.
                Open

                        next if local_platform == platform ||
                                (@new_platform && platforms.last == platform) ||
                                @path_changes ||
                                @dependency_changes ||
                                !@originally_locked_specs.incomplete_for_platform?(dependencies, platform)
                Severity: Major
                Found in bundler/lib/bundler/definition.rb - About 40 mins to fix

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

                      def converge_dependencies
                        changes = false
                  
                        @dependencies.each do |dep|
                          if dep.source
                  Severity: Minor
                  Found in bundler/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 lock has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def lock(file_or_preserve_unknown_sections = false, preserve_unknown_sections_or_unused = false)
                        if [true, false, nil].include?(file_or_preserve_unknown_sections)
                          target_lockfile = lockfile || Bundler.default_lockfile
                          preserve_unknown_sections = file_or_preserve_unknown_sections
                        else
                  Severity: Minor
                  Found in bundler/lib/bundler/definition.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 additional_base_requirements_to_prevent_downgrades has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def additional_base_requirements_to_prevent_downgrades(resolution_packages, last_resolve)
                        return resolution_packages unless @locked_gems && !sources.expired_sources?(@locked_gems.sources)
                        converge_specs(@originally_locked_specs - last_resolve).each do |locked_spec|
                          next if locked_spec.source.is_a?(Source::Path)
                          resolution_packages.base_requirements[locked_spec.name] = Gem::Requirement.new(">= #{locked_spec.version}")
                  Severity: Minor
                  Found in bundler/lib/bundler/definition.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 converge_locals has a Cognitive Complexity of 6 (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 bundler/lib/bundler/definition.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

                  There are no issues that match your filters.

                  Category
                  Status