lib/oxidized/hook/xmppdiff.rb
Method run_hook
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
def run_hook(ctx)
return unless ctx.node
return unless ctx.event.to_s == "post_store"
begin
- 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 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def connect
@client = Jabber::Client.new(Jabber::JID.new(cfg.jid))
log "Connecting to XMPP"
begin
Method validate_cfg!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def validate_cfg!
raise KeyError, 'hook.jid is required' unless cfg.has_key?('jid')
raise KeyError, 'hook.password is required' unless cfg.has_key?('password')
raise KeyError, 'hook.channel is required' unless cfg.has_key?('channel')
raise KeyError, 'hook.nick is required' unless cfg.has_key?('nick')
- 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"