Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update Rubocop and pull in recommended plugins #72

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
require:
- rubocop-rake
- rubocop-rspec

AllCops:
TargetRubyVersion: 2.7
NewCops: enable
Expand All @@ -20,9 +24,27 @@ Metrics/BlockLength:
- 'spec/**/*.rb'
- 'openfeature-sdk.gemspec'

Gemspec/DevelopmentDependencies:
EnforcedStyle: gemspec
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I typically don't use the development_dependency style and favor using Gemfile, but I opted to use what the project already uses.


Gemspec/RequireMFA:
Enabled: false

Style/DocumentDynamicEvalDefinition:
# TODO re-enable after figuring out what it actually wants
Enabled: false

RSpec/ContextWording:
Enabled: false
Comment on lines +37 to +38
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're using the OpenFeature specification language, disabling this rule as it will constantly be violated.


RSpec/MultipleExpectations:
Max: 2
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always find the single default expecation max as overly punitive; I think 2 is a much more reasonable default.


RSpec/NestedGroups:
Enabled: false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, since we're using the specification language and nesting, I think having a maximum here is overly restrictive.


RSpec/PendingWithoutReason:
Enabled: false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the pending output is readable enough without a reason.


RSpec/SpecFilePathFormat:
Enabled: false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion around this started in #71

26 changes: 21 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion openfeature-sdk.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment on lines +37 to +39
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I think we can remove the versioning. Since we use a Gemfile.lock in the repo, they won't update until they are explicitly bundle update'd.

That makes it a touch easier to update w/o needing to update the gemspec.

spec.add_development_dependency "simplecov", "~> 0.22.0"
spec.add_development_dependency "simplecov-cobertura", "~> 2.1.0"
end
6 changes: 4 additions & 2 deletions spec/openfeature/example_spec.rb
Original file line number Diff line number Diff line change
@@ -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__)

Expand All @@ -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,
Expand All @@ -22,3 +23,4 @@
end.not_to raise_error
end
end
# rubocop:enable RSpec/InstanceVariable, RSpec/ExampleLength
10 changes: 5 additions & 5 deletions spec/openfeature/sdk/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions spec/openfeature/sdk/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/openfeature/sdk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading