ytti/oxidized

View on GitHub

Showing 112 of 112 total issues

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 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 = []
    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 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

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

    describe 'model/Garderos' do
      before(:each) do
        init_model_helper
        @node = Oxidized::Node.new(name:  'example.com',
                                   input: 'ssh',
    Severity: Major
    Found in spec/model/garderos_spec.rb and 1 other location - About 1 hr to fix
    spec/model/aoscx_spec.rb on lines 3..22

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

    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 'model/Aoscx' do
      before(:each) do
        init_model_helper
        @node = Oxidized::Node.new(name:  'example.com',
                                   input: 'ssh',
    Severity: Major
    Found in spec/model/aoscx_spec.rb and 1 other location - About 1 hr to fix
    spec/model/garderos_spec.rb on lines 3..26

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

    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 run_hook has 32 lines of code (exceeds 25 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

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

          def pagination(data, node_want)
            node_data = []
            raise Oxidized::OxidizedError, "if using pagination, 'pagination_key_name' setting must be set" unless @cfg.pagination_key_name?
      
            next_key = @cfg.pagination_key_name
      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 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

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

      def shell_wait
        @ssh_output = ''
        # ssh_output gets appended by chanel.on-data (below)
        # We store the current length of @ssh_output in @ssh_output_length
        # if @ssh_output.length is bigger than @ssh_output_length, we got new data
      Severity: Minor
      Found in examples/device-simulation/device2yaml.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 a Cognitive Complexity of 11 (exceeds 5 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

      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 connect has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def connect
          @client = Jabber::Client.new(Jabber::JID.new(cfg.jid))
      
          log "Connecting to XMPP"
          begin
      Severity: Minor
      Found in lib/oxidized/hook/xmppdiff.rb - About 1 hr to fix

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

          def self.setup_logger
            FileUtils.mkdir_p(Config::LOG) unless File.directory?(Config::LOG)
            self.logger = if config.has_key?('use_syslog') && config.use_syslog
                            require 'syslog/logger'
                            Syslog::Logger.new('oxidized')
        Severity: Minor
        Found in lib/oxidized.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 store has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def store(file, outputs, opt = {})
              @msg   = opt[:msg]
              @user  = opt[:user]  || @cfg.user
              @email = opt[:email] || @cfg.email
              @opt   = opt
        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 transform_json has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def transform_json(data)
              nodes = []
              data.each do |node|
                next if node.empty?
        
        
        Severity: Minor
        Found in lib/oxidized/source/jsonfile.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 27 lines of code (exceeds 25 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

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

          def shell_wait
            @ssh_output = ''
            # ssh_output gets appended by chanel.on-data (below)
            # We store the current length of @ssh_output in @ssh_output_length
            # if @ssh_output.length is bigger than @ssh_output_length, we got new data
          Severity: Minor
          Found in examples/device-simulation/device2yaml.rb - About 1 hr to fix

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

                def run
                  status, config = :fail, nil
                  @input.each do |input|
                    # don't try input if model is missing config block, we may need strong config to class_name map
                    cfg_name = input.to_s.split('::').last.downcase
            Severity: Minor
            Found in lib/oxidized/node.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 load has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def load(node_want = nil)
                  nodes = []
                  db = connect
                  query = db[@cfg.table.to_sym]
                  query = query.with_sql(@cfg.query) if @cfg.query?
            Severity: Minor
            Found in lib/oxidized/source/sql.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

            Severity
            Category
            Status
            Source
            Language