Skip to content

Commit 0e24191

Browse files
committed
add rubocop-performance
1 parent f01650e commit 0e24191

File tree

8 files changed

+16
-10
lines changed

8 files changed

+16
-10
lines changed

.rubocop.yml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ inherit_from: .rubocop_todo.yml
33
require:
44
- rubocop-rake
55
- rubocop-rspec
6+
- rubocop-performance
67

78
AllCops:
89
NewCops: enable

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ gem 'guard-rspec'
1212
gem 'rake'
1313
gem 'rspec'
1414
gem 'rubocop'
15+
gem 'rubocop-performance'
1516
gem 'rubocop-rake'
1617
gem 'rubocop-rspec'

Gemfile.lock

+4
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ GEM
118118
rubocop (~> 1.41)
119119
rubocop-factory_bot (2.25.1)
120120
rubocop (~> 1.41)
121+
rubocop-performance (1.18.0)
122+
rubocop (>= 1.7.0, < 2.0)
123+
rubocop-ast (>= 0.4.0)
121124
rubocop-rake (0.6.0)
122125
rubocop (~> 1.0)
123126
rubocop-rspec (2.27.0)
@@ -147,6 +150,7 @@ DEPENDENCIES
147150
rake
148151
rspec
149152
rubocop
153+
rubocop-performance
150154
rubocop-rake
151155
rubocop-rspec
152156

lib/caramelize/filters/camel_case_to_wiki_links.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def run
1818
private
1919

2020
def format_link(link)
21-
link.gsub!(' ', '_')
22-
link.gsub!('.', '')
21+
link.tr!(' ', '_')
22+
link.delete!('.')
2323
"[[#{link}]]"
2424
end
2525
end

lib/caramelize/filters/swap_wiki_links.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def run
2020

2121
def format_link(label, link)
2222
link.downcase!
23-
link.gsub!(' ', '_')
24-
link.gsub!('.', '')
23+
link.tr!(' ', '_')
24+
link.delete!('.')
2525
"[[#{label}|#{link}]]"
2626
end
2727
end

lib/caramelize/input_wiki/redmine_wiki.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def read_pages
2424
build_page(row_page)
2525
end
2626
titles.uniq!
27-
revisions.sort! { |a, b| a.time <=> b.time }
27+
revisions.sort_by!(&:time)
2828

2929
revisions
3030
end
@@ -43,12 +43,12 @@ def read_authors
4343
def build_page(row_page)
4444
results_contents = database.query(single_page_query(row_page['id']))
4545

46-
wiki = wikis.select { |row| row['id'] == row_page['wiki_id'] }.first
46+
wiki = wikis.find { |row| row['id'] == row_page['wiki_id'] }
4747

4848
project_identifier = ''
4949

5050
if wiki
51-
project = projects.select { |row| row['id'] == wiki['project_id'] }.first
51+
project = projects.find { |row| row['id'] == wiki['project_id'] }
5252
project_identifier = "#{project['identifier']}/"
5353
end
5454

lib/caramelize/input_wiki/wiki.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def revisions_by_title(title)
1717
# new array only containing pages by this name sorted by time asc
1818
# this does not support renamed pages
1919
revisions.select { |revision| revision.title == title }
20-
.sort { |x, y| x.time <=> y.time }
20+
.sort_by(&:time)
2121
end
2222

2323
# return an empty array in case this action was not overridden
@@ -54,7 +54,7 @@ def filters
5454
end
5555

5656
def latest_revisions
57-
@latest_revisions ||= titles.map { |title| revisions_by_title(title).last }.compact
57+
@latest_revisions ||= titles.filter_map { |title| revisions_by_title(title).last }
5858
end
5959

6060
def markup

lib/caramelize/output_wiki/gollum.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def rename_page(page_title, new_title)
3838
def commit_history(revisions, options = {}, &block)
3939
revisions.each_with_index do |page, index|
4040
# call debug output from outside
41-
block.call(page, index) if block_given?
41+
yield(page, index) if block
4242
commit_revision(page, options.fetch(:markup, :markdown))
4343
end
4444
end

0 commit comments

Comments
 (0)