Commit af87b10a8895276ea94053880acfa52b73e8f2c8

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

Rubocop: method indentation consistency fixes

Sorry, this touches a lot of code.
.rubocop.yml
... ... @@ -21,7 +21,7 @@ Style/IndentationConsistency:
21 21 # modifier keywords shall be indented the same as public methods and that
22 22 # protected and private members shall be indented one step more than the
23 23 # modifiers.
24   - EnforcedStyle: rails
  24 + EnforcedStyle: rails
25 25  
26 26 Style/AccessModifierIndentation:
27 27 EnforcedStyle: outdent
... ...
.rubocop_todo.yml
... ... @@ -185,23 +185,6 @@ Style/IfUnlessModifier:
185 185 - 'app/models/notice.rb'
186 186 - 'app/models/user.rb'
187 187  
188   -# Offense count: 27
189   -# Cop supports --auto-correct.
190   -# Configuration parameters: EnforcedStyle, SupportedStyles.
191   -Style/IndentationConsistency:
192   - Exclude:
193   - - 'app/controllers/apps_controller.rb'
194   - - 'app/controllers/comments_controller.rb'
195   - - 'app/controllers/deploys_controller.rb'
196   - - 'app/controllers/users_controller.rb'
197   - - 'app/helpers/application_helper.rb'
198   - - 'app/models/app.rb'
199   - - 'app/models/comment.rb'
200   - - 'app/models/deploy.rb'
201   - - 'app/models/problem.rb'
202   - - 'app/models/watcher.rb'
203   - - 'lib/hoptoad.rb'
204   -
205 188 # Offense count: 6
206 189 # Cop supports --auto-correct.
207 190 Style/Lambda:
... ...
app/controllers/apps_controller.rb
... ... @@ -103,43 +103,43 @@ protected
103 103 end
104 104 end
105 105  
106   - def plug_params(app)
107   - app.watchers.build if app.watchers.none?
108   - app.issue_tracker ||= IssueTracker.new
109   - app.notification_service = NotificationService.new unless app.notification_service_configured?
110   - app.copy_attributes_from(params[:copy_attributes_from]) if params[:copy_attributes_from]
111   - end
  106 + def plug_params(app)
  107 + app.watchers.build if app.watchers.none?
  108 + app.issue_tracker ||= IssueTracker.new
  109 + app.notification_service = NotificationService.new unless app.notification_service_configured?
  110 + app.copy_attributes_from(params[:copy_attributes_from]) if params[:copy_attributes_from]
  111 + end
112 112  
113   - # email_at_notices is edited as a string, and stored as an array.
114   - def parse_email_at_notices_or_set_default
115   - if params[:app] && (val = params[:app][:email_at_notices])
116   - # Sanitize negative values, split on comma,
117   - # strip, parse as integer, remove all '0's.
118   - # If empty, set as default and show an error message.
119   - email_at_notices = val.gsub(/-\d+/,"").split(",").map{|v| v.strip.to_i }.reject{|v| v == 0}
120   - if email_at_notices.any?
121   - params[:app][:email_at_notices] = email_at_notices
122   - else
123   - default_array = params[:app][:email_at_notices] = Errbit::Config.email_at_notices
124   - flash[:error] = "Couldn't parse your notification frequency. Value was reset to default (#{default_array.join(', ')})."
125   - end
  113 + # email_at_notices is edited as a string, and stored as an array.
  114 + def parse_email_at_notices_or_set_default
  115 + if params[:app] && (val = params[:app][:email_at_notices])
  116 + # Sanitize negative values, split on comma,
  117 + # strip, parse as integer, remove all '0's.
  118 + # If empty, set as default and show an error message.
  119 + email_at_notices = val.gsub(/-\d+/,"").split(",").map{|v| v.strip.to_i }.reject{|v| v == 0}
  120 + if email_at_notices.any?
  121 + params[:app][:email_at_notices] = email_at_notices
  122 + else
  123 + default_array = params[:app][:email_at_notices] = Errbit::Config.email_at_notices
  124 + flash[:error] = "Couldn't parse your notification frequency. Value was reset to default (#{default_array.join(', ')})."
126 125 end
127 126 end
  127 + end
128 128  
129   - def parse_notice_at_notices_or_set_default
130   - if params[:app][:notification_service_attributes] && (val = params[:app][:notification_service_attributes][:notify_at_notices])
131   - # Sanitize negative values, split on comma,
132   - # strip, parse as integer, remove all '0's.
133   - # If empty, set as default and show an error message.
134   - notify_at_notices = val.gsub(/-\d+/,"").split(",").map{|v| v.strip.to_i }
135   - if notify_at_notices.any?
136   - params[:app][:notification_service_attributes][:notify_at_notices] = notify_at_notices
137   - else
138   - default_array = params[:app][:notification_service_attributes][:notify_at_notices] = Errbit::Config.notify_at_notices
139   - flash[:error] = "Couldn't parse your notification frequency. Value was reset to default (#{default_array.join(', ')})."
140   - end
  129 + def parse_notice_at_notices_or_set_default
  130 + if params[:app][:notification_service_attributes] && (val = params[:app][:notification_service_attributes][:notify_at_notices])
  131 + # Sanitize negative values, split on comma,
  132 + # strip, parse as integer, remove all '0's.
  133 + # If empty, set as default and show an error message.
  134 + notify_at_notices = val.gsub(/-\d+/,"").split(",").map{|v| v.strip.to_i }
  135 + if notify_at_notices.any?
  136 + params[:app][:notification_service_attributes][:notify_at_notices] = notify_at_notices
  137 + else
  138 + default_array = params[:app][:notification_service_attributes][:notify_at_notices] = Errbit::Config.notify_at_notices
  139 + flash[:error] = "Couldn't parse your notification frequency. Value was reset to default (#{default_array.join(', ')})."
141 140 end
142 141 end
  142 + end
143 143  
144 144 private def app_params
145 145 params.require(:app).permit!
... ...
app/controllers/comments_controller.rb
... ... @@ -30,11 +30,11 @@ protected
30 30 @app = App.find(params[:app_id])
31 31 end
32 32  
33   - def find_problem
34   - @problem = @app.problems.find(params[:problem_id])
35   - end
  33 + def find_problem
  34 + @problem = @app.problems.find(params[:problem_id])
  35 + end
36 36  
37   - def comment_params
38   - params.require(:comment).permit!
39   - end
  37 + def comment_params
  38 + params.require(:comment).permit!
  39 + end
40 40 end
... ...
app/controllers/deploys_controller.rb
... ... @@ -30,14 +30,14 @@ private
30 30 end
31 31 end
32 32  
33   - # handle Heroku's HTTP post deployhook format
34   - def heroku_deploy
35   - {
36   - :username => params[:user],
37   - :environment => params[:rack_env].try(:downcase) || params[:app],
38   - :repository => "git@heroku.com:#{params[:app]}.git",
39   - :revision => params[:head],
40   - }
41   - end
  33 + # handle Heroku's HTTP post deployhook format
  34 + def heroku_deploy
  35 + {
  36 + :username => params[:user],
  37 + :environment => params[:rack_env].try(:downcase) || params[:app],
  38 + :repository => "git@heroku.com:#{params[:app]}.git",
  39 + :revision => params[:head],
  40 + }
  41 + end
42 42 end
43 43  
... ...
app/helpers/application_helper.rb
... ... @@ -81,7 +81,7 @@ private
81 81 tallies.values.inject(0) {|sum, n| sum + n}
82 82 end
83 83  
84   - def head_size
85   - 4
86   - end
  84 + def head_size
  85 + 4
  86 + end
87 87 end
... ...
app/models/app.rb
... ... @@ -196,26 +196,26 @@ protected
196 196 )
197 197 end
198 198  
199   - def generate_api_key
200   - self.api_key ||= SecureRandom.hex
201   - end
  199 + def generate_api_key
  200 + self.api_key ||= SecureRandom.hex
  201 + end
202 202  
203   - def check_issue_tracker
204   - if issue_tracker.present?
205   - issue_tracker.valid?
206   - issue_tracker.errors.full_messages.each do |error|
207   - errors[:base] << error
208   - end if issue_tracker.errors
209   - end
  203 + def check_issue_tracker
  204 + if issue_tracker.present?
  205 + issue_tracker.valid?
  206 + issue_tracker.errors.full_messages.each do |error|
  207 + errors[:base] << error
  208 + end if issue_tracker.errors
210 209 end
  210 + end
211 211  
212   - def normalize_github_repo
213   - return if github_repo.blank?
214   - github_host = URI.parse(Errbit::Config.github_url).host
215   - github_host = Regexp.escape(github_host)
216   - github_repo.strip!
217   - github_repo.sub!(/(git@|https?:\/\/)#{github_host}(\/|:)/, '')
218   - github_repo.sub!(/\.git$/, '')
219   - end
  212 + def normalize_github_repo
  213 + return if github_repo.blank?
  214 + github_host = URI.parse(Errbit::Config.github_url).host
  215 + github_host = Regexp.escape(github_host)
  216 + github_repo.strip!
  217 + github_repo.sub!(/(git@|https?:\/\/)#{github_host}(\/|:)/, '')
  218 + github_repo.sub!(/\.git$/, '')
  219 + end
220 220 end
221 221  
... ...
app/models/comment.rb
... ... @@ -34,7 +34,7 @@ protected
34 34 err.inc(comments_count: 1)
35 35 end
36 36  
37   - def decrease_counter_cache
38   - err.inc(comments_count: -1) if err
39   - end
  37 + def decrease_counter_cache
  38 + err.inc(comments_count: -1) if err
  39 + end
40 40 end
... ...
app/models/deploy.rb
... ... @@ -32,16 +32,16 @@ protected
32 32 app.resolve_errs_on_deploy?
33 33 end
34 34  
35   - def store_cached_attributes_on_problems
36   - Problem.where(:app_id => app.id).update_all(
37   - last_deploy_at: created_at
38   - )
39   - end
  35 + def store_cached_attributes_on_problems
  36 + Problem.where(:app_id => app.id).update_all(
  37 + last_deploy_at: created_at
  38 + )
  39 + end
40 40  
41   - def deliver_email
42   - if app.notify_on_deploys? && app.notification_recipients.any?
43   - Mailer.deploy_notification(self).deliver_now
44   - end
  41 + def deliver_email
  42 + if app.notify_on_deploys? && app.notification_recipients.any?
  43 + Mailer.deploy_notification(self).deliver_now
45 44 end
  45 + end
46 46 end
47 47  
... ...
app/models/problem.rb
... ... @@ -257,7 +257,7 @@ private
257 257 counter
258 258 end
259 259  
260   - def attribute_index(value)
261   - Digest::MD5.hexdigest(value.to_s)
262   - end
  260 + def attribute_index(value)
  261 + Digest::MD5.hexdigest(value.to_s)
  262 + end
263 263 end
... ...
app/models/watcher.rb
... ... @@ -31,13 +31,13 @@ protected
31 31 errors.add(:base, "You must specify either a user or an email address") unless user.present? || email.present?
32 32 end
33 33  
34   - def clear_unused_watcher_type
35   - case watcher_type
36   - when 'user'
37   - self.email = nil
38   - when 'email'
39   - self.user = self.user_id = nil
40   - end
  34 + def clear_unused_watcher_type
  35 + case watcher_type
  36 + when 'user'
  37 + self.email = nil
  38 + when 'email'
  39 + self.user = self.user_id = nil
41 40 end
  41 + end
42 42 end
43 43  
... ...