Merge pull request #758 from magni-/rubocop_alias
Fix Style/Alias offenses
This commit is contained in:
commit
9658088a48
|
@ -18,19 +18,6 @@ Metrics/ModuleLength:
|
||||||
Metrics/PerceivedComplexity:
|
Metrics/PerceivedComplexity:
|
||||||
Max: 16
|
Max: 16
|
||||||
|
|
||||||
# Offense count: 11
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
||||||
# SupportedStyles: prefer_alias, prefer_alias_method
|
|
||||||
Style/Alias:
|
|
||||||
Exclude:
|
|
||||||
- 'lib/paper_trail.rb'
|
|
||||||
- 'lib/paper_trail/config.rb'
|
|
||||||
- 'lib/paper_trail/has_paper_trail.rb'
|
|
||||||
- 'lib/paper_trail/version_concern.rb'
|
|
||||||
- 'test/dummy/app/models/song.rb'
|
|
||||||
- 'test/unit/model_test.rb'
|
|
||||||
|
|
||||||
# Offense count: 33
|
# Offense count: 33
|
||||||
Style/Documentation:
|
Style/Documentation:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
|
@ -154,8 +154,7 @@ module PaperTrail
|
||||||
yield @config if block_given?
|
yield @config if block_given?
|
||||||
@config
|
@config
|
||||||
end
|
end
|
||||||
|
alias configure config
|
||||||
alias_method :configure, :config
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -32,14 +32,13 @@ module PaperTrail
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def track_associations
|
def track_associations?
|
||||||
if @track_associations.nil?
|
if @track_associations.nil?
|
||||||
PaperTrail::VersionAssociation.table_exists?
|
PaperTrail::VersionAssociation.table_exists?
|
||||||
else
|
else
|
||||||
@track_associations
|
@track_associations
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
alias_method :track_associations?, :track_associations
|
|
||||||
|
|
||||||
# Indicates whether PaperTrail is on or off. Default: true.
|
# Indicates whether PaperTrail is on or off. Default: true.
|
||||||
def enabled
|
def enabled
|
||||||
|
|
|
@ -255,6 +255,7 @@ module PaperTrail
|
||||||
|
|
||||||
# Utility method for reifying. Anything executed inside the block will
|
# Utility method for reifying. Anything executed inside the block will
|
||||||
# appear like a new record.
|
# appear like a new record.
|
||||||
|
# rubocop: disable Style/Alias
|
||||||
def appear_as_new_record
|
def appear_as_new_record
|
||||||
instance_eval {
|
instance_eval {
|
||||||
alias :old_new_record? :new_record?
|
alias :old_new_record? :new_record?
|
||||||
|
@ -263,6 +264,7 @@ module PaperTrail
|
||||||
yield
|
yield
|
||||||
instance_eval { alias :new_record? :old_new_record? }
|
instance_eval { alias :new_record? :old_new_record? }
|
||||||
end
|
end
|
||||||
|
# rubocop: enable Style/Alias
|
||||||
|
|
||||||
# Temporarily overwrites the value of whodunnit and then executes the
|
# Temporarily overwrites the value of whodunnit and then executes the
|
||||||
# provided block.
|
# provided block.
|
||||||
|
|
|
@ -242,7 +242,7 @@ module PaperTrail
|
||||||
def terminator
|
def terminator
|
||||||
@terminator ||= whodunnit
|
@terminator ||= whodunnit
|
||||||
end
|
end
|
||||||
alias_method :version_author, :terminator
|
alias version_author terminator
|
||||||
|
|
||||||
def sibling_versions(reload = false)
|
def sibling_versions(reload = false)
|
||||||
if reload || @sibling_versions.nil?
|
if reload || @sibling_versions.nil?
|
||||||
|
|
|
@ -23,8 +23,8 @@ class Song < ActiveRecord::Base
|
||||||
|
|
||||||
# `alias_method_chain` is deprecated in rails 5, but we cannot use the
|
# `alias_method_chain` is deprecated in rails 5, but we cannot use the
|
||||||
# suggested replacement, `Module#prepend`, because we still support ruby 1.9.
|
# suggested replacement, `Module#prepend`, because we still support ruby 1.9.
|
||||||
alias_method :attributes_without_name, :attributes
|
alias attributes_without_name attributes
|
||||||
alias_method :attributes, :attributes_with_name
|
alias attributes attributes_with_name
|
||||||
|
|
||||||
def changed_attributes_with_name
|
def changed_attributes_with_name
|
||||||
if name
|
if name
|
||||||
|
@ -36,6 +36,6 @@ class Song < ActiveRecord::Base
|
||||||
|
|
||||||
# `alias_method_chain` is deprecated in rails 5, but we cannot use the
|
# `alias_method_chain` is deprecated in rails 5, but we cannot use the
|
||||||
# suggested replacement, `Module#prepend`, because we still support ruby 1.9.
|
# suggested replacement, `Module#prepend`, because we still support ruby 1.9.
|
||||||
alias_method :changed_attributes_without_name, :changed_attributes
|
alias changed_attributes_without_name changed_attributes
|
||||||
alias_method :changed_attributes, :changed_attributes_with_name
|
alias changed_attributes changed_attributes_with_name
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue