Skip to content

Commit

Permalink
Add disables for rules were refactoring is impractical
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed Dec 10, 2023
1 parent ff0ef87 commit baf3bc6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/rspec/active_model/mocks/mocks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def association(association_name)
end
end

# rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity

# Creates a test double representing `string_or_model_class` with common
# ActiveModel methods stubbed out. Additional methods may be easily
# stubbed (via add_stubs) if `stubs` is passed. This is most useful for
Expand Down Expand Up @@ -194,6 +196,7 @@ def self.param_delimiter; "-"; end
yield m if block_given?
end
end
# rubocop:enable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity

module ActiveModelStubExtensions
# Stubs `persisted` to return false and `id` to return nil
Expand Down Expand Up @@ -229,6 +232,8 @@ def connection
end
end

# rubocop:disable Metrics/AbcSize,Metrics/MethodLength

# Creates an instance of `Model` with `to_param` stubbed using a
# generated value that is unique to each object. If `Model` is an
# `ActiveRecord` model, it is prohibited from accessing the database.
Expand Down Expand Up @@ -285,14 +290,17 @@ def stub_model(model_class, stubs={})
yield m if block_given?
end
end
# rubocop:enable Metrics/AbcSize,Metrics/MethodLength

private

# rubocop:disable Style/ClassVars
@@model_id = 1000

def next_id
@@model_id += 1
end
# rubocop:enable Style/ClassVars
end
end

Expand Down
2 changes: 2 additions & 0 deletions spec/rspec/active_model/mocks/mock_model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ def self.===(_other)
end

describe "ActiveModel Lint tests" do
# rubocop:disable Lint/EmptyExpression,Metrics/BlockNesting
begin
require 'minitest/assertions'
include Minitest::Assertions
Expand Down Expand Up @@ -525,6 +526,7 @@ def self.===(_other)
end
end
end
# rubocop:enable Lint/EmptyExpression,Metrics/BlockNesting

require 'active_model/lint'
include ActiveModel::Lint::Tests
Expand Down

0 comments on commit baf3bc6

Please sign in to comment.