File telegram_helper.rb
has 645 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'telegram/bot'
class TelegramHelper
attr_accessor :client
Method to_article
has 199 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_article(params, user, ticket, channel, article = nil)
if article
Rails.logger.debug { 'Update article from message...' }
else
Method to_article
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def to_article(params, user, ticket, channel, article = nil)
if article
Rails.logger.debug { 'Update article from message...' }
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"
Further reading
Method to_group
has 125 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_group(params, group_id, channel)
# begin import
Rails.logger.debug { 'import message' }
# map channel_post params to message
Method to_ticket
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def to_ticket(params, user, group_id, channel)
UserInfo.current_user_id = user.id
Rails.logger.debug { 'Create ticket from message...' }
Rails.logger.debug { params.inspect }
- 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 message_id
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def self.message_id(params)
message_id = nil
%i[message edited_message].each do |key|
next if !params[key]
next if !params[key][:message_id]
- 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_group
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def to_group(params, group_id, channel)
# begin import
Rails.logger.debug { 'import message' }
# map channel_post params to message
- 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_ticket
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_ticket(params, user, group_id, channel)
UserInfo.current_user_id = user.id
Rails.logger.debug { 'Create ticket from message...' }
Rails.logger.debug { params.inspect }
Method bot_duplicate?
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.bot_duplicate?(bot_id, channel_id = nil)
Channel.where(area: 'Telegram::Bot').each do |channel|
next if !channel.options
next if !channel.options[:bot]
next if !channel.options[:bot][:id]
- 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_or_update_channel
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.create_or_update_channel(token, params, channel = nil)
# verify token
bot = check_token(token)
Method to_user
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_user(params)
Rails.logger.debug { 'Create user from message...' }
Rails.logger.debug { params.inspect }
# do message_user lookup
Method bot_by_bot_id
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.bot_by_bot_id(bot_id)
Channel.where(area: 'Telegram::Bot').each do |channel|
next if !channel.options
next if !channel.options[:bot]
next if !channel.options[:bot][:id]
- 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_or_update_channel
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.create_or_update_channel(token, params, channel = nil)
# verify token
bot = check_token(token)
- 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_article
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def to_article(params, user, ticket, channel, article = nil)
Method to_user
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def to_user(params)
Rails.logger.debug { 'Create user from message...' }
Rails.logger.debug { params.inspect }
# do message_user lookup
- 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
Avoid too many return
statements within this method. Open
return article
Avoid too many return
statements within this method. Open
return if !ticket
Avoid too many return
statements within this method. Open
return
Avoid too many return
statements within this method. Open
return if !channel.options[:goodbye]
Avoid too many return
statements within this method. Open
return article
Avoid too many return
statements within this method. Open
return