zold-io/zold

View on GitHub
lib/zold/commands/merge.rb

Summary

Maintainability
C
1 day
Test Coverage

Method merge_one has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def merge_one(opts, patch, wallet, name, baseline: false, master: false)
      start = Time.now
      @log.debug("Adding copy ##{name}#{master ? ' (master)' : ''} to the patch #{wallet.mnemo}...")
      if opts['depth'].positive?
        patch.join(wallet, ledger: opts['ledger'], baseline: baseline, master: master) do |txn|
Severity: Minor
Found in lib/zold/commands/merge.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 merge has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def merge(id, cps, opts)
      start = Time.now
      cps = cps.all(masters_first: !opts['edge-baseline'])
      patch = Patch.new(@wallets, log: @log)
      score = 0
Severity: Minor
Found in lib/zold/commands/merge.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 run has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run(args = [])
      opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
        o.banner = "Usage: zold merge [ID...] [options]
Available options:"
        o.bool '--skip-propagate',
Severity: Minor
Found in lib/zold/commands/merge.rb - About 1 hr to fix

    Method merge has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def merge(id, cps, opts)
          start = Time.now
          cps = cps.all(masters_first: !opts['edge-baseline'])
          patch = Patch.new(@wallets, log: @log)
          score = 0
    Severity: Minor
    Found in lib/zold/commands/merge.rb - About 1 hr to fix

      Method merge_one has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def merge_one(opts, patch, wallet, name, baseline: false, master: false)
            start = Time.now
            @log.debug("Adding copy ##{name}#{master ? ' (master)' : ''} to the patch #{wallet.mnemo}...")
            if opts['depth'].positive?
              patch.join(wallet, ledger: opts['ledger'], baseline: baseline, master: master) do |txn|
      Severity: Minor
      Found in lib/zold/commands/merge.rb - About 1 hr to fix

        Method run has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def run(args = [])
              opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
                o.banner = "Usage: zold merge [ID...] [options]
        Available options:"
                o.bool '--skip-propagate',
        Severity: Minor
        Found in lib/zold/commands/merge.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

        There are no issues that match your filters.

        Category
        Status