Skip to content

Commit

Permalink
Merge pull request #735 from airblade/linter_2016-03-13
Browse files Browse the repository at this point in the history
Linter 2016 03 13
  • Loading branch information
jaredbeck committed Mar 14, 2016
2 parents 2bf0520 + f09f49a commit 5a7d5fd
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 85 deletions.
66 changes: 0 additions & 66 deletions .rubocop_todo.yml
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lib/paper_trail/config.rb
Expand Up @@ -44,7 +44,7 @@ def enabled
@mutex.synchronize { !!@enabled }
end

def enabled= enable
def enabled=(enable)
@mutex.synchronize { @enabled = enable }
end
end
Expand Down
14 changes: 7 additions & 7 deletions lib/paper_trail/has_paper_trail.rb
Expand Up @@ -93,7 +93,7 @@ def setup_model_for_paper_trail(options = {})
# `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,
Expand Down Expand Up @@ -216,7 +216,7 @@ def version_at(timestamp, reify_options = {})
# 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.
Expand Down Expand Up @@ -437,8 +437,8 @@ def save_associations(version)
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]
Expand All @@ -459,9 +459,9 @@ def save_associations(version)
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

Expand Down
3 changes: 1 addition & 2 deletions lib/paper_trail/serializers/json.rb
Expand Up @@ -25,8 +25,7 @@ def where_object_condition(arel_field, field, value)
# 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
Expand Down
2 changes: 1 addition & 1 deletion lib/paper_trail/version_concern.rb
Expand Up @@ -32,7 +32,7 @@ module VersionConcern

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
Expand Down
6 changes: 3 additions & 3 deletions spec/models/widget_spec.rb
Expand Up @@ -15,9 +15,9 @@
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

Expand Down
2 changes: 1 addition & 1 deletion test/dummy/app/models/widget.rb
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions test/dummy/config/application.rb
Expand Up @@ -54,9 +54,7 @@ class Application < Rails::Application
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'
Expand Down
2 changes: 1 addition & 1 deletion test/unit/model_test.rb
Expand Up @@ -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"
}
Expand Down

0 comments on commit 5a7d5fd

Please sign in to comment.