Showing 15 of 28 total issues
Method populate_centroids
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def populate_centroids(populate_method, number_of_clusters=@number_of_clusters)
tried_indexes = []
case populate_method
when 'random' # for initial assignment (without the :centroid_indices option) and for reassignment of empty cluster centroids (with :on_empty option 'random')
while @centroids.length < number_of_clusters &&
- 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 distance
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def distance(a, b)
d = 0
a.each_with_index do |att_a, i|
att_b = b[i]
if att_a.nil?
- 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
Class DataSet
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class DataSet
attr_reader :data_labels, :data_items
# Create a new DataSet. By default, empty.
Method build
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build(data)
raise "Error instance must be passed" unless data.is_a?(DataSet)
raise "Data should not be empty" if data.data_items.length == 0
y_mean = data.get_mean_or_mode[data.num_attributes - 1]
Method build
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def build(data)
raise "Error instance must be passed" unless data.is_a?(DataSet)
raise "Data should not be empty" if data.data_items.length == 0
y_mean = data.get_mean_or_mode[data.num_attributes - 1]
- 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 populate_centroids
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def populate_centroids(populate_method, number_of_clusters=@number_of_clusters)
tried_indexes = []
case populate_method
when 'random' # for initial assignment (without the :centroid_indices option) and for reassignment of empty cluster centroids (with :on_empty option 'random')
while @centroids.length < number_of_clusters &&
Method update_min_max
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update_min_max(atts)
atts.each_with_index do |att, i|
if att && att.is_a?(Numeric)
@min_values[i] = att if @min_values[i].nil? || @min_values[i] > att
@max_values[i] = att if @max_values[i].nil? || @max_values[i] < att
- 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 eval
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def eval(data)
votes = Votes.new
@pipes.each do |category, pipe|
pipe.each_with_index do |bounds, i|
if data[i].is_a? Numeric
- 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_pipe
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def update_pipe(pipe, data_item)
data_item[0...-1].each_with_index do |att, i|
if att.is_a? Numeric
pipe[i][:min] = att if att < pipe[i][:min]
pipe[i][:max] = att if att > pipe[i][:max]
- 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 reproduce
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.reproduce(a, b)
data_size = @@costs[0].length
available = []
0.upto(data_size-1) { |n| available << n }
token = a.data[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 initialize
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(nodes, learning_rate = 0.9, phase_one = 150, phase_two = 100,
phase_one_learning_rate = 0.1, phase_two_learning_rate = 0)
Method min_entropy_index
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def min_entropy_index(data_examples, domain, flag_att=[])
min_entropy = nil
min_index = 0
domain[0..-2].each_index do |index|
unless flag_att.include?(index)
- 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 build
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def build(data_set, number_of_clusters)
@data_set = data_set
@number_of_clusters = number_of_clusters
raise ArgumentError, 'Length of centroid indices array differs from the specified number of clusters' unless @centroid_indices.empty? || @centroid_indices.length == @number_of_clusters
raise ArgumentError, 'Invalid value for on_empty' unless @on_empty == 'eliminate' || @on_empty == 'terminate' || @on_empty == 'random' || @on_empty == 'outlier'
- 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_distance_matrix
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def update_distance_matrix(ci, cj)
ci, cj = cj, ci if cj > ci
distances_to_new_cluster = Array.new
(@distance_matrix.length+1).times do |cx|
if cx!= ci && cx!=cj
- 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 build
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def build(data_set, number_of_clusters)
@data_set = data_set
@number_of_clusters = number_of_clusters
@clusters = [@data_set[0..-1]]
- 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"