Showing 4 of 4 total issues
Class Rwanda
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Rwanda
include Singleton
attr_accessor :villages
DIVISIONS=[:province,:district,:sector,:cell,:village]
Method print_result
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def print_result(lines, division)
output = ''
# summary line
if lines.empty?
- 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 create_line
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def create_line(village, div)
new_line = " #{village.send(div)} is a #{div}#{' in' unless div==:province}"
unless div == :province
(0...Rwanda::DIVISIONS.index(div)).to_a.reverse.each do |n|
new_line << " #{village[n]}#{' '+Rwanda::DIVISIONS[n].to_s.capitalize+',' unless n==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 exist?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def exist?(district=false, sector=false, cell=false, village=false)
villages = @villages.dup
return false unless district
{district: district, sector: sector, cell: cell, village: village}.each_pair do |division_name,division|
#binding.pry
- 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"