jdantonio/concurrent-ruby

View on GitHub

Showing 303 of 498 total issues

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

    def acquire_write_lock
      if (held = @HeldCount.value) >= WRITE_LOCK_HELD
        # if we already have a write (exclusive) lock, there's no need to wait
        @HeldCount.value = held + WRITE_LOCK_HELD
        return true
Severity: Minor
Found in lib/concurrent-ruby/concurrent/atomic/reentrant_read_write_lock.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 ns_initialize has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

      def ns_initialize(opts)
        min_length       = opts.fetch(:min_threads, DEFAULT_MIN_POOL_SIZE).to_i
        max_length       = opts.fetch(:max_threads, DEFAULT_MAX_POOL_SIZE).to_i
        idletime         = opts.fetch(:idletime, DEFAULT_THREAD_IDLETIMEOUT).to_i
        @max_queue       = opts.fetch(:max_queue, DEFAULT_MAX_QUEUE_SIZE).to_i
Severity: Minor
Found in lib/concurrent-ruby/concurrent/executor/java_thread_pool_executor.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 readObject has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @SuppressWarnings("unchecked") private void readObject(java.io.ObjectInputStream s)
            throws java.io.IOException, ClassNotFoundException {
        s.defaultReadObject();
        this.segments = null; // unneeded
        // initialize transient final field

    Method readObject has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @SuppressWarnings("unchecked") private void readObject(java.io.ObjectInputStream s)
                throws java.io.IOException, ClassNotFoundException {
            s.defaultReadObject();
            this.segments = null; // unneeded
            // initialize transient final field

      Method acquire_write_lock has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def acquire_write_lock
            while true
              c = @Counter.value
              raise ResourceLimitError.new('Too many writer threads') if max_writers?(c)
      
      
      Severity: Minor
      Found in lib/concurrent-ruby/concurrent/atomic/read_write_lock.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 wait_until_resolved has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

            def wait_until_resolved(timeout)
              return true if resolved?
      
              touch
      
      
      Severity: Minor
      Found in lib/concurrent-ruby/concurrent/promises.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 equals has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          public boolean equals(Object o) {
              if (o != this) {
                  if (!(o instanceof Map))
                      return false;
                  Map<?,?> m = (Map<?,?>) o;

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

          private final Object internalGet(Object k) {
              int h = spread(k.hashCode());
              retry: for (Node[] tab = table; tab != null;) {
                  Node e, p; Object ek, ev; int eh;      // locals to read fields once
                  for (e = tabAt(tab, (tab.length - 1) & h); e != null; e = e.next) {

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

          private final Object internalGet(Object k) {
              int h = spread(k.hashCode());
              retry: for (AtomicReferenceArray<Node> tab = table; tab != null;) {
                  Node e, p; Object ek, ev; int eh;      // locals to read fields once
                  for (e = tabAt(tab, (tab.length() - 1) & h); e != null; e = e.next) {

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

          public boolean equals(Object o) {
              if (o != this) {
                  if (!(o instanceof Map))
                      return false;
                  Map<?,?> m = (Map<?,?>) o;

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

            def canonical_rules(rules, timeout, timeout_value, given_block)
              block = given_block || -> v { v }
              case rules.size
              when 0
                rules.push(on(ANY, &block))
      Severity: Minor
      Found in lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.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 internal_receive has a Cognitive Complexity of 19 (exceeds 5 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 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 ns_consume_pending_push has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

            def ns_consume_pending_push(matcher, remove = true)
              i = 0
              while true
                message, pushed = @PendingPush[i, 2]
                return NOTHING unless pushed
      Severity: Minor
      Found in lib/concurrent-ruby-edge/concurrent/edge/channel.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

      Class Base has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

            class Base < Synchronization::LockableObject
      
              # @!macro channel_buffer_capacity_reader
              #
              #   The maximum number of values which can be {#put} onto the buffer
      Severity: Minor
      Found in lib/concurrent-ruby-edge/concurrent/channel/buffer/base.rb - About 2 hrs to fix

        Class NonConcurrentMapBackend has 22 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class NonConcurrentMapBackend
        
              # WARNING: all public methods of the class must operate on the @backend
              # directly without calling each other. This is important because of the
              # SynchronizedMapBackend which uses a non-reentrant mutex for performance

          Method internalClear has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private final void internalClear() {
                  long delta = 0L; // negative number of deletions
                  int i = 0;
                  AtomicReferenceArray<Node> tab = table;
                  while (tab != null && i < tab.length()) {

            Method internalClear has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private final void internalClear() {
                    long delta = 0L; // negative number of deletions
                    int i = 0;
                    Node[] tab = table;
                    while (tab != null && i < tab.length) {

              Method value has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  def value(timeout = nil)
                    if @executor # TODO (pitr 12-Sep-2015): broken unsafe read?
                      super
                    else
                      # this function has been optimized for performance and
              Severity: Minor
              Found in lib/concurrent-ruby/concurrent/delay.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 validate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  def validate(value, allow_nil, raise_error)
                    if !allow_nil && value.nil?
                      raise_error ? raise(ValidationError.new('nil is not a valid value')) : false
                    elsif !validator.call(value)
                      raise_error ? raise(ValidationError) : false
              Severity: Minor
              Found in lib/concurrent-ruby-edge/concurrent/channel.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 find has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                      def self.find(head, item)
                        loop do
                          break_inner_loops = false
                          pred = head
                          curr = pred.next_node

              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