mirror of
https://github.com/paper-trail-gem/paper_trail.git
synced 2022-11-09 11:33:19 -05:00
Merge pull request #735 from airblade/linter_2016-03-13
Linter 2016 03 13
This commit is contained in:
commit
5a7d5fd562
9 changed files with 16 additions and 85 deletions
|
@ -62,67 +62,6 @@ Style/ClassAndModuleChildren:
|
|||
Style/Documentation:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
||||
# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
|
||||
Style/FirstParameterIndentation:
|
||||
Exclude:
|
||||
- 'lib/paper_trail/serializers/json.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: MaxLineLength.
|
||||
Style/IfUnlessModifier:
|
||||
Exclude:
|
||||
- 'test/dummy/config/application.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
||||
# SupportedStyles: special_inside_parentheses, consistent, align_braces
|
||||
Style/IndentHash:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: Width.
|
||||
Style/IndentationWidth:
|
||||
Exclude:
|
||||
- 'lib/paper_trail/has_paper_trail.rb'
|
||||
- 'spec/models/widget_spec.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# Cop supports --auto-correct.
|
||||
Style/Lambda:
|
||||
Exclude:
|
||||
- 'lib/paper_trail/has_paper_trail.rb'
|
||||
- 'lib/paper_trail/version_concern.rb'
|
||||
- 'test/dummy/app/models/widget.rb'
|
||||
- 'test/unit/model_test.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Style/LeadingCommentSpace:
|
||||
Exclude:
|
||||
- 'test/unit/model_test.rb'
|
||||
|
||||
# Offense count: 6
|
||||
# Cop supports --auto-correct.
|
||||
Style/LineEndConcatenation:
|
||||
Exclude:
|
||||
- 'lib/generators/paper_trail/install_generator.rb'
|
||||
- 'lib/paper_trail.rb'
|
||||
- 'lib/paper_trail/config.rb'
|
||||
- 'lib/paper_trail/has_paper_trail.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline
|
||||
Style/MethodDefParentheses:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 2
|
||||
Style/ModuleFunction:
|
||||
Exclude:
|
||||
|
@ -156,11 +95,6 @@ Style/MutableConstant:
|
|||
- 'test/dummy/app/models/widget.rb'
|
||||
- 'test/unit/associations_test.rb'
|
||||
|
||||
# Offense count: 1
|
||||
Style/NestedParenthesizedCalls:
|
||||
Exclude:
|
||||
- 'lib/paper_trail/has_paper_trail.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# Cop supports --auto-correct.
|
||||
Style/RescueModifier:
|
||||
|
|
|
@ -44,7 +44,7 @@ module PaperTrail
|
|||
@mutex.synchronize { !!@enabled }
|
||||
end
|
||||
|
||||
def enabled= enable
|
||||
def enabled=(enable)
|
||||
@mutex.synchronize { @enabled = enable }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -93,7 +93,7 @@ module PaperTrail
|
|||
# `has_many` syntax for specifying order uses a lambda in Rails 4
|
||||
if ::ActiveRecord::VERSION::MAJOR >= 4
|
||||
has_many versions_association_name,
|
||||
lambda { order(model.timestamp_sort_order) },
|
||||
-> { order(model.timestamp_sort_order) },
|
||||
class_name: version_class_name, as: :item
|
||||
else
|
||||
has_many versions_association_name,
|
||||
|
@ -216,7 +216,7 @@ module PaperTrail
|
|||
# add a deprecation warning if someone tries to use it.
|
||||
def versions_between(start_time, end_time, _reify_options = {})
|
||||
versions = send(self.class.versions_association_name).between(start_time, end_time)
|
||||
versions.collect { |version| version_at(version.send PaperTrail.timestamp_field) }
|
||||
versions.collect { |version| version_at(version.send(PaperTrail.timestamp_field)) }
|
||||
end
|
||||
|
||||
# Returns the object (not a Version) as it was most recently.
|
||||
|
@ -437,8 +437,8 @@ module PaperTrail
|
|||
return unless PaperTrail.config.track_associations?
|
||||
self.class.reflect_on_all_associations(:belongs_to).each do |assoc|
|
||||
assoc_version_args = {
|
||||
version_id: version.id,
|
||||
foreign_key_name: assoc.foreign_key
|
||||
version_id: version.id,
|
||||
foreign_key_name: assoc.foreign_key
|
||||
}
|
||||
|
||||
if assoc.options[:polymorphic]
|
||||
|
@ -459,9 +459,9 @@ module PaperTrail
|
|||
def set_transaction_id(version)
|
||||
return unless self.class.paper_trail_version_class.column_names.include?("transaction_id")
|
||||
if PaperTrail.transaction? && PaperTrail.transaction_id.nil?
|
||||
PaperTrail.transaction_id = version.id
|
||||
version.transaction_id = version.id
|
||||
version.save
|
||||
PaperTrail.transaction_id = version.id
|
||||
version.transaction_id = version.id
|
||||
version.save
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -25,8 +25,7 @@ module PaperTrail
|
|||
# 123.
|
||||
if value.is_a? Numeric
|
||||
arel_field.matches("%\"#{field}\":#{json_value},%").
|
||||
or(
|
||||
arel_field.matches("%\"#{field}\":#{json_value}}%"))
|
||||
or(arel_field.matches("%\"#{field}\":#{json_value}}%"))
|
||||
else
|
||||
arel_field.matches("%\"#{field}\":#{json_value}%")
|
||||
end
|
||||
|
|
|
@ -32,7 +32,7 @@ module PaperTrail
|
|||
|
||||
after_create :enforce_version_limit!
|
||||
|
||||
scope :within_transaction, lambda { |id| where transaction_id: id }
|
||||
scope :within_transaction, ->(id) { where transaction_id: id }
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
|
|
|
@ -15,9 +15,9 @@ describe Widget, type: :model do
|
|||
end
|
||||
|
||||
it "is possible to do assertions on versions" do
|
||||
expect(widget).to have_a_version_with name: "Leonard", an_integer: 1
|
||||
expect(widget).to have_a_version_with an_integer: 1
|
||||
expect(widget).to have_a_version_with name: "Tom"
|
||||
expect(widget).to have_a_version_with name: "Leonard", an_integer: 1
|
||||
expect(widget).to have_a_version_with an_integer: 1
|
||||
expect(widget).to have_a_version_with name: "Tom"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ class Widget < ActiveRecord::Base
|
|||
|
||||
# `has_many` syntax for specifying order uses a lambda in Rails 4
|
||||
if ::ActiveRecord::VERSION::MAJOR >= 4
|
||||
has_many :fluxors, lambda { order(:name) }
|
||||
has_many :fluxors, -> { order(:name) }
|
||||
else
|
||||
has_many :fluxors, order: :name
|
||||
end
|
||||
|
|
|
@ -54,9 +54,7 @@ module Dummy
|
|||
end
|
||||
|
||||
# `config.assets` is a `NoMethodError` in rails 5.
|
||||
if config.respond_to?(:assets)
|
||||
config.assets.enabled = false
|
||||
end
|
||||
config.assets.enabled = false if config.respond_to?(:assets)
|
||||
|
||||
# Version of your assets, change this if you want to expire all your assets
|
||||
# config.assets.version = '1.0'
|
||||
|
|
|
@ -698,7 +698,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
# In rails 5, `capture` is deprecated in favor of `capture_io`.
|
||||
#
|
||||
should "not generate warning" do
|
||||
assert_update_raises_nothing = -> {
|
||||
assert_update_raises_nothing = lambda {
|
||||
assert_nothing_raised {
|
||||
@wotsit.update_attributes! name: "changed"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue