ruby-concurrency/concurrent-ruby

View on GitHub

Showing 498 of 498 total issues

Method internalPutAll has 99 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private final void internalPutAll(Map<?, ?> m) {
        tryPresize(m.size());
        long delta = 0L;     // number of uncommitted additions
        boolean npe = false; // to throw exception on exit for nulls
        try {                // to clean up counts on other exceptions

    Method internalPutAll has 99 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private final void internalPutAll(Map<?, ?> m) {
            tryPresize(m.size());
            long delta = 0L;     // number of uncommitted additions
            boolean npe = false; // to throw exception on exit for nulls
            try {                // to clean up counts on other exceptions

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

          static final class MapEntry<K,V> implements Map.Entry<K, V> {
              final K key; // non-null
              V val;       // non-null
              final ConcurrentHashMapV8<K, V> map;
              MapEntry(K key, V val, ConcurrentHashMapV8<K, V> map) {
      ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/ConcurrentHashMapV8.java on lines 3285..3323

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

      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

          static final class MapEntry<K,V> implements Map.Entry<K, V> {
              final K key; // non-null
              V val;       // non-null
              final ConcurrentHashMapV8<K, V> map;
              MapEntry(K key, V val, ConcurrentHashMapV8<K, V> map) {
      ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMapV8.java on lines 3293..3331

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

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

          def acquire_read_lock
            if (held = @HeldCount.value) > 0
              # If we already have a lock, there's no need to wait
              if held & READ_LOCK_MASK == 0
                # But we do need to update the counter, if we were holding a write
      Severity: Minor
      Found in lib/concurrent-ruby/concurrent/atomic/reentrant_read_write_lock.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 internalPutIfAbsent has 97 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

        Method internalPutIfAbsent has 97 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private final Object internalPutIfAbsent(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, fv;

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

                          try {                        // needed in case equals() throws
                              if (tabAt(tab, i) == f) {
                                  count = 1;
                                  for (Node e = f;; ++count) {
                                      Object ek, ev;
          ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/ConcurrentHashMapV8.java on lines 1420..1446

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

          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

                          try {                        // needed in case equals() throws
                              if (tabAt(tab, i) == f) {
                                  count = 1;
                                  for (Node e = f;; ++count) {
                                      Object ek, ev;
          ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMapV8.java on lines 1428..1454

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

          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 rebuild has 94 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static final Node[] rebuild(Node[] tab) {
                  int n = tab.length;
                  Node[] nextTab = new Node[n << 1];
                  Node fwd = new Node(MOVED, nextTab, null, null);
                  int[] buffer = null;       // holds bins to revisit; null until needed

            Method rebuild has 94 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private static final AtomicReferenceArray<Node> rebuild(AtomicReferenceArray<Node> tab) {
                    int n = tab.length();
                    AtomicReferenceArray<Node> nextTab = new AtomicReferenceArray<Node>(n << 1);
                    Node fwd = new Node(MOVED, nextTab, null, null);
                    int[] buffer = null;       // holds bins to revisit; null until needed

              Method signature_types has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
              Open

                    def signature_types(meth, link = true)
                      meth = convert_method_to_overload(meth)
                      if meth.respond_to?(:object) && !meth.has_tag?(:return)
                        meth = meth.object
                      end
              Severity: Minor
              Found in support/yard_full_types.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 do_exchange has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
              Open

                  def do_exchange(value, timeout)
              
                    # ALGORITHM
                    #
                    # From the original Java version:
              Severity: Minor
              Found in lib/concurrent-ruby/concurrent/exchanger.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 putTreeNode has 93 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      @SuppressWarnings("unchecked") final TreeNode putTreeNode
                      (int h, RubyObject k, Object v) {
                          RubyClass c = k.getMetaClass();
                          boolean kNotComparable = !k.respondsTo("<=>");
                          TreeNode pp = root, p = null;

                Method putTreeNode has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        @SuppressWarnings("unchecked") final TreeNode putTreeNode
                        (int h, RubyObject k, Object v) {
                            RubyClass c = k.getMetaClass();
                            boolean kNotComparable = !k.respondsTo("<=>");
                            TreeNode pp = root, p = null;

                  JRubyMapBackend has 30 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                    @JRubyClass(name="JRubyMapBackend", parent="Object")
                      public static class JRubyMapBackend extends RubyObject {
                        // Defaults used by the CHM
                        static final int DEFAULT_INITIAL_CAPACITY = 16;
                        static final float DEFAULT_LOAD_FACTOR = 0.75f;

                    Class AbstractActor has 30 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                        class AbstractActor < Synchronization::Object
                    
                          include EnvironmentConstants
                          include Concern::Logging
                          safe_initialization!
                    Severity: Minor
                    Found in lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.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;
                                          t.acquire(0);
                                          try {
                      ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMapV8.java on lines 1848..1879

                      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

                      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

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

                                          try {
                                              if (tabAt(tab, i) == f) {
                                                  count = 1;
                                                  for (Node e = f;; ++count) {
                                                      Object ek, ev;
                      ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMapV8.java on lines 1529..1554

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language