ytti/oxidized

View on GitHub

Showing 43 of 102 total issues

Method work has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def work
      ended = []
      @jobs.delete_if { |job| ended << job unless job.alive? }
      ended.each      { |job| process job }
      @jobs.work
Severity: Minor
Found in lib/oxidized/worker.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 credentials has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def credentials(node)
    Proc.new do |_url, username_from_url, _allowed_types| # rubocop:disable Style/Proc
      git_user = cfg.has_key?('username') ? cfg.username : (username_from_url || 'git')
      if cfg.has_key?('password')
        log "Authenticating using username and password as '#{git_user}'", :debug
Severity: Minor
Found in lib/oxidized/hook/githubrepo.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 validate_cfg! has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_cfg!
    # Syntax check
    if cfg.has_key? "timeout"
      @timeout = cfg.timeout
      raise "invalid timeout value" unless @timeout.is_a?(Integer) &&
Severity: Minor
Found in lib/oxidized/hook/exec.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 clean has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def clean(cfg)
    out = []
    cfg.each_line do |line|
      next if line =~ /date \d{4}:\d{2}:\d{2}/
      next if line =~ /time \d{2}:\d{2}:\d{2}/
Severity: Minor
Found in lib/oxidized/model/sonicos.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_hook has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def run_hook(ctx)
    return unless ctx.node
    return unless ctx.event.to_s == "post_store"

    begin
Severity: Minor
Found in lib/oxidized/hook/xmppdiff.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 load has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.load(cmd_opts = {})
      usrdir = File.expand_path(cmd_opts[:home_dir] || Oxidized::Config::ROOT)
      cfgfile = cmd_opts[:config_file] || 'config'
      asetus = Asetus.new(name: 'oxidized', load: false, key_to_s: true, usrdir: usrdir, cfgfile: cfgfile)
      Oxidized.asetus = asetus
Severity: Minor
Found in lib/oxidized/config.rb - About 1 hr to fix

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

      def run_hook(ctx)
        return unless ctx.node
        return unless ctx.event.to_s == "post_store"
    
        log "Connecting to slack"
    Severity: Minor
    Found in lib/oxidized/hook/slackdiff.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 update has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def update(repo, file, data)
          return if data.empty?
    
          if @opt[:group]
            if @cfg.single_repo?
    Severity: Minor
    Found in lib/oxidized/output/git.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 load has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def load(_node_want = nil)
          nodes = []
          open_file.each_line do |line|
            next if line =~ /^\s*#/
    
    
    Severity: Minor
    Found in lib/oxidized/source/csv.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_input has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def run_input(input)
          rescue_fail = {}
          [input.class::RESCUE_FAIL, input.class.superclass::RESCUE_FAIL].each do |hash|
            hash.each do |level, errors|
              errors.each do |err|
    Severity: Minor
    Found in lib/oxidized/node.rb - About 1 hr to fix

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

          def make_ssh_opts
            secure = Oxidized.config.input.ssh.secure?
            ssh_opts = {
              number_of_password_prompts:      0,
              keepalive:                       vars(:ssh_no_keepalive) ? false : true,
      Severity: Minor
      Found in lib/oxidized/input/ssh.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 clean has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def clean(cfg)
          out = []
          cfg.each_line do |line|
            # drop the temperature, fan speed and voltage, which change each run
            next if line =~ /Output \d Config/i
      Severity: Minor
      Found in lib/oxidized/model/aosw.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 shell_open has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def shell_open(ssh)
            @ses = ssh.open_channel do |ch|
              ch.on_data do |_ch, data|
                if Oxidized.config.input.debug?
                  @log.print data
      Severity: Minor
      Found in lib/oxidized/input/ssh.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 clean has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def clean(cfg)
          out = []
          skip_blocks = 0
          cfg.each_line do |line|
            # If this is a stackable switch we should skip this block of information
      Severity: Minor
      Found in lib/oxidized/model/powerconnect.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 load has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def load(node_want = nil)
            nodes = []
            uri = URI.parse(@cfg.url)
            data = JSON.parse(read_http(uri, node_want))
            node_data = data
      Severity: Minor
      Found in lib/oxidized/source/http.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 oxidized_expect has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def oxidized_expect(options) ## rubocop:disable Metrics/PerceivedComplexity
            model    = @options["Model"]
            @log     = @options["Log"]
      
            expects  = [options[:expect]].flatten
      Severity: Minor
      Found in lib/oxidized/input/telnet.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 clean has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def clean(cfg)
          out = []
          skip_blocks = 0
          cfg.each_line do |line|
            # If this is a stackable switch we should skip this block of information
      Severity: Minor
      Found in lib/oxidized/model/dellx.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 oxidized_expect has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def oxidized_expect(options) ## rubocop:disable Metrics/PerceivedComplexity
            model    = @options["Model"]
            @log     = @options["Log"]
      
            expects  = [options[:expect]].flatten
      Severity: Minor
      Found in lib/oxidized/input/telnet.rb - About 1 hr to fix

        Method run_hook has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def run_hook(ctx)
            return unless ctx.node
            return unless ctx.event.to_s == "post_store"
        
            log "Connecting to Cisco Spark"
        Severity: Minor
        Found in lib/oxidized/hook/ciscosparkdiff.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 load has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def load(dir, file)
                require File.join dir, file + '.rb'
                klass = nil
                [Oxidized, Object].each do |mod|
                  klass   = mod.constants.find { |const| const.to_s.casecmp(file).zero? }
        Severity: Minor
        Found in lib/oxidized/manager.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

        Severity
        Category
        Status
        Source
        Language