diff --git a/.rubocop.yml b/.rubocop.yml index 8ebf83e..3b38f64 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -14,3 +14,14 @@ Style/EmptyLineBetweenDefs: Style/ExtraSpacing: AllowForAlignment: true + +Style/IndentationConsistency: + # `rails` style: + # prescribes that in classes and modules the `protected` and `private` + # 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 + +Style/AccessModifierIndentation: + EnforcedStyle: outdent diff --git a/app/controllers/api/v1/stats_controller.rb b/app/controllers/api/v1/stats_controller.rb index f4a3e09..081ccd1 100644 --- a/app/controllers/api/v1/stats_controller.rb +++ b/app/controllers/api/v1/stats_controller.rb @@ -23,9 +23,7 @@ class Api::V1::StatsController < ApplicationController end end - protected - - def require_api_key_or_authenticate_user! + protected def require_api_key_or_authenticate_user! if params[:api_key].present? if (@app = App.where(:api_key => params[:api_key]).first) return true diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a4d7a2f..8f72c89 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -17,7 +17,7 @@ class ApplicationController < ActionController::Base strategy StrongParametersWithEagerAttributesStrategy end - protected +protected ## # Check if the current_user is admin or not and redirect to root url if not diff --git a/app/controllers/apps_controller.rb b/app/controllers/apps_controller.rb index 1cfcb67..3b4336a 100644 --- a/app/controllers/apps_controller.rb +++ b/app/controllers/apps_controller.rb @@ -90,18 +90,18 @@ class AppsController < ApplicationController redirect_to edit_app_path(app) end - protected - - def initialize_subclassed_notification_service - # set the app's notification service - if params[:app][:notification_service_attributes] && (notification_type = params[:app][:notification_service_attributes][:type]) - available_notification_classes = [NotificationService] + NotificationService.subclasses - notification_class = available_notification_classes.detect{|c| c.name == notification_type} - if notification_class.present? - app.notification_service = notification_class.new(params[:app][:notification_service_attributes]) - end +protected + + def initialize_subclassed_notification_service + # set the app's notification service + if params[:app][:notification_service_attributes] && (notification_type = params[:app][:notification_service_attributes][:type]) + available_notification_classes = [NotificationService] + NotificationService.subclasses + notification_class = available_notification_classes.detect{|c| c.name == notification_type} + if notification_class.present? + app.notification_service = notification_class.new(params[:app][:notification_service_attributes]) end end + end def plug_params(app) app.watchers.build if app.watchers.none? @@ -141,9 +141,7 @@ class AppsController < ApplicationController end end - private - - def app_params - params.require(:app).permit! - end + private def app_params + params.require(:app).permit! + end end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 9333309..5292406 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -24,11 +24,11 @@ class CommentsController < ApplicationController redirect_to app_problem_path(@app, @problem) end - protected +protected - def find_app - @app = App.find(params[:app_id]) - end + def find_app + @app = App.find(params[:app_id]) + end def find_problem @problem = @app.problems.find(params[:problem_id]) diff --git a/app/controllers/deploys_controller.rb b/app/controllers/deploys_controller.rb index 320988d..a1504ac 100644 --- a/app/controllers/deploys_controller.rb +++ b/app/controllers/deploys_controller.rb @@ -16,19 +16,19 @@ class DeploysController < ApplicationController page(params[:page]).per(10) end - private +private - def default_deploy - if params[:deploy] - { - :username => params[:deploy][:local_username], - :environment => params[:deploy][:rails_env], - :repository => params[:deploy][:scm_repository], - :revision => params[:deploy][:scm_revision], - :message => params[:deploy][:message] - } - end + def default_deploy + if params[:deploy] + { + :username => params[:deploy][:local_username], + :environment => params[:deploy][:rails_env], + :repository => params[:deploy][:scm_repository], + :revision => params[:deploy][:scm_revision], + :message => params[:deploy][:message] + } end + end # handle Heroku's HTTP post deployhook format def heroku_deploy diff --git a/app/controllers/notices_controller.rb b/app/controllers/notices_controller.rb index b902422..2057ada 100644 --- a/app/controllers/notices_controller.rb +++ b/app/controllers/notices_controller.rb @@ -33,7 +33,7 @@ class NoticesController < ApplicationController redirect_to app_problem_path(problem.app, problem) end - private +private def notice_params return @notice_params if @notice_params diff --git a/app/controllers/problems_controller.rb b/app/controllers/problems_controller.rb index e7a136f..013efa0 100644 --- a/app/controllers/problems_controller.rb +++ b/app/controllers/problems_controller.rb @@ -134,12 +134,10 @@ class ProblemsController < ApplicationController end end - protected - ## # Redirect :back if no errors selected # - def need_selected_problem + protected def need_selected_problem if err_ids.empty? flash[:notice] = I18n.t('controllers.problems.flash.no_select_problem') redirect_to :back diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index f3941d8..8e02d35 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -39,9 +39,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController end end - private - - def update_user_with_github_attributes(user, login, token) + private def update_user_with_github_attributes(user, login, token) user.update_attributes( :github_login => login, :github_oauth_token => token diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a35fc27..382a1f0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -51,12 +51,12 @@ class UsersController < ApplicationController redirect_to user_path(user) end - protected +protected - def require_user_edit_priviledges - can_edit = current_user == user || current_user.admin? - redirect_to(root_path) unless can_edit - end + def require_user_edit_priviledges + can_edit = current_user == user || current_user.admin? + redirect_to(root_path) unless can_edit + end def user_params @user_params ||= params[:user] ? params.require(:user).permit(*user_permit_params) : {} diff --git a/app/decorators/backtrace_line_decorator.rb b/app/decorators/backtrace_line_decorator.rb index c689e9a..68486f9 100644 --- a/app/decorators/backtrace_line_decorator.rb +++ b/app/decorators/backtrace_line_decorator.rb @@ -49,7 +49,7 @@ class BacktraceLineDecorator < Draper::Decorator .sub(Backtrace::GEMS_PATH, "\\1") end - private +private def link_to_in_app_source_file(app, text) return unless in_app? diff --git a/app/decorators/issue_tracker_field_decorator.rb b/app/decorators/issue_tracker_field_decorator.rb index 41ee9ea..118d0df 100644 --- a/app/decorators/issue_tracker_field_decorator.rb +++ b/app/decorators/issue_tracker_field_decorator.rb @@ -17,9 +17,7 @@ class IssueTrackerFieldDecorator < Draper::Decorator :value => issue_tracker.options[key.to_s]) end - private - - def input_field + private def input_field object == :password ? :password_field : :text_field end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b5d5967..ca024ae 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -75,11 +75,11 @@ module ApplicationHelper end end - private +private - def total_from_tallies(tallies) - tallies.values.inject(0) {|sum, n| sum + n} - end + def total_from_tallies(tallies) + tallies.values.inject(0) {|sum, n| sum + n} + end def head_size 4 diff --git a/app/helpers/apps_helper.rb b/app/helpers/apps_helper.rb index 2676883..fc6827c 100644 --- a/app/helpers/apps_helper.rb +++ b/app/helpers/apps_helper.rb @@ -36,9 +36,7 @@ module AppsHelper @any_deploys end - private - - def detect_any_apps_with_attributes + private def detect_any_apps_with_attributes @any_github_repos = @any_issue_trackers = @any_deploys = @any_bitbucket_repos = @any_notification_services = false apps.each do |app| diff --git a/app/interactors/problem_destroy.rb b/app/interactors/problem_destroy.rb index ecdc837..017bde4 100644 --- a/app/interactors/problem_destroy.rb +++ b/app/interactors/problem_destroy.rb @@ -25,7 +25,7 @@ class ProblemDestroy }.count end - private +private def errs_id problem.errs.only(:id).map(&:id) diff --git a/app/interactors/resolved_problem_clearer.rb b/app/interactors/resolved_problem_clearer.rb index d950d37..fffe1ca 100644 --- a/app/interactors/resolved_problem_clearer.rb +++ b/app/interactors/resolved_problem_clearer.rb @@ -15,7 +15,7 @@ class ResolvedProblemClearer } end - private +private def nb_problem_resolved @count ||= criteria.count diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index c87f38b..6abe892 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -58,9 +58,7 @@ class Mailer < ActionMailer::Base :subject => "#{@user.name} commented on [#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" end - private - - def errbit_headers(header) + private def errbit_headers(header) header.each { |key,value| headers["X-Errbit-#{key}"] = value.to_s } end end diff --git a/app/models/app.rb b/app/models/app.rb index 19e89b5..83d4539 100644 --- a/app/models/app.rb +++ b/app/models/app.rb @@ -188,13 +188,13 @@ class App update_attribute(:api_key, SecureRandom.hex) end - protected +protected - def store_cached_attributes_on_problems - Problem.where(:app_id => id).update_all( - app_name: name - ) - end + def store_cached_attributes_on_problems + Problem.where(:app_id => id).update_all( + app_name: name + ) + end def generate_api_key self.api_key ||= SecureRandom.hex diff --git a/app/models/backtrace.rb b/app/models/backtrace.rb index e1d6805..e155bc5 100644 --- a/app/models/backtrace.rb +++ b/app/models/backtrace.rb @@ -22,9 +22,7 @@ class Backtrace Digest::SHA1.hexdigest(lines.map(&:to_s).join) end - private - - def generate_fingerprint + private def generate_fingerprint self.fingerprint = self.class.generate_fingerprint(lines) end end diff --git a/app/models/comment.rb b/app/models/comment.rb index c49c267..8d01fcd 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -28,11 +28,11 @@ class Comment app.emailable? && notification_recipients.any? end - protected +protected - def increase_counter_cache - err.inc(comments_count: 1) - end + def increase_counter_cache + err.inc(comments_count: 1) + end def decrease_counter_cache err.inc(comments_count: -1) if err diff --git a/app/models/deploy.rb b/app/models/deploy.rb index 49734a3..b8cf2ad 100644 --- a/app/models/deploy.rb +++ b/app/models/deploy.rb @@ -26,11 +26,11 @@ class Deploy revision.to_s[0,7] end - protected +protected - def should_resolve_app_errs? - app.resolve_errs_on_deploy? - end + def should_resolve_app_errs? + app.resolve_errs_on_deploy? + end def store_cached_attributes_on_problems Problem.where(:app_id => app.id).update_all( diff --git a/app/models/notice.rb b/app/models/notice.rb index 4b2f27d..845bfe4 100644 --- a/app/models/notice.rb +++ b/app/models/notice.rb @@ -124,7 +124,7 @@ class Notice message.gsub(/(#<.+?):[0-9a-f]x[0-9a-f]+(>)/, '\1\2') end - protected +protected def problem_recache problem.uncache_notice(self) diff --git a/app/models/notification_services/flowdock_service.rb b/app/models/notification_services/flowdock_service.rb index ba3a503..3563353 100644 --- a/app/models/notification_services/flowdock_service.rb +++ b/app/models/notification_services/flowdock_service.rb @@ -27,7 +27,7 @@ if defined? Flowdock flow.push_to_team_inbox(:subject => subject, :content => content(problem, url), :project => project_name(problem), :link => url) end - private + private # can only contain alphanumeric characters and underscores def project_name(problem) diff --git a/app/models/notification_services/gtalk_service.rb b/app/models/notification_services/gtalk_service.rb index ff88a39..8f84ee7 100644 --- a/app/models/notification_services/gtalk_service.rb +++ b/app/models/notification_services/gtalk_service.rb @@ -57,7 +57,7 @@ class NotificationServices::GtalkService < NotificationService client.close unless client.nil? end - private +private def send_to_users(client, message) user_id.tr(' ', ",").tr(';', ",").split(",").map(&:strip).reject(&:empty?).each do |user| diff --git a/app/models/problem.rb b/app/models/problem.rb index d02d08f..64c5051 100644 --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -244,18 +244,18 @@ class Problem Problem.where({'$text' => {'$search' => value}}) end - private - - def attribute_count_descrease(name, value) - counter = send(name) - index = attribute_index(value) - if counter[index] && counter[index]['count'] > 1 - counter[index]['count'] -= 1 - else - counter.delete(index) - end - counter +private + + def attribute_count_descrease(name, value) + counter = send(name) + index = attribute_index(value) + if counter[index] && counter[index]['count'] > 1 + counter[index]['count'] -= 1 + else + counter.delete(index) end + counter + end def attribute_index(value) Digest::MD5.hexdigest(value.to_s) diff --git a/app/models/user.rb b/app/models/user.rb index dc7d3ac..e7f559c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -83,9 +83,7 @@ class User :auth_token end - private - - def generate_authentication_token + private def generate_authentication_token loop do token = Devise.friendly_token break token unless User.where(authentication_token: token).first diff --git a/app/models/watcher.rb b/app/models/watcher.rb index c993862..58cc1e4 100644 --- a/app/models/watcher.rb +++ b/app/models/watcher.rb @@ -25,11 +25,11 @@ class Watcher user.try(:email) || email end - protected +protected - def ensure_user_or_email - errors.add(:base, "You must specify either a user or an email address") unless user.present? || email.present? - end + def ensure_user_or_email + 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 diff --git a/lib/airbrake_api/v3/notice_parser.rb b/lib/airbrake_api/v3/notice_parser.rb index bb6edc2..33c0de0 100644 --- a/lib/airbrake_api/v3/notice_parser.rb +++ b/lib/airbrake_api/v3/notice_parser.rb @@ -24,7 +24,7 @@ module AirbrakeApi ErrorReport.new(attributes) end - private + private def error raise AirbrakeApi::ParamsError unless params.key?('errors') && params['errors'].any? diff --git a/lib/hoptoad.rb b/lib/hoptoad.rb index a5a50ab..5306c71 100644 --- a/lib/hoptoad.rb +++ b/lib/hoptoad.rb @@ -13,13 +13,11 @@ module Hoptoad processor.process_notice(parsed) end - private - - def self.get_version_processor(version) - case version - when /2\.[01234]/ then Hoptoad::V2 - else; raise ApiVersionError - end + private def self.get_version_processor(version) + case version + when /2\.[01234]/ then Hoptoad::V2 + else; raise ApiVersionError end + end end diff --git a/lib/hoptoad/v2.rb b/lib/hoptoad/v2.rb index ad71e10..f57fe59 100644 --- a/lib/hoptoad/v2.rb +++ b/lib/hoptoad/v2.rb @@ -6,7 +6,7 @@ module Hoptoad rekey(parsed))) end - private + private def self.rekey(node) case node diff --git a/lib/overrides/hoptoad_notifier/hoptoad_notifier.rb b/lib/overrides/hoptoad_notifier/hoptoad_notifier.rb index bb18cc7..f628f98 100644 --- a/lib/overrides/hoptoad_notifier/hoptoad_notifier.rb +++ b/lib/overrides/hoptoad_notifier/hoptoad_notifier.rb @@ -4,23 +4,21 @@ HoptoadNotifier.module_eval do class << self - private + private def send_notice(notice) + # Log the error internally if we are not in a development environment. + if configuration.public? + app = App.find_or_initialize_by(:name => "Self.Errbit") + app.github_repo = "errbit/errbit" + app.save! + notice.send("api_key=", app.api_key) - def send_notice(notice) - # Log the error internally if we are not in a development environment. - if configuration.public? - app = App.find_or_initialize_by(:name => "Self.Errbit") - app.github_repo = "errbit/errbit" - app.save! - notice.send("api_key=", app.api_key) + # Create notice internally. + report = ErrorReport.new(notice.to_xml) + report.generate_notice! - # Create notice internally. - report = ErrorReport.new(notice.to_xml) - report.generate_notice! - - logger.info "Internal error was logged to 'Self.Errbit' app." - end + logger.info "Internal error was logged to 'Self.Errbit' app." end + end end end -- libgit2 0.21.2