ytti/oxidized

View on GitHub

Showing 48 of 112 total issues

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

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

            def get_diff(node, group, oid1, oid2)
              diff_commits = nil
              repo, = yield_repo_and_path(node, group)
              repo = Rugged::Repository.new repo
              commit = repo.lookup(oid1)
        Severity: Minor
        Found in lib/oxidized/output/git.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 resolve_repo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def resolve_repo(opt)
              type = git_type opt
              return nil unless type
        
              remote_repo = Oxidized.config.output.send(type).repo
        Severity: Minor
        Found in lib/oxidized/node.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 run_hook has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def run_hook(ctx)
            env = make_env ctx
            log "Execute: #{@cmd.inspect}", :debug
            th = Thread.new do
              run_cmd! env
        Severity: Minor
        Found in lib/oxidized/hook/exec.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 clean has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def clean(cfg)
            out = []
            cfg.each_line do |line|
              next if line =~ /^\s*$/
              next if line =~ /rogue (adhoc|client) (alert|Unknown) [\da-f]{2}:/
        Severity: Minor
        Found in lib/oxidized/model/aireos.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 validate_cfg! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def validate_cfg!
            raise KeyError, 'hook.jid is required' unless cfg.has_key?('jid')
            raise KeyError, 'hook.password is required' unless cfg.has_key?('password')
            raise KeyError, 'hook.channel is required' unless cfg.has_key?('channel')
            raise KeyError, 'hook.nick is required' unless cfg.has_key?('nick')
        Severity: Minor
        Found in lib/oxidized/hook/xmppdiff.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 login has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def login
                match_re = [@node.prompt]
                match_re << @username if @username
                match_re << @password if @password
                until (match = expect(match_re)) == @node.prompt
        Severity: Minor
        Found in lib/oxidized/input/cli.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 vars has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def vars(name)
            model_name = @node.model.class.name.to_s.downcase
            if @node.vars&.has_key?(name)
              @node.vars[name]
            elsif Oxidized.config.groups.has_key?(@node.group) && Oxidized.config.groups[@node.group].models.has_key(model_name) && Oxidized.config.groups[@node.group].models[model_name].vars.has_key?(name.to_s)
        Severity: Minor
        Found in lib/oxidized/config/vars.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 read_http has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def read_http(uri, node_want)
              http = Net::HTTP.new(uri.host, uri.port)
              http.use_ssl = true if uri.scheme == 'https'
              http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @cfg.secure
        
        
        Severity: Minor
        Found in lib/oxidized/source/http.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

        Severity
        Category
        Status
        Source
        Language