bundler/bundler

View on GitHub
lib/bundler/dsl.rb

Summary

Maintainability
F
3 days
Test Coverage

Method gem has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

    def gem(name, *args)
      options = args.last.is_a?(Hash) ? args.pop.dup : {}
      options["gemfile"] = @gemfile
      version = args || [">= 0"]

Severity: Minor
Found in lib/bundler/dsl.rb - About 7 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 dsl.rb has 454 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative "dependency"
require_relative "ruby_dsl"

module Bundler
  class Dsl
Severity: Minor
Found in lib/bundler/dsl.rb - About 6 hrs to fix

    Method normalize_options has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def normalize_options(name, version, opts)
          if name.is_a?(Symbol)
            raise GemfileError, %(You need to specify gem names as Strings. Use 'gem "#{name}"' instead)
          end
          if name =~ /\s/
    Severity: Minor
    Found in lib/bundler/dsl.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

    Class Dsl has 28 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Dsl
        include RubyDsl
    
        def self.evaluate(gemfile, lockfile, unlock)
          builder = new
    Severity: Minor
    Found in lib/bundler/dsl.rb - About 3 hrs to fix

      Method normalize_options has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def normalize_options(name, version, opts)
            if name.is_a?(Symbol)
              raise GemfileError, %(You need to specify gem names as Strings. Use 'gem "#{name}"' instead)
            end
            if name =~ /\s/
      Severity: Minor
      Found in lib/bundler/dsl.rb - About 2 hrs to fix

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

            def gem(name, *args)
              options = args.last.is_a?(Hash) ? args.pop.dup : {}
              options["gemfile"] = @gemfile
              version = args || [">= 0"]
        
        
        Severity: Minor
        Found in lib/bundler/dsl.rb - About 1 hr to fix

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

              def source(source, *args, &blk)
                options = args.last.is_a?(Hash) ? args.pop.dup : {}
                options = normalize_hash(options)
                source = normalize_source(source)
          
          
          Severity: Minor
          Found in lib/bundler/dsl.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 gemspec has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def gemspec(opts = nil)
                opts ||= {}
                path              = opts[:path] || "."
                glob              = opts[:glob]
                name              = opts[:name]
          Severity: Minor
          Found in lib/bundler/dsl.rb - About 1 hr to fix

            Method eval_gemfile has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def eval_gemfile(gemfile, contents = nil)
                  expanded_gemfile_path = Pathname.new(gemfile).expand_path(@gemfile && @gemfile.parent)
                  original_gemfile = @gemfile
                  @gemfile = expanded_gemfile_path
                  @gemfiles << expanded_gemfile_path
            Severity: Minor
            Found in lib/bundler/dsl.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

            Avoid deeply nested control flow statements.
            Open

                          if dep.requirements_list.include?(">= 0") && !current.requirements_list.include?(">= 0")
                            update_prompt = ". Gem already added"
                          else
                            update_prompt = ". If you want to update the gem version, run `bundle update #{current.name}`"
            
            
            Severity: Major
            Found in lib/bundler/dsl.rb - About 45 mins to fix

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

                  def check_primary_source_safety(source_list)
                    return if source_list.rubygems_primary_remotes.empty? && source_list.global_rubygems_source.nil?
              
                    if Bundler.feature_flag.disable_multisource?
                      msg = "This Gemfile contains multiple primary sources. " \
              Severity: Minor
              Found in lib/bundler/dsl.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 validate_keys has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def validate_keys(command, opts, valid_keys)
                    invalid_keys = opts.keys - valid_keys
              
                    git_source = opts.keys & @git_sources.keys.map(&:to_s)
                    if opts["branch"] && !(opts["git"] || opts["github"] || git_source.any?)
              Severity: Minor
              Found in lib/bundler/dsl.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

              There are no issues that match your filters.

              Category
              Status