From 311c015d2b009ea5aa8f55c15ecc1038fa466541 Mon Sep 17 00:00:00 2001 From: Laust Rud Jacobsen Date: Wed, 4 Nov 2015 23:10:29 +0100 Subject: [PATCH] Rubocop: hashes with strings for keys should get pretty alignment too --- .rubocop.yml | 1 + app/mailers/mailer.rb | 26 +++++++++++++------------- app/models/problem.rb | 34 +++++++++++++++++----------------- config/deploy.example.rb | 2 +- db/migrate/201510290041_extract_issue_tracker.rb | 24 ++++++++++++------------ lib/airbrake_api/v3/notice_parser.rb | 16 ++++++++-------- lib/tasks/errbit/demo.rake | 10 +++++----- spec/acceptance/acceptance_helper.rb | 6 +++--- spec/controllers/api/v3/notices_controller_spec.rb | 2 +- spec/lib/airbrake_api/v3/notice_parser_spec.rb | 8 ++++---- spec/models/error_report_spec.rb | 12 ++++++------ spec/models/notice_observer_spec.rb | 8 ++++---- spec/views/problems/show.html.haml_spec.rb | 2 +- 13 files changed, 76 insertions(+), 75 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index e1b437b..5344793 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -37,6 +37,7 @@ Style/IndentHash: EnforcedStyle: consistent Style/AlignHash: + EnforcedHashRocketStyle: table EnforcedColonStyle: table Style/SpaceAroundOperators: diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index a8a745f..1013793 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -5,12 +5,12 @@ require Rails.root.join('config/routes.rb') class Mailer < ActionMailer::Base helper ApplicationHelper - default :from => Errbit::Config.email_from, - 'X-Errbit-Host' => Errbit::Config.host, - 'X-Mailer' => 'Errbit', + default :from => Errbit::Config.email_from, + 'X-Errbit-Host' => Errbit::Config.host, + 'X-Mailer' => 'Errbit', 'X-Auto-Response-Suppress' => 'OOF, AutoReply', - 'Precedence' => 'bulk', - 'Auto-Submitted' => 'auto-generated' + 'Precedence' => 'bulk', + 'Auto-Submitted' => 'auto-generated' def err_notification(error_report) @notice = NoticeDecorator.new error_report.notice @@ -19,9 +19,9 @@ class Mailer < ActionMailer::Base count = error_report.problem.notices_count count = count > 1 ? "(#{count}) " : "" - errbit_headers 'App' => @app.name, + errbit_headers 'App' => @app.name, 'Environment' => @notice.environment_name, - 'Error-Id' => @notice.err_id + 'Error-Id' => @notice.err_id mail to: @app.notification_recipients, subject: "#{count}[#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" @@ -31,10 +31,10 @@ class Mailer < ActionMailer::Base @deploy = deploy @app = AppDecorator.new deploy.app - errbit_headers 'App' => @app.name, - 'Environment' => @deploy.environment, + errbit_headers 'App' => @app.name, + 'Environment' => @deploy.environment, 'Deploy-Revision' => @deploy.revision, - 'Deploy-User' => @deploy.username + 'Deploy-User' => @deploy.username mail to: @app.notification_recipients, subject: "[#{@app.name}] Deployed to #{@deploy.environment} by #{@deploy.username}" @@ -49,9 +49,9 @@ class Mailer < ActionMailer::Base recipients = @comment.notification_recipients - errbit_headers 'App' => @app.name, - 'Environment' => @notice.environment_name, - 'Problem-Id' => @problem.id, + errbit_headers 'App' => @app.name, + 'Environment' => @notice.environment_name, + 'Problem-Id' => @problem.id, 'Comment-Author' => @user.name mail to: recipients, diff --git a/app/models/problem.rb b/app/models/problem.rb index af9eb07..afce776 100644 --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -85,21 +85,21 @@ class Problem Problem.where('_id' => id).find_one_and_update({ '$set' => { - 'environment' => notice.environment_name, - 'error_class' => notice.error_class, - 'last_notice_at' => notice.created_at.utc, - 'message' => notice.message, - 'resolved' => false, - 'resolved_at' => nil, - 'where' => notice.where, - "messages.#{message_digest}.value" => notice.message, - "hosts.#{host_digest}.value" => notice.host, + 'environment' => notice.environment_name, + 'error_class' => notice.error_class, + 'last_notice_at' => notice.created_at.utc, + 'message' => notice.message, + 'resolved' => false, + 'resolved_at' => nil, + 'where' => notice.where, + "messages.#{message_digest}.value" => notice.message, + "hosts.#{host_digest}.value" => notice.host, "user_agents.#{user_agent_digest}.value" => notice.user_agent_string }, '$inc' => { - 'notices_count' => 1, - "messages.#{message_digest}.count" => 1, - "hosts.#{host_digest}.count" => 1, + 'notices_count' => 1, + "messages.#{message_digest}.count" => 1, + "hosts.#{host_digest}.count" => 1, "user_agents.#{user_agent_digest}.count" => 1 } }, return_document: :after) @@ -110,12 +110,12 @@ class Problem atomically do |doc| doc.set( - 'environment' => last_notice.environment_name, - 'error_class' => last_notice.error_class, + 'environment' => last_notice.environment_name, + 'error_class' => last_notice.error_class, 'last_notice_at' => last_notice.created_at, - 'message' => last_notice.message, - 'where' => last_notice.where, - 'notices_count' => notices_count.to_i > 1 ? notices_count - 1 : 0 + 'message' => last_notice.message, + 'where' => last_notice.where, + 'notices_count' => notices_count.to_i > 1 ? notices_count - 1 : 0 ) CACHED_NOTICE_ATTRIBUTES.each do |k, v| diff --git a/config/deploy.example.rb b/config/deploy.example.rb index bb3b949..2675a59 100644 --- a/config/deploy.example.rb +++ b/config/deploy.example.rb @@ -46,7 +46,7 @@ namespace :errbit do { 'config/newrelic.example.yml' => 'config/newrelic.yml', - 'config/unicorn.default.rb' => 'config/unicorn.rb' + 'config/unicorn.default.rb' => 'config/unicorn.rb' }.each do |src, target| unless test("[ -f #{shared_path}/#{target} ]") upload! src, "#{shared_path}/#{target}" diff --git a/db/migrate/201510290041_extract_issue_tracker.rb b/db/migrate/201510290041_extract_issue_tracker.rb index aab19ec..b5353a1 100644 --- a/db/migrate/201510290041_extract_issue_tracker.rb +++ b/db/migrate/201510290041_extract_issue_tracker.rb @@ -1,15 +1,15 @@ class ExtractIssueTracker < Mongoid::Migration TRACKER_MAPPING = { - 'ErrbitTracPlugin::IssueTracker' => 'trac', + 'ErrbitTracPlugin::IssueTracker' => 'trac', 'IssueTrackers::BitbucketIssuesTracker' => 'bitbucket', - 'IssueTrackers::FogbugzTracker' => 'fogbugz', - 'IssueTrackers::GithubIssuesTracker' => 'github', - 'IssueTrackers::GitlabTracker' => 'gitlab', - 'IssueTrackers::JiraTracker' => 'jira', - 'IssueTrackers::LighthouseTracker' => 'lighthouse', - 'IssueTrackers::PivotalLabsTracker' => 'pivotal', - 'IssueTrackers::RedmineTracker' => 'redmine', - 'IssueTrackers::UnfuddleTracker' => 'unfuddle' + 'IssueTrackers::FogbugzTracker' => 'fogbugz', + 'IssueTrackers::GithubIssuesTracker' => 'github', + 'IssueTrackers::GitlabTracker' => 'gitlab', + 'IssueTrackers::JiraTracker' => 'jira', + 'IssueTrackers::LighthouseTracker' => 'lighthouse', + 'IssueTrackers::PivotalLabsTracker' => 'pivotal', + 'IssueTrackers::RedmineTracker' => 'redmine', + 'IssueTrackers::UnfuddleTracker' => 'unfuddle' } def self.up @@ -29,9 +29,9 @@ class ExtractIssueTracker < Mongoid::Migration tracker = { 'type_tracker' => TRACKER_MAPPING[type], - 'options' => options, - 'updated_at' => updated_at, - 'created_at' => created_at + 'options' => options, + 'updated_at' => updated_at, + 'created_at' => created_at } App.where(_id: app.id).update("$set" => { issue_tracker: tracker }) diff --git a/lib/airbrake_api/v3/notice_parser.rb b/lib/airbrake_api/v3/notice_parser.rb index b53fb0c..b4811a7 100644 --- a/lib/airbrake_api/v3/notice_parser.rb +++ b/lib/airbrake_api/v3/notice_parser.rb @@ -45,9 +45,9 @@ module AirbrakeApi def server_environment { 'environment-name' => context['environment'], - 'hostname' => hostname, - 'project-root' => context['rootDirectory'], - 'app-version' => context['version'] + 'hostname' => hostname, + 'project-root' => context['rootDirectory'], + 'app-version' => context['version'] } end @@ -57,12 +57,12 @@ module AirbrakeApi ) { - 'cgi-data' => environment, - 'session' => params['session'], - 'params' => params['params'], - 'url' => url, + 'cgi-data' => environment, + 'session' => params['session'], + 'params' => params['params'], + 'url' => url, 'component' => context['component'], - 'action' => context['action'] + 'action' => context['action'] } end diff --git a/lib/tasks/errbit/demo.rake b/lib/tasks/errbit/demo.rake index fb04240..b9cff4e 100644 --- a/lib/tasks/errbit/demo.rake +++ b/lib/tasks/errbit/demo.rake @@ -34,9 +34,9 @@ namespace :errbit do backtrace = [] 99.times {|t| backtrace << { - 'number' => t.hash % 1000, - 'file' => "/path/to/file.rb", - 'method' => RANDOM_METHODS.sample.to_s + 'number' => t.hash % 1000, + 'file' => "/path/to/file.rb", + 'method' => RANDOM_METHODS.sample.to_s }} backtrace end @@ -51,8 +51,8 @@ namespace :errbit do backtrace: random_backtrace, request: { 'component' => 'main', - 'action' => 'error', - 'url' => "http://example.com/post/#{[111, 222, 333].sample}" + 'action' => 'error', + 'url' => "http://example.com/post/#{[111, 222, 333].sample}" }, server_environment: { 'environment-name' => Rails.env.to_s }, notifier: { name: "seeds.rb" }, diff --git a/spec/acceptance/acceptance_helper.rb b/spec/acceptance/acceptance_helper.rb index 044993c..66417be 100644 --- a/spec/acceptance/acceptance_helper.rb +++ b/spec/acceptance/acceptance_helper.rb @@ -7,9 +7,9 @@ OmniAuth.config.test_mode = true def mock_auth(user = "test_user", token = "abcdef") OmniAuth.config.mock_auth[:github] = Hashie::Mash.new( - 'provider' => 'github', - 'uid' => '1763', - 'extra' => { + 'provider' => 'github', + 'uid' => '1763', + 'extra' => { 'raw_info' => { 'login' => user } diff --git a/spec/controllers/api/v3/notices_controller_spec.rb b/spec/controllers/api/v3/notices_controller_spec.rb index 32c5cfc..60a8885 100644 --- a/spec/controllers/api/v3/notices_controller_spec.rb +++ b/spec/controllers/api/v3/notices_controller_spec.rb @@ -16,7 +16,7 @@ describe Api::V3::NoticesController, type: :controller do post :create, legit_body, legit_params notice = Notice.last expect(JSON.parse(response.body)).to eq( - 'id' => notice.id.to_s, + 'id' => notice.id.to_s, 'url' => app_problem_url(app, notice.problem) ) end diff --git a/spec/lib/airbrake_api/v3/notice_parser_spec.rb b/spec/lib/airbrake_api/v3/notice_parser_spec.rb index 023e428..424dd7a 100644 --- a/spec/lib/airbrake_api/v3/notice_parser_spec.rb +++ b/spec/lib/airbrake_api/v3/notice_parser_spec.rb @@ -21,16 +21,16 @@ describe AirbrakeApi::V3::NoticeParser do expect(report.message).to eq('Error: TestError') expect(report.backtrace.lines.size).to eq(9) expect(notice.user_attributes).to include( - 'Id' => 1, - 'Name' => 'John Doe', - 'Email' => 'john.doe@example.org', + 'Id' => 1, + 'Name' => 'John Doe', + 'Email' => 'john.doe@example.org', 'Username' => 'john' ) expect(notice.session).to include('isAdmin' => true) expect(notice.params).to include('returnTo' => 'dashboard') expect(notice.env_vars).to include( 'navigator_vendor' => 'Google Inc.', - 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36' + 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36' ) end diff --git a/spec/models/error_report_spec.rb b/spec/models/error_report_spec.rb index 506cfef..1456725 100644 --- a/spec/models/error_report_spec.rb +++ b/spec/models/error_report_spec.rb @@ -128,12 +128,12 @@ describe ErrorReport do # # expected = { - 'secure' => 'false', - 'httponly' => 'true', - 'path' => '/', - 'expire_after' => nil, - 'domain' => nil, - 'id' => nil + 'secure' => 'false', + 'httponly' => 'true', + 'path' => '/', + 'expire_after' => nil, + 'domain' => nil, + 'id' => nil } expect(subject.env_vars).to have_key('rack_session_options') expect(subject.env_vars['rack_session_options']).to eql(expected) diff --git a/spec/models/notice_observer_spec.rb b/spec/models/notice_observer_spec.rb index 0f48ee1..55a48a5 100644 --- a/spec/models/notice_observer_spec.rb +++ b/spec/models/notice_observer_spec.rb @@ -7,20 +7,20 @@ describe "Callback on Notice", type: 'model' do backtrace: [ { "number" => "425", - "file" => "[GEM_ROOT]/callbacks.rb", + "file" => "[GEM_ROOT]/callbacks.rb", "method" => "__callbacks" } ], request: { "component" => "application" }, server_environment: { - "project-root" => "/path/to/sample/project", + "project-root" => "/path/to/sample/project", "environment-name" => "development" }, api_key: api_key, notifier: { - "name" => "Hoptoad Notifier", + "name" => "Hoptoad Notifier", "version" => "2.3.2", - "url" => "http://hoptoadapp.com" + "url" => "http://hoptoadapp.com" }, framework: "Rails: 3.2.11" } diff --git a/spec/views/problems/show.html.haml_spec.rb b/spec/views/problems/show.html.haml_spec.rb index 5c971e6..ef1fc12 100644 --- a/spec/views/problems/show.html.haml_spec.rb +++ b/spec/views/problems/show.html.haml_spec.rb @@ -33,7 +33,7 @@ describe "problems/show.html.haml", type: 'view' do } let(:trackers) { { - 'github' => github_tracker, + 'github' => github_tracker, 'pivotal' => pivotal_tracker } } -- libgit2 0.21.2