Showing 39 of 53 total issues
Class CorpApi
has 49 methods (exceeds 20 allowed). Consider refactoring. Open
class CorpApi < ApiBase
attr_reader :agentid
def initialize(appid, secret, token_file, agentid, network_setting, jsapi_ticket_file)
super()
Class Message
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
class Message
class << self
def from_hash(message_hash)
new(message_hash)
end
Method loading_config!
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private_class_method def self.loading_config!
configs = config_from_file || config_from_environment
configs.merge!(config_from_db)
configs.transform_keys! do |key|
- 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 load_controller_wechat
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def load_controller_wechat(account, opts = {})
cfg = Wechat.config(account)
self.token = opts[:token] || cfg.token
self.appid = opts[:appid] || cfg.appid
self.corpid = opts[:corpid] || cfg.corpid
- 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
File responder.rb
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'English'
require 'rexml/document'
module Wechat
module Responder
Method on
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def on(message_type, with: nil, respond: nil, &block)
config = respond.nil? ? {} : { respond: respond }
config[:proc] = block if block_given?
if with.present?
- 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 config_from_file
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private_class_method def self.config_from_file
if defined?(::Rails)
config_file = ENV.fetch('WECHAT_CONF_FILE') { Rails.root.join('config', 'wechat.yml') }
resolve_config_file(config_file, Rails.env.to_s)
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 responder_for
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def responder_for(message)
message_type = message[:MsgType].to_sym
responders = user_defined_responders(message_type)
case message_type
- 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 resolve_config_file
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private_class_method def self.resolve_config_file(config_file, env)
return unless File.exist?(config_file)
begin
raw_data = load_yaml(ERB.new(File.read(config_file)).result)
- 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 deep_recursive
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def deep_recursive(hash, &block)
hash.inject({}) do |memo, val|
key, value = *val
case value.class.name
when 'Hash'
- 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 match_responders
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def match_responders(responders, value)
matched = responders.each_with_object({}) do |responder, memo|
condition = responder[:with]
if condition.nil?
- 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_response
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_response(response, as_type)
content_type = response.headers[:content_type]
parse_as = {
%r{^application/json} => :json,
%r{^image/.*} => :file,
Method loading_config!
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private_class_method def self.loading_config!
configs = config_from_file || config_from_environment
configs.merge!(config_from_db)
configs.transform_keys! do |key|
Method on
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def on(message_type, with: nil, respond: nil, &block)
config = respond.nil? ? {} : { respond: respond }
config[:proc] = block if block_given?
if with.present?
Method request
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def request(path, header = {}, &_block)
url_base = header.delete(:base) || base
as = header.delete(:as)
header['Accept'] ||= 'application/json'
response = yield("#{url_base}#{path}", header)
- 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 wechat_config_js
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def wechat_config_js(config_options = {})
account = config_options[:account]
# Get domain_name, api and app_id
if account.blank? || account == controller.class.wechat_cfg_account
Method responder_for
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def responder_for(message)
message_type = message[:MsgType].to_sym
responders = user_defined_responders(message_type)
case message_type
Method get_wechat_api
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_wechat_api(api_type, corpid, appid, secret, access_token, agentid, network_setting, jsapi_ticket, qcloud_setting)
Method with
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.with(options)
account = options[:account] || :default
c = ApiLoader.config(account)
token_file = options[:token_file] || c.access_token.presence || '/var/tmp/wechat_access_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 load_controller_wechat
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def load_controller_wechat(account, opts = {})
cfg = Wechat.config(account)
self.token = opts[:token] || cfg.token
self.appid = opts[:appid] || cfg.appid
self.corpid = opts[:corpid] || cfg.corpid