inertia186/radiator

View on GitHub

Showing 1,476 of 1,476 total issues

Method has too many lines. [26/10]
Open

      def request(options)
        request = post_request
        skip_health_check = options.delete(:skip_health_check)
        request.body = JSON[options.merge(jsonrpc: '2.0', id: rpc_id)]
        

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method handle_error has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def handle_error(response, request_options, method_name, tries)
      parser = ErrorParser.new(response)
      _signatures, exp = extract_signatures(request_options)
      
      if (!!exp && exp < Time.now.utc) || (tries > 2 && !parser.node_degraded?)
Severity: Minor
Found in lib/radiator/api.rb - About 3 hrs 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

Perceived complexity for parse_error_response is too high. [22/7]
Open

    def parse_error_response
      if response.nil?
        @expiry = false
        @can_retry = false
        @can_reprepare = false
Severity: Minor
Found in lib/radiator/error_parser.rb by rubocop

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Perceived complexity for initialize is too high. [22/7]
Open

    def initialize(options = {})
      @user = options[:user]
      @password = options[:password]
      @chain = (options[:chain] || 'hive').to_sym
      @url = options[:url] || Api::default_url(@chain)
Severity: Minor
Found in lib/radiator/api.rb by rubocop

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

File stream.rb has 309 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Radiator
  # Radiator::Stream allows a live view of the STEEM blockchain.
  # 
  # All values returned by `get_dynamic_global_properties` can be streamed.
  # 
Severity: Minor
Found in lib/radiator/stream.rb - About 3 hrs to fix

    Assignment Branch Condition size for shutdown is too high. [29.58/15]
    Open

        def shutdown
          @uri = nil
          @http_id = nil
          @http_memo.each do |k|
            v = @http_memo.delete(k)
    Severity: Minor
    Found in lib/radiator/api.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for default_failover_urls is too high. [28.37/15]
    Open

        def self.default_failover_urls(chain)
          case chain.to_sym
          when :steem, :hive
            begin
              _api = Radiator::Api.new(url: DEFAULT_HIVE_FAILOVER_URLS.sample, failover_urls: DEFAULT_HIVE_FAILOVER_URLS)
    Severity: Minor
    Found in lib/radiator/api.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for finalize is too high. [27.89/15]
    Open

        def self.finalize(api, network_broadcast_api, self_logger, logger)
          proc {
            if !!api && !api.stopped?
              puts "DESTROY: #{api.inspect}" if ENV['LOG'] == 'TRACE'
              api.shutdown
    Severity: Minor
    Found in lib/radiator/transaction.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for http is too high. [27.59/15]
    Open

        def http
          return @http_memo[http_id] if @http_memo.keys.include? http_id
          
          @http_memo[http_id] = if @persist && @persist_error_count < 10
            idempotent = api_name != :network_broadcast_api
    Severity: Minor
    Found in lib/radiator/api.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [22/10]
    Open

        def method_names
          @method_names ||= [
            :normalize_post,
            :get_post_header,
            :get_discussion,
    Severity: Minor
    Found in lib/radiator/bridge.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Method has too many lines. [22/10]
    Open

        def method_names
          @method_names ||= [
            :get_trending_tags,
            :get_tags_used_by_author,
            :get_discussion,
    Severity: Minor
    Found in lib/radiator/tag_api.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Perceived complexity for operations is too high. [19/7]
    Open

        def operations(type = nil, start = nil, mode = :irreversible, options = {include_virtual: false}, &block)
          type = [type].flatten.compact.map(&:to_sym)
          include_virtual = !!options[:include_virtual]
          
          if virtual_op_type?(type)
    Severity: Minor
    Found in lib/radiator/stream.rb by rubocop

    This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

    Example:

    def my_method                   # 1
      if cond                       # 1
        case var                    # 2 (0.8 + 4 * 0.2, rounded)
        when 1 then func_one
        when 2 then func_two
        when 3 then func_three
        when 4..10 then func_other
        end
      else                          # 1
        do_something until a && b   # 2
      end                           # ===
    end                             # 7 complexity points

    Method has too many lines. [21/10]
    Open

        def self.finalize(api, network_broadcast_api, self_logger, logger)
          proc {
            if !!api && !api.stopped?
              puts "DESTROY: #{api.inspect}" if ENV['LOG'] == 'TRACE'
              api.shutdown
    Severity: Minor
    Found in lib/radiator/transaction.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Perceived complexity for prepare is too high. [18/7]
    Open

        def prepare
          raise TransactionError, "No wif or private key." unless !!@wif || !!@private_key
    
          @payload = nil
    
    
    Severity: Minor
    Found in lib/radiator/transaction.rb by rubocop

    This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

    Example:

    def my_method                   # 1
      if cond                       # 1
        case var                    # 2 (0.8 + 4 * 0.2, rounded)
        when 1 then func_one
        when 2 then func_two
        when 3 then func_three
        when 4..10 then func_other
        end
      else                          # 1
        do_something until a && b   # 2
      end                           # ===
    end                             # 7 complexity points

    Assignment Branch Condition size for http is too high. [26.17/15]
    Open

          def http
            @http ||= if persist?
              if defined? Net::HTTP::Persistent::DEFAULT_POOL_SIZE
                Net::HTTP::Persistent.new(name: http_id, pool_size: @pool_size).tap do |http|
                  http.keep_alive = 30

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Cyclomatic complexity for operations is too high. [17/6]
    Open

        def operations(type = nil, start = nil, mode = :irreversible, options = {include_virtual: false}, &block)
          type = [type].flatten.compact.map(&:to_sym)
          include_virtual = !!options[:include_virtual]
          
          if virtual_op_type?(type)
    Severity: Minor
    Found in lib/radiator/stream.rb by rubocop

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    Method default_failover_urls has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.default_failover_urls(chain)
          case chain.to_sym
          when :steem, :hive
            begin
              _api = Radiator::Api.new(url: DEFAULT_HIVE_FAILOVER_URLS.sample, failover_urls: DEFAULT_HIVE_FAILOVER_URLS)
    Severity: Minor
    Found in lib/radiator/api.rb - About 2 hrs 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

    Cyclomatic complexity for prepare is too high. [16/6]
    Open

        def prepare
          raise TransactionError, "No wif or private key." unless !!@wif || !!@private_key
    
          @payload = nil
    
    
    Severity: Minor
    Found in lib/radiator/transaction.rb by rubocop

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    Assignment Branch Condition size for process is too high. [25.96/15]
    Open

        def process(broadcast = false)
          prepare
    
          if broadcast
            loop do
    Severity: Minor
    Found in lib/radiator/transaction.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [20/10]
    Open

        def coerce_backtrace
          can_retry = false
          
          case @error['code']
          when -32003
    Severity: Minor
    Found in lib/radiator/error_parser.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Severity
    Category
    Status
    Source
    Language