Showing 16 of 436 total issues
Method perform
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def perform(user_id, redis_namespace, bot_class_name)
# Retrieve the latest message for this user.
raw_message = pop_raw_message(user_id, redis_namespace)
# Do nothing if no message available. This could be due to multiple
- Read upRead up
- Create a ticketCreate a ticket
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
File chunk.rb
has 317 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Hg
module Chunk
def self.included(base)
base.extend ClassMethods
base.prepend Initializer
- Create a ticketCreate a ticket
Method perform
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform(user_id, redis_namespace, bot_class_name)
# Retrieve the latest message for this user.
raw_message = pop_raw_message(user_id, redis_namespace)
# Do nothing if no message available. This could be due to multiple
- Create a ticketCreate a ticket
Method query
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def query(message, context_name: nil)
# TODO: which logger?
retry_counter = 0
begin
- Create a ticketCreate a ticket
Method button
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def button(text, options = {})
# TODO: text needs a better name
# If the first argument is a chunk, then make this button a link to that chunk
if text.is_a? Class
klass = text
- Create a ticketCreate a ticket
Method query
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def query(message, context_name: nil)
# TODO: which logger?
retry_counter = 0
begin
- Read upRead up
- Create a ticketCreate a ticket
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 initialize_message_handlers
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize_message_handlers
::Facebook::Messenger::Bot.on :postback do |postback|
begin
# Show a typing indicator to the user
show_typing(postback.sender['id'])
- Create a ticketCreate a ticket
Method quick_reply
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def quick_reply(title, options = {})
quick_reply_content = {
content_type: 'text',
title: title
}
- Create a ticketCreate a ticket
Method deliver
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def deliver
Sidekiq::Logging.logger.info 'DELIVERABLES'
self.class.deliverables.each do |deliverable|
if deliverable.is_a? Hash
Sidekiq::Logging.logger.info JSON.pretty_generate(deliverable)
- Read upRead up
- Create a ticketCreate a ticket
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
Avoid deeply nested control flow statements. Open
if ENV['CHATBASE_API_KEY']
if !nlu_response[:intent] || request.intent == 'Default'
@client.not_handled = true
else
@client.set_chatbase_fields(request.intent, message.text, false)
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
@client.set_chatbase_fields(
request.intent,
message.text,
false
) if ENV['CHATBASE_API_KEY']
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if ENV['CHATBASE_API_KEY']
@client.set_chatbase_fields(
request.action,
message.text,
false)
- Create a ticketCreate a ticket
Method quick_reply
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def quick_reply(title, options = {})
quick_reply_content = {
content_type: 'text',
title: title
}
- Read upRead up
- Create a ticketCreate a ticket
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 7 (exceeds 5 allowed). Consider refactoring. Open
def perform(user_id, redis_namespace, bot_class_name)
# Retrieve the latest postback for this user
raw_postback = pop_raw_postback(user_id, redis_namespace)
# Do nothing if no postback available. This could be due to multiple
- Read upRead up
- Create a ticketCreate a ticket
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 button
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def button(text, options = {})
# TODO: text needs a better name
# If the first argument is a chunk, then make this button a link to that chunk
if text.is_a? Class
klass = text
- Read upRead up
- Create a ticketCreate a ticket
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 initialize_message_handlers
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize_message_handlers
::Facebook::Messenger::Bot.on :postback do |postback|
begin
# Show a typing indicator to the user
show_typing(postback.sender['id'])
- Read upRead up
- Create a ticketCreate a ticket
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"