ruby-concurrency/thread_safe

View on GitHub

Showing 181 of 329 total issues

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

    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;

        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

            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

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

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

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

                            @JRubyClass(name="JRubyCacheBackend", parent="Object")
                            public static class JRubyCacheBackend extends RubyObject {
                                // Defaults used by the CHM
                                static final int DEFAULT_INITIAL_CAPACITY = 16;
                                static final float DEFAULT_LOAD_FACTOR = 0.75f;
                        Severity: Minor
                        Found in ext/org/jruby/ext/thread_safe/JRubyCacheBackendLibrary.java - About 3 hrs to fix

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

                            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;

                              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/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

                              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) {
                              Severity: Minor
                              Found in ext/org/jruby/ext/thread_safe/jsr166e/ConcurrentHashMapV8.java - 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 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 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;
                                Severity
                                Category
                                Status
                                Source
                                Language