jdantonio/concurrent-ruby

View on GitHub

Showing 303 of 498 total issues

Method canonical_rules has 27 lines of code (exceeds 25 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 1 hr to fix

    Method tryAwaitLock has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            final void tryAwaitLock(AtomicReferenceArray<Node> tab, int i) {
                if (tab != null && i >= 0 && i < tab.length()) { // sanity check
                    int r = ThreadLocalRandom.current().nextInt(); // randomize spins
                    int spins = MAX_SPINS, h;
                    while (tabAt(tab, i) == this && ((h = hash) & LOCKED) != 0) {

      Method getTreeNode has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              @SuppressWarnings("unchecked") final TreeNode getTreeNode
              (int h, RubyObject k, TreeNode p) {
                  RubyClass c = k.getMetaClass(); boolean kNotComparable = !k.respondsTo("<=>");
                  while (p != null) {
                      int dir, ph;  RubyObject pk; RubyClass pc;

        Method tryAwaitLock has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                final void tryAwaitLock(Node[] tab, int i) {
                    if (tab != null && i >= 0 && i < tab.length) { // sanity check
                        int r = ThreadLocalRandom.current().nextInt(); // randomize spins
                        int spins = MAX_SPINS, h;
                        while (tabAt(tab, i) == this && ((h = hash) & LOCKED) != 0) {

          Method getTreeNode has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  @SuppressWarnings("unchecked") final TreeNode getTreeNode
                  (int h, RubyObject k, TreeNode p) {
                      RubyClass c = k.getMetaClass(); boolean kNotComparable = !k.respondsTo("<=>");
                      while (p != null) {
                          int dir, ph;  RubyObject pk; RubyClass pc;

            Method define_struct_class has 26 lines of code (exceeds 25 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

              Method acquire_write_lock has 26 lines of code (exceeds 25 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 1 hr to fix

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

                def new_tree(n, size = 10)
                  values = [*1..size].collect{|i| i * n }.sample(size)
                  root = Tree.new(values.shift)
                
                  inserter = ->(current, new) do
                Severity: Minor
                Found in examples/a-tour-of-go-channels/equivalent-binary-trees.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 on_envelope has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                        def on_envelope(envelope)
                          result = pass envelope
                          if result != MESSAGE_PROCESSED && !envelope.future.nil?
                            envelope.future.fulfill result
                            log(DEBUG) { "finished processing of #{envelope.message.inspect}"}
                Severity: Minor
                Found in lib/concurrent-ruby-edge/concurrent/actor/behaviour/sets_results.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 exception has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def exception(*args)
                        raise Concurrent::Error, 'it is not rejected' unless rejected?
                        raise ArgumentError unless args.size <= 1
                        reason = Array(internal_state.reason).flatten.compact
                        if reason.size > 1
                Severity: Minor
                Found in lib/concurrent-ruby/concurrent/promises.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 wait! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def wait!(timeout = nil, resolve_on_timeout = nil)
                        super(timeout) or if resolve_on_timeout
                                            if resolve(*resolve_on_timeout, false)
                                              false
                                            else
                Severity: Minor
                Found in lib/concurrent-ruby/concurrent/promises.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 perform has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def perform
                        loop do
                          ivar, method, args, block = synchronize { @queue.first }
                          break unless ivar # queue is empty
                
                
                Severity: Minor
                Found in lib/concurrent-ruby/concurrent/async.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_top_stock has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                def get_top_stock(symbols, year, timeout = 10)
                  api_key = ENV['ALPHAVANTAGE_KEY']
                  abort(error_message) unless api_key
                
                  stock_prices = symbols.collect{|symbol| Concurrent::dataflow{ get_year_end_closing(symbol, year, api_key) }}
                Severity: Minor
                Found in docs-source/top-stock-scala/top-stock.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 single_test has 7 arguments (exceeds 4 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)
                Severity: Major
                Found in examples/benchmark_read_write_lock.rb - About 50 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                                      if (count >= TREE_THRESHOLD)
                                                          replaceWithTreeBin(tab, i, k);

                    Avoid deeply nested control flow statements.
                    Open

                                                if ((pr = p.right) != null && h >= pr.hash && (r = getTreeNode(h, k, pr)) != null)
                                                    return r;
                                                // try to continue iterating on the left side
                                                else if ((pl = p.left) != null && h <= pl.hash)
                                                    dir = -1;

                      Avoid deeply nested control flow statements.
                      Open

                                              if (busy == 0 && casBusy()) {
                                                  boolean created = false;
                                                  try {               // Recheck under lock
                                                      Cell[] rs; int m, j;
                                                      if ((rs = cells) != null &&
                      Severity: Major
                      Found in ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/Striped64.java - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                    if (!collide && q != null && q.hash == p.hash)
                                                        collide = true;

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

                                      Ruby runtime,
                                      RubyModule namespace,
                                      String parentName,
                                      String name,
                                      Class javaImplementation,
                          Severity: Minor
                          Found in ext/concurrent-ruby/com/concurrent_ruby/ext/SynchronizationLibrary.java - About 45 mins to fix

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

                                    @JRubyMethod(name = "ns_wait", optional = 1, visibility = Visibility.PROTECTED)
                                    public IRubyObject nsWait(ThreadContext context, IRubyObject[] args) {
                                        Ruby runtime = context.runtime;
                                        if (args.length > 1) {
                                            throw runtime.newArgumentError(args.length, 1);
                            Severity: Minor
                            Found in ext/concurrent-ruby/com/concurrent_ruby/ext/SynchronizationLibrary.java - 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

                            Severity
                            Category
                            Status
                            Source
                            Language