aozorahack/aozora2html

View on GitHub

Showing 50 of 50 total issues

File aozora2html.rb has 1112 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative 'aozora2html/version'
require_relative 'extensions'
require_relative 'aozora2html/error'
require_relative 'aozora2html/i18n'
require_relative 'aozora2html/midashi_counter'
Severity: Major
Found in lib/aozora2html.rb - About 2 days to fix

    Consider simplifying this complex logical expression.
    Open

          if ((code >= '81ad') && (code <= '81b7')) ||
             ((code >= '81c0') && (code <= '81c7')) ||
             ((code >= '81cf') && (code <= '81d9')) ||
             ((code >= '81e9') && (code <= '81ef')) ||
             ((code >= '81f8') && (code <= '81fb')) ||
    Severity: Critical
    Found in lib/aozora2html/utils.rb - About 2 days to fix

      Method illegal_char_check has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
      Open

          def illegal_char_check(char, line)
            return unless char.is_a?(String)
      
            code = char.unpack1('H*')
            if (code == '21') ||
      Severity: Minor
      Found in lib/aozora2html/utils.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

      Class Aozora2Html has 63 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Aozora2Html
        # 全角バックスラッシュが出せないから直打ち
        KU = ['18e5'].pack('h*').force_encoding('shift_jis')
        NOJI = ['18f5'].pack('h*').force_encoding('shift_jis')
        DAKUTEN = ['18d8'].pack('h*').force_encoding('shift_jis')
      Severity: Major
      Found in lib/aozora2html.rb - About 1 day to fix

        Method rearrange_ruby has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.rearrange_ruby(parser, targets, upper_ruby, under_ruby)
                unless include_ruby?(targets)
                  return Aozora2Html::Tag::Ruby.new(parser, targets, upper_ruby, under_ruby)
                end
        
        
        Severity: Minor
        Found in lib/aozora2html/tag/ruby.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 exec_style has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
        Open

          def exec_style(targets, command)
            try_kuten = kuten2png(command)
            if try_kuten != command
              try_kuten
            elsif command.match?(TCY_COMMAND)
        Severity: Minor
        Found in lib/aozora2html.rb - About 6 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

        Method parse has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            def parse
              loop do
                first = read_char
        
                found = Aozora2Html::ACCENT_TABLE[first]
        Severity: Minor
        Found in lib/aozora2html/accent_parser.rb - About 3 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

        Method exec_block_start_command has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

          def exec_block_start_command(command)
            original_command = command.dup
            command.sub!(/^#{OPEN_MARK}/o, '')
            match_buf = +''
            if command.match?(INDENT_TYPE[:jisage])
        Severity: Minor
        Found in lib/aozora2html.rb - About 3 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

        Method exec_inline_start_command has 86 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def exec_inline_start_command(command)
            case command
            when CHUUKI_COMMAND
              @style_stack.push([command, '</ruby>'])
              push_char('<ruby><rb>')
        Severity: Major
        Found in lib/aozora2html.rb - About 3 hrs to fix

          Method search_front_reference has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

            def search_front_reference(string)
              if string.length == 0
                return false
              end
          
          
          Severity: Minor
          Found in lib/aozora2html.rb - About 3 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

          Consider simplifying this complex logical expression.
          Open

                if (code == '21') ||
                   (code == '23') ||
                   ((code >= 'a1') && (code <= 'a5')) ||
                   ((code >= '28') && (code <= '29')) ||
                   (code == '5b') ||
          Severity: Critical
          Found in lib/aozora2html/utils.rb - About 3 hrs to fix

            Method exec_inline_start_command has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

              def exec_inline_start_command(command)
                case command
                when CHUUKI_COMMAND
                  @style_stack.push([command, '</ruby>'])
                  push_char('<ruby><rb>')
            Severity: Minor
            Found in lib/aozora2html.rb - About 2 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

            Method rearrange_ruby has 68 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def self.rearrange_ruby(parser, targets, upper_ruby, under_ruby)
                    unless include_ruby?(targets)
                      return Aozora2Html::Tag::Ruby.new(parser, targets, upper_ruby, under_ruby)
                    end
            
            
            Severity: Major
            Found in lib/aozora2html/tag/ruby.rb - About 2 hrs to fix

              Method exec_block_start_command has 67 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def exec_block_start_command(command)
                  original_command = command.dup
                  command.sub!(/^#{OPEN_MARK}/o, '')
                  match_buf = +''
                  if command.match?(INDENT_TYPE[:jisage])
              Severity: Major
              Found in lib/aozora2html.rb - About 2 hrs to fix

                Method exec_style has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def exec_style(targets, command)
                    try_kuten = kuten2png(command)
                    if try_kuten != command
                      try_kuten
                    elsif command.match?(TCY_COMMAND)
                Severity: Major
                Found in lib/aozora2html.rb - About 2 hrs to fix

                  Method dispatch_aozora_command has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def dispatch_aozora_command
                      # 「[」の次が「#」でなければ注記ではない
                      if @stream.peek_char(0) != IGETA_MARK
                        return COMMAND_BEGIN
                      end
                  Severity: Minor
                  Found in lib/aozora2html.rb - About 2 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

                  Method parse has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def parse
                        loop do
                          first = read_char
                  
                          found = Aozora2Html::ACCENT_TABLE[first]
                  Severity: Minor
                  Found in lib/aozora2html/accent_parser.rb - About 2 hrs to fix

                    Method search_front_reference has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def search_front_reference(string)
                        if string.length == 0
                          return false
                        end
                    
                    
                    Severity: Minor
                    Found in lib/aozora2html.rb - About 1 hr to fix

                      Method build_header_info has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def build_header_info
                            header_info = { title: @header[0] }
                            case @header.length
                            when 2
                              process_person(@header[1], header_info)
                      Severity: Minor
                      Found in lib/aozora2html/header.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 illegal_char_check has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def illegal_char_check(char, line)
                            return unless char.is_a?(String)
                      
                            code = char.unpack1('H*')
                            if (code == '21') ||
                      Severity: Minor
                      Found in lib/aozora2html/utils.rb - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language