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.
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
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",
Method execute
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
def execute
@verbose = Gem.configuration.really_verbose
check_ruby_version
Method execute
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def execute
@verbose = Gem.configuration.really_verbose
check_ruby_version
- Read upRead up
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
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|
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",
- Read upRead up
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
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|
- Read upRead up
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",
- Read upRead up
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
- Read upRead up
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"