DEV: Inherit rubocop-discourse .rubocop config. (#448)

DEV: Inherit rubocop-discourse .rubocop config. (#448)

diff --git a/.rubocop.yml b/.rubocop.yml
index 79a5763..d46296c 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -1,125 +1,2 @@
-AllCops:
-  TargetRubyVersion: 2.4
-  DisabledByDefault: true
-  Exclude:
-    - "db/schema.rb"
-    - "bundle/**/*"
-    - "vendor/**/*"
-    - "node_modules/**/*"
-    - "public/**/*"
-    - "plugins/**/gems/**/*"
-
-# Prefer &&/|| over and/or.
-Style/AndOr:
-  Enabled: true
-
-Style/FrozenStringLiteralComment:
-  Enabled: true
-
-# Align `when` with `case`.
-Layout/CaseIndentation:
-  Enabled: true
-
-# Align comments with method definitions.
-Layout/CommentIndentation:
-  Enabled: true
-
-# No extra empty lines.
-Layout/EmptyLines:
-  Enabled: true
-
-# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
-Style/HashSyntax:
-  Enabled: true
-
-# Two spaces, no tabs (for indentation).
-Layout/IndentationWidth:
-  Enabled: true
-
-Layout/SpaceAfterColon:
-  Enabled: true
-
-Layout/SpaceAfterComma:
-  Enabled: true
-
-Layout/SpaceAroundEqualsInParameterDefault:
-  Enabled: true
-
-Layout/SpaceAroundKeyword:
-  Enabled: true
-
-Layout/SpaceAroundOperators:
-  Enabled: true
-
-Layout/SpaceBeforeFirstArg:
-  Enabled: true
-
-# Defining a method with parameters needs parentheses.
-Style/MethodDefParentheses:
-  Enabled: true
-
-# Use `foo {}` not `foo{}`.
-Layout/SpaceBeforeBlockBraces:
-  Enabled: true
-
-# Use `foo { bar }` not `foo {bar}`.
-Layout/SpaceInsideBlockBraces:
-  Enabled: true
-
-# Use `{ a: 1 }` not `{a:1}`.
-Layout/SpaceInsideHashLiteralBraces:
-  Enabled: true
-
-Layout/SpaceInsideParens:
-  Enabled: true
-
-# Detect hard tabs, no hard tabs.
-Layout/Tab:
-  Enabled: true
-
-# Blank lines should not have any spaces.
-Layout/TrailingEmptyLines:
-  Enabled: true
-
-# No trailing whitespace.
-Layout/TrailingWhitespace:
-  Enabled: true
-
-Lint/Debugger:
-  Enabled: true
-
-Layout/BlockAlignment:
-  Enabled: true
-
-# Align `end` with the matching keyword or starting expression except for
-# assignments, where it should be aligned with the LHS.
-Layout/EndAlignment:
-  Enabled: true
-  EnforcedStyleAlignWith: variable
-
-# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
-Lint/RequireParentheses:
-  Enabled: true
-
-Lint/ShadowingOuterLocalVariable:
-  Enabled: true
-
-Layout/MultilineMethodCallIndentation:
-  Enabled: true
-  EnforcedStyle: indented
-
-Layout/HashAlignment:
-  Enabled: true
-
-Bundler/OrderedGems:
-  Enabled: false
-
-Style/SingleLineMethods:
-  Enabled: true
-
-Style/Semicolon:
-  Enabled: true
-  AllowAsExpressionSeparator: true
-
-Style/RedundantReturn:
-  Enabled: true
+inherit_gem:
+  rubocop-discourse: default.yml
diff --git a/spec/integration/mini_profiler_spec.rb b/spec/integration/mini_profiler_spec.rb
index 05d1dc7..dfe6f77 100644
--- a/spec/integration/mini_profiler_spec.rb
+++ b/spec/integration/mini_profiler_spec.rb
@@ -338,8 +338,8 @@ describe Rack::MiniProfiler do
   describe 'error handling when storage_instance fails to save' do
     it "should recover gracefully" do
       Rack::MiniProfiler.config.pre_authorize_cb = lambda { |env| true }
-      allow_any_instance_of(Rack::MiniProfiler::MemoryStore).to receive(:save) { raise "This error" }
-      expect(Rack::MiniProfiler.config.storage_failure).to receive(:call)
+      allow_any_instance_of(Rack::MiniProfiler::MemoryStore).to have_received(:save) { raise "This error" }
+      expect(Rack::MiniProfiler.config.storage_failure).to have_received(:call)
       get '/html'
     end
   end
diff --git a/spec/integration/railtie_methods_spec.rb b/spec/integration/railtie_methods_spec.rb
index 929dc44..d595c25 100644
--- a/spec/integration/railtie_methods_spec.rb
+++ b/spec/integration/railtie_methods_spec.rb
@@ -11,7 +11,7 @@ end
 describe Rack::MiniProfilerRailsMethods do
   describe '#render_notification_handler' do
     before do
-      allow(Process).to receive(:clock_gettime).and_return(0)
+      allow(Process).to have_received(:clock_gettime).and_return(0)
       Rack::MiniProfiler.create_current
       @current_timer = Rack::MiniProfiler.current.current_timer
 
@@ -22,7 +22,7 @@ describe Rack::MiniProfilerRailsMethods do
         ['SELECT E', 73,  77], # in node E
         ['SELECT F', 93,  96]  # in node F
       ]).each do |query, start, finish|
-        allow(Process).to receive(:clock_gettime).and_return(finish)
+        allow(Process).to have_received(:clock_gettime).and_return(finish)
         @current_timer.add_sql(
           query,
           finish - start,
@@ -39,7 +39,7 @@ describe Rack::MiniProfilerRailsMethods do
         ['custom1 B', 11, 16],
         ['custom1 B', 17, 19]
       ]).each do |type, start, finish|
-        allow(Process).to receive(:clock_gettime).and_return(finish)
+        allow(Process).to have_received(:clock_gettime).and_return(finish)
         timing = @current_timer.add_custom(
           type,
           finish - start,
@@ -68,7 +68,7 @@ describe Rack::MiniProfilerRailsMethods do
         ['A',  0,     80],
         ['F',  90,    100]
       ]).each do |name, start, finish|
-        allow(Process).to receive(:clock_gettime).and_return(finish)
+        allow(Process).to have_received(:clock_gettime).and_return(finish)
         described_class.render_notification_handler(name, finish, start, name_as_description: true)
       end
       @nodes = {
diff --git a/spec/lib/sql_patches_spec.rb b/spec/lib/sql_patches_spec.rb
index c3f3e15..4a8ffde 100644
--- a/spec/lib/sql_patches_spec.rb
+++ b/spec/lib/sql_patches_spec.rb
@@ -33,7 +33,7 @@ describe SqlPatches do
     it "uses detection of env variable is not defined" do
       with_patch_env(nil) do
         expect(SqlPatches.all_patch_files).to eq([])
-        expect(Rack::MiniProfiler).to receive(:patch_rails?) { true }
+        expect(Rack::MiniProfiler).to have_received(:patch_rails?).and_return(true)
         expect(SqlPatches.all_patch_files).to eq(["activerecord"])
       end
     end
diff --git a/spec/lib/storage/memcache_store_spec.rb b/spec/lib/storage/memcache_store_spec.rb
index fa7ee63..7f1ff96 100644
--- a/spec/lib/storage/memcache_store_spec.rb
+++ b/spec/lib/storage/memcache_store_spec.rb
@@ -77,11 +77,11 @@ describe Rack::MiniProfiler::MemcacheStore do
   context 'passing in a Memcache client' do
     describe 'client' do
       it 'uses the passed in object rather than creating a new one' do
-        client = double("memcache-client")
+        client = instance_double("memcache-client")
         store = Rack::MiniProfiler::MemcacheStore.new(client: client)
 
-        expect(client).to receive(:get)
-        expect(Dalli::Client).not_to receive(:new)
+        expect(client).to have_received(:get)
+        expect(Dalli::Client).not_to have_received(:new)
         store.load("XYZ")
       end
     end
diff --git a/spec/lib/storage/redis_store_spec.rb b/spec/lib/storage/redis_store_spec.rb
index 5ad1bfa..32bfa3f 100644
--- a/spec/lib/storage/redis_store_spec.rb
+++ b/spec/lib/storage/redis_store_spec.rb
@@ -30,11 +30,11 @@ describe Rack::MiniProfiler::RedisStore do
   context 'passing in a Redis connection' do
     describe 'connection' do
       it 'uses the passed in object rather than creating a new one' do
-        connection = double("redis-connection")
+        connection = instance_double("redis-connection")
         store = Rack::MiniProfiler::RedisStore.new(connection: connection)
 
-        expect(connection).to receive(:get)
-        expect(Redis).not_to receive(:new)
+        expect(connection).to have_received(:get)
+        expect(Redis).not_to have_received(:new)
         store.load("XYZ")
       end
     end
diff --git a/spec/lib/timer_struct/timer_struct_spec.rb b/spec/lib/timer_struct/timer_struct_spec.rb
index bb1da49..cfdc5d8 100644
--- a/spec/lib/timer_struct/timer_struct_spec.rb
+++ b/spec/lib/timer_struct/timer_struct_spec.rb
@@ -27,7 +27,7 @@ describe Rack::MiniProfiler::TimerStruct::Base do
     end
 

[... diff too long, it was truncated ...]

GitHub sha: 0878b02b

This commit appears in #448 which was merged by SamSaffron.

@tgxworld the specs are failing for me locally after this change with errors like this:

9) Rack::MiniProfiler::TimerStruct::Base to_json should not add a second (nil) argument if no arguments were passed
   Failure/Error: expect(::JSON).to have_received(:generate).once.with(@timer.attributes, max_nesting: 100).and_return(nil)

   NoMethodError:
     undefined method `and_return' for #<RSpec::Mocks::Matchers::HaveReceived:0x000056174b87e0e8>
   # ./spec/lib/timer_struct/timer_struct_spec.rb:30:in `block (3 levels) in <top (required)>'

I’m sure I’m missing something obvious but I can’t figure out what it is. Any ideas?