From e7656a9d96b4f60eb37f8b276ba45c89b96226b5 Mon Sep 17 00:00:00 2001 From: Thiago Araujo Date: Sun, 16 Nov 2025 13:28:42 -0700 Subject: [PATCH 1/2] deps: bump Rubocop version from `v1.75.4` to `v1.81.7` --- Gemfile | 2 +- Gemfile.lock | 6 +++--- lib/faker/books/lovecraft.rb | 2 +- lib/faker/default/company.rb | 2 +- lib/faker/default/hipster.rb | 2 +- lib/faker/default/html.rb | 2 +- lib/faker/default/lorem.rb | 2 +- lib/faker/default/markdown.rb | 4 ++-- lib/faker/default/types.rb | 4 ++-- test/faker/default/test_faker_company.rb | 4 ++-- test/faker/default/test_faker_internet.rb | 14 +++++++------- test/faker/default/test_faker_markdown.rb | 2 +- test/helpers/test_faker_deprecator.rb | 1 + test/test_da_dk_locale.rb | 4 ++-- 14 files changed, 26 insertions(+), 25 deletions(-) diff --git a/Gemfile b/Gemfile index bf99691bbd..24ebe3e528 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ gem 'benchmark' gem 'minitest', '5.25.5' gem 'pry', '0.15.2' gem 'rake', '13.3.1' -gem 'rubocop', '1.75.4' +gem 'rubocop', '1.81.7' gem 'rubocop-minitest', '0.38.2' gem 'rubocop-rake', '0.7.1' gem 'simplecov', '0.22.0' diff --git a/Gemfile.lock b/Gemfile.lock index 8926e68932..2dc78d0f78 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -32,7 +32,7 @@ GEM rainbow (3.1.1) rake (13.3.1) regexp_parser (2.11.3) - rubocop (1.75.4) + rubocop (1.81.7) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -40,7 +40,7 @@ GEM parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.44.0, < 2.0) + rubocop-ast (>= 1.47.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) rubocop-ast (1.48.0) @@ -78,7 +78,7 @@ DEPENDENCIES minitest (= 5.25.5) pry (= 0.15.2) rake (= 13.3.1) - rubocop (= 1.75.4) + rubocop (= 1.81.7) rubocop-minitest (= 0.38.2) rubocop-rake (= 0.7.1) simplecov (= 0.22.0) diff --git a/lib/faker/books/lovecraft.rb b/lib/faker/books/lovecraft.rb index 143b692fbc..eb6a9b63e5 100644 --- a/lib/faker/books/lovecraft.rb +++ b/lib/faker/books/lovecraft.rb @@ -240,7 +240,7 @@ def paragraph_by_chars(characters: 256) paragraph += " #{paragraph(sentence_count: 3)}" while paragraph.length < characters - "#{paragraph[0...characters - 1]}." + "#{paragraph[0...(characters - 1)]}." end end end diff --git a/lib/faker/default/company.rb b/lib/faker/default/company.rb index 1a32ec17a4..e694f9802f 100644 --- a/lib/faker/default/company.rb +++ b/lib/faker/default/company.rb @@ -591,7 +591,7 @@ def collect_regon_sum(array) def weight_sum(array, weights) sum = 0 - (0..weights.size - 1).each do |index| + (0..(weights.size - 1)).each do |index| sum += (array[index] * weights[index]) end sum diff --git a/lib/faker/default/hipster.rb b/lib/faker/default/hipster.rb index 57b7f802b6..f1616f9349 100644 --- a/lib/faker/default/hipster.rb +++ b/lib/faker/default/hipster.rb @@ -147,7 +147,7 @@ def paragraph_by_chars(characters: 256, supplemental: false) paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < characters - "#{paragraph[0...characters - 1]}." + "#{paragraph[0...(characters - 1)]}." end end end diff --git a/lib/faker/default/html.rb b/lib/faker/default/html.rb index 06896ce413..a78be30ea4 100644 --- a/lib/faker/default/html.rb +++ b/lib/faker/default/html.rb @@ -187,7 +187,7 @@ def element(tag: 'div', content: Lorem.sentence(word_count: 3), attributes: { cl def random(exclude: []) method_list = available_methods exclude.each { |ex| method_list.delete_if { |meth| meth == ex.to_sym } } - send(method_list[Faker::Config.random.rand(0..method_list.length - 1)]) + send(method_list[Faker::Config.random.rand(0..(method_list.length - 1))]) end ## diff --git a/lib/faker/default/lorem.rb b/lib/faker/default/lorem.rb index 0567e49e12..1fbd9f4139 100644 --- a/lib/faker/default/lorem.rb +++ b/lib/faker/default/lorem.rb @@ -194,7 +194,7 @@ def paragraph_by_chars(number: 256, supplemental: false) paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < number - "#{paragraph[0...number - 1]}." + "#{paragraph[0...(number - 1)]}." end ## diff --git a/lib/faker/default/markdown.rb b/lib/faker/default/markdown.rb index 63b3c75c54..1f12e0f435 100644 --- a/lib/faker/default/markdown.rb +++ b/lib/faker/default/markdown.rb @@ -28,7 +28,7 @@ def headers def emphasis paragraph = Faker::Lorem.paragraph(sentence_count: 3) words = paragraph.split - position = rand(0..words.length - 1) + position = rand(0..(words.length - 1)) formatting = fetch('markdown.emphasis') words[position] = "#{formatting}#{words[position]}#{formatting}" words.join(' ') @@ -133,7 +133,7 @@ def table def random(*args) method_list = available_methods args&.each { |ex| method_list.delete_if { |meth| meth == ex.to_sym } } - send(method_list[Faker::Config.random.rand(0..method_list.length - 1)]) + send(method_list[Faker::Config.random.rand(0..(method_list.length - 1))]) end ## diff --git a/lib/faker/default/types.rb b/lib/faker/default/types.rb index e5ac23c99f..486521e9bb 100644 --- a/lib/faker/default/types.rb +++ b/lib/faker/default/types.rb @@ -116,7 +116,7 @@ def rb_array(len: 1, type: -> { random_type }) # # @faker.version 1.8.6 def random_type - type_to_use = SIMPLE_TYPES[rand(0..SIMPLE_TYPES.length - 1)] + type_to_use = SIMPLE_TYPES[rand(0..(SIMPLE_TYPES.length - 1))] case type_to_use when :string rb_string @@ -136,7 +136,7 @@ def random_type # @faker.version 1.8.6 def random_complex_type types = SIMPLE_TYPES + COMPLEX_TYPES - type_to_use = types[rand(0..types.length - 1)] + type_to_use = types[rand(0..(types.length - 1))] case type_to_use when :string rb_string diff --git a/test/faker/default/test_faker_company.rb b/test/faker/default/test_faker_company.rb index e6457c23d3..a6e1a6846e 100644 --- a/test/faker/default/test_faker_company.rb +++ b/test/faker/default/test_faker_company.rb @@ -251,7 +251,7 @@ def test_spanish_b_algorithm end def text_indian_gst_number - assert_match(/^([0-2][0-9]|[3][0-7])[A-Z]{3}[ABCFGHLJPTK][A-Z]\d{4}[A-Z][A-Z0-9][Z][A-Z0-9]$/i, @tester.indian_gst_number) + assert_match(/^([0-2][0-9]|3[0-7])[A-Z]{3}[ABCFGHLJPTK][A-Z]\d{4}[A-Z][A-Z0-9]Z[A-Z0-9]$/i, @tester.indian_gst_number) end def test_state_code_in_indian_gst_number @@ -264,7 +264,7 @@ def test_state_code_in_indian_gst_number end def test_indian_gst_number_with_state_code - assert_match(/^(22)[A-Z]{3}[ABCFGHLJPTK][A-Z]\d{4}[A-Z][A-Z0-9][Z][A-Z0-9]$/i, @tester.indian_gst_number(state_code: '22')) + assert_match(/^(22)[A-Z]{3}[ABCFGHLJPTK][A-Z]\d{4}[A-Z][A-Z0-9]Z[A-Z0-9]$/i, @tester.indian_gst_number(state_code: '22')) end private diff --git a/test/faker/default/test_faker_internet.rb b/test/faker/default/test_faker_internet.rb index 3e8c360940..ce8d0a1bff 100644 --- a/test/faker/default/test_faker_internet.rb +++ b/test/faker/default/test_faker_internet.rb @@ -56,7 +56,7 @@ def test_email_against_name_generator deterministically_verify -> { @tester.email(name: Faker::Name.unique.name) } do |email| # reject emails with duplicated punctuation # e.g.: "mr._faker.jr.@example.com" - refute_match(/[\p{Punct}]{2,}/, email) + refute_match(/\p{Punct}{2,}/, email) end end @@ -108,7 +108,7 @@ def test_username end def test_username_with_apostrophes - assert_match(/\A[a-z]+([_\.][a-z]+)*\z/, @tester.username(specifier: "Alexis O'Connell")) + assert_match(/\A[a-z]+([_.][a-z]+)*\z/, @tester.username(specifier: "Alexis O'Connell")) end def test_user_name_alias @@ -154,7 +154,7 @@ def test_username_with_closed_range_arg def test_username_with_open_range_arg (1..32).each do |min_length| - (min_length + 1..33).each do |max_length| + ((min_length + 1)..33).each do |max_length| l = @tester.username(specifier: (min_length...max_length)).length assert_operator l, :>=, min_length @@ -165,7 +165,7 @@ def test_username_with_open_range_arg def test_username_with_range_and_separators (1..32).each do |min_length| - (min_length + 1..33).each do |max_length| + ((min_length + 1)..33).each do |max_length| u = @tester.username(specifier: (min_length...max_length), separators: %w[=]) assert u.length.between? min_length, max_length - 1 @@ -270,14 +270,14 @@ def test_password_with_special_chars_and_mixed_case password = @tester.password(min_length: 4, max_length: 6, mix_case: true, special_characters: true) assert_match(/[!@#$%\^&*]+/, password) - assert_match(/[A-z]+/, password) + assert_match(/[A-Za-z]+/, password) end end def test_deterministic_password_with_special_chars_and_mixed_case deterministically_verify -> { @tester.password(min_length: 4, max_length: 6, mix_case: true, special_characters: true) }, depth: 4 do |password| assert_match(/[!@#$%\^&*]+/, password) - assert_match(/[A-z]+/, password) + assert_match(/[A-Za-z]+/, password) end end @@ -286,7 +286,7 @@ def test_password_with_special_chars_and_mixed_case_on_3chars_password password = @tester.password(min_length: 3, max_length: 6, mix_case: true, special_characters: true) assert_match(/[!@#$%\^&*]+/, password) - assert_match(/[A-z]+/, password) + assert_match(/[A-Za-z]+/, password) end end diff --git a/test/faker/default/test_faker_markdown.rb b/test/faker/default/test_faker_markdown.rb index b30523a7c8..23fecc6c48 100644 --- a/test/faker/default/test_faker_markdown.rb +++ b/test/faker/default/test_faker_markdown.rb @@ -101,6 +101,6 @@ def test_sandwich def random_method method_list = Faker::Markdown.public_methods(false) - Faker::Base.methods - method_list[rand(0..method_list.length - 1)] + method_list[rand(0..(method_list.length - 1))] end end diff --git a/test/helpers/test_faker_deprecator.rb b/test/helpers/test_faker_deprecator.rb index 931bf96e87..6ab5f8faa5 100644 --- a/test/helpers/test_faker_deprecator.rb +++ b/test/helpers/test_faker_deprecator.rb @@ -49,5 +49,6 @@ def self.say end include Faker::Deprecator + deprecate_generator('Dogs', Cats) end diff --git a/test/test_da_dk_locale.rb b/test/test_da_dk_locale.rb index 71639116e2..848868ea60 100644 --- a/test/test_da_dk_locale.rb +++ b/test/test_da_dk_locale.rb @@ -57,7 +57,7 @@ def test_da_dk_phone_number_methods def test_da_dk_counrty_code assert_equal '+45', Faker::PhoneNumber.country_code - assert_match(/(\+45)[\s](\d\d[\s-]?){4}$/, Faker::PhoneNumber.phone_number_with_country_code) - assert_match(/(\+45)[\s](\d\d[\s-]?){4}$/, Faker::PhoneNumber.cell_phone_with_country_code) + assert_match(/(\+45)\s(\d\d[\s-]?){4}$/, Faker::PhoneNumber.phone_number_with_country_code) + assert_match(/(\+45)\s(\d\d[\s-]?){4}$/, Faker::PhoneNumber.cell_phone_with_country_code) end end From 6a49086461b4cb5bb66d7a8a65cd6095c4193f3f Mon Sep 17 00:00:00 2001 From: Thiago Araujo Date: Sun, 16 Nov 2025 13:41:33 -0700 Subject: [PATCH 2/2] fix: Rubocop format --- lib/faker/default/boolean.rb | 3 ++- test/faker/default/test_faker_code.rb | 6 +++--- test/faker/default/test_faker_lorem_flickr.rb | 12 ++++++------ test/faker/default/test_faker_vehicle.rb | 10 +++++----- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/faker/default/boolean.rb b/lib/faker/default/boolean.rb index 44947ad0e0..023a75e066 100644 --- a/lib/faker/default/boolean.rb +++ b/lib/faker/default/boolean.rb @@ -15,7 +15,8 @@ class << self # Faker::Boolean.boolean(true_ratio: 0.2) #=> false # # @faker.version 1.6.2 - def boolean(true_ratio: 0.5) + # + def boolean(true_ratio: 0.5) # rubocop:disable Naming/PredicateMethod (rand < true_ratio) end end diff --git a/test/faker/default/test_faker_code.rb b/test/faker/default/test_faker_code.rb index 4448e482ec..b701a92f95 100644 --- a/test/faker/default/test_faker_code.rb +++ b/test/faker/default/test_faker_code.rb @@ -52,16 +52,16 @@ def test_imei_regexp end def test_imei_luhn_value - assert luhn_checksum_valid(@tester.imei) + assert luhn_checksum_valid?(@tester.imei) end def test_sin assert_match(/\d{9}/, @tester.sin) assert_equal(9, @tester.sin.length) - assert luhn_checksum_valid(@tester.sin) + assert luhn_checksum_valid?(@tester.sin) end - def luhn_checksum_valid(numbers) + def luhn_checksum_valid?(numbers) sum = 0 i = 0 diff --git a/test/faker/default/test_faker_lorem_flickr.rb b/test/faker/default/test_faker_lorem_flickr.rb index e555313cce..b779f63c38 100644 --- a/test/faker/default/test_faker_lorem_flickr.rb +++ b/test/faker/default/test_faker_lorem_flickr.rb @@ -35,7 +35,7 @@ def test_image_with_search_terms_and_match_all end def test_grayscale_image - @tester.grayscale_image == 'https://loremflickr.com/g/300/300/all' + assert_equal('https://loremflickr.com/g/300/300/all', @tester.grayscale_image) end def test_grayscale_image_with_incorrect_size @@ -45,7 +45,7 @@ def test_grayscale_image_with_incorrect_size end def test_grayscale_image_without_search_terms - @tester.grayscale_image(size: '50x60') == 'https://loremflickr.com/g/50/60/all' + assert_equal('https://loremflickr.com/g/50/60/all', @tester.grayscale_image(size: '50x60')) end def test_grayscale_image_with_single_search_term @@ -61,7 +61,7 @@ def test_grayscale_image_with_search_terms_and_match_all end def test_pixelated_image - @tester.pixelated_image == 'https://loremflickr.com/p/300/300/all' + assert_equal('https://loremflickr.com/p/300/300/all', @tester.pixelated_image) end def test_pixelated_image_with_incorrect_size @@ -71,7 +71,7 @@ def test_pixelated_image_with_incorrect_size end def test_pixelated_image_without_search_terms - @tester.pixelated_image(size: '50x60') == 'https://loremflickr.com/p/50/60/all' + assert_equal('https://loremflickr.com/p/50/60/all', @tester.pixelated_image(size: '50x60')) end def test_pixelated_image_with_single_search_term @@ -87,7 +87,7 @@ def test_pixelated_image_with_search_terms_and_match_all end def test_colorized_image - @tester.colorized_image == 'https://loremflickr.com/red/300/300/all' + assert_equal('https://loremflickr.com/red/300/300/all', @tester.colorized_image) end def test_colorized_image_with_incorrect_size @@ -97,7 +97,7 @@ def test_colorized_image_with_incorrect_size end def test_colorized_image_without_search_terms - @tester.colorized_image(size: '50x60', color: 'red') == 'https://loremflickr.com/red/50/60/all' + assert_equal('https://loremflickr.com/red/50/60/all', @tester.colorized_image(size: '50x60', color: 'red')) end def test_colorized_image_with_unsupported_colorization diff --git a/test/faker/default/test_faker_vehicle.rb b/test/faker/default/test_faker_vehicle.rb index 55a095dca6..c88701625d 100644 --- a/test/faker/default/test_faker_vehicle.rb +++ b/test/faker/default/test_faker_vehicle.rb @@ -11,12 +11,12 @@ def setup end def test_vin - assert valid_vin('11111111111111111') # known valid test string - assert valid_vin('FAKERGEM5FAKERGEM') # valid checksum - refute valid_vin('ABCDEFGH123456789') # invalid checksum + assert valid_vin?('11111111111111111') # known valid test string + assert valid_vin?('FAKERGEM5FAKERGEM') # valid checksum + refute valid_vin?('ABCDEFGH123456789') # invalid checksum deterministically_verify -> { @tester.vin }, depth: 4 do |vin| - assert valid_vin(vin) + assert valid_vin?(vin) end end @@ -117,7 +117,7 @@ def doors_condition(doors) assert_kind_of Integer, doors end - def valid_vin(vin) + def valid_vin?(vin) if vin && vin =~ VIN_REGEX total = 0 vin.chars.each_with_index do |char, index|