jdantonio/concurrent-ruby

View on GitHub

Showing 498 of 498 total issues

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

            else if ((fh = f.hash) == MOVED) {
                if ((fk = f.key) instanceof TreeBin) {
                    TreeBin t = (TreeBin)fk;
                    t.acquire(0);
                    try {
ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/ConcurrentHashMapV8.java on lines 1840..1871

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

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

Method compute_physical_processor_count has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

      def compute_physical_processor_count
        ppc = case RbConfig::CONFIG["target_os"]
              when /darwin\d\d/
                IO.popen("/usr/sbin/sysctl -n hw.physicalcpu", &:read).to_i
              when /linux/
Severity: Minor
Found in lib/concurrent-ruby/concurrent/utility/processor_counter.rb - About 3 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 internalReplace has 89 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private final Object internalReplace(Object k, Object v, Object cv) {
        int h = spread(k.hashCode());
        Object oldVal = null;
        for (Node[] tab = table;;) {
            Node f; int i, fh; Object fk;

    Method internalReplace has 89 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private final Object internalReplace(Object k, Object v, Object cv) {
            int h = spread(k.hashCode());
            Object oldVal = null;
            for (AtomicReferenceArray<Node> tab = table;;) {
                Node f; int i, fh; Object fk;

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

          public boolean equals(Object o) {
              if (o != this) {
                  if (!(o instanceof Map))
                      return false;
                  Map<?,?> m = (Map<?,?>) o;
      ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/ConcurrentHashMapV8.java on lines 3189..3211

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

      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

          public boolean equals(Object o) {
              if (o != this) {
                  if (!(o instanceof Map))
                      return false;
                  Map<?,?> m = (Map<?,?>) o;
      ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMapV8.java on lines 3197..3219

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

      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

      Method tryAwaitLock has a Cognitive Complexity of 24 (exceeds 5 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) {

      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 tryAwaitLock has a Cognitive Complexity of 24 (exceeds 5 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) {

      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 retry_update has a Cognitive Complexity of 24 (exceeds 5 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 3 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 Agent has 28 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Agent < Synchronization::LockableObject
          include Concern::Observable
      
          ERROR_MODES = [:continue, :fail].freeze
          private_constant :ERROR_MODES
      Severity: Minor
      Found in lib/concurrent-ruby/concurrent/agent.rb - About 3 hrs to fix

        Method internalPut has 82 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private final Object internalPut(Object k, Object v) {
                int h = spread(k.hashCode());
                int count = 0;
                for (AtomicReferenceArray<Node> tab = table;;) {
                    int i; Node f; int fh; Object fk;

          Method internalPut has 82 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private final Object internalPut(Object k, Object v) {
                  int h = spread(k.hashCode());
                  int count = 0;
                  for (Node[] tab = table;;) {
                      int i; Node f; int fh; Object fk;

            Method ask has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

                  def ask(message, timeout, timeout_value)
                    log DEBUG, @Pid, asked: message
                    if @Terminated.resolved?
                      raise NoActor.new(@Pid)
                    else
            Severity: Minor
            Found in lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb - About 3 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

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

                        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) {
                                if (spins >= 0) {
            ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/ConcurrentHashMapV8.java on lines 671..696

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

            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

                        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) {
                                if (spins >= 0) {
            ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMapV8.java on lines 664..689

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

            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

            Class RubyThreadPoolExecutor has 27 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class RubyThreadPoolExecutor < RubyExecutorService
            
                # @!macro thread_pool_executor_constant_default_max_pool_size
                DEFAULT_MAX_POOL_SIZE      = 2_147_483_647 # java.lang.Integer::MAX_VALUE
            
            
            Severity: Minor
            Found in lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb - About 3 hrs to fix

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

                          else if ((fh = f.hash) == MOVED) {
                              if ((fk = f.key) instanceof TreeBin) {
                                  TreeBin t = (TreeBin)fk;
                                  boolean added = false;
                                  t.acquire(0);
              ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/ConcurrentHashMapV8.java on lines 1592..1620

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

              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

                          else if ((fh = f.hash) == MOVED) {
                              if ((fk = f.key) instanceof TreeBin) {
                                  TreeBin t = (TreeBin)fk;
                                  boolean added = false;
                                  t.acquire(0);
              ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMapV8.java on lines 1600..1628

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

              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

              Method inner_run has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                    def inner_run(*args, &body)
                      first       = !!body
                      future_body = -> message, _actor do
                        kind, reason, value =
                            if message.is_a?(::Array) && message.first == TERMINATE
              Severity: Minor
              Found in lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb - About 3 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 Promise has 26 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class Promise < IVar
              
                  # Initialize a new Promise with the provided options.
                  #
                  # @!macro executor_and_deref_options
              Severity: Minor
              Found in lib/concurrent-ruby/concurrent/promise.rb - About 3 hrs to fix
                Severity
                Category
                Status
                Source
                Language