ruby-concurrency/thread_safe

View on GitHub

Showing 329 of 329 total issues

Class AtomicReferenceCacheBackend has 38 methods (exceeds 20 allowed). Consider refactoring.
Open

  class AtomicReferenceCacheBackend
    class Table < Util::PowerOfTwoTuple
      def cas_new_node(i, hash, key, value)
        cas(i, nil, Node.new(hash, key, value))
      end
Severity: Minor
Found in lib/thread_safe/atomic_reference_cache_backend.rb - About 5 hrs to fix

    Method internalComputeIfAbsent has 123 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private final Object internalComputeIfAbsent(K k,
                                                     Fun<? super K, ?> mf) {
            int h = spread(k.hashCode());
            Object val = null;
            int count = 0;
    Severity: Major
    Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 4 hrs to fix

      Method internalComputeIfAbsent has 123 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private final Object internalComputeIfAbsent(K k,
                                                       Fun<? super K, ?> mf) {
              int h = spread(k.hashCode());
              Object val = null;
              int count = 0;

        Method getTreeNode has a Cognitive Complexity of 32 (exceeds 5 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;
        Severity: Minor
        Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 4 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 getTreeNode has a Cognitive Complexity of 32 (exceeds 5 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;

        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

            public static class KeySetView<K,V> extends CHMView<K,V> implements Set<K>, java.io.Serializable {
                private static final long serialVersionUID = 7249069246763182397L;
                private final V value;
                KeySetView(ConcurrentHashMapV8<K, V> map, V value) {  // non-public
                    super(map);
        ext/org/jruby/ext/thread_safe/jsr166e/nounsafe/ConcurrentHashMapV8.java on lines 3629..3689

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

        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 static class KeySetView<K,V> extends CHMView<K,V> implements Set<K>, java.io.Serializable {
                private static final long serialVersionUID = 7249069246763182397L;
                private final V value;
                KeySetView(ConcurrentHashMapV8<K, V> map, V value) {  // non-public
                    super(map);
        ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java on lines 3637..3697

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

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

            @SuppressWarnings("unchecked") private final Object internalMerge
            (K k, V v, BiFun<? super V, ? super V, ? extends V> mf) {
                int h = spread(k.hashCode());
                Object val = null;
                int delta = 0;
        Severity: Major
        Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 4 hrs to fix

          Method internalMerge has 103 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @SuppressWarnings("unchecked") private final Object internalMerge
              (K k, V v, BiFun<? super V, ? super V, ? extends V> mf) {
                  int h = spread(k.hashCode());
                  Object val = null;
                  int delta = 0;

            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/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java on lines 1652..1680

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

            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/org/jruby/ext/thread_safe/jsr166e/nounsafe/ConcurrentHashMapV8.java on lines 1644..1672

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

            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/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java on lines 1733..1770

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

            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/org/jruby/ext/thread_safe/jsr166e/nounsafe/ConcurrentHashMapV8.java on lines 1725..1762

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

            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 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
            Severity: Major
            Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 3 hrs to fix

              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/org/jruby/ext/thread_safe/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/org/jruby/ext/thread_safe/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 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;

                  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;
                  Severity: Major
                  Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 3 hrs to fix

                    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/org/jruby/ext/thread_safe/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

                    Severity
                    Category
                    Status
                    Source
                    Language