rubygems/rubygems

View on GitHub
lib/rubygems/commands/setup_command.rb

Summary

Maintainability
F
3 days
Test Coverage

File setup_command.rb has 511 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative "../command"

##
# Installs RubyGems itself.  This command is ordinarily only available from a
# RubyGems checkout or tarball.
Severity: Major
Found in lib/rubygems/commands/setup_command.rb - About 1 day to fix

    Class SetupCommand has 29 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Gem::Commands::SetupCommand < Gem::Command
      HISTORY_HEADER = %r{^#\s*[\d.a-zA-Z]+\s*/\s*\d{4}-\d{2}-\d{2}\s*$}
      VERSION_MATCHER = %r{^#\s*([\d.a-zA-Z]+)\s*/\s*\d{4}-\d{2}-\d{2}\s*$}
    
      ENV_PATHS = %w[/usr/bin/env /bin/env].freeze
    Severity: Minor
    Found in lib/rubygems/commands/setup_command.rb - About 3 hrs to fix

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

        def initialize
          super "setup", "Install RubyGems",
                format_executable: false, document: %w[ri],
                force: true,
                site_or_vendor: "sitelibdir",
      Severity: Major
      Found in lib/rubygems/commands/setup_command.rb - About 3 hrs to fix

        Method execute has 70 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def execute
            @verbose = Gem.configuration.really_verbose
        
            check_ruby_version
        
        
        Severity: Major
        Found in lib/rubygems/commands/setup_command.rb - About 2 hrs to fix

          Method execute has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def execute
              @verbose = Gem.configuration.really_verbose
          
              check_ruby_version
          
          
          Severity: Minor
          Found in lib/rubygems/commands/setup_command.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 install_default_bundler_gem has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def install_default_bundler_gem(bin_dir)
              current_default_spec = Gem::Specification.default_stubs.find {|s| s.name == "bundler" }
              specs_dir = if current_default_spec && default_dir == Gem.default_dir
                Gem::Specification.remove_spec current_default_spec
                loaded_from = current_default_spec.loaded_from
          Severity: Minor
          Found in lib/rubygems/commands/setup_command.rb - About 1 hr to fix

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

              def install_executables(bin_dir)
                prog_mode = options[:prog_mode] || 0o755
            
                executables = { "gem" => "exe" }
                executables.each do |tool, path|
            Severity: Minor
            Found in lib/rubygems/commands/setup_command.rb - About 1 hr to fix

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

                def initialize
                  super "setup", "Install RubyGems",
                        format_executable: false, document: %w[ri],
                        force: true,
                        site_or_vendor: "sitelibdir",
              Severity: Minor
              Found in lib/rubygems/commands/setup_command.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 install_rdoc has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def install_rdoc
                  gem_doc_dir = File.join Gem.dir, "doc"
                  rubygems_name = "rubygems-#{Gem::VERSION}"
                  rubygems_doc_dir = File.join gem_doc_dir, rubygems_name
              
              
              Severity: Minor
              Found in lib/rubygems/commands/setup_command.rb - About 1 hr to fix

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

                  def install_executables(bin_dir)
                    prog_mode = options[:prog_mode] || 0o755
                
                    executables = { "gem" => "exe" }
                    executables.each do |tool, path|
                Severity: Minor
                Found in lib/rubygems/commands/setup_command.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 remove_old_bin_files has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def remove_old_bin_files(bin_dir)
                    old_bin_files = {
                      "gem_mirror" => "gem mirror",
                      "gem_server" => "gem server",
                      "gemlock" => "gem lock",
                Severity: Minor
                Found in lib/rubygems/commands/setup_command.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 install_rdoc has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def install_rdoc
                    gem_doc_dir = File.join Gem.dir, "doc"
                    rubygems_name = "rubygems-#{Gem::VERSION}"
                    rubygems_doc_dir = File.join gem_doc_dir, rubygems_name
                
                
                Severity: Minor
                Found in lib/rubygems/commands/setup_command.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