tomlobato/dns_one

View on GitHub

Showing 16 of 16 total issues

Method query has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def query dom_name, res_class, ip_address
        return unless dom_name =~ Util::DOM_REGEX

        dom_name = dom_name.dup
        res_class_short = Util.last_mod res_class # :A, :NS, found in conf.yml:record_sets items
Severity: Minor
Found in lib/dns_one/zone_search.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 remove has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def remove
        unless is_setup?
            die "Nothing to remove. Exiting."
        end

Severity: Minor
Found in lib/dns_one/setup.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 test_sorted has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def test_sorted(max_idx)
  puts "preparing..."
  arr_orig = (0..max_idx).to_a
  arr_1 = arr_orig.dup
  new_elm = arr_1.delete(arr_1.sample)
Severity: Minor
Found in util/benchmark-cache_store.rb - About 1 hr to fix

    Method resolve has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def resolve transaction
            rcode = :NoError
            resp_log = []
    
            begin
    Severity: Minor
    Found in lib/dns_one/server.rb - About 1 hr to fix

      Method query has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def query dom_name, res_class, ip_address
              return unless dom_name =~ Util::DOM_REGEX
      
              dom_name = dom_name.dup
              res_class_short = Util.last_mod res_class # :A, :NS, found in conf.yml:record_sets items
      Severity: Minor
      Found in lib/dns_one/zone_search.rb - About 1 hr to fix

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

            def on_response ip_address, domain_name, res_class, rcode, resp_log, from_cache
                @stat_mutex.synchronize {
                    @stat[:requests] ||= 0
                    @stat[:requests] += 1
                    
        Severity: Minor
        Found in lib/dns_one/req_log/account.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 print has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.print
                stat = new(from_outside: true, readonly: true)
                %w(rcode req_resource cache).each do |key|
                    puts "--- #{key} ---"
                    stat.get_counts(key.to_sym).each_pair do |k, v|
        Severity: Minor
        Found in lib/dns_one/req_log/db.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 set_backend has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def set_backend
                if file = @conf.backend.file
                    unless ::File.exists? file
                        Util.die "Domain list file #{file} not found (pwd = #{Dir.pwd})."
                    end
        Severity: Minor
        Found in lib/dns_one/zone_search.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 listen_updater_bell has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def listen_updater_bell
                unless @conf[:http_bell_port]
                    return 
                end
                require "socket"  
        Severity: Minor
        Found in lib/dns_one/backend/http_bell.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 check_record_sets has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def check_record_sets
                if @conf.record_sets.blank?
                    Util.die "Record sets cannot be empty. Check file."
                end
        
        
        Severity: Minor
        Found in lib/dns_one/zone_search.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 on_response has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def on_response ip_address, domain_name, res_class, rcode, resp_log, from_cache
        Severity: Minor
        Found in lib/dns_one/req_log/account.rb - About 45 mins to fix

          Method on_response has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def on_response ip_address, domain_name, res_class, rcode, resp_log, from_cache
          Severity: Minor
          Found in lib/dns_one/req_log/db.rb - About 45 mins to fix

            Method resolve has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def resolve transaction
                    rcode = :NoError
                    resp_log = []
            
                    begin
            Severity: Minor
            Found in lib/dns_one/server.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 init_logger has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def init_logger logdev, level = Logger::WARN, shift_age = 10, shift_size = 2**20
                    if logdev.is_a? String
                        begin
                            if File.exists? logdev
                                File.writable? logdev
            Severity: Minor
            Found in lib/dns_one/util.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

            Method find_record_set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def find_record_set dom_name
                    dom_name, use_cache = check_debug_tags dom_name
                    dom_name = normalize_domain dom_name
                    
                    enabled_cache = use_cache && @backend.allow_cache
            Severity: Minor
            Found in lib/dns_one/zone_search.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

            Method log_update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def log_update point, recs = nil
                    case point
                    when :start
                        @log_update_t0 = Time.now
                        Global.logger.info "update`ing..."
            Severity: Minor
            Found in lib/dns_one/backend/http_bell.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

            Severity
            Category
            Status
            Source
            Language