From 6cd06830a0ba45f1583ede6da86c079460e92f10 Mon Sep 17 00:00:00 2001 From: Laust Rud Jacobsen Date: Wed, 4 Nov 2015 21:29:16 +0100 Subject: [PATCH] Rubocop: use trailing dots when invocations cross multiple lines --- .rubocop.yml | 4 ++++ .rubocop_todo.yml | 6 ------ app/controllers/problems_controller.rb | 14 +++++++------- app/controllers/site_config_controller.rb | 8 ++++---- app/decorators/backtrace_line_decorator.rb | 6 +++--- app/helpers/application_helper.rb | 4 ++-- spec/controllers/api/v3/notices_controller_spec.rb | 4 ++-- spec/models/notice_observer_spec.rb | 28 ++++++++++++++-------------- 8 files changed, 36 insertions(+), 38 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 8ef403e..1699a46 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -29,6 +29,10 @@ Style/AccessModifierIndentation: Style/AlignParameters: EnforcedStyle: with_fixed_indentation +Style/DotPosition: + # Support code copy/paste into console + EnforcedStyle: trailing + Style/IndentHash: EnforcedStyle: consistent diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 26a056a..75a4275 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -115,12 +115,6 @@ Style/ConstantName: Style/Documentation: Enabled: false -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/DotPosition: - Enabled: false - # Offense count: 5 Style/EachWithObject: Exclude: diff --git a/app/controllers/problems_controller.rb b/app/controllers/problems_controller.rb index 013efa0..6d31ab0 100644 --- a/app/controllers/problems_controller.rb +++ b/app/controllers/problems_controller.rb @@ -32,11 +32,11 @@ class ProblemsController < ApplicationController } expose(:problems) { - pro = Problem - .for_apps(app_scope) - .in_env(params_environement) - .all_else_unresolved(all_errs) - .ordered_by(params_sort, params_order) + pro = Problem. + for_apps(app_scope). + in_env(params_environement). + all_else_unresolved(all_errs). + ordered_by(params_sort, params_order) if request.format == :html pro.page(params[:page]).per(current_user.per_page) @@ -48,8 +48,8 @@ class ProblemsController < ApplicationController def index; end def show - @notices = problem.object.notices.reverse_ordered - .page(params[:notice]).per(1) + @notices = problem.object.notices.reverse_ordered. + page(params[:notice]).per(1) @notice = NoticeDecorator.new @notices.first @comment = Comment.new end diff --git a/app/controllers/site_config_controller.rb b/app/controllers/site_config_controller.rb index 7d767ed..ba02621 100644 --- a/app/controllers/site_config_controller.rb +++ b/app/controllers/site_config_controller.rb @@ -13,10 +13,10 @@ class SiteConfigController < ApplicationController end private def filtered_update_params - params - .require(:site_config) - .require(:notice_fingerprinter_attributes) - .permit( + params. + require(:site_config). + require(:notice_fingerprinter_attributes). + permit( :error_class, :message, :backtrace_lines, diff --git a/app/decorators/backtrace_line_decorator.rb b/app/decorators/backtrace_line_decorator.rb index 432c97a..dc91169 100644 --- a/app/decorators/backtrace_line_decorator.rb +++ b/app/decorators/backtrace_line_decorator.rb @@ -44,9 +44,9 @@ class BacktraceLineDecorator < Draper::Decorator end def decorated_path - path - .sub(Backtrace::IN_APP_PATH, '') - .sub(Backtrace::GEMS_PATH, "\\1") + path. + sub(Backtrace::IN_APP_PATH, ''). + sub(Backtrace::GEMS_PATH, "\\1") end private diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 69634a2..133a8f3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -56,8 +56,8 @@ module ApplicationHelper def create_percentage_table_from_tallies(tallies, options = {}) total = (options[:total] || total_from_tallies(tallies)) percent = 100.0 / total.to_f - rows = tallies.map {|value, count| [(count.to_f * percent), value]} \ - .sort {|a, b| b[0] <=> a[0]} + rows = tallies.map {|value, count| [(count.to_f * percent), value]}. \ + sort {|a, b| b[0] <=> a[0]} render "problems/tally_table", :rows => rows end diff --git a/spec/controllers/api/v3/notices_controller_spec.rb b/spec/controllers/api/v3/notices_controller_spec.rb index 1a3e46c..cd735d3 100644 --- a/spec/controllers/api/v3/notices_controller_spec.rb +++ b/spec/controllers/api/v3/notices_controller_spec.rb @@ -22,8 +22,8 @@ describe Api::V3::NoticesController, type: :controller do end it 'responds with 400 when request attributes are not valid' do - allow_any_instance_of(AirbrakeApi::V3::NoticeParser) - .to receive(:report).and_raise(AirbrakeApi::ParamsError) + allow_any_instance_of(AirbrakeApi::V3::NoticeParser). + to receive(:report).and_raise(AirbrakeApi::ParamsError) post :create, project_id: 'ID' expect(response.status).to eq(400) expect(response.body).to eq('Invalid request') diff --git a/spec/models/notice_observer_spec.rb b/spec/models/notice_observer_spec.rb index 6c3ea0b..cd3c617 100644 --- a/spec/models/notice_observer_spec.rb +++ b/spec/models/notice_observer_spec.rb @@ -94,8 +94,8 @@ describe "Callback on Notice", type: 'model' do err.problem.update_attributes notices_count: 99 err.problem.resolve! - expect(Mailer).to receive(:err_notification) - .and_return(double('email', :deliver_now => true)) + expect(Mailer).to receive(:err_notification). + and_return(double('email', :deliver_now => true)) ErrorReport.new(notice_attrs).generate_notice! end @@ -118,10 +118,10 @@ describe "Callback on Notice", type: 'model' do it 'sends email' do error_report = ErrorReport.new(notice_attrs) - expect(error_report.app.notification_service) - .to receive(:create_notification).and_raise(ArgumentError) - expect(Mailer) - .to receive(:err_notification).and_return(double(:deliver_now => true)) + expect(error_report.app.notification_service). + to receive(:create_notification).and_raise(ArgumentError) + expect(Mailer). + to receive(:err_notification).and_return(double(:deliver_now => true)) error_report.generate_notice! end @@ -153,8 +153,8 @@ describe "Callback on Notice", type: 'model' do it 'creates a hipchat notification' do error_report = ErrorReport.new(notice_attrs) - expect(error_report.app.notification_service) - .to receive(:create_notification) + expect(error_report.app.notification_service). + to receive(:create_notification) error_report.generate_notice! end end @@ -171,16 +171,16 @@ describe "Callback on Notice", type: 'model' do it "should create a campfire notification on first notice" do error_report = ErrorReport.new(notice_attrs) - expect(error_report.app.notification_service) - .to receive(:create_notification) + expect(error_report.app.notification_service). + to receive(:create_notification) error_report.generate_notice! # one end it "should create a campfire notification on second notice" do ErrorReport.new(notice_attrs).generate_notice! # one error_report = ErrorReport.new(notice_attrs) - expect(error_report.app.notification_service) - .to receive(:create_notification) + expect(error_report.app.notification_service). + to receive(:create_notification) error_report.generate_notice! # two end @@ -188,8 +188,8 @@ describe "Callback on Notice", type: 'model' do ErrorReport.new(notice_attrs).generate_notice! # one ErrorReport.new(notice_attrs).generate_notice! # two error_report = ErrorReport.new(notice_attrs) - expect(error_report.app.notification_service) - .to_not receive(:create_notification) + expect(error_report.app.notification_service). + to_not receive(:create_notification) error_report.generate_notice! # three end end -- libgit2 0.21.2