From a5cbdca4622b6358e1fa26cdc56858b1c483c3f2 Mon Sep 17 00:00:00 2001 From: Justin Harris Date: Fri, 26 Dec 2025 12:28:25 -0500 Subject: [PATCH] [Ruby] Add trailing commas + bump RuboCop --- .github/workflows/ruby_build_test.yml | 3 ++- ruby/optify/.rubocop.yml | 9 +++++++++ ruby/optify/.vscode/settings.json | 3 +++ .../benchmarks/get_canonical_feature_names.rb | 2 +- ruby/optify/benchmarks/get_options.rb | 4 ++-- .../optify/lib/optify_ruby/provider_module.rb | 20 +++++++++---------- ruby/optify/optify.gemspec | 4 ++-- ruby/optify/test/additional_features_test.rb | 14 ++++++------- ruby/optify/test/metadata_test.rb | 8 ++++---- ruby/optify/test/optify_test.rb | 2 +- ruby/optify/test/schema_validation_test.rb | 4 ++-- 11 files changed, 43 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ruby_build_test.yml b/.github/workflows/ruby_build_test.yml index 6f74ec1c..68ca28ed 100644 --- a/.github/workflows/ruby_build_test.yml +++ b/.github/workflows/ruby_build_test.yml @@ -54,8 +54,9 @@ jobs: with: # Can see versions using `curl https://cache.ruby-lang.org/pub/misc/ci_versions/cruby.json` # We don't need the latest bleeding edge. + # Ruby 4.0 is not yet released, so exclude it. stable-ruby-versions: | - exclude: [head] + exclude: [head, "4.0"] build_from_hash: name: "[from_hash] Build & Test" diff --git a/ruby/optify/.rubocop.yml b/ruby/optify/.rubocop.yml index 1b543f2b..0d3d4208 100644 --- a/ruby/optify/.rubocop.yml +++ b/ruby/optify/.rubocop.yml @@ -67,3 +67,12 @@ Sorbet/ForbidTTypeAlias: Sorbet/ForbidTUnsafe: Enabled: true + +Style/TrailingCommaInArguments: + EnforcedStyleForMultiline: diff_comma + +Style/TrailingCommaInArrayLiteral: + EnforcedStyleForMultiline: diff_comma + +Style/TrailingCommaInHashLiteral: + EnforcedStyleForMultiline: diff_comma diff --git a/ruby/optify/.vscode/settings.json b/ruby/optify/.vscode/settings.json index cfea02db..6e133692 100644 --- a/ruby/optify/.vscode/settings.json +++ b/ruby/optify/.vscode/settings.json @@ -60,5 +60,8 @@ }, "[ruby]": { "editor.formatOnSave": true + }, + "[yaml]": { + "editor.formatOnSave": true } } diff --git a/ruby/optify/benchmarks/get_canonical_feature_names.rb b/ruby/optify/benchmarks/get_canonical_feature_names.rb index b6883090..0c601db1 100644 --- a/ruby/optify/benchmarks/get_canonical_feature_names.rb +++ b/ruby/optify/benchmarks/get_canonical_feature_names.rb @@ -21,7 +21,7 @@ ['a', feature_a, 'b', feature_b], ['a', feature_a, 'b', feature_b, 'A_with_comments', 'a', 'B'], ['a', feature_a, 'b', feature_b, 'A_with_comments', 'a', 'B', 'a', feature_a, 'b', feature_b, 'A_with_comments', 'a', 'B', 'a', feature_a, 'b', feature_b, 'A_with_comments', - 'a', 'B'] + 'a', 'B'], ] #: (Optify::OptionsProvider, Array[String]) -> Array[String] diff --git a/ruby/optify/benchmarks/get_options.rb b/ruby/optify/benchmarks/get_options.rb index 9534c2cd..abff4aaf 100644 --- a/ruby/optify/benchmarks/get_options.rb +++ b/ruby/optify/benchmarks/get_options.rb @@ -20,7 +20,7 @@ [feature_a], ['a', feature_a, 'b', feature_b], ['a', feature_a, 'b', feature_b, 'A_with_comments', 'a', 'B', 'a', feature_a, 'b', feature_b, 'A_with_comments', 'a', 'B', 'a', feature_a, 'b', feature_b, 'A_with_comments', - 'a', 'B'] + 'a', 'B'], ] # Configurable values test suite @@ -39,7 +39,7 @@ %w[simple with_files_in_arguments], %w[simple complex_deep_merge], %w[simple complex_wide_structure], - %w[simple complex_deep_merge complex_nested_objects complex_wide_structure] + %w[simple complex_deep_merge complex_nested_objects complex_wide_structure], ] Benchmark.bm do |x| diff --git a/ruby/optify/lib/optify_ruby/provider_module.rb b/ruby/optify/lib/optify_ruby/provider_module.rb index 2a1089cd..ea2e3ddd 100644 --- a/ruby/optify/lib/optify_ruby/provider_module.rb +++ b/ruby/optify/lib/optify_ruby/provider_module.rb @@ -102,19 +102,19 @@ def get_options_with_cache(key, feature_names, config_class, _cache_options, pre cache_key = [key, feature_names, are_configurable_strings_enabled, config_class] @cache #: as !nil .fetch(cache_key) do - # Handle a cache miss. + # Handle a cache miss. - # We can avoid converting the features names because they're already converted from filtering above, if that was desired. - # We don't need the constraints because we filtered the features above. - # We already know there are no overrides because we checked above. - preferences = GetOptionsPreferences.new - preferences.skip_feature_name_conversion = true - preferences.enable_configurable_strings if are_configurable_strings_enabled + # We can avoid converting the features names because they're already converted from filtering above, if that was desired. + # We don't need the constraints because we filtered the features above. + # We already know there are no overrides because we checked above. + preferences = GetOptionsPreferences.new + preferences.skip_feature_name_conversion = true + preferences.enable_configurable_strings if are_configurable_strings_enabled - result = _get_options(key, feature_names, config_class, nil, preferences) + result = _get_options(key, feature_names, config_class, nil, preferences) - @cache #: as !nil - .[]= cache_key, result + @cache #: as !nil + .[]= cache_key, result end end end diff --git a/ruby/optify/optify.gemspec b/ruby/optify/optify.gemspec index d4175e73..f2374391 100644 --- a/ruby/optify/optify.gemspec +++ b/ruby/optify/optify.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |spec| 'bug_tracker_uri' => 'https://github.com/juharris/optify/issues', # Not needed because it's the same as the source_code_uri # 'homepage_uri' => 'https://github.com/juharris/optify', - 'source_code_uri' => 'https://github.com/juharris/optify' + 'source_code_uri' => 'https://github.com/juharris/optify', } # Cross-compilation @@ -44,7 +44,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake-compiler', '~> 1.3.0' spec.add_development_dependency 'rbs', '~> 4.0.0.dev.4' - spec.add_development_dependency 'rubocop', '~> 1.76.1' + spec.add_development_dependency 'rubocop', '~> 1.82.1' spec.add_development_dependency 'rubocop-sorbet', '~> 0.11.0' spec.add_development_dependency 'sorbet', sorbet_version, sorbet_version_upper_bound spec.add_development_dependency 'tapioca', '~> 0.17.7' diff --git a/ruby/optify/test/additional_features_test.rb b/ruby/optify/test/additional_features_test.rb index 27367fd9..bd494faa 100644 --- a/ruby/optify/test/additional_features_test.rb +++ b/ruby/optify/test/additional_features_test.rb @@ -49,9 +49,9 @@ def test_provider_get_options_with_overrides_complex 'rootString' => 'new string', 'myObject' => { 'one' => 1321, - 'something new for test_provider_get_options_with_overrides' => 'hello' - } - } + 'something new for test_provider_get_options_with_overrides' => 'hello', + }, + }, } opts_json = provider.get_options_json_with_preferences('myConfig', ['a'], preferences) @@ -78,12 +78,12 @@ def test_configurable_values_get_all_options_with_overrides 'message' => { '$type' => 'Optify.ConfigurableString', 'base' => { - 'liquid' => 'Hello {{ name }}!' + 'liquid' => 'Hello {{ name }}!', }, 'arguments' => { - 'name' => 'from the test' - } - } + 'name' => 'from the test', + }, + }, } features = [] diff --git a/ruby/optify/test/metadata_test.rb b/ruby/optify/test/metadata_test.rb index 8f7aa8ba..6986cde1 100644 --- a/ruby/optify/test/metadata_test.rb +++ b/ruby/optify/test/metadata_test.rb @@ -15,8 +15,8 @@ def test_features_with_metadata name: 'feature_A', aliases: ['a'], details: 'The file is for testing.', - owners: 'a-team@company.com' - } + owners: 'a-team@company.com', + }, ) assert_equal(expected_metadata, a_metadata) @@ -26,8 +26,8 @@ def test_features_with_metadata name: 'feature_B/initial', aliases: ['b'], details: { 'description' => 'This is a description of the feature.' }, - owners: 'team-b@company.com' - } + owners: 'team-b@company.com', + }, ) assert_equal(expected_metadata, b_metadata) diff --git a/ruby/optify/test/optify_test.rb b/ruby/optify/test/optify_test.rb index a272523b..3d97c445 100644 --- a/ruby/optify/test/optify_test.rb +++ b/ruby/optify/test/optify_test.rb @@ -182,7 +182,7 @@ def test_features_and_aliases 'b', 'feature_A', 'feature_B/initial'], - features_and_aliases + features_and_aliases, ) end end diff --git a/ruby/optify/test/schema_validation_test.rb b/ruby/optify/test/schema_validation_test.rb index 3b727f72..c63cbb4a 100644 --- a/ruby/optify/test/schema_validation_test.rb +++ b/ruby/optify/test/schema_validation_test.rb @@ -26,7 +26,7 @@ def test_invalid_file_fails_schema_validation invalid_file_path = File.join(temp_dir, 'invalid.json') invalid_config = { - invalidProperty: 'this property is not allowed by the schema' + invalidProperty: 'this property is not allowed by the schema', } File.write(invalid_file_path, JSON.dump(invalid_config)) @@ -45,7 +45,7 @@ def test_schema_validation_with_provider_builder invalid_file_path = File.join(temp_dir, 'invalid.json') invalid_config = { - invalidProperty: 'this property is not allowed by the schema' + invalidProperty: 'this property is not allowed by the schema', } File.write(invalid_file_path, JSON.dump(invalid_config))