From af87b10a8895276ea94053880acfa52b73e8f2c8 Mon Sep 17 00:00:00 2001 From: Laust Rud Jacobsen Date: Sat, 31 Oct 2015 11:14:59 +0100 Subject: [PATCH] Rubocop: method indentation consistency fixes --- .rubocop.yml | 2 +- .rubocop_todo.yml | 17 ----------------- app/controllers/apps_controller.rb | 62 +++++++++++++++++++++++++++++++------------------------------- app/controllers/comments_controller.rb | 12 ++++++------ app/controllers/deploys_controller.rb | 18 +++++++++--------- app/helpers/application_helper.rb | 6 +++--- app/models/app.rb | 36 ++++++++++++++++++------------------ app/models/comment.rb | 6 +++--- app/models/deploy.rb | 18 +++++++++--------- app/models/problem.rb | 6 +++--- app/models/watcher.rb | 14 +++++++------- 11 files changed, 90 insertions(+), 107 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 6cda0d2..df2a352 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -21,7 +21,7 @@ Style/IndentationConsistency: # modifier keywords shall be indented the same as public methods and that # protected and private members shall be indented one step more than the # modifiers. - EnforcedStyle: rails + EnforcedStyle: rails Style/AccessModifierIndentation: EnforcedStyle: outdent diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 68178d8..994e765 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -185,23 +185,6 @@ Style/IfUnlessModifier: - 'app/models/notice.rb' - 'app/models/user.rb' -# Offense count: 27 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/IndentationConsistency: - Exclude: - - 'app/controllers/apps_controller.rb' - - 'app/controllers/comments_controller.rb' - - 'app/controllers/deploys_controller.rb' - - 'app/controllers/users_controller.rb' - - 'app/helpers/application_helper.rb' - - 'app/models/app.rb' - - 'app/models/comment.rb' - - 'app/models/deploy.rb' - - 'app/models/problem.rb' - - 'app/models/watcher.rb' - - 'lib/hoptoad.rb' - # Offense count: 6 # Cop supports --auto-correct. Style/Lambda: diff --git a/app/controllers/apps_controller.rb b/app/controllers/apps_controller.rb index b9dc45b..80f9a81 100644 --- a/app/controllers/apps_controller.rb +++ b/app/controllers/apps_controller.rb @@ -103,43 +103,43 @@ protected end end - def plug_params(app) - app.watchers.build if app.watchers.none? - app.issue_tracker ||= IssueTracker.new - app.notification_service = NotificationService.new unless app.notification_service_configured? - app.copy_attributes_from(params[:copy_attributes_from]) if params[:copy_attributes_from] - end + def plug_params(app) + app.watchers.build if app.watchers.none? + app.issue_tracker ||= IssueTracker.new + app.notification_service = NotificationService.new unless app.notification_service_configured? + app.copy_attributes_from(params[:copy_attributes_from]) if params[:copy_attributes_from] + end - # email_at_notices is edited as a string, and stored as an array. - def parse_email_at_notices_or_set_default - if params[:app] && (val = params[:app][:email_at_notices]) - # Sanitize negative values, split on comma, - # strip, parse as integer, remove all '0's. - # If empty, set as default and show an error message. - email_at_notices = val.gsub(/-\d+/,"").split(",").map{|v| v.strip.to_i }.reject{|v| v == 0} - if email_at_notices.any? - params[:app][:email_at_notices] = email_at_notices - else - default_array = params[:app][:email_at_notices] = Errbit::Config.email_at_notices - flash[:error] = "Couldn't parse your notification frequency. Value was reset to default (#{default_array.join(', ')})." - end + # email_at_notices is edited as a string, and stored as an array. + def parse_email_at_notices_or_set_default + if params[:app] && (val = params[:app][:email_at_notices]) + # Sanitize negative values, split on comma, + # strip, parse as integer, remove all '0's. + # If empty, set as default and show an error message. + email_at_notices = val.gsub(/-\d+/,"").split(",").map{|v| v.strip.to_i }.reject{|v| v == 0} + if email_at_notices.any? + params[:app][:email_at_notices] = email_at_notices + else + default_array = params[:app][:email_at_notices] = Errbit::Config.email_at_notices + flash[:error] = "Couldn't parse your notification frequency. Value was reset to default (#{default_array.join(', ')})." end end + end - def parse_notice_at_notices_or_set_default - if params[:app][:notification_service_attributes] && (val = params[:app][:notification_service_attributes][:notify_at_notices]) - # Sanitize negative values, split on comma, - # strip, parse as integer, remove all '0's. - # If empty, set as default and show an error message. - notify_at_notices = val.gsub(/-\d+/,"").split(",").map{|v| v.strip.to_i } - if notify_at_notices.any? - params[:app][:notification_service_attributes][:notify_at_notices] = notify_at_notices - else - default_array = params[:app][:notification_service_attributes][:notify_at_notices] = Errbit::Config.notify_at_notices - flash[:error] = "Couldn't parse your notification frequency. Value was reset to default (#{default_array.join(', ')})." - end + def parse_notice_at_notices_or_set_default + if params[:app][:notification_service_attributes] && (val = params[:app][:notification_service_attributes][:notify_at_notices]) + # Sanitize negative values, split on comma, + # strip, parse as integer, remove all '0's. + # If empty, set as default and show an error message. + notify_at_notices = val.gsub(/-\d+/,"").split(",").map{|v| v.strip.to_i } + if notify_at_notices.any? + params[:app][:notification_service_attributes][:notify_at_notices] = notify_at_notices + else + default_array = params[:app][:notification_service_attributes][:notify_at_notices] = Errbit::Config.notify_at_notices + flash[:error] = "Couldn't parse your notification frequency. Value was reset to default (#{default_array.join(', ')})." end end + end private def app_params params.require(:app).permit! diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 5292406..af97ffa 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -30,11 +30,11 @@ protected @app = App.find(params[:app_id]) end - def find_problem - @problem = @app.problems.find(params[:problem_id]) - end + def find_problem + @problem = @app.problems.find(params[:problem_id]) + end - def comment_params - params.require(:comment).permit! - end + def comment_params + params.require(:comment).permit! + end end diff --git a/app/controllers/deploys_controller.rb b/app/controllers/deploys_controller.rb index a1504ac..b670df5 100644 --- a/app/controllers/deploys_controller.rb +++ b/app/controllers/deploys_controller.rb @@ -30,14 +30,14 @@ private end end - # handle Heroku's HTTP post deployhook format - def heroku_deploy - { - :username => params[:user], - :environment => params[:rack_env].try(:downcase) || params[:app], - :repository => "git@heroku.com:#{params[:app]}.git", - :revision => params[:head], - } - end + # handle Heroku's HTTP post deployhook format + def heroku_deploy + { + :username => params[:user], + :environment => params[:rack_env].try(:downcase) || params[:app], + :repository => "git@heroku.com:#{params[:app]}.git", + :revision => params[:head], + } + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ca024ae..701f14a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -81,7 +81,7 @@ private tallies.values.inject(0) {|sum, n| sum + n} end - def head_size - 4 - end + def head_size + 4 + end end diff --git a/app/models/app.rb b/app/models/app.rb index 83d4539..db77fc7 100644 --- a/app/models/app.rb +++ b/app/models/app.rb @@ -196,26 +196,26 @@ protected ) end - def generate_api_key - self.api_key ||= SecureRandom.hex - end + def generate_api_key + self.api_key ||= SecureRandom.hex + end - def check_issue_tracker - if issue_tracker.present? - issue_tracker.valid? - issue_tracker.errors.full_messages.each do |error| - errors[:base] << error - end if issue_tracker.errors - end + def check_issue_tracker + if issue_tracker.present? + issue_tracker.valid? + issue_tracker.errors.full_messages.each do |error| + errors[:base] << error + end if issue_tracker.errors end + end - def normalize_github_repo - return if github_repo.blank? - github_host = URI.parse(Errbit::Config.github_url).host - github_host = Regexp.escape(github_host) - github_repo.strip! - github_repo.sub!(/(git@|https?:\/\/)#{github_host}(\/|:)/, '') - github_repo.sub!(/\.git$/, '') - end + def normalize_github_repo + return if github_repo.blank? + github_host = URI.parse(Errbit::Config.github_url).host + github_host = Regexp.escape(github_host) + github_repo.strip! + github_repo.sub!(/(git@|https?:\/\/)#{github_host}(\/|:)/, '') + github_repo.sub!(/\.git$/, '') + end end diff --git a/app/models/comment.rb b/app/models/comment.rb index 8d01fcd..e639afe 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -34,7 +34,7 @@ protected err.inc(comments_count: 1) end - def decrease_counter_cache - err.inc(comments_count: -1) if err - end + def decrease_counter_cache + err.inc(comments_count: -1) if err + end end diff --git a/app/models/deploy.rb b/app/models/deploy.rb index b8cf2ad..47079d7 100644 --- a/app/models/deploy.rb +++ b/app/models/deploy.rb @@ -32,16 +32,16 @@ protected app.resolve_errs_on_deploy? end - def store_cached_attributes_on_problems - Problem.where(:app_id => app.id).update_all( - last_deploy_at: created_at - ) - end + def store_cached_attributes_on_problems + Problem.where(:app_id => app.id).update_all( + last_deploy_at: created_at + ) + end - def deliver_email - if app.notify_on_deploys? && app.notification_recipients.any? - Mailer.deploy_notification(self).deliver_now - end + def deliver_email + if app.notify_on_deploys? && app.notification_recipients.any? + Mailer.deploy_notification(self).deliver_now end + end end diff --git a/app/models/problem.rb b/app/models/problem.rb index 64c5051..40c036f 100644 --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -257,7 +257,7 @@ private counter end - def attribute_index(value) - Digest::MD5.hexdigest(value.to_s) - end + def attribute_index(value) + Digest::MD5.hexdigest(value.to_s) + end end diff --git a/app/models/watcher.rb b/app/models/watcher.rb index 58cc1e4..8372aff 100644 --- a/app/models/watcher.rb +++ b/app/models/watcher.rb @@ -31,13 +31,13 @@ protected errors.add(:base, "You must specify either a user or an email address") unless user.present? || email.present? end - def clear_unused_watcher_type - case watcher_type - when 'user' - self.email = nil - when 'email' - self.user = self.user_id = nil - end + def clear_unused_watcher_type + case watcher_type + when 'user' + self.email = nil + when 'email' + self.user = self.user_id = nil end + end end -- libgit2 0.21.2