ruby-concurrency/thread_safe

View on GitHub

Showing 181 of 329 total issues

File atomic_reference_cache_backend.rb has 613 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ThreadSafe
  # A Ruby port of the Doug Lea's jsr166e.ConcurrentHashMapV8 class version 1.59
  # available in public domain.
  #
  # Original source code available here:
Severity: Major
Found in lib/thread_safe/atomic_reference_cache_backend.rb - About 1 day to fix

    Method rebuild has a Cognitive Complexity of 65 (exceeds 5 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

    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 rebuild has a Cognitive Complexity of 65 (exceeds 5 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
    Severity: Minor
    Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 1 day 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

    ConcurrentHashMapV8 has 60 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class ConcurrentHashMapV8<K, V>
            implements ConcurrentMap<K, V>, Serializable, ConcurrentHashMap<K, V> {
        private static final long serialVersionUID = 7249069246763182397L;
    
        /**
    Severity: Major
    Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 1 day to fix

      Method retryUpdate has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
      Open

          final void retryUpdate(long x, HashCode hc, boolean wasUncontended) {
              int h = hc.code;
              boolean collide = false;                // True if last slot nonempty
              for (;;) {
                  Cell[] as; Cell a; int n; long v;
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/nounsafe/Striped64.java - About 1 day 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 retryUpdate has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
      Open

          final void retryUpdate(long x, HashCode hc, boolean wasUncontended) {
              int h = hc.code;
              boolean collide = false;                // True if last slot nonempty
              for (;;) {
                  Cell[] as; Cell a; int n; long v;
      Severity: Minor
      Found in ext/org/jruby/ext/thread_safe/jsr166e/Striped64.java - About 1 day 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

      ConcurrentHashMapV8 has 58 methods (exceeds 20 allowed). Consider refactoring.
      Open

      public class ConcurrentHashMapV8<K, V>
              implements ConcurrentMap<K, V>, Serializable, ConcurrentHashMap<K, V> {
          private static final long serialVersionUID = 7249069246763182397L;
      
          /**

        Method readObject has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
        Open

            @SuppressWarnings("unchecked") private void readObject(java.io.ObjectInputStream s)
                    throws java.io.IOException, ClassNotFoundException {
                s.defaultReadObject();
                this.segments = null; // unneeded
                // initialize transient final field

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

            @SuppressWarnings("unchecked") private void readObject(java.io.ObjectInputStream s)
                    throws java.io.IOException, ClassNotFoundException {
                s.defaultReadObject();
                this.segments = null; // unneeded
                // initialize transient final field
        Severity: Minor
        Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 7 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 deleteTreeNode has 159 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                final void deleteTreeNode(TreeNode p) {
                    TreeNode next = (TreeNode)p.next; // unlink traversal pointers
                    TreeNode pred = p.prev;
                    if (pred == null)
                        first = next;
        Severity: Major
        Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 6 hrs to fix

          Method deleteTreeNode has 159 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  final void deleteTreeNode(TreeNode p) {
                      TreeNode next = (TreeNode)p.next; // unlink traversal pointers
                      TreeNode pred = p.prev;
                      if (pred == null)
                          first = next;

            Method internalClear has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
            Open

                private final void internalClear() {
                    long delta = 0L; // negative number of deletions
                    int i = 0;
                    AtomicReferenceArray<Node> tab = table;
                    while (tab != null && i < tab.length()) {

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

                private final void internalClear() {
                    long delta = 0L; // negative number of deletions
                    int i = 0;
                    Node[] tab = table;
                    while (tab != null && i < tab.length) {
            Severity: Minor
            Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 6 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 advance has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

                    final V advance() {
                        Node e = next;
                        V ev = null;
                        outer: do {
                            if (e != null)                  // advance past used/skipped node

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

                    final V advance() {
                        Node e = next;
                        V ev = null;
                        outer: do {
                            if (e != null)                  // advance past used/skipped node
            Severity: Minor
            Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - About 5 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 rebuild has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

                def rebuild(table)
                  old_table_size = table.size
                  new_table      = table.next_in_size_table
                  # puts "#{old_table_size} -> #{new_table.size}"
                  forwarder      = Node.new(MOVED, new_table, NULL)
            Severity: Minor
            Found in lib/thread_safe/atomic_reference_cache_backend.rb - About 5 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 internalCompute has 126 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @SuppressWarnings("unchecked") private final Object internalCompute
                (K k, boolean onlyIfPresent, BiFun<? super K, ? 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 5 hrs to fix

              Method internalCompute has 126 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

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

                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
                    Severity
                    Category
                    Status
                    Source
                    Language