Showing 16 of 16 total issues
File client.rb
has 348 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "rqrcode"
require "logger"
require "uri"
module WeChat::Bot
Class Client
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class Client
def initialize(bot)
@bot = bot
clone!
end
Class Contact
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Contact
# 联系人分类
module Kind
User = :user
Group = :group
Method start_runloop_thread
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def start_runloop_thread
@is_alive = true
retry_count = 0
Thread.new do
- 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 start
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def start
@client.login
@client.contacts
@contact_list.each do |c|
- 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 default_config
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.default_config
{
# Bot Configurations
verbose: false,
fireman: 'filehelper',
Method login
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def login
return @bot.logger.info("你已经登录") if logged?
check_count = 0
until logged?
- 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 sync_messages
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def sync_messages
query = {
"sid" => store(:sid),
"skey" => store(:skey),
"pass_ticket" => store(:pass_ticket)
- 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 login
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def login
return @bot.logger.info("你已经登录") if logged?
check_count = 0
until logged?
Method start_runloop_thread
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def start_runloop_thread
@is_alive = true
retry_count = 0
Thread.new do
Method sync_messages
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def sync_messages
query = {
"sid" => store(:sid),
"skey" => store(:skey),
"pass_ticket" => store(:pass_ticket)
Method dispatch
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def dispatch(event, message = nil, *args)
threads = []
if handlers = find(event, message)
already_run = Set.new
- 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 find
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def find(**args)
@mutex.synchronize do
return @cache[args[:username]] if args[:username]
if args[:nickname]
- 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 initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(bot, event, pattern, options = {}, &block)
Method store
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def store(*args)
return @store[args[0].to_sym] = args[1] if args.size == 2
if args.size == 1
obj = args[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 parse
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def parse(raw, update = false)
@raw = raw
parse_kind
parse_members
- 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"