Showing 20 of 20 total issues
Method build
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
def build
base_iml = "#{@name}.iml"
doc = REXML::Document.new
doc.context[:attribute_quote] = :quote
- 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 print_string
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def print_string(s)
s = s.to_s.dup
until s.empty?
if s.sub!(/([^\e]*)?\e([\[\(])([0-9\;\=]*)([a-zA-Z@])(.*)/, '\5')
@out.write(concealed(Regexp.last_match(1)))
- 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 execute
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def execute(call, out_file, prefix: ' ')
rakefile = call.path
profile = *call.profile.map(&:to_s)
- 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 unpack_tar
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def unpack_tar(stream, dst_dir) # rubocop:disable all
Gem::Package::TarReader.new(stream) do |tar|
dest = nil
tar.each do |entry|
if entry.full_name == TAR_LONGLINK
- 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 build
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build
base_iml = "#{@name}.iml"
doc = REXML::Document.new
doc.context[:attribute_quote] = :quote
Method print_string
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def print_string(s)
s = s.to_s.dup
until s.empty?
if s.sub!(/([^\e]*)?\e([\[\(])([0-9\;\=]*)([a-zA-Z@])(.*)/, '\5')
@out.write(concealed(Regexp.last_match(1)))
Method execute
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def execute(call, out_file, prefix: ' ')
rakefile = call.path
profile = *call.profile.map(&:to_s)
Method run
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def run(task, working_dir, *args) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
prepare(task, working_dir)
initialize_state(*args) if stateful?
if changed?
- 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 update_smart
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def update_smart(src_product, dst_product, dst_dir, log: false) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/LineLength
if dst_product
# Check if file changed. If so updating it
# TODO: Should we or should not check hashsum
if product_changed?(src_product, dst_product)
- 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 create_manifest
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.create_manifest(opts, splitter) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
if splitter.nil?
splitter = lambda do |s|
lines = []
while s.size > MANIFEST_LINE_SIZE
- 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 build
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def build # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
log_msg "Compiling #{@srcs.size} classes"
classed_dir = job_path('classes')
out_dir = job_path('out')
- 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 create_manifest
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.create_manifest(opts, splitter) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
if splitter.nil?
splitter = lambda do |s|
lines = []
while s.size > MANIFEST_LINE_SIZE
Method on_job_arg_set
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def on_job_arg_set(name, type, old_digest, old_val, new_digest, new_val)
Method javac_cmd
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def javac_cmd(p = {}) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/LineLength
p = p.clone
source_version = p.delete(:source) || JAVA_SOURCE
target_version = p.delete(:target) || JAVA_TARGET
max_mem = p.delete(:max_mem)
- 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 putc
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def putc(c) # rubocop:disable Metrics/MethodLength
c = c.ord
if @buffer.empty?
# match \e
if c == 27
- 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 check_synthetic_arguments
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def check_synthetic_arguments(args)
raise "Expected Hash got #{args.inspect}" unless args.is_a?(Hash)
job_args = @job_args.keys
extra = args.keys - job_args
raise "Unknown arguments: #{extra.join(', ')}" unless extra.empty?
- 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 glob_base_pre25
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def glob_base_pre25(pattern, base) # rubocop:disable Metrics/AbcSize
# This should cover exceptional cases for base argument like: nil, '', '.'
return glob(pattern) if base.nil? || !File.exist?(base)
# Here we use fact that absolute_path just manipulates with content of
# its argument without invoking real file system. So we can safely try
- 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 load_configuration_streams
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def load_configuration_streams(dir)
# Read all known files
streams = CONFIGURATION_FILES
.map { |f| [dir ? File.join(dir, f) : f, f] }
.select { |path, _name| File.exist?(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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def ln(products, dir, base_dir: nil)
targets = prelink(products, dir, base_dir)
targets.each do |from, to|
FileUtils.ln(File.expand_path(from.src), File.expand_path(to.src))
end
- 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 27.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def ln_s(products, dir, base_dir: nil)
targets = prelink(products, dir, base_dir)
targets.each do |from, to|
FileUtils.ln_s(File.expand_path(from.src), File.expand_path(to.src))
end
- 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 27.
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