zold-io/zold-stress

View on GitHub

Showing 5 of 7 total issues

Method send has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def send
      raise 'Too few wallets in the pool' if @wallets.all.count < 2
      paid = []
      all = @wallets.all
      Tempfile.open do |f|
Severity: Minor
Found in lib/zold/stress/pmnts.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

Method send has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def send
      start = Time.now
      sent = Zold::Stress::Pmnts.new(
        pvt: @pvt, wallets: @wallets,
        remotes: @remotes, stats: @stats,
Severity: Minor
Found in lib/zold/stress/round.rb - About 1 hr to fix

    Method match has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def match
          total = 0
          @air.fetch.each do |p|
            next unless @wallets.acq(p[:target], &:exists?)
            t = @wallets.acq(p[:target], &:txns).find { |x| x.details == p[:details] && x.bnf == p[:source] }
    Severity: Minor
    Found in lib/zold/stress/round.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 to_s has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_s
          [
            "#{tps.round(2)} tps",
            %w[update push pull paid arrived].map do |m|
              if @stats.exists?(m)
    Severity: Minor
    Found in lib/zold/stress/summary.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 put has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def put(metric, value)
          raise "Invalid type of \"#{value}\" (#{value.class.name})" unless value.is_a?(Integer) || value.is_a?(Float)
          @mutex.synchronize do
            @history[metric] = [] unless @history[metric]
            @history[metric] << { time: Time.now, value: value }
    Severity: Minor
    Found in lib/zold/stress/stats.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