Method detect_delimiter
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def detect_delimiter
# Calculate variances of the N first lines for each delimiter, then grab the one that changes less
@delimiter = DEFAULT_DELIMITER unless first_line
- 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 CsvNormalizer
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class CsvNormalizer
LINE_SIZE_FOR_CLEANING = 5000
LINES_FOR_DETECTION = 100 # How many lines to read?
SAMPLE_READ_LIMIT = 500000 # Read big enough sample bytes for the encoding sampling
Method detect_delimiter
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def detect_delimiter
# Calculate variances of the N first lines for each delimiter, then grab the one that changes less
@delimiter = DEFAULT_DELIMITER unless first_line
Method normalize
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def normalize(temporary_filepath)
temporary_csv = CSV.open(temporary_filepath, 'w', col_sep: OUTPUT_DELIMITER, encoding: 'UTF-8')
CSV.open(filepath, "rb:#{encoding}", col_sep: @delimiter) do |input|
- 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 encoding
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def encoding
return @encoding unless @encoding.nil?
source_file = SourceFile.new(filepath)
if source_file.encoding
- 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 run
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def run
return self unless File.exists?(filepath)
detect_delimiter
- 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"