zold-io/zold

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

Summary

Maintainability
D
2 days
Test Coverage

Method run has 95 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 remote <command> [options]
Available commands:
    #{Rainbow('remote show').green}
Severity: Major
Found in lib/zold/commands/remote.rb - About 3 hrs to fix

    File remote.rb has 313 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'slop'
    require 'semantic'
    require 'rainbow'
    require 'net/http'
    require 'json'
    Severity: Minor
    Found in lib/zold/commands/remote.rb - About 3 hrs to fix

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

          def update(opts)
            st = Time.now
            seen = Set.new
            capacity = []
            opts['depth'].times do
      Severity: Minor
      Found in lib/zold/commands/remote.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 update has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def update(opts)
            st = Time.now
            seen = Set.new
            capacity = []
            opts['depth'].times do
      Severity: Minor
      Found in lib/zold/commands/remote.rb - About 1 hr to fix

        Method elect has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def elect(opts)
              scores = []
              @remotes.iterate(@log, farm: @farm, threads: opts['threads']) do |r|
                uri = '/'
                res = r.http(uri).get
        Severity: Minor
        Found in lib/zold/commands/remote.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 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 remote <command> [options]
        Available commands:
            #{Rainbow('remote show').green}
        Severity: Minor
        Found in lib/zold/commands/remote.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 show has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def show
              @remotes.all.each do |r|
                score = Rainbow("/#{r[:score]}").color(r[:score].positive? ? :green : :red)
                @log.info(
                  [
        Severity: Minor
        Found in lib/zold/commands/remote.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 reboot has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def reboot(r, json, opts)
              return unless json['repo'] == Zold::REPO
              mine = Semantic::Version.new(VERSION)
              if mine < Semantic::Version.new(json['version'])
                if opts['reboot']
        Severity: Minor
        Found in lib/zold/commands/remote.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 select has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def select(opts)
              @remotes.all.shuffle.sort_by { |r| r[:errors] }.reverse.each_with_index do |r, idx|
                next if idx < opts['max-nodes']
                next if r[:master] && !opts['masters-too']
                @remotes.remove(r[:host], r[:port])
        Severity: Minor
        Found in lib/zold/commands/remote.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 add has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def add(host, port, opts)
              if opts['ignore-node'].include?("#{host}:#{port}")
                @log.debug("#{host}:#{port} won't be added since it's in the --ignore-node list")
                return
              end
        Severity: Minor
        Found in lib/zold/commands/remote.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 trim has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def trim(opts)
              all = @remotes.all
              all.each do |r|
                next if r[:errors] <= opts['tolerate']
                @remotes.remove(r[:host], r[:port]) if !opts['masters-too'] || !r[:master]
        Severity: Minor
        Found in lib/zold/commands/remote.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

        There are no issues that match your filters.

        Category
        Status