lib/roma/routing/cb_rttable.rb

Summary

Maintainability
D
2 days
Test Coverage

Class ChurnbasedRoutingTable has 35 methods (exceeds 20 allowed). Consider refactoring.
Open

    class ChurnbasedRoutingTable < RoutingTable

      include Routing::RandomPartitioner

      attr :fname
Severity: Minor
Found in lib/roma/routing/cb_rttable.rb - About 4 hrs to fix

    File cb_rttable.rb has 331 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'roma/routing/rttable'
    require 'roma/routing/random_partitioner'
    
    module Roma
      module Routing
    Severity: Minor
    Found in lib/roma/routing/cb_rttable.rb - About 3 hrs to fix

      Method leave has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

            def leave(nid)
              unless @enabled_failover
                return
              end
              return unless @rd.nodes.include?(nid)
      Severity: Minor
      Found in lib/roma/routing/cb_rttable.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 leave has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def leave(nid)
              unless @enabled_failover
                return
              end
              return unless @rd.nodes.include?(nid)
      Severity: Minor
      Found in lib/roma/routing/cb_rttable.rb - About 1 hr to fix

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

              def vnode_balance(ap)
                # amount of primary at node = amount of vnode / amount of node
                n = (2**div_bits) / nodes.length
        
                pcount = scount = 0
        Severity: Minor
        Found in lib/roma/routing/cb_rttable.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 sample_vnode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def sample_vnode(without_nodes)
                short_idx = {}
                idx = {}
                @rd.v_idx.each_pair{|vn, nids|
                  unless list_include?(nids, without_nodes)
        Severity: Minor
        Found in lib/roma/routing/cb_rttable.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 set_route has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def set_route(vn, clk, nids)
                return "#{vn} is not found." unless @rd.v_idx.key?(vn)
                @lock.synchronize {
                  return "It's old table." if @rd.v_clk[vn] > clk
                  nids.each{ |nid|
        Severity: Minor
        Found in lib/roma/routing/cb_rttable.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 can_i_release? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def can_i_release?(ap_str, rep_host)
                buf = self.nodes
                buf.delete(ap_str)
                hosts = []
        
        
        Severity: Minor
        Found in lib/roma/routing/cb_rttable.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 search_lost_vnodes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def search_lost_vnodes(t)
                ret = []
                @rd.each_log_all(@fname){|log_t,line|
                  next if t > log_t
                  s = line.split(/ /)
        Severity: Minor
        Found in lib/roma/routing/cb_rttable.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

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

                if log_list.length==0
                  @log_name="#{@fname}.1"
                else
                  if File::stat("#{@fname}.#{log_list.last[0]}").size == 0
                    @log_name="#{@fname}.#{log_list.last[0]}"
        Severity: Minor
        Found in lib/roma/routing/cb_rttable.rb and 1 other location - About 1 hr to fix
        lib/roma/storage/basic_storage.rb on lines 732..738

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

        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

        There are no issues that match your filters.

        Category
        Status