Showing 8 of 9 total issues
Method format
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
def format(key)
case key.to_sym
when :e then era_name
when :g then era_name.to_s == '' ? '' : era_year
when :G then era_name.to_s == '' ? '' : Utils.i2z(era_year)
- 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 get_data
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def get_data
era_n = {}
era_s = {}
cur_o = 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 Date
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Date
attr_accessor :year, :month, :day, :era_year, :era_name
def self.today
jd(::Date.today.jd)
Method format
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def format(key)
case key.to_sym
when :e then era_name
when :g then era_name.to_s == '' ? '' : era_year
when :G then era_name.to_s == '' ? '' : Utils.i2z(era_year)
Method get_data
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_data
era_n = {}
era_s = {}
cur_o = nil
Method _parse
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def self._parse(str)
str = str.to_s.gsub(/[[:space:]]/, '')
match = REGEX.match(str)
match && !match[0].empty? or
raise ArgumentError, "Invaild Date: #{str}"
- 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 _parse
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self._parse(str)
str = str.to_s.gsub(/[[:space:]]/, '')
match = REGEX.match(str)
match && !match[0].empty? or
raise ArgumentError, "Invaild Date: #{str}"
Method initialize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def initialize(era_name, era_year, month = 1, day = 1, is_leap_month = false)
raise ArgumentError, "Undefined era '#{era_name}'" if
era_name.to_s != '' && era_name != '紀元前' && !ERA_BY_NAME[era_name]
@month = month
- 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"