Skip to content

Commit

Permalink
fix rubocop offenses (errbit#1211)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevecrozz authored Jul 15, 2017
1 parent 908131b commit 8d690fd
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ before_script:
- bundle exec rake errbit:bootstrap
script:
- bundle exec rspec
- bundle exec rubocop --lint
- bundle exec rubocop
matrix:
allow_failures:
- rvm: ruby-head
Expand Down
5 changes: 1 addition & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ group :development do
gem 'capistrano-rails', require: false
gem 'capistrano-rbenv', require: false
gem 'capistrano3-puma', require: false


# better errors
gem 'better_errors'
gem 'binding_of_caller', platform: 'ruby'
gem 'meta_request'
Expand All @@ -100,7 +97,7 @@ group :heroku, :production do
end

group :no_docker, :test, :development do
gem 'therubyracer', :platform => :ruby # C Ruby (MRI) or Rubinius, but NOT Windows
gem 'therubyracer', platform: :ruby # C Ruby (MRI) or Rubinius, but NOT Windows
end

gem 'puma'
Expand Down
14 changes: 7 additions & 7 deletions app/controllers/apps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ class AppsController < ApplicationController
before_action :parse_email_at_notices_or_set_default, only: [:create, :update]
before_action :parse_notice_at_notices_or_set_default, only: [:create, :update]

expose(:app_scope) {
expose(:app_scope) do
params[:search].present? ? App.search(params[:search]) : App.all
}
end

expose(:apps) do
app_scope.to_a.sort.map { |app| AppDecorator.new(app) }
Expand Down Expand Up @@ -133,11 +133,11 @@ def parse_email_at_notices_or_set_default
# 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
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/sort_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module SortHelper
def link_for_sort(name, field = nil)
field ||= name.underscore
current = (params_sort == field)
order = (current && (params_order == "asc")) ? "desc" : "asc"
url = request.path + "?sort=#{field}&order=#{order}"
url += "&all_errs=true" if all_errs
order = (current && (params_order == "asc")) ? "desc" : "asc"
url = request.path + "?sort=#{field}&order=#{order}"
url += "&all_errs=true" if all_errs
options = {}
options.merge!(class: "current #{order}") if current
link_to(name, url, options)
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/destroy_problems_by_app_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ def perform(app_id)
app = App.find_by(id: app_id)
::ProblemDestroy.execute(app.problems)
end
end
end
2 changes: 1 addition & 1 deletion app/jobs/destroy_problems_by_id_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ def perform(problem_ids)
problems = Problem.find(bson_problem_ids).to_a
::ProblemDestroy.execute(problems)
end
end
end
4 changes: 1 addition & 3 deletions app/models/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ class App
reject_if: proc { |attrs| !NotificationService.subclasses.map(&:to_s).include?(attrs[:type].to_s) }
accepts_nested_attributes_for :notice_fingerprinter

index({
name: "text"
}, default_language: "english")
index({ name: "text" }, default_language: "english")

scope :search, ->(value) { where('$text' => { '$search' => value }) }
scope :watched_by, lambda { |user|
Expand Down
2 changes: 1 addition & 1 deletion app/models/issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def close
if issue_tracker.respond_to? :close_issue
issue_tracker.close_issue(problem.issue_link, user: user.as_document)
end

errors.empty?
rescue => ex
errors.add :base, "There was an error during issue closing: #{ex.message}"
Expand Down
6 changes: 2 additions & 4 deletions app/models/notification_services/hipchat_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ def create_notification(problem)
client[room_id].send('Errbit', message, color: 'red', notify: true, message_format: format)
end

private

def message_html(problem)
private def message_html(problem)
url = app_problem_url(problem.app, problem)
<<-MSG.strip_heredoc
<strong>#{ERB::Util.html_escape problem.app.name}</strong> error in <strong>#{ERB::Util.html_escape problem.environment}</strong> at <strong>#{ERB::Util.html_escape problem.where}</strong> (<a href="#{url}">details</a>)<br>
Expand All @@ -65,7 +63,7 @@ def message_html(problem)
MSG
end

def message_text(problem)
private def message_text(problem)
url = app_problem_url(problem.app, problem)
<<-MSG
#{self[:mentions]} #{problem.app.name} error in #{problem.environment}: #{problem.message.to_s.truncate(100)}
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/sucker_punch.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require 'sucker_punch/async_syntax'
require 'sucker_punch/async_syntax'
6 changes: 2 additions & 4 deletions spec/acceptance/acceptance_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ def mock_auth(user = "test_user", token = "abcdef")

OmniAuth.config.mock_auth[:google_oauth2] = Hashie::Mash.new(
provider: 'google',
uid: user,
info: {
email: '[email protected]'
}
uid: user,
info: { email: '[email protected]' }
)
end

Expand Down
10 changes: 5 additions & 5 deletions spec/controllers/apps_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
it_requires_authentication
it_requires_admin_privileges for: { new: :get, edit: :get, create: :post, update: :put, destroy: :delete }

let(:app_params) {{ name: 'BestApp' }}
let(:app_params) { { name: 'BestApp' } }
let(:admin) { Fabricate(:admin) }
let(:user) { Fabricate(:user) }
let(:watcher) { Fabricate(:user_watcher, app: app, user: user) }
Expand Down Expand Up @@ -267,8 +267,8 @@

context "changing email_at_notices" do
before do
allow(Errbit::Config)
.to receive(:per_app_email_at_notices).and_return(true)
allow(Errbit::Config).
to receive(:per_app_email_at_notices).and_return(true)
end

it "should parse legal csv values" do
Expand Down Expand Up @@ -312,7 +312,7 @@
SiteConfig.document.update_attributes(notice_fingerprinter: notice_fingerprinter)
put :update, id: @app.id, app: {
notice_fingerprinter_attributes: { backtrace_lines: 42 },
use_site_fingerprinter: '1'
use_site_fingerprinter: '1'
}
@app.reload
end
Expand All @@ -329,7 +329,7 @@
SiteConfig.document.update_attributes(notice_fingerprinter: notice_fingerprinter)
put :update, id: @app.id, app: {
notice_fingerprinter_attributes: { backtrace_lines: 42 },
use_site_fingerprinter: '0'
use_site_fingerprinter: '0'
}
@app.reload
end
Expand Down
1 change: 0 additions & 1 deletion spec/controllers/problems_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
expect(controller.problems).to include(@problem1)
expect(controller.problems).to include(@problem2)
end

end

describe "GET /apps/:app_id/problems/:id" do
Expand Down
20 changes: 10 additions & 10 deletions spec/controllers/site_config_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,24 @@

it 'updates apps that are using site wide notice fingerprinter' do
put :update, site_config: {
notice_fingerprinter_attributes: {
backtrace_lines: 10,
environment_name: false
}
notice_fingerprinter_attributes: {
backtrace_lines: 10,
environment_name: false
}
}
app = App.new(name: 'my_app')
app.save
expect(app.notice_fingerprinter.backtrace_lines).to be 10
expect(app.notice_fingerprinter.backtrace_lines).to be 10
expect(app.notice_fingerprinter.environment_name).to be false

put :update, site_config: {
notice_fingerprinter_attributes: {
backtrace_lines: 11,
environment_name: true
}
notice_fingerprinter_attributes: {
backtrace_lines: 11,
environment_name: true
}
}
app.reload
expect(app.notice_fingerprinter.backtrace_lines).to be 11
expect(app.notice_fingerprinter.backtrace_lines).to be 11
expect(app.notice_fingerprinter.environment_name).to be true
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/fabricators/notification_service_fabricator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

Fabricator :slack_notification_service, from: :notification_service, class_name: "NotificationServices::SlackService" do
service_url { sequence :word }
room_id { sequence(:room_id) { |i| "#room-#{i}" } }
room_id { sequence(:room_id) { |i| "#room-#{i}" } }
end

Fabricator :hipchat_notification_service, from: :notification_service, class_name: "NotificationServices::HipchatService" do
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/airbrake_api/v3/notice_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@

it 'takes the hostname from the context' do
parser = described_class.new(
'errors' => ['MyError'],
'context' => { 'hostname' => 'app01.infra.example.com', 'url' => 'http://example.com/some-page' },
'environment' => {})
'errors' => ['MyError'],
'context' => { 'hostname' => 'app01.infra.example.com', 'url' => 'http://example.com/some-page' },
'environment' => {})
expect(parser.attributes[:server_environment]['hostname']).to eq('app01.infra.example.com')
end

Expand Down
2 changes: 1 addition & 1 deletion spec/models/error_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def framework
end

context "as [1,3]" do
let(:email_at_notices) { [1,3] }
let(:email_at_notices) { [1, 3] }

it "sends email on 1st occurrence" do
1.times { described_class.new(xml).generate_notice! }
Expand Down

0 comments on commit 8d690fd

Please sign in to comment.