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'
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')
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)
- 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 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])
- 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 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>')
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
- 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 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>')
- 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 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])
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)
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
- 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 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
Method hyoki
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def hyoki
# <br /> times fix
@out.print "<br />\r\n</div>\r\n<div class=\"notation_notes\">\r\n<hr />\r\n<br />\r\n●表記について<br />\r\n<ul>\r\n".to_sjis
@out.print "\t<li>このファイルは W3C 勧告 XHTML1.1 にそった形式で作成されています。</li>\r\n".to_sjis
if @chuuki_table[:chuki]
- 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 general_output
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def general_output
if @style_stack.last
raise Aozora2Html::Error, I18n.t(:dont_crlf_in_style, @style_stack.last_command)
end
- 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 general_output
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def general_output
if @style_stack.last
raise Aozora2Html::Error, I18n.t(:dont_crlf_in_style, @style_stack.last_command)
end
Method dispatch_aozora_command
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def dispatch_aozora_command
# 「[」の次が「#」でなければ注記ではない
if @stream.peek_char(0) != IGETA_MARK
return COMMAND_BEGIN
end
Method parse_body
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_body
char = read_char
check = true
case char
when ACCENT_BEGIN
Method hyoki
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def hyoki
# <br /> times fix
@out.print "<br />\r\n</div>\r\n<div class=\"notation_notes\">\r\n<hr />\r\n<br />\r\n●表記について<br />\r\n<ul>\r\n".to_sjis
@out.print "\t<li>このファイルは W3C 勧告 XHTML1.1 にそった形式で作成されています。</li>\r\n".to_sjis
if @chuuki_table[:chuki]
Method parse_tail
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_tail
char = read_char
check = true
case char
when ACCENT_BEGIN
Method initialize
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(input, output, gaiji_dir: nil, css_files: nil, use_jisx0213: nil, use_unicode: nil)
@stream = if input.respond_to?(:read) ## readable IO?
Jstream.new(input)
else
Jstream.new(File.open(input, 'rb:Shift_JIS'))
Method exec_frontref_command
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def exec_frontref_command(command)
_whole, reference, spec1, spec2 = command.match(PAT_FRONTREF).to_a
spec = if spec1
spec1 + spec2
else
- 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 recovery_front_reference
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def recovery_front_reference(reference)
reference.each do |elt|
# if @ruby_buf.protected
if @ruby_buf.present?
@ruby_buf.push(elt)
- 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
Avoid deeply nested control flow statements. Open
case dir
when LEFT_MARK, OVER_MARK
filter = ->(x) { x.sub('under', 'over') }
end
Method apply_warichu
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def apply_warichu(command)
if command.match?(END_MARK)
if @stream.peek_char(0) != PAREN_END_MARK
push_char(PAREN_END_MARK)
end
- 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 process
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def process
catch(:terminate) do
parse
rescue Aozora2Html::Error => e
puts e.message(line_number)
- 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
Avoid deeply nested control flow statements. Open
if command.match?(TEN_MARK)
case dir
when LEFT_MARK, UNDER_MARK
filter = ->(x) { "#{x}_after" }
end
Method implicit_close
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def implicit_close(type)
return unless @indent_stack.last
if check_close_match(type)
# ok, nested multiline tags, go ahead
- 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 apply_chitsuki
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def apply_chitsuki(string, multiline: false)
if string.match?(CLOSE_MARK + INDENT_TYPE[:chitsuki] + END_MARK) ||
string.match?(CLOSE_MARK + JIAGE_COMMAND + END_MARK)
explicit_close(:chitsuki)
@indent_stack.pop
- 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 judge_chuuki
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def judge_chuuki
# 注記が入るかどうかチェック
i = 0
loop do
case @stream.peek_char(i)
- 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 initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize(input, output, gaiji_dir: nil, css_files: nil, use_jisx0213: nil, use_unicode: nil)
@stream = if input.respond_to?(:read) ## readable IO?
Jstream.new(input)
else
Jstream.new(File.open(input, 'rb:Shift_JIS'))
- 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 dispatch_gaiji
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def dispatch_gaiji
# 「※」の次が「[」でなければ外字ではない
if @stream.peek_char(0) != COMMAND_BEGIN
return GAIJI_MARK
end
- 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_body
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def parse_body
char = read_char
check = true
case char
when ACCENT_BEGIN
- 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 apply_jisage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def apply_jisage(command)
if command.match?(MADE_MARK) || command.match?(END_MARK)
# 字下げ終わり
explicit_close(:jisage)
@indent_stack.pop
- 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 exec_block_end_command
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def exec_block_end_command(command)
original_command = command.dup
command.sub!(/^#{CLOSE_MARK}/o, '')
matched = false
mode = detect_command_mode(command)
- 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"