moneytrackio/tezos_client

View on GitHub

Showing 15 of 15 total issues

Class OperationMgr has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

  class OperationMgr
    include Crypto
    using CurrencyUtils

    attr_accessor :rpc_interface,
Severity: Minor
Found in lib/tezos_client/operation_mgr.rb - About 3 hrs to fix

    Class TezosClient has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class TezosClient
      module Crypto
        using StringUtils
    
        PREFIXES = {
    Severity: Minor
    Found in lib/tezos_client/crypto.rb - About 2 hrs to fix

      Method monitor_operation has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def monitor_operation(operation_id, timeout: 120)
          including_block = nil
      
          monitoring_thread = rpc_interface.monitor_block do |block_header|
            log "recently received block: #{block_header.pretty_inspect}"
      Severity: Minor
      Found in lib/tezos_client.rb - About 1 hr 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 create_logger has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def create_logger(param)
              return unless param
      
              if param.is_a? String
                if param == "stdout"
      Severity: Minor
      Found in lib/tezos_client/logger.rb - About 1 hr 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 treat_char has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def treat_char(char, is_last_char)
              return if treat_escape(char)
      
              unless popen || sopen
                if is_last_char || char == " "
      Severity: Minor
      Found in lib/tezos_client/encode_utils.rb - About 1 hr 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 treat_val has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def treat_val
              unless @val.empty?
                if @val == @val.to_i.to_s
                  if !ret[:prim]
                    @ret = { "int" => @val }
      Severity: Minor
      Found in lib/tezos_client/encode_utils.rb - About 1 hr 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 tezos_contents_log_filter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def tezos_contents_log_filter(content)
            if content.is_a? Array
              content.map { |el| tezos_contents_log_filter(el) }
            elsif content.is_a? Hash
              content.reduce({}) do |h, (k, v)|
      Severity: Minor
      Found in lib/tezos_client/logger.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 treat_parenthesis has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def treat_parenthesis(char)
              case char
              when "("
                @val += char if @popen
                @popen = true
      Severity: Minor
      Found in lib/tezos_client/encode_utils.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 decode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def decode
                if data.key?(:bytes)
                  if data[:bytes].start_with?("0000")
                    encode_tz(:tz1, data[:bytes][4..-1])
                  elsif data[:bytes].start_with?("0001")
      Severity: Minor
      Found in lib/tezos_client/tools/convert_to_hash/address.rb - About 45 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 treat_double_quote has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def treat_double_quote(char)
              return false unless char == '"'
      
              if @sopen
                @sopen = false
      Severity: Minor
      Found in lib/tezos_client/encode_utils.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 format_response has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def format_response(response)
                if response.is_a? Array
                  response.map do |el|
                    (el.is_a? Hash) ? el.with_indifferent_access : el
                  end
      Severity: Minor
      Found in lib/tezos_client/rpc_interface/request_manager.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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                def normalized_type
                  if type[:args].size > 2
                    {
                      prim: "pair",
                      args: [
      Severity: Minor
      Found in lib/tezos_client/tools/convert_to_hash/pair.rb and 1 other location - About 25 mins to fix
      lib/tezos_client/tools/convert_to_hash/pair.rb on lines 45..58

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 31.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                def normalized_data
                  if expanded_data[:args].size > 2
                    {
                      prim: "Pair",
                      args: [
      Severity: Minor
      Found in lib/tezos_client/tools/convert_to_hash/pair.rb and 1 other location - About 25 mins to fix
      lib/tezos_client/tools/convert_to_hash/pair.rb on lines 20..33

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 31.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Method block_include_operation? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def block_include_operation?(operation_id, block_id)
          retries ||= 0
      
          operations = rpc_interface.get("chains/main/blocks/#{block_id}/operation_hashes")
          operations.flatten.include? operation_id
      Severity: Minor
      Found in lib/tezos_client.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 data_n has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

                def data_n(n)
                  if data.is_a? ::Array
                    is_last_arg = n == (args_count - 1)
                    # Handle the case when last arg is i Pair, which arguments are the last elements of the data
                    if is_last_arg && data.size > args_count
      Severity: Minor
      Found in lib/tezos_client/tools/hash_to_micheline/pair.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