Method cluster
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def cluster(distance = :euclidean, linkage = :avg)
@distance_strategy = select_distance_strategy distance
@linkage_strategy = select_linkage_strategy linkage
@clusters = {} # Clusters list
Method populate_distance_matrix
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def populate_distance_matrix
@clusters.each do |key_i, cluster_i|
@clusters.each do |key_j, cluster_j|
dist = (key_i) == (key_j) ? INFINITY :
dynamic_method(@distance_strategy).call(cluster_i.left, cluster_j.left)
- 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 cluster
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def cluster(distance = :euclidean, linkage = :avg)
@distance_strategy = select_distance_strategy distance
@linkage_strategy = select_linkage_strategy linkage
@clusters = {} # Clusters list
- 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 update_mins
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def update_mins(merged_cluster)
@clusters.keys.each do |key_i|
if is_the_closest?(merged_cluster, key_i)
min_key = key_i
@clusters.keys.each do |key_j|
- 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"