rubinius/rubinius

View on GitHub
library/rubygems/remote_fetcher.rb

Summary

Maintainability
D
1 day
Test Coverage

Method download has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

  def download(spec, source_uri, install_dir = Gem.dir)
    cache_dir =
      if Dir.pwd == install_dir then # see fetch_command
        install_dir
      elsif File.writable? install_dir then
Severity: Minor
Found in library/rubygems/remote_fetcher.rb - About 6 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 download has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def download(spec, source_uri, install_dir = Gem.dir)
    cache_dir =
      if Dir.pwd == install_dir then # see fetch_command
        install_dir
      elsif File.writable? install_dir then
Severity: Major
Found in library/rubygems/remote_fetcher.rb - About 2 hrs to fix

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

      def fetch_path(uri, mtime = nil, head = false)
        uri = URI.parse uri unless URI::Generic === uri
    
        raise ArgumentError, "bad uri: #{uri}" unless uri
    
    
    Severity: Minor
    Found in library/rubygems/remote_fetcher.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 fetch_http has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      def fetch_http uri, last_modified = nil, head = false, depth = 0
        fetch_type = head ? Net::HTTP::Head : Net::HTTP::Get
        response   = request uri, fetch_type, last_modified do |req|
          headers.each { |k,v| req.add_field(k,v) }
        end
    Severity: Minor
    Found in library/rubygems/remote_fetcher.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

    File remote_fetcher.rb has 256 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'rubygems'
    require 'rubygems/request'
    require 'rubygems/uri_formatter'
    require 'rubygems/user_interaction'
    require 'rubygems/request/connection_pools'
    Severity: Minor
    Found in library/rubygems/remote_fetcher.rb - About 2 hrs to fix

      There are no issues that match your filters.

      Category
      Status