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)
Severity: Minor
Found in lib/wareki/date.rb - About 1 day to fix

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

Severity: Minor
Found in build-util/parse_wikipedia.rb - About 5 hrs to fix

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)
Severity: Minor
Found in lib/wareki/date.rb - About 2 hrs to fix

    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)
    Severity: Minor
    Found in lib/wareki/date.rb - About 1 hr to fix

      Method get_data has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def get_data
          era_n = {}
          era_s = {}
          cur_o = nil
      
      
      Severity: Minor
      Found in build-util/parse_wikipedia.rb - About 1 hr to fix

        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}"
        Severity: Minor
        Found in lib/wareki/date.rb - About 1 hr to fix

        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}"
        Severity: Minor
        Found in lib/wareki/date.rb - About 1 hr to fix

          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
          Severity: Minor
          Found in lib/wareki/date.rb - About 35 mins to fix

          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

          Severity
          Category
          Status
          Source
          Language