jdantonio/concurrent-ruby

View on GitHub

Showing 498 of 498 total issues

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

class AnActor < Concurrent::Actor::RestartingContext
  def initialize(init)
    @counter = init
  end

Severity: Minor
Found in docs-source/actor/define.in.rb and 1 other location - About 50 mins to fix
docs-source/actor/define.out.rb on lines 3..25

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

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

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

class AnActor < Concurrent::Actor::RestartingContext
  def initialize(init)
    @counter = init
  end

Severity: Minor
Found in docs-source/actor/define.out.rb and 1 other location - About 50 mins to fix
docs-source/actor/define.in.rb on lines 3..25

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

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

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

crawlers = Array.new web_crawler_count do |i|
  Thread.new do
    while true
      # crawl the web until cancelled
      break if @cancellation.canceled?
Severity: Minor
Found in docs-source/medium-example.out.rb and 1 other location - About 45 mins to fix
docs-source/medium-example.in.rb on lines 129..144

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

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

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

crawlers = Array.new web_crawler_count do |i|
  Thread.new do
    while true
      # crawl the web until cancelled
      break if @cancellation.canceled?
Severity: Minor
Found in docs-source/medium-example.in.rb and 1 other location - About 45 mins to fix
docs-source/medium-example.out.rb on lines 146..161

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

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

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

module Concurrent

  # @!macro concurrent_hash
  #
  #   A thread-safe subclass of Hash. This version locks against the object
Severity: Minor
Found in lib/concurrent-ruby/concurrent/hash.rb and 1 other location - About 45 mins to fix
lib/concurrent-ruby/concurrent/array.rb on lines 4..53

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

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

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

module Concurrent

  # @!macro concurrent_array
  #
  #   A thread-safe subclass of Array. This version locks against the object
Severity: Minor
Found in lib/concurrent-ruby/concurrent/array.rb and 1 other location - About 45 mins to fix
lib/concurrent-ruby/concurrent/hash.rb on lines 4..49

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

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

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

            Avoid deeply nested control flow statements.
            Open

                                        if ((pr = p.right) != null && h >= pr.hash && (r = getTreeNode(h, k, pr)) != null)
                                            return r;
                                        else // continue descending down the left subtree
                                            dir = -1;

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

                  @SuppressWarnings("unchecked") private void writeObject(java.io.ObjectOutputStream s)
                          throws java.io.IOException {
                      if (segments == null) { // for serialization compatibility
                          segments = (Segment<K,V>[])
                                  new Segment<?,?>[DEFAULT_CONCURRENCY_LEVEL];

              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

              Avoid deeply nested control flow statements.
              Open

                                                  if ((e.val = v) == null) {
                                                      deleted = true;
                                                      Node en = e.next;
                                                      if (pred != null)
                                                          pred.next = en;

                Avoid deeply nested control flow statements.
                Open

                                        for (Node e = tabAt(tab, i); e != null; e = e.next) {
                                            if (++c > TREE_THRESHOLD &&
                                                    (e.key instanceof Comparable)) {
                                                replaceWithTreeBin(tab, i, e.key);
                                                break;

                  Avoid deeply nested control flow statements.
                  Open

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

                    Avoid deeply nested control flow statements.
                    Open

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

                      Avoid deeply nested control flow statements.
                      Open

                                                          if ((p.val = v) == null) {
                                                              deleted = true;
                                                              t.deleteTreeNode(p);
                                                          }

                        Avoid deeply nested control flow statements.
                        Open

                                                            if ((p.val = v) == null) {
                                                                deleted = true;
                                                                t.deleteTreeNode(p);
                                                            }
                          Severity
                          Category
                          Status
                          Source
                          Language