DEV: follow rubocop rules

DEV: follow rubocop rules

auto corrects existing rubocop rules so syntax is consistent

From 260c2072a66bbf3a8251af3aea33882a67149823 Mon Sep 17 00:00:00 2001
From: Sam <sam.saffron@gmail.com>
Date: Mon, 10 Dec 2018 13:34:32 +1100
Subject: [PATCH] DEV: follow rubocop rules

auto corrects existing rubocop rules so syntax is consistent

diff --git a/Gemfile b/Gemfile
index 0eff971..b6be25b 100644
--- a/Gemfile
+++ b/Gemfile
@@ -3,13 +3,13 @@ ruby '>= 2.2.0'
 
 gemspec
 
-gem 'codecov', :require => false, :group => :test
+gem 'codecov', require: false, group: :test
 
 if RUBY_VERSION < '2.2.2'
   gem 'rack', '1.6.4'
 end
 
 group :development do
-  gem 'guard', :platforms => [:mri_22, :mri_23]
-  gem 'guard-rspec', :platforms => [:mri_22, :mri_23]
+  gem 'guard', platforms: [:mri_22, :mri_23]
+  gem 'guard-rspec', platforms: [:mri_22, :mri_23]
 end
diff --git a/Guardfile b/Guardfile
index f505b99..3817c94 100644
--- a/Guardfile
+++ b/Guardfile
@@ -2,7 +2,7 @@
 # More info at https://github.com/guard/guard#readme
 
 directories %w(lib spec) \
- .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
+  .select { |d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist") }
 
 ## Note: if you are using the `directories` clause above and you are not
 ## watching the project directory ('.'), then you will want to move
@@ -27,4 +27,3 @@ guard :rspec, cmd: 'bundle exec rspec', failed_mode: :focus do
   watch(%r{^lib/mini_profiler/(.+)\.rb$})     { |m| "spec/lib/#{m[1]}_spec.rb" }
   watch('spec/spec_helper.rb')  { "spec" }
 end
-
diff --git a/Rakefile b/Rakefile
index 6302a93..2564ef0 100644
--- a/Rakefile
+++ b/Rakefile
@@ -9,7 +9,7 @@ require 'rubocop/rake_task'
 
 RuboCop::RakeTask.new
 
-task :default => [:rubocop, :spec]
+task default: [:rubocop, :spec]
 
 require 'rspec/core'
 require 'rspec/core/rake_task'
@@ -18,23 +18,23 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
 end
 
 desc "builds a gem"
-task :build => :update_asset_version do
+task build: :update_asset_version do
   `gem build rack-mini-profiler.gemspec 1>&2`
 end
 
 desc "compile sass"
-task :compile_sass => :copy_files do
+task compile_sass: :copy_files do
   `sass lib/html/includes.scss > lib/html/includes.css`
 end
 
 desc "update asset version file"
-task :update_asset_version => :compile_sass do
+task update_asset_version: :compile_sass do
   require 'digest/md5'
   h = []
   Dir.glob('lib/html/*.{js,html,css,tmpl}').each do |f|
     h << Digest::MD5.hexdigest(::File.read(f))
   end
-  File.open('lib/mini_profiler/asset_version.rb','w') do |f|
+  File.open('lib/mini_profiler/asset_version.rb', 'w') do |f|
     f.write \
 "module Rack
   class MiniProfiler
@@ -44,9 +44,7 @@ end"
   end
 end
 
-
 desc "copy files from other parts of the tree"
 task :copy_files do
   # TODO grab files from MiniProfiler/UI
 end
-
diff --git a/lib/mini_profiler/asset_version.rb b/lib/mini_profiler/asset_version.rb
index a86ce5d..89823cf 100644
--- a/lib/mini_profiler/asset_version.rb
+++ b/lib/mini_profiler/asset_version.rb
@@ -2,4 +2,4 @@ module Rack
   class MiniProfiler
     ASSET_VERSION = '251162ee7dc30da30d5370581c664510'.freeze
   end
-end
\ No newline at end of file
+end
diff --git a/lib/mini_profiler/config.rb b/lib/mini_profiler/config.rb
index 6caa5db..6851202 100644
--- a/lib/mini_profiler/config.rb
+++ b/lib/mini_profiler/config.rb
@@ -19,12 +19,12 @@ module Rack
           @base_url_path    = "/mini-profiler-resources/".dup
           @disable_caching  = true
           # called prior to rack chain, to ensure we are allowed to profile
-          @pre_authorize_cb = lambda {|env| true}
+          @pre_authorize_cb = lambda { |env| true }
 
           # called after rack chain, to ensure we are REALLY allowed to profile
           @skip_schema_queries    = false
           @storage                = MiniProfiler::MemoryStore
-          @user_provider          = Proc.new{|env| Rack::Request.new(env).ip}
+          @user_provider          = Proc.new { |env| Rack::Request.new(env).ip }
           @authorization_mode     = :allow_all
           @backtrace_threshold_ms = 0
           @flamegraph_sample_rate = 0.5
@@ -79,13 +79,12 @@ module Rack
         position.include?('right') ? 'right' : 'left'
       end
 
-
       def merge!(config)
         if config
           if Hash === config
-            config.each{|k,v| instance_variable_set "@#{k}",v}
+            config.each { |k, v| instance_variable_set "@#{k}", v }
           else
-            self.class.attributes.each{ |k|
+            self.class.attributes.each { |k|
               v = config.send k
               instance_variable_set "@#{k}", v if v
             }
diff --git a/lib/mini_profiler/context.rb b/lib/mini_profiler/context.rb
index 9f01f8f..8ebeb3f 100644
--- a/lib/mini_profiler/context.rb
+++ b/lib/mini_profiler/context.rb
@@ -1,12 +1,12 @@
 # frozen_string_literal: true
 
 class Rack::MiniProfiler::Context
-  attr_accessor :inject_js,:current_timer,:page_struct,:skip_backtrace,
-                :full_backtrace,:discard, :mpt_init, :measure
+  attr_accessor :inject_js, :current_timer, :page_struct, :skip_backtrace,
+                :full_backtrace, :discard, :mpt_init, :measure
 
   def initialize(opts = {})
     opts["measure"] = true unless opts.key? "measure"
-    opts.each do |k,v|
+    opts.each do |k, v|
       self.instance_variable_set('@' + k, v)
     end
   end
diff --git a/lib/mini_profiler/gc_profiler.rb b/lib/mini_profiler/gc_profiler.rb
index d8fe3d5..514641a 100644
--- a/lib/mini_profiler/gc_profiler.rb
+++ b/lib/mini_profiler/gc_profiler.rb
@@ -30,7 +30,7 @@ class Rack::MiniProfiler::GCProfiler
       end
     end
 
-    result = {:stats => stats, :ids => ids}
+    result = { stats: stats, ids: ids }
     @ignore << result.__id__
 
     result
@@ -38,10 +38,10 @@ class Rack::MiniProfiler::GCProfiler
 
   def diff_object_stats(before, after)
     diff = {}.compare_by_identity
-    after.each do |k,v|
+    after.each do |k, v|
       diff[k] = v - before[k]
     end
-    before.each do |k,v|
+    before.each do |k, v|
       diff[k] = 0 - v unless after.has_key?(k)
     end
 
@@ -50,7 +50,7 @@ class Rack::MiniProfiler::GCProfiler
 
   def analyze_strings(ids_before, ids_after)
     result = {}
-    ids_after.each do |id,_|
+    ids_after.each do |id, _|
       obj = ObjectSpace._id2ref(id)
       if String === obj && !ids_before.include?(obj.object_id)
         result[obj] ||= 0
@@ -64,8 +64,8 @@ class Rack::MiniProfiler::GCProfiler
     new_objects = 0
     memory_allocated = 0
 
-    ids_after.each do |id,_|
-      if !ids_before.include?(id) && obj=ObjectSpace._id2ref(id)
+    ids_after.each do |id, _|
+      if !ids_before.include?(id) && obj = ObjectSpace._id2ref(id)
         # this is going to be version specific (may change in 2.1)
         size = ObjectSpace.memsize_of(obj)
         memory_allocated += size
@@ -80,15 +80,15 @@ class Rack::MiniProfiler::GCProfiler
     memory_allocated = 0
     objects = 0
 
-    ids_before.each do |id,_|
-      if obj=ObjectSpace._id2ref(id)
+    ids_before.each do |id, _|
+      if obj = ObjectSpace._id2ref(id)
         # this is going to be version specific (may change in 2.1)
         memory_allocated += ObjectSpace.memsize_of(obj)
         objects += 1
       end
     end
 
-    [objects,memory_allocated]
+    [objects, memory_allocated]
   end
 
   def profile_gc(app, env)
@@ -107,7 +107,7 @@ class Rack::MiniProfiler::GCProfiler
     # so we don't blow out on memory
     prev_gc_state ? GC.disable : GC.enable
 
-    diff                          = diff_object_stats(stat_before[:stats],stat_after[:stats])
+    diff                          = diff_object_stats(stat_before[:stats], stat_after[:stats])
     string_analysis               = analyze_strings(stat_before[:ids], stat_after[:ids])
     new_objects, memory_allocated = analyze_growth(stat_before[:ids], stat_after[:ids])
     objects_before, memory_before = analyze_initial_state(stat_before[:ids])
@@ -122,7 +122,7 @@ Memory allocated outside heap (bytes): #{memory_before}
 
 G

GitHub