diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 8eda4263..d4c758bb 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -10,11 +10,12 @@ jobs: test: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - ruby-version: ['2.6', '2.7'] + ruby-version: ['3.2', '3.1', '3.0', '2.7', '2.6'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: @@ -22,5 +23,15 @@ jobs: bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Run tests run: bundle exec rake + + rubocop: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + bundler-cache: true - name: Rubocop - run: bundle exec rubocop \ No newline at end of file + run: bundle exec rubocop diff --git a/.rubocop.yml b/.rubocop.yml index ca6fa782..fbc2dd09 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,7 +1,10 @@ +require: + - rubocop-performance + inherit_from: .rubocop_todo.yml AllCops: - TargetRubyVersion: 2.4 + TargetRubyVersion: 2.6 Exclude: - '*.gemspec' - 'Gemfile*' diff --git a/Gemfile b/Gemfile index 7949e731..90d2278e 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,7 @@ source 'https://rubygems.org' gemspec group :test do - gem 'rubocop', '~> 0.52.1', require: false + gem 'rubocop', '~> 1.0', require: false + gem 'rubocop-performance', require: false gem 'awesome_print', require: 'ap' end diff --git a/lib/fhir_client.rb b/lib/fhir_client.rb index 338e116b..adc9a0b0 100644 --- a/lib/fhir_client.rb +++ b/lib/fhir_client.rb @@ -9,10 +9,10 @@ FHIR.logger.level = Logger::INFO root = File.expand_path '.', File.dirname(File.absolute_path(__FILE__)) -Dir.glob(File.join(root, 'fhir_client', 'sections', '**', '*.rb')).each do |file| +Dir.glob(File.join(root, 'fhir_client', 'sections', '**', '*.rb')).sort.each do |file| require file end -Dir.glob(File.join(root, 'fhir_client', 'ext', '**', '*.rb')).each do |file| +Dir.glob(File.join(root, 'fhir_client', 'ext', '**', '*.rb')).sort.each do |file| require file end @@ -25,6 +25,6 @@ require_relative 'fhir_client/client_exception' require_relative 'fhir_client/version' -Dir.glob(File.join(root, 'fhir_client', 'model', '**', '*.rb')).each do |file| +Dir.glob(File.join(root, 'fhir_client', 'model', '**', '*.rb')).sort.each do |file| require file end diff --git a/lib/fhir_client/ext/bundle.rb b/lib/fhir_client/ext/bundle.rb index cacd7f8b..6c8dae46 100644 --- a/lib/fhir_client/ext/bundle.rb +++ b/lib/fhir_client/ext/bundle.rb @@ -1,23 +1,23 @@ module FHIR module BundleExtras def self_link - link.select { |n| n.relation == 'self' }.first + link.find { |n| n.relation == 'self' } end def first_link - link.select { |n| n.relation == 'first' }.first + link.find { |n| n.relation == 'first' } end def last_link - link.select { |n| n.relation == 'last' }.first + link.find { |n| n.relation == 'last' } end def next_link - link.select { |n| n.relation == 'next' }.first + link.find { |n| n.relation == 'next' } end def previous_link - link.select { |n| n.relation == 'previous' || n.relation == 'prev' }.first + link.find { |n| n.relation == 'previous' || n.relation == 'prev' } end def get_by_id(id)