Showing 29 of 35 total issues
Method group_params
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
def self.group_params(params = {})
grouped_params = {}
params.each do |field, value|
# next if segment_from_hash(field.to_s, value, /ntp_(.+)/, :ntp, grouped_params)
- 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 camera_control
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
def camera_control(params)
params.all? do |key, value|
# validation
case key
when :resolution
- 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
Class Client
has 33 methods (exceeds 20 allowed). Consider refactoring. Open
class Client
# @!attribute [rw] connection
# @return [Faraday] The HTTP connection object to the camera
attr_accessor :connection
File client.rb
has 303 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "foscam/constants"
module Foscam
class Client
# @!attribute [rw] connection
Method segment_from_hash
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.segment_from_hash(str, value, regexp, new_key, dst = {}, &block)
# throw TypeError, "Argument 1 [str] is a #{str.class.to_s}. Expected a String." unless str.is_a?(String)
# throw TypeError, "Argument 3 [regexp] is a #{regexp.class.to_s}. Expected a Regexp/" unless regexp.is_a?(Regexp)
# throw TypeError, "Argument 4 [new_key] is a #{new_key.class.to_s}. Expected a String or Symbol." unless new_key.is_a?(String) || new_key.is_a?(Symbol)
# throw TypeError, "Argument 5 [dst] is a #{dst.class.to_s}. Expected a Hash" unless dst.is_a?(Hash)
- 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 camera_control
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def camera_control(params)
params.all? do |key, value|
# validation
case key
when :resolution
Method to_hash
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def to_hash
h = {}
h.merge!({:ntp_svr => self.ntp_svr }) unless ntp_svr.nil?
h.merge!({:ntp_enable => self.ntp_enable ? "1" : "0" }) unless ntp_enable.nil?
h.merge!({:now => self.time.to_i, :tz => -self.time.utc_offset }) unless time.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 to_hash
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def to_hash
result = [:ssid, :wpa_psk].inject({}) do |h, key|
h.merge!({key => send(key) }) unless send(key).nil?
h
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 dirty_params_hash
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def dirty_params_hash
h = {}
h.merge!({:motion_armed => self.motion_armed }) if motion_armed_changed?
h.merge!({:motion_sensitivity => self.motion_sensitivity }) if motion_sensitivity_changed?
h.merge!({:motion_compensation => self.motion_compensation }) if motion_compensation_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 set_misc
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def set_misc(params)
url_params = params.clone
[:ptz_patrol_rate, :ptz_patrol_up_rate, :ptz_patrol_down_rate, :ptz_patrol_left_rate, :ptz_patrol_right_rate].each do |key|
throw "invalid parameter value" if (url_params.has_key?(key) && (url_params[key].to_i < 0 || url_params[key].to_i > 100))
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 client=
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def client=(obj)
unless obj.nil?
MailServer::client = obj
params = client.get_params
unless params.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 set_id
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def set_id
flag = false
if @id.nil?
cam_params = client.get_params
unless cam_params.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 group_params
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.group_params(params = {})
grouped_params = {}
params.each do |field, value|
# next if segment_from_hash(field.to_s, value, /ntp_(.+)/, :ntp, grouped_params)
Method initialize
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def initialize(params = {})
self.days = {}
[:sunday, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday].each do |day|
abbrev = day.to_s[0..2]
bit0 = params.has_key?("#{abbrev}_0".to_sym) ? params["#{abbrev}_0".to_sym] : 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 segment_from_hash
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.segment_from_hash(str, value, regexp, new_key, dst = {}, &block)
Method busy_at?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def busy_at?(time)
time = time.to_time if time.is_a?(DateTime)
if time.sunday?
days[:sunday].busy_at?(time)
elsif time.monday?
- 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 get_forbidden
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_forbidden
response = @connection.get("get_forbidden.cgi")
params = response.success? ? parse_response(response) : {}
schedule = {}
unless params.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 connect
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def connect(params = {})
@url = params[:url] if params.has_key?(:url)
@username = params[:username] if params.has_key?(:username)
@password = params[:password] if params.has_key?(:password)
@connection = Faraday.new( :url => @url) unless @url.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 dirty_params_hash
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def dirty_params_hash
h = {}
h.merge!({:sender => self.sender}) if sender_changed?
h.merge!({:user => self.username}) if username_changed?
h.merge!({:pwd => self.password}) if password_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 save
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def save
run_callbacks :save do
flag = false
if changed? && is_valid?
@previously_changed = changes
- 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"