Showing 18 of 18 total issues
Class AppRunner
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class AppRunner
extend Reflectable
include Reflectable
class << self
Method sleep
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def sleep(timeout)
read_ports = [@sleep_reader]
read_ports << @udp_wakeup if @udp_wakeup
rs, = IO.select(read_ports, nil, nil, timeout) rescue nil
- 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 as_json
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def as_json
json = ActiveSupport::OrderedHash.new
if attributes_for_device && attributes_for_device.key?(MDM_KEY)
json['mdm'] = attributes_for_device[MDM_KEY]
- 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 up
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.up
add_column :rapns_notifications, :type, :string, :null => true
add_column :rapns_apps, :type, :string, :null => true
AddGcm::Rapns::Notification.update_all :type => 'Rapns::Apns::Notification'
Method process
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def process(failure_partitions = {})
@successes = []
@failures = Failures.new
failure_partitions.each_key do |category|
failures[category] = []
- 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
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def write(data)
reconnect_idle if idle_period_exceeded?
retry_count = 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 create_gcm_like_notification
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_gcm_like_notification(notification, attrs, data, registration_ids, deliver_after, app)
Method create_adm_notification
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_adm_notification(attrs, data, registration_ids, deliver_after, app)
Method mark_failed
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def mark_failed(notification, code, description, time, opts = {})
Method create_gcm_notification
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_gcm_notification(attrs, data, registration_ids, deliver_after, app)
Similar blocks of code found in 2 locations. Consider refactoring. Open
class TooManyRequestsError < StandardError
attr_reader :code, :description, :response
def initialize(code, notification_id, description, response)
@code = code
- 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 36.
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
class RetryableError < StandardError
attr_reader :code, :description, :response
def initialize(code, notification_id, description, response)
@code = code
- 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 36.
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 alert
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def alert
string_or_json = read_attribute(:alert)
if has_attribute?(:alert_is_json)
if alert_is_json?
- 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_for_error
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check_for_error
if @connection.select(SELECT_TIMEOUT)
error = nil
if tuple = @connection.read(ERROR_TUPLE_BYTES)
- 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 perform
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def perform
begin
@notification.registration_ids.each do |registration_id|
handle_response(do_post(registration_id), registration_id)
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 setup_logger
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def setup_logger(log)
if Rapns.config.logger
@logger = Rapns.config.logger
elsif ActiveSupport.const_defined?('BufferedLogger')
@logger = ActiveSupport::BufferedLogger.new(log, Rails.logger.level)
- 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 daemonize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.daemonize
if RUBY_VERSION < "1.9"
exit if fork
Process.setsid
exit if fork
- 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 alert=
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def alert=(alert)
if alert.is_a?(Hash)
write_attribute(:alert, multi_json_dump(alert))
self.alert_is_json = true if has_attribute?(:alert_is_json)
else
- 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"