ytti/oxidized

View on GitHub

Showing 112 of 112 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

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

describe Oxidized::JSONFile do
  describe '#setup' do
    before(:each) do
      Asetus.any_instance.expects(:load)
      Asetus.any_instance.expects(:create).returns(false)
Severity: Major
Found in spec/source/jsonfile_spec.rb and 1 other location - About 3 hrs to fix
spec/source/sql_spec.rb on lines 4..41

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 108.

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

describe Oxidized::SQL do
  describe '#setup' do
    before(:each) do
      Asetus.any_instance.expects(:load)
      Asetus.any_instance.expects(:create).returns(false)
Severity: Major
Found in spec/source/sql_spec.rb and 1 other location - About 3 hrs to fix
spec/source/jsonfile_spec.rb on lines 4..41

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 108.

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 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 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 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 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 47 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'
      # configuration file with full path as a class instance variable
      @configfile = File.join(usrdir, cfgfile)
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

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

      cmd :secret do |cfg|
        cfg.gsub! /cli ftp password default \d,(\S+)/, 'cli ftp password default <secret hidden> \2'
        cfg.gsub! /secret \d,(\S+)/, 'secret <secret hidden> \2'
        cfg.gsub! /shared-secret \d,(\S+)/, 'shared-secret <secret hidden> \2'
        cfg.gsub! /password \d,(\S+)/, 'password <secret hidden> \2'
    Severity: Major
    Found in lib/oxidized/model/sonicos.rb and 1 other location - About 1 hr to fix
    lib/oxidized/model/aosw.rb on lines 27..46

    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 66.

    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

      cmd :secret do |cfg|
        cfg.gsub!(/secret (\S+)$/, 'secret <secret removed>')
        cfg.gsub!(/enable secret (\S+)$/, 'enable secret <secret removed>')
        cfg.gsub!(/PRE-SHARE (\S+)$/, 'PRE-SHARE <secret removed>')
        cfg.gsub!(/ipsec (\S+)$/, 'ipsec <secret removed>')
    Severity: Major
    Found in lib/oxidized/model/aosw.rb and 1 other location - About 1 hr to fix
    lib/oxidized/model/sonicos.rb on lines 13..29

    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 66.

    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 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 run_hook has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def run_hook(ctx)
        unless ctx.node.repo
          log "Oxidized output is not git, can't push to remote", :error
          return
        end
    Severity: Minor
    Found in lib/oxidized/hook/githubrepo.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 37 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

      Identical blocks of code found in 2 locations. 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: Major
      Found in lib/oxidized/model/powerconnect.rb and 1 other location - About 1 hr to fix
      lib/oxidized/model/dellx.rb on lines 55..74

      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 61.

      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

      Identical blocks of code found in 2 locations. 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: Major
      Found in lib/oxidized/model/dellx.rb and 1 other location - About 1 hr to fix
      lib/oxidized/model/powerconnect.rb on lines 59..78

      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 61.

      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 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 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 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

      Severity
      Category
      Status
      Source
      Language