From 1095d7830db91ac55b5dc0140597f76700c8d3ff Mon Sep 17 00:00:00 2001 From: Laust Rud Jacobsen Date: Sat, 31 Oct 2015 13:35:12 +0100 Subject: [PATCH] Rubocop: space after comma,consistently --- .rubocop_todo.yml | 5 ----- app/controllers/apps_controller.rb | 4 ++-- app/controllers/users_controller.rb | 2 +- app/decorators/issue_tracker_type_decorator.rb | 2 +- app/helpers/application_helper.rb | 4 ++-- app/helpers/form_helper.rb | 2 +- app/mailers/mailer.rb | 2 +- app/models/deploy.rb | 2 +- app/models/issue_tracker.rb | 2 +- app/models/notice.rb | 6 +++--- app/models/problem.rb | 4 ++-- db/seeds.rb | 2 +- spec/controllers/notices_controller_spec.rb | 2 +- spec/decorators/app_decorator_spec.rb | 2 +- spec/models/app_spec.rb | 4 ++-- spec/models/error_report_spec.rb | 8 ++++---- spec/models/notice_observer_spec.rb | 4 ++-- spec/requests/notices_controller_spec.rb | 8 ++++---- spec/views/apps/edit.html.haml_spec.rb | 2 +- spec/views/apps/new.html.haml_spec.rb | 2 +- 20 files changed, 32 insertions(+), 37 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 994e765..cd9a33d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -311,11 +311,6 @@ Style/SingleSpaceBeforeFirstArg: - 'spec/fabricators/notice_fabricator.rb' - 'spec/fabricators/user_fabricator.rb' -# Offense count: 43 -# Cop supports --auto-correct. -Style/SpaceAfterComma: - Enabled: false - # Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. diff --git a/app/controllers/apps_controller.rb b/app/controllers/apps_controller.rb index 80f9a81..37cb3ca 100644 --- a/app/controllers/apps_controller.rb +++ b/app/controllers/apps_controller.rb @@ -116,7 +116,7 @@ protected # 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} + 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 @@ -131,7 +131,7 @@ protected # 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 } + 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 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 382a1f0..2b5e1f5 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -63,7 +63,7 @@ protected end def user_permit_params - @user_permit_params ||= [:name,:username, :email, :github_login, :per_page, :time_zone] + @user_permit_params ||= [:name, :username, :email, :github_login, :per_page, :time_zone] @user_permit_params << :admin if current_user.admin? && current_user.id != params[:id] @user_permit_params |= [:password, :password_confirmation] if user_password_params.values.all?{|pa| !pa.blank? } @user_permit_params diff --git a/app/decorators/issue_tracker_type_decorator.rb b/app/decorators/issue_tracker_type_decorator.rb index 194a9b7..02c5e06 100644 --- a/app/decorators/issue_tracker_type_decorator.rb +++ b/app/decorators/issue_tracker_type_decorator.rb @@ -6,7 +6,7 @@ class IssueTrackerTypeDecorator < Draper::Decorator def icons return unless object.icons - object.icons.reduce({}) do |c, (k,v)| + object.icons.reduce({}) do |c, (k, v)| c[k] = "data:#{v[0]};base64,#{Base64.encode64(v[1])}"; c end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 701f14a..2982cb0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -5,7 +5,7 @@ module ApplicationHelper def generate_problem_ical(notices) RiCal.Calendar do |cal| - notices.each_with_index do |notice,idx| + notices.each_with_index do |notice, idx| cal.event do |event| event.summary = "#{idx+1} #{notice.message}" event.description = notice.url if notice.url @@ -21,7 +21,7 @@ module ApplicationHelper def generate_ical(deploys) RiCal.Calendar { |cal| - deploys.each_with_index do |deploy,idx| + deploys.each_with_index do |deploy, idx| cal.event do |event| event.summary = "#{idx+1} #{deploy.repository}" event.description = deploy.revision.to_s diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb index 7b4e461..d0784b3 100644 --- a/app/helpers/form_helper.rb +++ b/app/helpers/form_helper.rb @@ -11,6 +11,6 @@ module FormHelper end def label_for_attr(builder, field) - (builder.object_name + field).gsub(/[\[\]]/,'_').squeeze('_') + (builder.object_name + field).gsub(/[\[\]]/, '_').squeeze('_') end end diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index 6abe892..e8108d3 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -59,6 +59,6 @@ class Mailer < ActionMailer::Base end private def errbit_headers(header) - header.each { |key,value| headers["X-Errbit-#{key}"] = value.to_s } + header.each { |key, value| headers["X-Errbit-#{key}"] = value.to_s } end end diff --git a/app/models/deploy.rb b/app/models/deploy.rb index 47079d7..0db5861 100644 --- a/app/models/deploy.rb +++ b/app/models/deploy.rb @@ -23,7 +23,7 @@ class Deploy end def short_revision - revision.to_s[0,7] + revision.to_s[0, 7] end protected diff --git a/app/models/issue_tracker.rb b/app/models/issue_tracker.rb index ad4eac0..bc74a7d 100644 --- a/app/models/issue_tracker.rb +++ b/app/models/issue_tracker.rb @@ -27,7 +27,7 @@ class IssueTracker # Allow the tracker to validate its own params def validate_tracker - (tracker.errors || {}).each do |k,v| + (tracker.errors || {}).each do |k, v| errors.add k, v end end diff --git a/app/models/notice.rb b/app/models/notice.rb index 845bfe4..b122ff8 100644 --- a/app/models/notice.rb +++ b/app/models/notice.rb @@ -132,15 +132,15 @@ protected def sanitize [:server_environment, :request, :notifier].each do |h| - send("#{h}=",sanitize_hash(send(h))) + send("#{h}=", sanitize_hash(send(h))) end end def sanitize_hash(hash) hash.recurse do |recurse_hash| - recurse_hash.inject({}) do |h,(k,v)| + recurse_hash.inject({}) do |h, (k, v)| if k.is_a?(String) - h[k.gsub(/\./,'.').gsub(/^\$/,'$')] = v + h[k.gsub(/\./, '.').gsub(/^\$/, '$')] = v else h[k] = v end diff --git a/app/models/problem.rb b/app/models/problem.rb index 40c036f..d40a297 100644 --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -118,7 +118,7 @@ class Problem 'notices_count' => notices_count.to_i > 1 ? notices_count - 1 : 0 ) - CACHED_NOTICE_ATTRIBUTES.each do |k,v| + CACHED_NOTICE_ATTRIBUTES.each do |k, v| digest = Digest::MD5.hexdigest(notice.send(v)) field = "#{k}.#{digest}" @@ -132,7 +132,7 @@ class Problem end def recache - CACHED_NOTICE_ATTRIBUTES.each do |k,v| + CACHED_NOTICE_ATTRIBUTES.each do |k, v| # clear all cached attributes send("#{k}=", {}) diff --git a/db/seeds.rb b/db/seeds.rb index c5ce067..159b13b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -6,7 +6,7 @@ puts "-------------------------------" # Create an initial Admin User admin_username = "errbit" admin_email = "errbit@#{Errbit::Config.host}" -admin_pass = SecureRandom.urlsafe_base64(12)[0,12] +admin_pass = SecureRandom.urlsafe_base64(12)[0, 12] puts "Creating an initial admin user:" puts "-- username: #{admin_username}" if Errbit::Config.user_has_username diff --git a/spec/controllers/notices_controller_spec.rb b/spec/controllers/notices_controller_spec.rb index 1e3614a..57bf019 100644 --- a/spec/controllers/notices_controller_spec.rb +++ b/spec/controllers/notices_controller_spec.rb @@ -2,7 +2,7 @@ describe NoticesController, type: 'controller' do it_requires_authentication :for => { :locate => :get } let(:notice) { Fabricate(:notice) } - let(:xml) { Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read } + let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } let(:app) { Fabricate(:app) } let(:error_report) { double(:valid? => true, :generate_notice! => true, :notice => notice, :should_keep? => true) } diff --git a/spec/decorators/app_decorator_spec.rb b/spec/decorators/app_decorator_spec.rb index f317983..44eb885 100644 --- a/spec/decorators/app_decorator_spec.rb +++ b/spec/decorators/app_decorator_spec.rb @@ -1,7 +1,7 @@ describe AppDecorator do describe "#email_at_notices" do it 'return the list separate by comma' do - expect(AppDecorator.new(double(:email_at_notices => [2,3])).email_at_notices).to eql '2, 3' + expect(AppDecorator.new(double(:email_at_notices => [2, 3])).email_at_notices).to eql '2, 3' end end diff --git a/spec/models/app_spec.rb b/spec/models/app_spec.rb index 622bc4b..eca3710 100644 --- a/spec/models/app_spec.rb +++ b/spec/models/app_spec.rb @@ -188,7 +188,7 @@ describe App, type: 'model' do expect(Err.where(conditions).first).to be_nil expect { app.find_or_create_err!(conditions) - }.to change(Problem,:count).by(1) + }.to change(Problem, :count).by(1) end context "without error_class" do @@ -201,7 +201,7 @@ describe App, type: 'model' do expect(Err.where(conditions).first).to be_nil expect { app.find_or_create_err!(conditions) - }.to change(Problem,:count).by(1) + }.to change(Problem, :count).by(1) end end end diff --git a/spec/models/error_report_spec.rb b/spec/models/error_report_spec.rb index 10fa029..907b010 100644 --- a/spec/models/error_report_spec.rb +++ b/spec/models/error_report_spec.rb @@ -18,7 +18,7 @@ end describe ErrorReport do let(:xml){ - Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read + Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } let(:error_report) { ErrorReport.new(xml) } @@ -53,7 +53,7 @@ describe ErrorReport do context "with a minimal notice" do let(:xml){ - Rails.root.join('spec','fixtures','minimal_test_notice.xml').read + Rails.root.join('spec', 'fixtures', 'minimal_test_notice.xml').read } it 'save a notice' do @@ -236,7 +236,7 @@ describe ErrorReport do context "with xml without request section" do let(:xml){ - Rails.root.join('spec','fixtures','hoptoad_test_notice_without_request_section.xml').read + Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_without_request_section.xml').read } it "save a notice" do expect { @@ -249,7 +249,7 @@ describe ErrorReport do context "with xml with only a single line of backtrace" do let(:xml){ - Rails.root.join('spec','fixtures','hoptoad_test_notice_with_one_line_of_backtrace.xml').read + Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_with_one_line_of_backtrace.xml').read } it "save a notice" do expect { diff --git a/spec/models/notice_observer_spec.rb b/spec/models/notice_observer_spec.rb index f29f766..c2a5a51 100644 --- a/spec/models/notice_observer_spec.rb +++ b/spec/models/notice_observer_spec.rb @@ -78,7 +78,7 @@ describe "Callback on Notice", type: 'model' do Fabricate( :app_with_watcher, notify_on_errs: true, - email_at_notices: [1,100] + email_at_notices: [1, 100] ) end let(:notice_attrs) { notice_attrs_for.call(app.api_key) } @@ -161,7 +161,7 @@ describe "Callback on Notice", type: 'model' do describe "should send a notification at desired intervals" do let(:notification_service) do - Fabricate(:campfire_notification_service, notify_at_notices: [1,2]) + Fabricate(:campfire_notification_service, notify_at_notices: [1, 2]) end let(:app) { Fabricate(:app, notification_service: notification_service) } let(:notice_attrs) { notice_attrs_for.call(app.api_key) } diff --git a/spec/requests/notices_controller_spec.rb b/spec/requests/notices_controller_spec.rb index 565f70b..52f1cd4 100644 --- a/spec/requests/notices_controller_spec.rb +++ b/spec/requests/notices_controller_spec.rb @@ -3,7 +3,7 @@ describe "Notices management", type: 'request' do describe "create a new notice" do context "with valide notice" do - let(:xml) { Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read } + let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } it 'save a new notice' do expect { post '/notifier_api/v2/notices', :data => xml @@ -15,7 +15,7 @@ describe "Notices management", type: 'request' do end context "with notice with empty backtrace" do - let(:xml) { Rails.root.join('spec','fixtures','hoptoad_test_notice_without_line_of_backtrace.xml').read } + let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_without_line_of_backtrace.xml').read } it 'save a new notice' do expect { post '/notifier_api/v2/notices', :data => xml @@ -28,7 +28,7 @@ describe "Notices management", type: 'request' do context "with notice with bad api_key" do let(:errbit_app) { Fabricate(:app) } - let(:xml) { Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read } + let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } it 'not save a new notice and return 422' do expect { post '/notifier_api/v2/notices', :data => xml @@ -39,7 +39,7 @@ describe "Notices management", type: 'request' do end context "with GET request" do - let(:xml) { Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read } + let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } it 'save a new notice' do expect { get '/notifier_api/v2/notices', :data => xml diff --git a/spec/views/apps/edit.html.haml_spec.rb b/spec/views/apps/edit.html.haml_spec.rb index 3515214..9c03211 100644 --- a/spec/views/apps/edit.html.haml_spec.rb +++ b/spec/views/apps/edit.html.haml_spec.rb @@ -27,7 +27,7 @@ describe "apps/edit.html.haml", type: 'view' do context "with unvalid app" do let(:app) { app = stub_model(App) - app.errors.add(:base,'You must specify your') + app.errors.add(:base, 'You must specify your') app } diff --git a/spec/views/apps/new.html.haml_spec.rb b/spec/views/apps/new.html.haml_spec.rb index 31840dc..5594d70 100644 --- a/spec/views/apps/new.html.haml_spec.rb +++ b/spec/views/apps/new.html.haml_spec.rb @@ -23,7 +23,7 @@ describe "apps/new.html.haml", type: 'view' do context "with unvalid app" do let(:app) { app = stub_model(App) - app.errors.add(:base,'You must specify your') + app.errors.add(:base, 'You must specify your') app } -- libgit2 0.21.2