From a5547e01016987fe530382eb682f655b74326ad3 Mon Sep 17 00:00:00 2001 From: Max VelDink Date: Wed, 13 Sep 2023 20:41:29 -0400 Subject: [PATCH 1/2] Update rubocop and pull in recommended plugins Signed-off-by: Max VelDink --- .rubocop.yml | 4 ++++ Gemfile.lock | 26 +++++++++++++++++++++----- openfeature-sdk.gemspec | 4 +++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 2e6ab23..33bb55c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,7 @@ +require: + - rubocop-rake + - rubocop-rspec + AllCops: TargetRubyVersion: 2.7 NewCops: enable diff --git a/Gemfile.lock b/Gemfile.lock index 05ffa60..418621b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,10 +7,12 @@ GEM remote: https://rubygems.org/ specs: ast (2.4.2) + base64 (0.1.1) concurrent-ruby (1.2.2) diff-lcs (1.5.0) docile (1.4.0) json (2.6.3) + language_server-protocol (3.17.0.3) markly (0.10.0) parallel (1.23.0) parser (3.2.2.3) @@ -34,18 +36,30 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) rspec-support (3.12.1) - rubocop (1.37.1) + rubocop (1.56.3) + base64 (~> 0.1.1) json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.1.2.1) + parser (>= 3.2.2.3) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.23.0, < 2.0) + rubocop-ast (>= 1.28.1, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) + unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.29.0) parser (>= 3.2.1.0) + rubocop-capybara (2.18.0) + rubocop (~> 1.41) + rubocop-factory_bot (2.23.1) + rubocop (~> 1.33) + rubocop-rake (0.6.0) + rubocop (~> 1.0) + rubocop-rspec (2.24.0) + rubocop (~> 1.33) + rubocop-capybara (~> 2.17) + rubocop-factory_bot (~> 2.22) ruby-progressbar (1.13.0) simplecov (0.22.0) docile (~> 1.1) @@ -74,7 +88,9 @@ DEPENDENCIES openfeature-sdk! rake (~> 13.0) rspec (~> 3.12.0) - rubocop (~> 1.37.1) + rubocop (~> 1.56) + rubocop-rake (~> 0.6) + rubocop-rspec (~> 2.24) simplecov (~> 0.22.0) simplecov-cobertura (~> 2.1.0) diff --git a/openfeature-sdk.gemspec b/openfeature-sdk.gemspec index 430073c..4c35d5f 100644 --- a/openfeature-sdk.gemspec +++ b/openfeature-sdk.gemspec @@ -34,7 +34,9 @@ Gem::Specification.new do |spec| spec.add_development_dependency "markly" spec.add_development_dependency "rake", "~> 13.0" spec.add_development_dependency "rspec", "~> 3.12.0" - spec.add_development_dependency "rubocop", "~> 1.37.1" + spec.add_development_dependency "rubocop", "~> 1.56" + spec.add_development_dependency "rubocop-rake", "~> 0.6" + spec.add_development_dependency "rubocop-rspec", "~> 2.24" spec.add_development_dependency "simplecov", "~> 0.22.0" spec.add_development_dependency "simplecov-cobertura", "~> 2.1.0" end From c24ea2244b3606b23931171c81d93bbe9137744c Mon Sep 17 00:00:00 2001 From: Max VelDink Date: Wed, 13 Sep 2023 20:42:02 -0400 Subject: [PATCH 2/2] Correct new Rubocop errors Signed-off-by: Max VelDink --- .rubocop.yml | 18 ++++++++++++++++++ spec/openfeature/example_spec.rb | 6 ++++-- spec/openfeature/sdk/api_spec.rb | 10 +++++----- spec/openfeature/sdk/client_spec.rb | 3 +-- spec/openfeature/sdk_spec.rb | 4 ++-- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 33bb55c..aaae456 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -24,9 +24,27 @@ Metrics/BlockLength: - 'spec/**/*.rb' - 'openfeature-sdk.gemspec' +Gemspec/DevelopmentDependencies: + EnforcedStyle: gemspec + Gemspec/RequireMFA: Enabled: false Style/DocumentDynamicEvalDefinition: # TODO re-enable after figuring out what it actually wants Enabled: false + +RSpec/ContextWording: + Enabled: false + +RSpec/MultipleExpectations: + Max: 2 + +RSpec/NestedGroups: + Enabled: false + +RSpec/PendingWithoutReason: + Enabled: false + +RSpec/SpecFilePathFormat: + Enabled: false diff --git a/spec/openfeature/example_spec.rb b/spec/openfeature/example_spec.rb index ce536c4..920a9e7 100644 --- a/spec/openfeature/example_spec.rb +++ b/spec/openfeature/example_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true -RSpec.describe "README example" do +# rubocop:disable RSpec/InstanceVariable, RSpec/ExampleLength +RSpec.describe "README example" do # rubocop:disable RSpec/DescribeClass before do @readme_md = Pathname.new("../../../README.md").expand_path(__FILE__) @@ -13,7 +14,7 @@ end end - it "works" do + it "exercises code in the README" do expect do eval @example_codeblock.string_content, # rubocop:disable Security/Eval binding, @@ -22,3 +23,4 @@ end.not_to raise_error end end +# rubocop:enable RSpec/InstanceVariable, RSpec/ExampleLength diff --git a/spec/openfeature/sdk/api_spec.rb b/spec/openfeature/sdk/api_spec.rb index 095ed63..de479be 100644 --- a/spec/openfeature/sdk/api_spec.rb +++ b/spec/openfeature/sdk/api_spec.rb @@ -39,17 +39,17 @@ before do api.configure do |config| config.provider = OpenFeature::SDK::Provider::NoOpProvider.new - config.hooks << hook1 - config.hooks << hook2 + config.hooks << first_hook + config.hooks << second_hook end end - let(:hook1) { "my_hook" } - let(:hook2) { "my_other_hook" } + let(:first_hook) { "my_hook" } + let(:second_hook) { "my_other_hook" } it do expect(api).to respond_to(:hooks) - expect(api.hooks).to have_attributes(size: 2).and eq([hook1, hook2]) + expect(api.hooks).to have_attributes(size: 2).and eq([first_hook, second_hook]) end end diff --git a/spec/openfeature/sdk/client_spec.rb b/spec/openfeature/sdk/client_spec.rb index 5f2f3cb..2ec93c8 100644 --- a/spec/openfeature/sdk/client_spec.rb +++ b/spec/openfeature/sdk/client_spec.rb @@ -10,6 +10,7 @@ RSpec.describe OpenFeature::SDK::Client do subject(:client) { described_class.new(provider: provider, client_options: client_metadata) } + let(:provider) { OpenFeature::SDK::Provider::NoOpProvider.new } let(:client_metadata) { OpenFeature::SDK::Metadata.new(name: name) } let(:name) { "my-openfeature-client" } @@ -29,8 +30,6 @@ context "Requirement 1.2.2" do it "MUST define a metadata member or accessor, containing an immutable name field or accessor of type string, which corresponds to the name value supplied during client creation." do - expect(client).to respond_to(:metadata) - expect(client.metadata).to respond_to(:name) expect(client.metadata.name).to eq(name) end end diff --git a/spec/openfeature/sdk_spec.rb b/spec/openfeature/sdk_spec.rb index 873eba1..4bb6bb2 100644 --- a/spec/openfeature/sdk_spec.rb +++ b/spec/openfeature/sdk_spec.rb @@ -6,9 +6,9 @@ end it "can be configured" do - expect(OpenFeature::SDK).to respond_to(:configure) + expect(described_class).to respond_to(:configure) - OpenFeature::SDK.configure do |config| + described_class.configure do |config| # don't test here, rely on OpenFeature::SDK::API instead end end