File test_case.rb
has 939 lines of code (exceeds 250 allowed). Consider refactoring. Open
begin
gem 'minitest', '~> 4.0'
rescue NoMethodError, Gem::LoadError
# for ruby tests
end
Class TestCase
has 71 methods (exceeds 20 allowed). Consider refactoring. Open
class Gem::TestCase < MiniTest::Unit::TestCase
attr_accessor :fetcher # :nodoc:
attr_accessor :gem_repo # :nodoc:
Method setup
has 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setup
super
@orig_gem_home = ENV['GEM_HOME']
@orig_gem_path = ENV['GEM_PATH']
Method teardown
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def teardown
$LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH
if @orig_LOADED_FEATURES
if @orig_LOAD_PATH
paths = @orig_LOAD_PATH.map {|path| File.join(File.expand_path(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 util_make_gems
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
def util_make_gems(prerelease = false)
@a1 = quick_gem 'a', '1' do |s|
s.files = %w[lib/code.rb]
s.require_paths = %w[lib]
s.date = Gem::Specification::TODAY - 86400
Method setup
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def setup
super
@orig_gem_home = ENV['GEM_HOME']
@orig_gem_path = ENV['GEM_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 teardown
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def teardown
$LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH
if @orig_LOADED_FEATURES
if @orig_LOAD_PATH
paths = @orig_LOAD_PATH.map {|path| File.join(File.expand_path(path), "/")}
Method util_setup_spec_fetcher
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def util_setup_spec_fetcher(*specs)
all_specs = Gem::Specification.to_a + specs
Gem::Specification._resort! all_specs
spec_fetcher = Gem::SpecFetcher.fetcher
Method new_spec
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def new_spec name, version, deps = nil, *files # :nodoc:
require 'rubygems/specification'
spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
Method new_spec
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def new_spec name, version, deps = nil, *files # :nodoc:
require 'rubygems/specification'
spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
- 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 assert_contains_make_command
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def assert_contains_make_command(target, output, msg = nil)
if output.match(/\n/)
msg = message(msg) {
'Expected output containing make command "%s": %s' % [
('%s %s' % [make_command, target]).rstrip,
- 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 util_set_RUBY_VERSION
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def util_set_RUBY_VERSION(version, patchlevel = nil, revision = nil)
if Gem.instance_variables.include? :@ruby_version or
Gem.instance_variables.include? '@ruby_version' then
Gem.send :remove_instance_variable, :@ruby_version
end
- 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 rubybin
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.rubybin
ruby = ENV["RUBY"]
return ruby if ruby
ruby = "ruby"
rubyexe = "#{ruby}.exe"
- 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 util_spec
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def util_spec name, version = 2, deps = nil # :yields: specification
raise "deps or block, not both" if deps and block_given?
spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
- 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 write_file
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def write_file(path)
path = File.join @gemhome, path unless Pathname.new(path).absolute?
dir = File.dirname path
FileUtils.mkdir_p dir unless File.directory? dir
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = name
s.version = version
s.author = 'A User'
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 37.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = name
s.version = version
s.author = 'A User'
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 37.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76