voxable-labs/hg

View on GitHub

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
Severity: Minor
Found in app/workers/hg/message_worker.rb - About 5 hrs to fix

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
Severity: Minor
Found in lib/hg/chunk.rb - About 3 hrs to fix

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
Severity: Major
Found in app/workers/hg/message_worker.rb - About 2 hrs to fix

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
Severity: Minor
Found in lib/hg/api_ai_client.rb - About 1 hr to fix

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
Severity: Minor
Found in lib/hg/chunk.rb - About 1 hr to fix

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
Severity: Minor
Found in lib/hg/api_ai_client.rb - About 1 hr to fix

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'])
Severity: Minor
Found in lib/hg/messenger/bot.rb - About 1 hr to fix

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
}
Severity: Minor
Found in lib/hg/chunk.rb - About 1 hr to fix

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)
Severity: Minor
Found in lib/hg/chunk.rb - About 1 hr to fix

Avoid deeply nested control flow statements.
Open

if ENV['CHATBASE_API_KEY']
@client.set_chatbase_fields(
request.action,
message.text,
false)
Severity: Major
Found in app/workers/hg/message_worker.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

@client.set_chatbase_fields(
request.intent,
message.text,
false
) if ENV['CHATBASE_API_KEY']
Severity: Major
Found in app/workers/hg/message_worker.rb - About 45 mins to fix

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)
Severity: Major
Found in app/workers/hg/message_worker.rb - About 45 mins to fix

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
}
Severity: Minor
Found in lib/hg/chunk.rb - About 35 mins to fix

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
Severity: Minor
Found in app/workers/hg/postback_worker.rb - About 35 mins to fix

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
Severity: Minor
Found in lib/hg/chunk.rb - About 25 mins to fix

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'])
Severity: Minor
Found in lib/hg/messenger/bot.rb - About 25 mins to fix
Severity
Category
Status
Source
Language