Commit c6a3576e1d9e1bb9b78cffff5aec2cb9821ed14a

Authored by Laust Rud Jacobsen
1 parent c5dd4c3e
Exists in master and in 1 other branch production

Rubocop: prefer format() over % for readability and discoverability

.rubocop_todo.yml
@@ -88,16 +88,6 @@ Style/FileName: @@ -88,16 +88,6 @@ Style/FileName:
88 - 'config/initializers/cve-2013-0156.rb' 88 - 'config/initializers/cve-2013-0156.rb'
89 - 'script/rspec-queue-mongoid.rb' 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 # Offense count: 27 91 # Offense count: 27
102 # Configuration parameters: MinBodyLength. 92 # Configuration parameters: MinBodyLength.
103 Style/GuardClause: 93 Style/GuardClause:
app/decorators/backtrace_line_decorator.rb
@@ -73,13 +73,13 @@ private @@ -73,13 +73,13 @@ private
73 73
74 def link_to_github(app, text = nil) 74 def link_to_github(app, text = nil)
75 return unless app.github_repo? 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 h.link_to(text || file_name, href, target: '_blank') 77 h.link_to(text || file_name, href, target: '_blank')
78 end 78 end
79 79
80 def link_to_bitbucket(app, text = nil) 80 def link_to_bitbucket(app, text = nil)
81 return unless app.bitbucket_repo? 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 h.link_to(text || file_name, href, target: '_blank') 83 h.link_to(text || file_name, href, target: '_blank')
84 end 84 end
85 85
app/helpers/problems_helper.rb
1 module ProblemsHelper 1 module ProblemsHelper
2 def problem_confirm(action) 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 end 4 end
5 5
6 def truncated_problem_message(problem) 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,12 +15,22 @@ describe "apps/edit.html.haml", type: 'view' do
15 15
16 it "should confirm the 'reset' link" do 16 it "should confirm the 'reset' link" do
17 render 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 end 24 end
20 25
21 it "should confirm the 'destroy' link" do 26 it "should confirm the 'destroy' link" do
22 render 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 end 34 end
25 end 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,13 +66,23 @@ describe "problems/show.html.haml", type: 'view' do
66 66
67 it "should confirm the 'resolve' link by default" do 67 it "should confirm the 'resolve' link by default" do
68 render 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 end 75 end
71 76
72 it "should confirm the 'resolve' link if configuration is unset" do 77 it "should confirm the 'resolve' link if configuration is unset" do
73 allow(Errbit::Config).to receive(:confirm_err_actions).and_return(nil) 78 allow(Errbit::Config).to receive(:confirm_err_actions).and_return(nil)
74 render 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 end 86 end
77 87
78 it "should not confirm the 'resolve' link if configured not to" do 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,7 +53,12 @@ describe 'users/show.html.haml', type: 'view' do
53 53
54 it "should confirm the 'resolve' link by default" do 54 it "should confirm the 'resolve' link by default" do
55 render 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 end 62 end
58 end 63 end
59 end 64 end