jdantonio/concurrent-ruby

View on GitHub

Showing 303 of 498 total issues

Method single_test has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def single_test(lock, n_readers, n_writers, reader_iterations=50, writer_iterations=50, reader_sleep=0.001, writer_sleep=0.001)
  puts "Testing #{lock.class} with #{n_readers} readers and #{n_writers} writers. Readers iterate #{reader_iterations} times, sleeping #{reader_sleep}s each time, writers iterate #{writer_iterations} times, sleeping #{writer_sleep}s each time"
  mutex = Mutex.new
  bad   = false
  data  = 0
Severity: Minor
Found in examples/benchmark_read_write_lock.rb - About 1 hr to fix

    Method splitTreeBin has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static void splitTreeBin(AtomicReferenceArray<Node> nextTab, int i, TreeBin t) {
            int bit = nextTab.length() >>> 1;
            TreeBin lt = new TreeBin();
            TreeBin ht = new TreeBin();
            int lc = 0, hc = 0;

      Method splitTreeBin has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static void splitTreeBin(Node[] nextTab, int i, TreeBin t) {
              int bit = nextTab.length >>> 1;
              TreeBin lt = new TreeBin();
              TreeBin ht = new TreeBin();
              int lc = 0, hc = 0;

        Method internal_receive has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def internal_receive
                raise if @behaviour.empty?
                rules_matcher  = Or[*@behaviour.map(&:first)]
                matcher        = -> m { m.is_a?(Ask) ? rules_matcher === m.message : rules_matcher === m }
                start          = nil
        Severity: Minor
        Found in lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb - About 1 hr to fix

          Method retry_update has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def retry_update(x, hash_code, was_uncontended) # :yields: current_value
                    hash     = hash_code
                    collided = false # True if last slot nonempty
                    while true
                      if current_cells = cells
          Severity: Minor
          Found in lib/concurrent-ruby/concurrent/thread_safe/util/striped64.rb - About 1 hr to fix

            Method consume_signal has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def consume_signal(message)
                    if AbstractSignal === message
                      case message
                      when Ask
                        @reply = message.probe
            Severity: Minor
            Found in lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb - About 1 hr to fix

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

                  private final AtomicReferenceArray<Node> initTable() {
                      AtomicReferenceArray<Node> tab; int sc;
                      while ((tab = table) == null) {
                          if ((sc = sizeCtl) < 0)
                              Thread.yield(); // lost initialization race; just spin

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

                      public final Object[] toArray() {
                          long sz = map.mappingCount();
                          if (sz > (long)(MAX_ARRAY_SIZE))
                              throw new OutOfMemoryError(oomeMsg);
                          int n = (int)sz;

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

                      public final Object[] toArray() {
                          long sz = map.mappingCount();
                          if (sz > (long)(MAX_ARRAY_SIZE))
                              throw new OutOfMemoryError(oomeMsg);
                          int n = (int)sz;

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

                  private final Node[] initTable() {
                      Node[] tab; int sc;
                      while ((tab = table) == null) {
                          if ((sc = sizeCtl) < 0)
                              Thread.yield(); // lost initialization race; just spin

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

                  def restart(new_value, opts = {})
                    clear_actions = opts.fetch(:clear_actions, false)
                    synchronize do
                      raise Error.new('agent is not failed') unless failed?
                      raise ValidationError unless ns_validate(new_value)
              Severity: Minor
              Found in lib/concurrent-ruby/concurrent/agent.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 push has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def push(item)
                    # allocate a new node with the item embedded
                    new_node = Node.new(item, nil)
              
                    # keep trying until the operation succeeds
              Severity: Minor
              Found in lib/concurrent-ruby-edge/concurrent/edge/lock_free_queue.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 define_struct_class has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                    def self.define_struct_class(parent, base, name, members, &block)
                      clazz = Class.new(base || Object) do
                        include parent
                        self.const_set(:MEMBERS, members.collect{|member| member.to_s.to_sym}.freeze)
                        def ns_initialize(*values)
              Severity: Minor
              Found in lib/concurrent-ruby/concurrent/synchronization/abstract_struct.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 initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def initialize(opts = {})
                    # undocumented -- for internal use only
                    if opts.is_a? Buffer::Base
                      self.buffer = opts
                      return
              Severity: Minor
              Found in lib/concurrent-ruby-edge/concurrent/channel.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 define_struct has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                    def define_struct(name, members, &block)
                      synchronize do
                        clazz = Synchronization::AbstractStruct.define_struct_class(SettableStruct, Synchronization::LockableObject, name, members, &block)
                        members.each_with_index do |member, index|
                          clazz.send :remove_method, member if clazz.instance_methods.include? member
              Severity: Minor
              Found in lib/concurrent-ruby/concurrent/settable_struct.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 advance has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      final V advance() {
                          Node e = next;
                          V ev = null;
                          outer: do {
                              if (e != null)                  // advance past used/skipped node

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

                    private final void tryPresize(int size) {
                        int c = (size >= (MAXIMUM_CAPACITY >>> 1)) ? MAXIMUM_CAPACITY :
                                tableSizeFor(size + (size >>> 1) + 1);
                        int sc;
                        while ((sc = sizeCtl) >= 0) {

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

                      private final void tryPresize(int size) {
                          int c = (size >= (MAXIMUM_CAPACITY >>> 1)) ? MAXIMUM_CAPACITY :
                                  tableSizeFor(size + (size >>> 1) + 1);
                          int sc;
                          while ((sc = sizeCtl) >= 0) {

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

                            final V advance() {
                                Node e = next;
                                V ev = null;
                                outer: do {
                                    if (e != null)                  // advance past used/skipped node

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

                            def ns_initialize(opts, &block)
                              @mailbox              = ::Array.new
                              @serialized_execution = SerializedExecution.new
                              @children             = Set.new
                      
                      
                      Severity: Minor
                      Found in lib/concurrent-ruby-edge/concurrent/actor/core.rb - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language