Commit b3b149ad11733eaa503c503c01cbe52f05dc941e

Authored by Laust Rud Jacobsen
1 parent 1095d783
Exists in master and in 1 other branch production

Rubocop: inject a space around operators, letting them breathe a bit

.rubocop.yml
... ... @@ -31,3 +31,9 @@ Style/AlignParameters:
31 31  
32 32 Style/IndentHash:
33 33 EnforcedStyle: consistent
  34 +
  35 +Style/SpaceAroundOperators:
  36 + MultiSpaceAllowedForOperators:
  37 + - '='
  38 + - '=>'
  39 + - '||='
... ...
.rubocop_todo.yml
... ... @@ -317,21 +317,6 @@ Style/SingleSpaceBeforeFirstArg:
317 317 Style/SpaceAroundEqualsInParameterDefault:
318 318 Enabled: false
319 319  
320   -# Offense count: 28
321   -# Cop supports --auto-correct.
322   -# Configuration parameters: MultiSpaceAllowedForOperators.
323   -Style/SpaceAroundOperators:
324   - Exclude:
325   - - 'app/controllers/api/v1/problems_controller.rb'
326   - - 'app/helpers/application_helper.rb'
327   - - 'app/helpers/apps_helper.rb'
328   - - 'app/helpers/hash_helper.rb'
329   - - 'app/models/issue_tracker.rb'
330   - - 'app/models/notification_service.rb'
331   - - 'config/load.rb'
332   - - 'spec/controllers/problems_controller_spec.rb'
333   - - 'spec/models/notice_observer_spec.rb'
334   -
335 320 # Offense count: 27
336 321 # Cop supports --auto-correct.
337 322 # Configuration parameters: EnforcedStyle, SupportedStyles.
... ...
app/controllers/api/v1/problems_controller.rb
... ... @@ -24,7 +24,7 @@ class Api::V1::ProblemsController < ApplicationController
24 24 if params.key?(:start_date) && params.key?(:end_date)
25 25 start_date = Time.parse(params[:start_date]).utc
26 26 end_date = Time.parse(params[:end_date]).utc
27   - query = {:first_notice_at=>{"$lte"=>end_date}, "$or"=>[{:resolved_at=>nil}, {:resolved_at=>{"$gte"=>start_date}}]}
  27 + query = {:first_notice_at => {"$lte" => end_date}, "$or" => [{:resolved_at => nil}, {:resolved_at => {"$gte" => start_date}}]}
28 28 end
29 29  
30 30 results = benchmark("[api/v1/problems_controller/index] query time") do
... ...
app/helpers/application_helper.rb
... ... @@ -7,7 +7,7 @@ module ApplicationHelper
7 7 RiCal.Calendar do |cal|
8 8 notices.each_with_index do |notice, idx|
9 9 cal.event do |event|
10   - event.summary = "#{idx+1} #{notice.message}"
  10 + event.summary = "#{idx + 1} #{notice.message}"
11 11 event.description = notice.url if notice.url
12 12 event.dtstart = notice.created_at.utc
13 13 event.dtend = notice.created_at.utc + 60.minutes
... ... @@ -23,7 +23,7 @@ module ApplicationHelper
23 23 RiCal.Calendar { |cal|
24 24 deploys.each_with_index do |deploy, idx|
25 25 cal.event do |event|
26   - event.summary = "#{idx+1} #{deploy.repository}"
  26 + event.summary = "#{idx + 1} #{deploy.repository}"
27 27 event.description = deploy.revision.to_s
28 28 event.dtstart = deploy.created_at.utc
29 29 event.dtend = deploy.created_at.utc + 60.minutes
... ...
app/helpers/hash_helper.rb
... ... @@ -9,11 +9,11 @@ module HashHelper
9 9 sorted_keys = hash.keys.sort
10 10 sorted_keys.each do |key|
11 11 val = hash[key].is_a?(Hash) ? pretty_hash(hash[key], nesting) : hash[key].inspect
12   - pretty += "\n#{' '*nesting*tab_size}"
  12 + pretty += "\n#{' ' * nesting * tab_size}"
13 13 pretty += "#{key.inspect} => #{val}"
14 14 pretty += "," unless key == sorted_keys.last
15 15 end
16 16 nesting -= 1
17   - pretty += "\n#{' '*nesting*tab_size}}"
  17 + pretty += "\n#{' ' * nesting * tab_size}}"
18 18 end
19 19 end
... ...
app/models/notification_service.rb
... ... @@ -40,7 +40,7 @@ class NotificationService
40 40  
41 41 # Allows us to set the issue tracker class from a single form.
42 42 def type; _type; end
43   - def type=(t); self._type=t; end
  43 + def type=(t); self._type = t; end
44 44  
45 45 def url; nil; end
46 46  
... ...
config/load.rb
... ... @@ -52,8 +52,7 @@ Errbit::Config = Configurator.run({
52 52 smtp_password: %w(SMTP_PASSWORD SENDGRID_PASSWORD),
53 53 smtp_domain: ['SMTP_DOMAIN', 'SENDGRID_DOMAIN', ->(values) {
54 54 values[:smtp_domain] ||
55   - (values[:email_from] && values[:email_from].split('@').last)||
56   - nil
  55 + (values[:email_from] && values[:email_from].split('@').last) || nil
57 56 }],
58 57  
59 58 # sendmail settings
... ...
spec/controllers/problems_controller_spec.rb
... ... @@ -95,8 +95,8 @@ describe ProblemsController, type: 'controller' do
95 95 before do
96 96 sign_in user
97 97 @app = Fabricate(:app)
98   - @problem1 = Fabricate(:problem, :app=>@app, message: "Most important")
99   - @problem2 = Fabricate(:problem, :app=>@app, message: "Very very important")
  98 + @problem1 = Fabricate(:problem, :app => @app, message: "Most important")
  99 + @problem2 = Fabricate(:problem, :app => @app, message: "Very very important")
100 100 end
101 101  
102 102 it "renders successfully" do
... ... @@ -380,8 +380,8 @@ describe ProblemsController, type: 'controller' do
380 380 before do
381 381 sign_in user
382 382 @app = Fabricate(:app)
383   - @problem1 = Fabricate(:problem, :app=>@app)
384   - @problem2 = Fabricate(:problem, :app=>@app)
  383 + @problem1 = Fabricate(:problem, :app => @app)
  384 + @problem2 = Fabricate(:problem, :app => @app)
385 385 end
386 386  
387 387 it "destroys all problems" do
... ...
spec/models/notice_observer_spec.rb
... ... @@ -6,9 +6,9 @@ describe "Callback on Notice", type: 'model' do
6 6 message: "some message",
7 7 backtrace: [
8 8 {
9   - "number"=>"425",
10   - "file"=>"[GEM_ROOT]/callbacks.rb",
11   - "method"=>"__callbacks"
  9 + "number" => "425",
  10 + "file" => "[GEM_ROOT]/callbacks.rb",
  11 + "method" => "__callbacks"
12 12 }
13 13 ],
14 14 request: { "component" => "application" },
... ... @@ -18,9 +18,9 @@ describe "Callback on Notice", type: 'model' do
18 18 },
19 19 api_key: api_key,
20 20 notifier: {
21   - "name"=>"Hoptoad Notifier",
22   - "version"=>"2.3.2",
23   - "url"=>"http://hoptoadapp.com"
  21 + "name" => "Hoptoad Notifier",
  22 + "version" => "2.3.2",
  23 + "url" => "http://hoptoadapp.com"
24 24 },
25 25 framework: "Rails: 3.2.11"
26 26 }
... ...