Eric-Guo/wechat

View on GitHub

Showing 39 of 53 total issues

Method run_responder has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def run_responder(request)
      self.class.responder_for(request) do |responder, *args|
        responder ||= self.class.user_defined_responders(:fallback).first

        next if responder.nil?
Severity: Minor
Found in lib/wechat/responder.rb - About 55 mins to fix

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_oauth2 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def wechat_oauth2(scope = 'snsapi_base', page_url = nil, account = nil, &block)
      # ensure wechat initialization
      self.class.corpid || self.class.appid || self.class.wechat

      api = wechat(account)
Severity: Minor
Found in lib/wechat/controller_api.rb - About 55 mins to fix

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 app_config_is_valid has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def app_config_is_valid
    if self[:appid].present?
      # public account
      errors.add(:secret, 'cannot be nil when appid is set') if self[:secret].blank?
    elsif self[:corpid].present?
Severity: Minor
Found in lib/generators/wechat/templates/app/models/wechat_config.rb - About 55 mins to fix

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 a Cognitive Complexity of 9 (exceeds 5 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,
Severity: Minor
Found in lib/wechat/http_client.rb - About 55 mins to fix

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 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def initialize(appid, secret, token_file, network_setting, jsapi_ticket_file, record = nil)
Severity: Minor
Found in lib/wechat/api.rb - About 45 mins to fix

    Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def initialize(appid, secret, token_file, agentid, network_setting, jsapi_ticket_file)
    Severity: Minor
    Found in lib/wechat/corp_api.rb - About 45 mins to fix

      Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def initialize(timeout, skip_verify_ssl, proxy_url, proxy_port, proxy_username, proxy_password)
      Severity: Minor
      Found in lib/wechat/network_setting.rb - About 45 mins to fix

        Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def initialize(appid, secret, token_file, network_setting, jsapi_ticket_file, qcloud_setting)
        Severity: Minor
        Found in lib/wechat/mp_api.rb - About 45 mins to fix

          Method tcb_do_upload_file has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                def tcb_do_upload_file(q_path, upload_url, signature, x_cos_security_token, x_cos_meta_fileid, file)
          Severity: Minor
          Found in lib/wechat/concern/qcloud.rb - About 45 mins to fix

            Method news_message_send has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def news_message_send(userid, title, description, link_url, pic_url)
            Severity: Minor
            Found in lib/wechat/corp_api.rb - About 35 mins to fix

              Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                    def initialize(client, appid, secret, token_file, record = nil)
              Severity: Minor
              Found in lib/wechat/token/access_token_base.rb - About 35 mins to fix

                Method ticket has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                      def ticket(tries = 2)
                        # Possible two worker running, one worker refresh ticket, other unaware, so must read every time
                        read_ticket_from_store
                        refresh if remain_life_seconds < @random_generator.rand(30..(3 * 60))
                        access_ticket
                Severity: Minor
                Found in lib/wechat/ticket/jsapi_base.rb - About 35 mins to fix

                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 token has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                      def token(tries = 2)
                        # Possible two worker running, one worker refresh ticket, other unaware, so must read every time
                        read_qcloud_token_from_store
                        refresh if remain_life_seconds < @random_generator.rand(30..(3 * 60))
                        qcloud_token
                Severity: Minor
                Found in lib/wechat/qcloud/token.rb - About 35 mins to fix

                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 post_body has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def post_body
                      if request.media_type == 'application/json'
                        data_hash = params
                
                        if @we_encrypt_mode && data['Encrypt'].present?
                Severity: Minor
                Found in lib/wechat/responder.rb - About 35 mins to fix

                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 with_access_token has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def with_access_token(params = {}, tries = 2)
                      params ||= {}
                      yield(params.merge(access_token: access_token.token))
                    rescue AccessTokenExpiredError
                      access_token.refresh
                Severity: Minor
                Found in lib/wechat/api_base.rb - About 25 mins to fix

                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 missing_necessary_attributes? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                      def missing_necessary_attributes?
                        return true unless record.respond_to?(:access_token)
                        return true unless record.respond_to?(:token_expires_in)
                        return true unless record.respond_to?(:got_token_at)
                
                
                Severity: Minor
                Found in lib/wechat/token/access_token_base.rb - About 25 mins to fix

                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 a Cognitive Complexity of 6 (exceeds 5 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
                Severity: Minor
                Found in lib/wechat/helpers.rb - About 25 mins to fix

                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 known_scan_with_match_responders has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                      def known_scan_with_match_responders(responders, message)
                        matched = responders.each_with_object({}) do |responder, memo|
                          if %w[scan subscribe].freeze.include?(message[:Event]) && message[:EventKey] == responder[:with]
                            memo[:scaned] ||= [responder, message[:Ticket]]
                          elsif %w[scancode_push scancode_waitmsg].freeze.include?(message[:Event]) && message[:EventKey] == responder[:with]
                Severity: Minor
                Found in lib/wechat/responder.rb - About 25 mins to fix

                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 verify_signature has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def verify_signature
                      if @we_encrypt_mode
                        signature = params[:signature] || params[:msg_signature]
                        msg_encrypt = params[:echostr] || request_encrypt_content
                      else
                Severity: Minor
                Found in lib/wechat/responder.rb - About 25 mins to fix

                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

                Severity
                Category
                Status
                Source
                Language