Commit c6a3576e1d9e1bb9b78cffff5aec2cb9821ed14a
1 parent
c5dd4c3e
Exists in
master
and in
1 other branch
Rubocop: prefer format() over % for readability and discoverability
Showing
6 changed files
with
33 additions
and
18 deletions
Show diff stats
.rubocop_todo.yml
... | ... | @@ -88,16 +88,6 @@ Style/FileName: |
88 | 88 | - 'config/initializers/cve-2013-0156.rb' |
89 | 89 | - 'script/rspec-queue-mongoid.rb' |
90 | 90 | |
91 | -# Offense count: 8 | |
92 | -# Configuration parameters: EnforcedStyle, SupportedStyles. | |
93 | -Style/FormatString: | |
94 | - Exclude: | |
95 | - - 'app/decorators/backtrace_line_decorator.rb' | |
96 | - - 'app/helpers/problems_helper.rb' | |
97 | - - 'spec/views/apps/edit.html.haml_spec.rb' | |
98 | - - 'spec/views/problems/show.html.haml_spec.rb' | |
99 | - - 'spec/views/users/show.html.haml_spec.rb' | |
100 | - | |
101 | 91 | # Offense count: 27 |
102 | 92 | # Configuration parameters: MinBodyLength. |
103 | 93 | Style/GuardClause: | ... | ... |
app/decorators/backtrace_line_decorator.rb
... | ... | @@ -73,13 +73,13 @@ private |
73 | 73 | |
74 | 74 | def link_to_github(app, text = nil) |
75 | 75 | return unless app.github_repo? |
76 | - href = "%s#L%s" % [app.github_url_to_file(decorated_path + file_name), number] | |
76 | + href = format("%s#L%s", app.github_url_to_file(decorated_path + file_name), number) | |
77 | 77 | h.link_to(text || file_name, href, target: '_blank') |
78 | 78 | end |
79 | 79 | |
80 | 80 | def link_to_bitbucket(app, text = nil) |
81 | 81 | return unless app.bitbucket_repo? |
82 | - href = "%s#%s-%s" % [app.bitbucket_url_to_file(decorated_path + file_name), file_name, number] | |
82 | + href = format("%s#%s-%s", app.bitbucket_url_to_file(decorated_path + file_name), file_name, number) | |
83 | 83 | h.link_to(text || file_name, href, target: '_blank') |
84 | 84 | end |
85 | 85 | ... | ... |
app/helpers/problems_helper.rb
1 | 1 | module ProblemsHelper |
2 | 2 | def problem_confirm(action) |
3 | - t('problems.confirm.%s' % action) unless Errbit::Config.confirm_err_actions.eql? false | |
3 | + t(format('problems.confirm.%s', action)) unless Errbit::Config.confirm_err_actions.eql? false | |
4 | 4 | end |
5 | 5 | |
6 | 6 | def truncated_problem_message(problem) | ... | ... |
spec/views/apps/edit.html.haml_spec.rb
... | ... | @@ -15,12 +15,22 @@ describe "apps/edit.html.haml", type: 'view' do |
15 | 15 | |
16 | 16 | it "should confirm the 'reset' link" do |
17 | 17 | render |
18 | - expect(action_bar).to have_selector('a.button[data-confirm="%s"]' % I18n.t('apps.confirm_destroy_all_problems')) | |
18 | + expect(action_bar).to have_selector( | |
19 | + format( | |
20 | + 'a.button[data-confirm="%s"]', | |
21 | + I18n.t('apps.confirm_destroy_all_problems') | |
22 | + ) | |
23 | + ) | |
19 | 24 | end |
20 | 25 | |
21 | 26 | it "should confirm the 'destroy' link" do |
22 | 27 | render |
23 | - expect(action_bar).to have_selector('a.button[data-confirm="%s"]' % I18n.t('apps.confirm_delete')) | |
28 | + expect(action_bar).to have_selector( | |
29 | + format( | |
30 | + 'a.button[data-confirm="%s"]', | |
31 | + I18n.t('apps.confirm_delete') | |
32 | + ) | |
33 | + ) | |
24 | 34 | end |
25 | 35 | end |
26 | 36 | ... | ... |
spec/views/problems/show.html.haml_spec.rb
... | ... | @@ -66,13 +66,23 @@ describe "problems/show.html.haml", type: 'view' do |
66 | 66 | |
67 | 67 | it "should confirm the 'resolve' link by default" do |
68 | 68 | render |
69 | - expect(action_bar).to have_selector('a.resolve[data-confirm="%s"]' % I18n.t('problems.confirm.resolve_one')) | |
69 | + expect(action_bar).to have_selector( | |
70 | + format( | |
71 | + 'a.resolve[data-confirm="%s"]', | |
72 | + I18n.t('problems.confirm.resolve_one') | |
73 | + ) | |
74 | + ) | |
70 | 75 | end |
71 | 76 | |
72 | 77 | it "should confirm the 'resolve' link if configuration is unset" do |
73 | 78 | allow(Errbit::Config).to receive(:confirm_err_actions).and_return(nil) |
74 | 79 | render |
75 | - expect(action_bar).to have_selector('a.resolve[data-confirm="%s"]' % I18n.t('problems.confirm.resolve_one')) | |
80 | + expect(action_bar).to have_selector( | |
81 | + format( | |
82 | + 'a.resolve[data-confirm="%s"]', | |
83 | + I18n.t('problems.confirm.resolve_one') | |
84 | + ) | |
85 | + ) | |
76 | 86 | end |
77 | 87 | |
78 | 88 | it "should not confirm the 'resolve' link if configured not to" do | ... | ... |
spec/views/users/show.html.haml_spec.rb
... | ... | @@ -53,7 +53,12 @@ describe 'users/show.html.haml', type: 'view' do |
53 | 53 | |
54 | 54 | it "should confirm the 'resolve' link by default" do |
55 | 55 | render |
56 | - expect(view.content_for(:action_bar)).to have_selector('a.delete[data-confirm="%s"]' % I18n.t('.users.confirm_delete')) | |
56 | + expect(view.content_for(:action_bar)).to have_selector( | |
57 | + format( | |
58 | + 'a.delete[data-confirm="%s"]', | |
59 | + I18n.t('.users.confirm_delete') | |
60 | + ) | |
61 | + ) | |
57 | 62 | end |
58 | 63 | end |
59 | 64 | end | ... | ... |