Skip to content

Commit

Permalink
Merge pull request #1598 from kmuto/update-rubocop
Browse files Browse the repository at this point in the history
update rubocop to 1.3.0
  • Loading branch information
takahashim authored Nov 13, 2020
2 parents a0db998 + ec3c4bf commit cc52c4c
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 37 deletions.
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ Style/ClassMethods:
Style/CommentedKeyword:
Enabled: false

Style/DocumentDynamicEvalDefinition:
Enabled: false

Style/FloatDivision:
Enabled: false

Expand Down Expand Up @@ -592,6 +595,8 @@ Naming/VariableName:
Naming/VariableNumber:
EnforcedStyle: normalcase
Enabled: true
Exclude:
- test/*

#### Security

Expand Down
5 changes: 1 addition & 4 deletions bin/review-check
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def each_paragraph(f)
case line
when /\A\#@ok\((.*)\)/
@review_utils_word_ok = $1
when /\A\#@/
when /\A\#@/, /\A\s*\z/
# do nothing
next
when %r{\A//caption\{(.*?)//\}}
Expand All @@ -145,9 +145,6 @@ def each_paragraph(f)
end
when /\A=/
yield [line.slice(/\A=+(?:\[.*?\])?\s+(.*)/, 1).strip], f.lineno
when /\A\s*\z/
# skip
next
else
buf = [line.strip]
lineno = f.lineno
Expand Down
14 changes: 7 additions & 7 deletions lib/review/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -369,19 +369,19 @@ def compile_headline(line)
caption = m[4].strip
index = level - 1
if tag
if tag !~ %r{\A/}
if caption.empty?
warn 'headline is empty.'
end
close_current_tagged_section(level)
open_tagged_section(tag, level, label, caption)
else
if tag.start_with?('/')
open_tag = tag[1..-1]
prev_tag_info = @tagged_section.pop
if prev_tag_info.nil? || prev_tag_info.first != open_tag
error "#{open_tag} is not opened."
end
close_tagged_section(*prev_tag_info)
else
if caption.empty?
warn 'headline is empty.'
end
close_current_tagged_section(level)
open_tagged_section(tag, level, label, caption)
end
else
if caption.empty?
Expand Down
6 changes: 3 additions & 3 deletions lib/review/idgxmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1182,10 +1182,10 @@ def inline_chapref(id)
chs = ['', '「', '」']
if @book.config['chapref']
chs2 = @book.config['chapref'].split(',')
if chs2.size != 3
error '--chapsplitter must have exactly 3 parameters with comma.'
else
if chs2.size == 3
chs = chs2
else
error '--chapsplitter must have exactly 3 parameters with comma.'
end
end
s = "#{chs[0]}#{@book.chapter_index.number(id)}#{chs[1]}#{@book.chapter_index.title(id)}#{chs[2]}"
Expand Down
12 changes: 6 additions & 6 deletions lib/review/latexbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ def notoc_end(level)
end

def nodisp_begin(level, _label, caption)
if @output.pos != 0
blank
else
if @output.pos == 0
puts macro('clearpage')
else
blank
end
puts macro('addcontentsline', 'toc', HEADLINE[level], compile_inline(caption))
# FIXME: headings
Expand Down Expand Up @@ -1369,10 +1369,10 @@ def index(str)
else
if item =~ /\A[[:ascii:]]+\Z/ || @index_mecab.nil?
esc_item = escape_index(escape(item))
if esc_item != item
"#{escape_index(item)}@#{esc_item}"
else
if esc_item == item
esc_item
else
"#{escape_index(item)}@#{esc_item}"
end
else
yomi = NKF.nkf('-w --hiragana', @index_mecab.parse(item).force_encoding('UTF-8').chomp)
Expand Down
15 changes: 9 additions & 6 deletions lib/review/preprocessor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def preproc(f)

when /\A\s*\z/ # empty line
@f.puts
else
else # rubocop:disable Lint/DuplicateBranch
@f.print line
end
end
Expand Down Expand Up @@ -222,11 +222,14 @@ def parse_optargs(str)

def optarg_value(spec)
case spec
when 'true' then true # [name=true]
when 'false' then false # [name=false]
when 'nil' then nil # [name=nil]
when nil then true # [name]
when /^\d+$/ then $&.to_i # [name=8]
when 'true' # [name=true], [name]
true
when 'false' # [name=false]
false
when 'nil' # [name=nil]
nil
when /^\d+$/ # [name=8]
$&.to_i
else # [name=val]
spec
end
Expand Down
8 changes: 2 additions & 6 deletions lib/review/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,7 @@ def convert_documentclass_opts(yml, cls, prev_opts)
opts << "paper=#{v.sub('j', '').sub('paper', '')}"
when /[\d.]+ptj/ # not cared...
opts << "fontsize=#{v.sub('j', '')}"
when /[\d.]+pt/
opts << "fontsize=#{v}"
when /[\d.]+Q/
when /[\d.]+pt/, /[\d.]+Q/
opts << "fontsize=#{v}"
when 'landscape', 'oneside', 'twoside', 'vartwoside', 'onecolumn',
'twocolumn', 'titlepage', 'notitlepage', 'openright',
Expand All @@ -442,9 +440,7 @@ def convert_documentclass_opts(yml, cls, prev_opts)
opts << "paper=#{v.sub('j', '').sub('paper', '')}"
when /[\d.]+ptj/ # not cared...
opts << "fontsize=#{v.sub('j', '')}"
when /[\d.]+pt/
opts << "fontsize=#{v}"
when /[\d.]+Q/
when /[\d.]+pt/, /[\d.]+Q/
opts << "fontsize=#{v}"
when 'landscape', 'oneside', 'twoside', 'onecolumn', 'twocolumn', 'titlepage', 'notitlepage', 'openright', 'openany', 'leqno', 'fleqn', 'draft', 'final', 'report'
# pass-through
Expand Down
2 changes: 1 addition & 1 deletion review.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gem::Specification.new do |gem|
gem.add_dependency('rubyzip')
gem.add_development_dependency('pygments.rb')
gem.add_development_dependency('rake')
gem.add_development_dependency('rubocop', '~> 1.0.0')
gem.add_development_dependency('rubocop', '~> 1.3.0')
gem.add_development_dependency('rubocop-performance')
gem.add_development_dependency('simplecov')
gem.add_development_dependency('test-unit')
Expand Down
4 changes: 2 additions & 2 deletions test/test_book_chapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ def test_on_chaps?
assert !pre.on_chaps?

ch2_path = File.join(dir, 'chapter2.re')
File.open(ch2_path, 'w') {}
FileUtils.touch(ch2_path)
ch2 = Book::Chapter.new(book, 2, 'chapter2', ch2_path)

ch3_path = File.join(dir, 'chapter3.re')
File.open(ch3_path, 'w') {}
FileUtils.touch(ch3_path)
ch3 = Book::Chapter.new(book, 3, 'chapter3', ch3_path)

assert ch2.on_chaps?
Expand Down
8 changes: 6 additions & 2 deletions test/test_lineinput.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ def test_while_match
io = StringIO.new("abc\ndef\nghi")
li = LineInput.new(io)

li.while_match(/^[ad]/) {}
li.while_match(/^[ad]/) do
# skip
end
assert_equal 2, li.lineno
assert_equal 'ghi', li.gets
end
Expand All @@ -131,7 +133,9 @@ def test_until_match
io = StringIO.new("abc\ndef\nghi")
li = LineInput.new(io)

li.until_match(/^[^a]/) {}
li.until_match(/^[^a]/) do
# skip
end
assert_equal 1, li.lineno
assert_equal "def\n", li.gets
end
Expand Down

0 comments on commit cc52c4c

Please sign in to comment.