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
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 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 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"