Showing 498 of 498 total issues
Identical blocks of code found in 2 locations. Consider refactoring. Open
static final class TreeBin extends AbstractQueuedSynchronizer {
private static final long serialVersionUID = 2249069246763182397L;
transient TreeNode root; // root of tree
transient TreeNode first; // head of next-pointer list
- Read upRead up
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 3385.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
static final class TreeBin extends AbstractQueuedSynchronizer {
private static final long serialVersionUID = 2249069246763182397L;
transient TreeNode root; // root of tree
transient TreeNode first; // head of next-pointer list
- Read upRead up
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 3385.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
File ConcurrentHashMapV8.java
has 2355 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
* Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at
* http://creativecommons.org/publicdomain/zero/1.0/
*/
File ConcurrentHashMapV8.java
has 2304 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
* Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at
* http://creativecommons.org/publicdomain/zero/1.0/
*/
Method deleteTreeNode
has a Cognitive Complexity of 193 (exceeds 5 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;
- Read upRead up
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 a Cognitive Complexity of 193 (exceeds 5 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;
- Read upRead up
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
File promises.rb
has 1196 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'concurrent/synchronization/object'
require 'concurrent/atomic/atomic_boolean'
require 'concurrent/atomic/atomic_fixnum'
require 'concurrent/collection/lock_free_stack'
require 'concurrent/configuration'
Method internalComputeIfAbsent
has a Cognitive Complexity of 132 (exceeds 5 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;
- Read upRead up
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 internalComputeIfAbsent
has a Cognitive Complexity of 132 (exceeds 5 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;
- Read upRead up
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 a Cognitive Complexity of 123 (exceeds 5 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;
- Read upRead up
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 a Cognitive Complexity of 123 (exceeds 5 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;
- Read upRead up
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
File erlang_actor.rb
has 899 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'set'
require 'concurrent/atomic/count_down_latch'
require 'concurrent/concern/logging'
require 'concurrent/edge/channel'
require 'concurrent/errors'
Method internalPutIfAbsent
has a Cognitive Complexity of 106 (exceeds 5 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;
- Read upRead up
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 a Cognitive Complexity of 106 (exceeds 5 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;
- Read upRead up
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 a Cognitive Complexity of 102 (exceeds 5 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;
- Read upRead up
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 a Cognitive Complexity of 102 (exceeds 5 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;
- Read upRead up
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 a Cognitive Complexity of 95 (exceeds 5 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;
- Read upRead up
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 a Cognitive Complexity of 95 (exceeds 5 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;
- Read upRead up
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 a Cognitive Complexity of 91 (exceeds 5 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;
- Read upRead up
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 a Cognitive Complexity of 91 (exceeds 5 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;
- Read upRead up
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"