Showing 90 of 90 total issues
Method require_release
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def require_release(path, warn: false, required: true)
if path.include?("-release")
new_path = path
else
new_path = path.gsub(/(.*)rcs-([^\/]+)/, '\1rcs-\2-release')
- 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 trace_setup
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def trace_setup
pwd = File.expand_path(Dir.pwd)
raise "FATAL: Invalid execution directory." unless File.directory?("#{pwd}/lib")
- 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 process_http_request
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_http_request
EM.defer do
begin
trace(:info, "[#{@http[:host]}] REQ #{@http_protocol} #{@http_request_method} #{@http_content.size} bytes from #{remote_addr}")
Method decode_content
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def decode_content(common_info, chunks)
stream = StringIO.new chunks.join
until stream.eof?
tm = stream.read 36
Method append
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def append(file_id, data, options = {})
attributes = if options[:filename]
files_collection.find(filename: file_id).first
else
file_id = objectid(file_id)
Method decode_from_to
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def decode_from_to(common_info, stream)
tm = stream.read 36
info = Hash[common_info]
info[:da] = Time.gm(*(tm.unpack('L*')), 0)
info[:data] = Hash.new if info[:data].nil?
Method request
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def request(payload, options = {}, retry_count = self.max_retries)
msg = options[:store] ? [] : [payload]
msg = ["#{payload.size} B", options.inspect]
trace(:debug, "REQ #{msg.join(' | ')}")
Method chunkerize
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def chunkerize(data)
offset = 0
chunk_num = 0
loop do
- 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 decode_content
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def decode_content(common_info, chunks)
stream = StringIO.new chunks.join
entries = []
- 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
unless @calendar.fields[:location].nil?
location = @calendar.fields[:location]
unless location.empty?
info[:data][:location] = location
info[:data][:info] += " - " unless info[:data][:info].empty?
- 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 45.
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
unless @calendar.fields[:body].nil?
body = @calendar.fields[:body]
unless body.empty?
info[:data][:body] = body
info[:data][:info] += " - " unless info[:data][:info].empty?
- 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 45.
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
Method decode_content
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def decode_content(common_info, chunks)
stream = StringIO.new chunks.join
until stream.eof?
- 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 task
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def task(name, &block)
if name.kind_of?(Hash)
name.each do |alias_name, task_name|
raise("Undefined task `#{task_name}'") unless @@tasks[task_name.to_s]
@@tasks[alias_name.to_s] = @@tasks[task_name.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 service_failure
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def service_failure(service_name, reset = 0, action1 = "restart/60000", action2 = "restart/60000", action3 = "restart/60000")
Method require_component
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def require_component(name, opts = {})
$invocation_directory = Dir.pwd
$invocation_directory = ENV['CWD'] if ENV['CWD']
init_script = caller[0].scan(/^(.+)\:\d+\:.+$/)[0][0]
- 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 decode_additional_header
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def decode_additional_header(data)
raise EvidenceDeserializeError.new("incomplete PHOTO") if data.nil? or data.bytesize == 0
binary = StringIO.new data
- 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 decode_content
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def decode_content(common_info, chunks)
stream = StringIO.new chunks.join
output = stream.read
- 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 rm_rf
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def rm_rf(path, allow: [], check: true)
if localhost?
FileUtils.rm_rf(unixpath(path))
else
request("ruby -e 'require \"fileutils\"; FileUtils.rm_rf(\"#{unixpath(path)}\");'", exec: 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 decode_content
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def decode_content(common_info, chunks)
stream = StringIO.new chunks.join
until stream.eof?
info = Hash[common_info]
- 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 call
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.call(command, read: false)
command = "netsh advfirewall #{command.strip}"
unless exists?
raise "The Windows Firewall is missing. You cannot call the command #{command.inspect} on this OS."
- 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"