Skip to content

Commit

Permalink
Update rubocop requirement from ~> 0.79 to ~> 1.64 (#20)
Browse files Browse the repository at this point in the history
* Update rubocop requirement from ~> 0.79 to ~> 1.64

Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](rubocop/rubocop@v0.79.0...v1.64.1)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>

* Add require ostruct to fix unitialized constant error

* Autocorrect rubocop fixes

* Address manual rubocop fixes

* Enable new cops and autocorrect

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: JDutil <[email protected]>
  • Loading branch information
dependabot[bot] and JDutil authored Jun 18, 2024
1 parent 972b261 commit bb89c49
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Relaxed.Ruby.Style
## Version 2.1
AllCops:
TargetRubyVersion: 2.7.5
NewCops: enable
TargetRubyVersion: 3.0.0

Gemspec/OrderedDependencies:
Enabled: false
Expand Down
3 changes: 1 addition & 2 deletions contentful_lite.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0.0'

spec.files = Dir["lib/**/*", "LICENSE", "README.md"]
spec.test_files = Dir["spec/**/*"]
spec.require_paths = ["lib"]

spec.add_dependency "http", '~> 5.0'
Expand All @@ -23,5 +22,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "webmock", '~> 3.18'
spec.add_development_dependency "simplecov", '~> 0.17'
spec.add_development_dependency "vcr", '~> 6.0'
spec.add_development_dependency "rubocop", '~> 0.79'
spec.add_development_dependency "rubocop", '~> 1.64'
end
2 changes: 1 addition & 1 deletion lib/contentful_lite/assets_array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class AssetsArray < BaseArray
# @param raw [Hash] raw response from Contentful API
# @api private
def initialize(raw)
super(raw)
super

# Create the array of asset objects
@items.collect! { |item| ContentfulLite::Asset.new(item) }
Expand Down
1 change: 1 addition & 0 deletions lib/contentful_lite/base_array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class BaseArray < Delegator
# @param raw [Hash] raw response from Contentful API
# @api private
def initialize(raw)
super
@total = raw['total']
@skip = raw['skip']
@limit = raw['limit']
Expand Down
1 change: 1 addition & 0 deletions lib/contentful_lite/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def initialize(response, body)
super(body['sys'] && body['sys']['type'] == 'Error' ? "#{body['sys']['id']}: #{body['message']}" : "Invalid Contentful Response: #{body}")
end
end

class NotFoundError < RequestError; end

attr_reader :space_id, :environment, :preview
Expand Down
4 changes: 2 additions & 2 deletions lib/contentful_lite/entries_array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class EntriesArray < BaseArray
# @param raw [Hash] raw response from Contentful API
# @api private
def initialize(raw)
super(raw)
super

# Collect arrays of missing (unresolvable) links
@errors = raw.fetch('errors', []).collect! { |error| error.fetch('details', {}) }.each_with_object({}) do |error_detail, hash|
Expand Down Expand Up @@ -52,7 +52,7 @@ def build_entry(id)

klass = ContentfulLite::Entry.get_class(hash['sys']['contentType']['sys']['id'])
@entries[id] = klass.new(hash)
@entries[id].localized_fields.values.each do |fields|
@entries[id].localized_fields.each_value do |fields|
fields.transform_values! { |field| solve_link(field) }
end
@entries[id]
Expand Down
4 changes: 2 additions & 2 deletions lib/contentful_lite/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class Entry
# @param raw [Hash] raw response from Contentful API
# @api private
def initialize(raw)
super(raw)
super
@content_type_id = raw['sys']['contentType']['sys']['id']
@localized_fields.values.each do |fields|
@localized_fields.each_value do |fields|
fields.transform_values! { |value| build_link(value) }
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class IncludedAssetValidator < ActiveModel::EachValidator

def validate_child(record, attr_name, value, idx = nil)
record_error(record, attr_name, "value#{idx} is not a published asset") && return unless value.is_a?(ContentfulLite::Asset)

record_error(record, attr_name, "value#{idx} has an invalid asset type. Expecting #{options[:type]}") if options[:type] && !value&.content_type&.include?(options[:type].to_s)
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/contentful_lite/validations/included_child_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ def validate_each(record, attr_name, value)
private

def record_error(record, attr_name, message)
record.errors.add(attr_name, :invalid, **{ message: message }.merge(options.except(self.class.options_keys)))
record.errors.add(attr_name, :invalid, message: message, **options.except(self.class.options_keys))
end

def validate_array(record, attr_name, value)
record_error(record, attr_name, "value is not an array") && return unless value.is_a?(Array)

value.each_with_index { |asset, idx| validate_child(record, attr_name, asset, "[#{idx}]") }
end

Expand Down
1 change: 1 addition & 0 deletions spec/link_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'spec_helper'
require 'ostruct'

RSpec.describe ContentfulLite::Link do
let(:entry_hash) { JSON.parse(File.read('fixtures/entries/nyancat.json')) }
Expand Down
1 change: 1 addition & 0 deletions spec/validations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def create_validable_model(validation_method, options)
include ContentfulLite::Validations::Entry
attr_reader :fake_field
attr_accessor :locale

send(validation_method, :fake_field, options)

def initialize(value)
Expand Down

0 comments on commit bb89c49

Please sign in to comment.