diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 75d373a..fa8e0da 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -215,11 +215,8 @@ Style/MutableConstant: # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: - - 'lib/hawk/http/instrumentation.rb' - - 'lib/hawk/model/association.rb' - 'lib/hawk/model/pagination.rb' - 'lib/hawk/model/proxy.rb' - - 'lib/hawk/model/schema.rb' - 'lib/hawk/rake/default_task.rb' # Configuration parameters: AllowedMethods. @@ -232,10 +229,3 @@ Style/OptionalBooleanParameter: Style/RedundantSelfAssignment: Exclude: - 'lib/hawk/model/proxy.rb' - -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/ZeroLengthPredicate: - Exclude: - - 'lib/hawk/http/instrumentation.rb' - - 'lib/hawk/model/association.rb' - - 'lib/hawk/model/schema.rb' diff --git a/lib/hawk/http/instrumentation.rb b/lib/hawk/http/instrumentation.rb index e4deb97..b48e7f6 100644 --- a/lib/hawk/http/instrumentation.rb +++ b/lib/hawk/http/instrumentation.rb @@ -30,7 +30,7 @@ def instrument(type, payload) elapsed = (Time.now.to_f - start) * 1000 url = payload[:url].to_s - if payload[:params] && payload[:params].size > 0 + if payload[:params].present? url << '?' << payload[:params].inject('') { |s, (k, v)| s << [k, '=', v, '&'].join }.chomp('&') end diff --git a/lib/hawk/model/association.rb b/lib/hawk/model/association.rb index 5472cb2..d2cef85 100644 --- a/lib/hawk/model/association.rb +++ b/lib/hawk/model/association.rb @@ -13,7 +13,7 @@ def self.included(base) # def initialize(attributes = {}, params = {}) super - if attributes.size > 0 && self.class.associations? + if attributes.present? && self.class.associations? preload_associations(attributes, params, self.class) end end @@ -136,7 +136,7 @@ def associations # Check whether associations are defined # def associations? - @_associations && @_associations.size > 0 + @_associations.present? end # Check whether the given attribute is an association diff --git a/lib/hawk/model/schema.rb b/lib/hawk/model/schema.rb index 0503130..75ccf75 100644 --- a/lib/hawk/model/schema.rb +++ b/lib/hawk/model/schema.rb @@ -51,7 +51,7 @@ def cast!(attributes) end def schema(attributes = nil) - if attributes && attributes.size > 0 && self.class.schema.nil? + if attributes.present? && self.class.schema.nil? self.class.define_schema_from(attributes) end self.class.schema || {}