inertia186/radiator

View on GitHub

Showing 1,476 of 1,476 total issues

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

    def recover_transaction(signatures, expected_rpc_id, after)
      debug "Looking for signatures: #{signatures.map{|s| s[0..5]}} since: #{after}"
      
      count = 0
      start = Time.now.utc
Severity: Minor
Found in lib/radiator/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.

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

    def process(broadcast = false)
      prepare

      if broadcast
        loop do
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.

Method parse_error_response has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
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 - About 4 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 blocks is too high. [31/7]
Open

    def blocks(start = nil, mode = :irreversible, max_blocks_per_node = MAX_BLOCKS_PER_NODE, &block)
      reset_api
      
      replay = !!start
      counter = 0
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

Assignment Branch Condition size for recover_transaction is too high. [38.55/15]
Open

    def recover_transaction(signatures, expected_rpc_id, after)
      debug "Looking for signatures: #{signatures.map{|s| s[0..5]}} since: #{after}"
      
      count = 0
      start = Time.now.utc
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. [32/10]
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 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. [32/10]
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 if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Cyclomatic complexity for blocks is too high. [28/6]
Open

    def blocks(start = nil, mode = :irreversible, max_blocks_per_node = MAX_BLOCKS_PER_NODE, &block)
      reset_api
      
      replay = !!start
      counter = 0
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.

Assignment Branch Condition size for healthy? is too high. [36.62/15]
Open

    def healthy?(url)
      begin
        # Note, not all nodes support the /health uri.  But even if they don't,
        # they'll respond status code 200 OK, even if the body shows an error.
        
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 finalize has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
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 - About 4 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

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

    def method_names
      @method_names ||= [
        :head_block_number,
        :head_block_id,
        :time,
Severity: Minor
Found in lib/radiator/stream.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 parse_error_response has 98 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def parse_error_response
      if response.nil?
        @expiry = false
        @can_retry = false
        @can_reprepare = false
Severity: Major
Found in lib/radiator/error_parser.rb - About 3 hrs to fix

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

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

          def initialize(options = {})
            @root_url = options[:root_url] || 'https://api.steem-engine.net/rpc'
            
            @self_hashie_logger = false
            @hashie_logger = if options[:hashie_logger].nil?

    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.

    Assignment Branch Condition size for request is too high. [34.34/15]
    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 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. [28/10]
    Open

        def send_log(level, obj, prefix = nil)
          log_message = case obj
          when String
            log_message = if !!prefix
              "#{prefix} :: #{obj}"
    Severity: Minor
    Found in lib/radiator/utils.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 blocks has 94 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def blocks(start = nil, mode = :irreversible, max_blocks_per_node = MAX_BLOCKS_PER_NODE, &block)
          reset_api
          
          replay = !!start
          counter = 0
    Severity: Major
    Found in lib/radiator/stream.rb - About 3 hrs to fix

      Cyclomatic complexity for parse_error_response is too high. [23/6]
      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 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 has too many lines. [27/10]
      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 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. [27/10]
      Open

          def healthy?(url)
            begin
              # Note, not all nodes support the /health uri.  But even if they don't,
              # they'll respond status code 200 OK, even if the body shows an error.
              
      Severity: Minor
      Found in lib/radiator/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.

      Severity
      Category
      Status
      Source
      Language