From 3491704f9f2212afa9696bfb4efc8da6d03f03e0 Mon Sep 17 00:00:00 2001 From: Mauro Morales Date: Tue, 4 Oct 2022 15:04:43 +0200 Subject: [PATCH] Remove warnings added on #1698 --- lib/faker.rb | 34 ------------ lib/faker/books/dune.rb | 12 +---- lib/faker/books/lovecraft.rb | 45 +++------------- lib/faker/default/address.rb | 30 ++--------- lib/faker/default/alphanumeric.rb | 10 +--- lib/faker/default/app.rb | 13 +---- lib/faker/default/avatar.rb | 15 +----- lib/faker/default/bank.rb | 12 +---- lib/faker/default/boolean.rb | 5 +- lib/faker/default/chile_rut.rb | 14 +---- lib/faker/default/code.rb | 19 ++----- lib/faker/default/commerce.rb | 20 ++----- lib/faker/default/company.rb | 12 +---- lib/faker/default/crypto_coin.rb | 18 ++----- lib/faker/default/date.rb | 43 ++------------- lib/faker/default/demographic.rb | 6 +-- lib/faker/default/driving_licence.rb | 12 +---- lib/faker/default/file.rb | 25 ++------- lib/faker/default/fillmurray.rb | 13 +---- lib/faker/default/finance.rb | 6 +-- lib/faker/default/hipster.rb | 51 +++--------------- lib/faker/default/id_number.rb | 12 +---- lib/faker/default/internet.rb | 80 ++++------------------------ lib/faker/default/invoice.rb | 19 ++----- lib/faker/default/json.rb | 22 +------- lib/faker/default/lorem.rb | 75 ++++---------------------- lib/faker/default/lorem_flickr.rb | 36 ++----------- lib/faker/default/lorem_pixel.rb | 11 +--- lib/faker/default/markdown.rb | 7 +-- lib/faker/default/measurement.rb | 48 +++-------------- lib/faker/default/name.rb | 6 +-- lib/faker/default/nhs.rb | 6 +-- lib/faker/default/number.rb | 65 ++++------------------ lib/faker/default/omniauth.rb | 44 ++------------- lib/faker/default/phone_number.rb | 6 +-- lib/faker/default/placeholdit.rb | 13 +---- lib/faker/default/relationship.rb | 6 +-- lib/faker/default/source.rb | 19 ++----- lib/faker/default/string.rb | 6 +-- lib/faker/default/stripe.rb | 24 ++------- lib/faker/default/time.rb | 36 ++----------- lib/faker/default/twitter.rb | 20 ++----- lib/faker/default/types.rb | 32 ++--------- lib/faker/default/vehicle.rb | 19 ++----- lib/faker/default/world_cup.rb | 13 +---- lib/faker/games/dota.rb | 6 +-- lib/faker/movies/star_wars.rb | 6 +-- 47 files changed, 143 insertions(+), 909 deletions(-) diff --git a/lib/faker.rb b/lib/faker.rb index cb67b6b15b..a1138d8405 100644 --- a/lib/faker.rb +++ b/lib/faker.rb @@ -262,40 +262,6 @@ def disable_enforce_available_locales private - def warn_for_deprecated_arguments - keywords = [] - yield(keywords) - - return if keywords.empty? - - method_name = caller.first.match(/`(?.*)'/)[:method_name] - - keywords.each.with_index(1) do |keyword, index| - i = case index - when 1 then '1st' - when 2 then '2nd' - when 3 then '3rd' - else "#{index}th" - end - - warn_with_uplevel(<<~MSG, uplevel: 5) - Passing `#{keyword}` with the #{i} argument of `#{method_name}` is deprecated. Use keyword argument like `#{method_name}(#{keyword}: ...)` instead. - MSG - end - - warn(<<~MSG) - - To automatically update from positional arguments to keyword arguments, - install rubocop-faker and run: - - rubocop \\ - --require rubocop-faker \\ - --only Faker/DeprecatedArguments \\ - --auto-correct - - MSG - end - # Workaround for emulating `warn '...', uplevel: 1` in Ruby 2.4 or lower. def warn_with_uplevel(message, uplevel: 1) at = parse_caller(caller[uplevel]).join(':') diff --git a/lib/faker/books/dune.rb b/lib/faker/books/dune.rb index 4365919769..9036d879bf 100644 --- a/lib/faker/books/dune.rb +++ b/lib/faker/books/dune.rb @@ -71,11 +71,7 @@ def planet # #=> "He who controls the spice, controls the universe!" # # @faker.version 1.9.3 - def quote(legacy_character = NOT_GIVEN, character: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :character if legacy_character != NOT_GIVEN - end - + def quote(character: nil) quoted_characters = translate('faker.dune.quotes').keys if character.nil? @@ -106,11 +102,7 @@ def quote(legacy_character = NOT_GIVEN, character: nil) # #=> "May thy knife chip and shatter." # # @faker.version 1.9.3 - def saying(legacy_source = NOT_GIVEN, source: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :source if legacy_source != NOT_GIVEN - end - + def saying(source: nil) sourced_sayings = translate('faker.dune.sayings').keys if source.nil? diff --git a/lib/faker/books/lovecraft.rb b/lib/faker/books/lovecraft.rb index bca5027b91..ff0b2c2095 100644 --- a/lib/faker/books/lovecraft.rb +++ b/lib/faker/books/lovecraft.rb @@ -29,11 +29,7 @@ def location # #=> "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fht... # # @faker.version 1.9.3 - def fhtagn(legacy_number = NOT_GIVEN, number: 1) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - end - + def fhtagn(number: 1) Array.new(number) { fetch('lovecraft.fhtagn') }.join('. ') end @@ -86,12 +82,7 @@ def tome # #=> "Effulgence unmentionable gambrel." # # @faker.version 1.9.3 - def sentence(legacy_word_count = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, random_words_to_add: 6, open_compounds_allowed: true) - warn_for_deprecated_arguments do |keywords| - keywords << :word_count if legacy_word_count != NOT_GIVEN - keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN - end - + def sentence(word_count: 4, random_words_to_add: 6, open_compounds_allowed: true) "#{words(number: word_count + rand(random_words_to_add.to_i).to_i, spaces_allowed: open_compounds_allowed).join(' ').capitalize}." end @@ -138,12 +129,7 @@ def word # # ] # # @faker.version 1.9.3 - def words(legacy_number = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, number: 3, spaces_allowed: false) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - keywords << :spaces_allowed if legacy_spaces_allowed != NOT_GIVEN - end - + def words(number: 3, spaces_allowed: false) resolved_num = resolve(number) word_list = translate('faker.lovecraft.words') word_list *= ((resolved_num / word_list.length) + 1) @@ -176,11 +162,7 @@ def words(legacy_number = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, number: # # ] # # @faker.version 1.9.3 - def sentences(legacy_number = NOT_GIVEN, number: 3) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - end - + def sentences(number: 3) [].tap do |sentences| 1.upto(resolve(number)) do sentences << sentence(word_count: 3) @@ -207,12 +189,7 @@ def sentences(legacy_number = NOT_GIVEN, number: 3) # #=> "Stench cyclopean fainted antiquarian nameless. Antiquarian ululate tenebrous non-euclidean effulgence." # # @faker.version 1.9.3 - def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_random_sentences_to_add = NOT_GIVEN, sentence_count: 3, random_sentences_to_add: 3) - warn_for_deprecated_arguments do |keywords| - keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN - keywords << :random_sentences_to_add if legacy_random_sentences_to_add != NOT_GIVEN - end - + def paragraph(sentence_count: 3, random_sentences_to_add: 3) sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i).join(' ') end @@ -238,11 +215,7 @@ def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_random_sentences_to_add # # ] # # @faker.version 1.9.3 - def paragraphs(legacy_number = NOT_GIVEN, number: 3) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - end - + def paragraphs(number: 3) [].tap do |paragraphs| 1.upto(resolve(number)) do paragraphs << paragraph(sentence_count: 3) @@ -263,11 +236,7 @@ def paragraphs(legacy_number = NOT_GIVEN, number: 3) # #=> "Effulgence madness noisome. Fungus stygian mortal madness amorphous dank. Decadent noisome hideous effulgence. Tentacles charne." # # @faker.version 1.9.3 - def paragraph_by_chars(legacy_characters = NOT_GIVEN, characters: 256) - warn_for_deprecated_arguments do |keywords| - keywords << :characters if legacy_characters != NOT_GIVEN - end - + def paragraph_by_chars(characters: 256) paragraph = paragraph(sentence_count: 3) paragraph += " #{paragraph(sentence_count: 3)}" while paragraph.length < characters diff --git a/lib/faker/default/address.rb b/lib/faker/default/address.rb index 81e679060d..fcbdb5b8e3 100644 --- a/lib/faker/default/address.rb +++ b/lib/faker/default/address.rb @@ -18,11 +18,7 @@ class << self # #=> "Northfort, California" # # @faker.version 0.3.0 - def city(legacy_options = NOT_GIVEN, options: {}) - warn_for_deprecated_arguments do |keywords| - keywords << :options if legacy_options != NOT_GIVEN - end - + def city(options: {}) parse(options[:with_state] ? 'address.city_with_state' : 'address.city') end @@ -49,11 +45,7 @@ def street_name # Faker::Address.street_address #=> "282 Kevin Brook" # # @faker.version 0.3.0 - def street_address(legacy_include_secondary = NOT_GIVEN, include_secondary: false) - warn_for_deprecated_arguments do |keywords| - keywords << :include_secondary if legacy_include_secondary != NOT_GIVEN - end - + def street_address(include_secondary: false) numerify(parse('address.street_address') + (include_secondary ? " #{secondary_address}" : '')) end @@ -121,11 +113,7 @@ def mail_box # Faker::Address.zip_code(state_abbreviation: 'CO') #=> "80011" # # @faker.version 0.3.0 - def zip_code(legacy_state_abbreviation = NOT_GIVEN, state_abbreviation: '') - warn_for_deprecated_arguments do |keywords| - keywords << :state_abbreviation if legacy_state_abbreviation != NOT_GIVEN - end - + def zip_code(state_abbreviation: '') if state_abbreviation.empty? letterified_string = letterify(fetch('address.postcode')) return numerify(letterified_string, leading_zero: true) @@ -242,11 +230,7 @@ def country # Faker::Address.country_by_code(code: 'NL') #=> "Netherlands" # # @faker.version 1.9.2 - def country_by_code(legacy_code = NOT_GIVEN, code: 'US') - warn_for_deprecated_arguments do |keywords| - keywords << :code if legacy_code != NOT_GIVEN - end - + def country_by_code(code: 'US') fetch("address.country_by_code.#{code}") end @@ -260,11 +244,7 @@ def country_by_code(legacy_code = NOT_GIVEN, code: 'US') # Faker::Address.country_name_to_code(name: 'united_states') #=> "US" # # @faker.version 1.9.2 - def country_name_to_code(legacy_name = NOT_GIVEN, name: 'united_states') - warn_for_deprecated_arguments do |keywords| - keywords << :name if legacy_name != NOT_GIVEN - end - + def country_name_to_code(name: 'united_states') fetch("address.country_by_name.#{name}") end diff --git a/lib/faker/default/alphanumeric.rb b/lib/faker/default/alphanumeric.rb index a0bda47b0f..83caf4ec23 100644 --- a/lib/faker/default/alphanumeric.rb +++ b/lib/faker/default/alphanumeric.rb @@ -19,10 +19,7 @@ class << self # Faker::Alphanumeric.alpha(number: 10) #=> "zlvubkrwga" # # @faker.version 1.9.2 - def alpha(legacy_number = NOT_GIVEN, number: 32) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - end + def alpha(number: 32) char_count = resolve(number) return '' if char_count.to_i < 1 @@ -46,10 +43,7 @@ def alpha(legacy_number = NOT_GIVEN, number: 32) # Faker::Alphanumeric.alphanumeric(number: 10, min_alpha: 3, min_numeric: 3) #=> "3yfq2phx8b" # # @faker.version 2.1.3 - def alphanumeric(legacy_number = NOT_GIVEN, number: 32, min_alpha: 0, min_numeric: 0) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - end + def alphanumeric(number: 32, min_alpha: 0, min_numeric: 0) char_count = resolve(number) return '' if char_count.to_i < 1 raise ArgumentError, 'min_alpha must be greater than or equal to 0' if min_alpha&.negative? diff --git a/lib/faker/default/app.rb b/lib/faker/default/app.rb index d9b78a28da..abcf1510d3 100644 --- a/lib/faker/default/app.rb +++ b/lib/faker/default/app.rb @@ -42,8 +42,6 @@ def author parse('app.author') end - # rubocop:disable Metrics/ParameterLists - ## # Produces a String representing a semantic version identifier. # @@ -62,16 +60,9 @@ def author # Faker::App.semantic_version(patch: 5..6) #=> "7.2.6" # # @faker.version 1.4.3 - def semantic_version(legacy_major = NOT_GIVEN, legacy_minor = NOT_GIVEN, legacy_patch = NOT_GIVEN, major: 0..9, minor: 0..9, patch: 1..9) - warn_for_deprecated_arguments do |keywords| - keywords << :major if legacy_major != NOT_GIVEN - keywords << :minor if legacy_minor != NOT_GIVEN - keywords << :patch if legacy_patch != NOT_GIVEN - end - + def semantic_version(major: 0..9, minor: 0..9, patch: 1..9) [major, minor, patch].map { |chunk| sample(Array(chunk)) }.join('.') end - # rubocop:enable Metrics/ParameterLists - end + end end end diff --git a/lib/faker/default/avatar.rb b/lib/faker/default/avatar.rb index feb80e0a61..9d4cdca99c 100644 --- a/lib/faker/default/avatar.rb +++ b/lib/faker/default/avatar.rb @@ -6,8 +6,6 @@ class << self # @private SUPPORTED_FORMATS = %w[png jpg bmp].freeze - # rubocop:disable Metrics/ParameterLists - ## # Produces a URL for an avatar from robohash.org # @@ -38,15 +36,7 @@ class << self # #=> "https://robohash.org/my-own-slug.bmp?size=50x50&set=set1&bgset=bg1" # # @faker.version 1.4.3 - def image(legacy_slug = NOT_GIVEN, legacy_size = NOT_GIVEN, legacy_format = NOT_GIVEN, legacy_set = NOT_GIVEN, legacy_bgset = NOT_GIVEN, slug: nil, size: '300x300', format: 'png', set: 'set1', bgset: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :slug if legacy_slug != NOT_GIVEN - keywords << :size if legacy_size != NOT_GIVEN - keywords << :format if legacy_format != NOT_GIVEN - keywords << :set if legacy_set != NOT_GIVEN - keywords << :bgset if legacy_bgset != NOT_GIVEN - end - + def image(slug: nil, size: '300x300', format: 'png', set: 'set1', bgset: nil) raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/ raise ArgumentError, "Supported formats are #{SUPPORTED_FORMATS.join(', ')}" unless SUPPORTED_FORMATS.include?(format) @@ -54,7 +44,6 @@ def image(legacy_slug = NOT_GIVEN, legacy_size = NOT_GIVEN, legacy_format = NOT_ bgset_query = "&bgset=#{bgset}" if bgset "https://robohash.org/#{slug}.#{format}?size=#{size}&set=#{set}#{bgset_query}" end - # rubocop:enable Metrics/ParameterLists - end + end end end diff --git a/lib/faker/default/bank.rb b/lib/faker/default/bank.rb index 50f7c16383..563ad888e6 100644 --- a/lib/faker/default/bank.rb +++ b/lib/faker/default/bank.rb @@ -16,11 +16,7 @@ class << self # Faker::Bank.account_number(digits: 13) #=> 673858237902 # # @faker.version 1.9.1 - def account_number(legacy_digits = NOT_GIVEN, digits: 10) - warn_for_deprecated_arguments do |keywords| - keywords << :digits if legacy_digits != NOT_GIVEN - end - + def account_number(digits: 10) output = '' output += rand.to_s[2..] while output.length < digits @@ -40,14 +36,10 @@ def account_number(legacy_digits = NOT_GIVEN, digits: 10) # Faker::Bank.iban(country_code: nil) #=> "DE45186738071857270067" # # @faker.version 1.7.0 - def iban(legacy_country_code = NOT_GIVEN, country_code: 'GB') + def iban(country_code: 'GB') # Each country has its own format for bank accounts # Many of them use letters in certain parts of the account # Using regex patterns we can create virtually any type of bank account - warn_for_deprecated_arguments do |keywords| - keywords << :country_code if legacy_country_code != NOT_GIVEN - end - country_code ||= iban_country_code begin diff --git a/lib/faker/default/boolean.rb b/lib/faker/default/boolean.rb index 0cd34684b0..44947ad0e0 100644 --- a/lib/faker/default/boolean.rb +++ b/lib/faker/default/boolean.rb @@ -15,10 +15,7 @@ class << self # Faker::Boolean.boolean(true_ratio: 0.2) #=> false # # @faker.version 1.6.2 - def boolean(legacy_true_ratio = NOT_GIVEN, true_ratio: 0.5) - warn_for_deprecated_arguments do |keywords| - keywords << :true_ratio if legacy_true_ratio != NOT_GIVEN - end + def boolean(true_ratio: 0.5) (rand < true_ratio) end end diff --git a/lib/faker/default/chile_rut.rb b/lib/faker/default/chile_rut.rb index f8e22241f3..796cf6e4c6 100644 --- a/lib/faker/default/chile_rut.rb +++ b/lib/faker/default/chile_rut.rb @@ -18,12 +18,7 @@ class << self # Faker::ChileRut.rut(min_rut: 20890156, fixed: true) #=> 20890156 # # @faker.version 1.9.2 - def rut(legacy_min_rut = NOT_GIVEN, legacy_fixed = NOT_GIVEN, min_rut: 1, fixed: false) - warn_for_deprecated_arguments do |keywords| - keywords << :min_rut if legacy_min_rut != NOT_GIVEN - keywords << :fixed if legacy_fixed != NOT_GIVEN - end - + def rut(min_rut: 1, fixed: false) @last_rut = fixed ? min_rut : rand_in_range(min_rut, 99_999_999) end @@ -83,12 +78,7 @@ def check_digit # Faker::ChileRut.full_rut(min_rut: 30686957, fixed: true) #=> "30686957-4" # # @faker.version next - def full_rut(legacy_min_rut = NOT_GIVEN, legacy_fixed = NOT_GIVEN, min_rut: 0, fixed: false, formatted: false) - warn_for_deprecated_arguments do |keywords| - keywords << :min_rut if legacy_min_rut != NOT_GIVEN - keywords << :fixed if legacy_fixed != NOT_GIVEN - end - + def full_rut(min_rut: 0, fixed: false, formatted: false) if formatted "#{rut(min_rut: min_rut, fixed: fixed).to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1.').reverse}-#{dv}" else diff --git a/lib/faker/default/code.rb b/lib/faker/default/code.rb index 6f0e0f4e50..ec2ea8c0cb 100644 --- a/lib/faker/default/code.rb +++ b/lib/faker/default/code.rb @@ -29,11 +29,7 @@ def npi # Faker::Code.isbn #=> "170366802-2" # # @faker.version 2.2.0 - def isbn(legacy_base = NOT_GIVEN, base: 10) - warn_for_deprecated_arguments do |keywords| - keywords << :base if legacy_base != NOT_GIVEN - end - + def isbn(base: 10) case base when 10 then generate_base10_isbn when 13 then generate_base13_isbn @@ -53,11 +49,7 @@ def isbn(legacy_base = NOT_GIVEN, base: 10) # Faker::Code.ean #=> "9941880131907" # # @faker.version 2.2.0 - def ean(legacy_base = NOT_GIVEN, base: 13) - warn_for_deprecated_arguments do |keywords| - keywords << :base if legacy_base != NOT_GIVEN - end - + def ean(base: 13) case base when 8 then generate_base8_ean when 13 then generate_base13_ean @@ -99,12 +91,7 @@ def rut # Faker::Code.nric #=> "S6372958B" # # @faker.version 2.2.0 - def nric(legacy_min_age = NOT_GIVEN, legacy_max_age = NOT_GIVEN, min_age: 18, max_age: 65) - warn_for_deprecated_arguments do |keywords| - keywords << :min_age if legacy_min_age != NOT_GIVEN - keywords << :max_age if legacy_max_age != NOT_GIVEN - end - + def nric(min_age: 18, max_age: 65) birthyear = Date.birthday(min_age: min_age, max_age: max_age).year prefix = birthyear < 2000 ? 'S' : 'T' values = birthyear.to_s[-2..] diff --git a/lib/faker/default/commerce.rb b/lib/faker/default/commerce.rb index 939b7f32f3..91ea13421a 100644 --- a/lib/faker/default/commerce.rb +++ b/lib/faker/default/commerce.rb @@ -27,11 +27,7 @@ def color # Faker::Commerce.promotion_code(digits: 2) #=> "AmazingPrice57" # # @faker.version 1.7.0 - def promotion_code(legacy_digits = NOT_GIVEN, digits: 6) - warn_for_deprecated_arguments do |keywords| - keywords << :digits if legacy_digits != NOT_GIVEN - end - + def promotion_code(digits: 6) [ fetch('commerce.promotion_code.adjective'), fetch('commerce.promotion_code.noun'), @@ -52,12 +48,7 @@ def promotion_code(legacy_digits = NOT_GIVEN, digits: 6) # Faker::Commerce.department(max: 2, fixed_amount: true) #=> "Books & Tools" # # @faker.version 1.2.0 - def department(legacy_max = NOT_GIVEN, legacy_fixed_amount = NOT_GIVEN, max: 3, fixed_amount: false) - warn_for_deprecated_arguments do |keywords| - keywords << :max if legacy_max != NOT_GIVEN - keywords << :fixed_amount if legacy_fixed_amount != NOT_GIVEN - end - + def department(max: 3, fixed_amount: false) num = max if fixed_amount num ||= 1 + rand(max) @@ -112,12 +103,7 @@ def material # Faker::Commerce.price(range: 0..10.0, as_string: true) #=> "2.18" # # @faker.version 1.2.0 - def price(legacy_range = NOT_GIVEN, legacy_as_string = NOT_GIVEN, range: 0..100.0, as_string: false) - warn_for_deprecated_arguments do |keywords| - keywords << :range if legacy_range != NOT_GIVEN - keywords << :as_string if legacy_as_string != NOT_GIVEN - end - + def price(range: 0..100.0, as_string: false) price = (rand(range) * 100).floor / 100.0 if as_string price_parts = price.to_s.split('.') diff --git a/lib/faker/default/company.rb b/lib/faker/default/company.rb index 374252dc05..cc4c110eeb 100644 --- a/lib/faker/default/company.rb +++ b/lib/faker/default/company.rb @@ -309,11 +309,7 @@ def polish_taxpayer_identification_number # # @faker.version 1.9.1 # Get a random Polish register of national economy number. More info https://pl.wikipedia.org/wiki/REGON - def polish_register_of_national_economy(legacy_length = NOT_GIVEN, length: 9) - warn_for_deprecated_arguments do |keywords| - keywords << :length if legacy_length != NOT_GIVEN - end - + def polish_register_of_national_economy(length: 9) raise ArgumentError, 'Length should be 9 or 14' unless [9, 14].include? length random_digits = [] @@ -385,11 +381,7 @@ def south_african_trust_registration_number # Faker::Company.brazilian_company_number #=> "37205322000500" # # @faker.version 1.9.2 - def brazilian_company_number(legacy_formatted = NOT_GIVEN, formatted: false) - warn_for_deprecated_arguments do |keywords| - keywords << :formatted if legacy_formatted != NOT_GIVEN - end - + def brazilian_company_number(formatted: false) digits = Array.new(8) { Faker::Number.digit.to_i } + [0, 0, 0, Faker::Number.non_zero_digit.to_i] factors = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 6].cycle diff --git a/lib/faker/default/crypto_coin.rb b/lib/faker/default/crypto_coin.rb index 9ee3969ade..b9d4b6ce3e 100644 --- a/lib/faker/default/crypto_coin.rb +++ b/lib/faker/default/crypto_coin.rb @@ -16,11 +16,7 @@ class << self # Faker::CryptoCoin.coin_name #=> "Bitcoin" # # @faker.version 1.9.2 - def coin_name(legacy_coin = NOT_GIVEN, coin: coin_array) - warn_for_deprecated_arguments do |keywords| - keywords << :coin if legacy_coin != NOT_GIVEN - end - + def coin_name(coin: coin_array) coin[COIN_NAME] end @@ -33,11 +29,7 @@ def coin_name(legacy_coin = NOT_GIVEN, coin: coin_array) # Faker::CryptoCoin.acronym #=> "BTC" # # @faker.version 1.9.2 - def acronym(legacy_coin = NOT_GIVEN, coin: coin_array) - warn_for_deprecated_arguments do |keywords| - keywords << :coin if legacy_coin != NOT_GIVEN - end - + def acronym(coin: coin_array) coin[ACRONYM] end @@ -50,11 +42,7 @@ def acronym(legacy_coin = NOT_GIVEN, coin: coin_array) # Faker::CryptoCoin.url_logo #=> "https://i.imgur.com/EFz61Ei.png" # # @faker.version 1.9.2 - def url_logo(legacy_coin = NOT_GIVEN, coin: coin_array) - warn_for_deprecated_arguments do |keywords| - keywords << :coin if legacy_coin != NOT_GIVEN - end - + def url_logo(coin: coin_array) coin[URL_LOGO] end diff --git a/lib/faker/default/date.rb b/lib/faker/default/date.rb index 900729f073..6d1997c1af 100644 --- a/lib/faker/default/date.rb +++ b/lib/faker/default/date.rb @@ -17,20 +17,13 @@ class << self # Faker::Date.between(from: 2.days.ago, to: Date.today) #=> # # # @faker.version 1.0.0 - def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from:, to:) - warn_for_deprecated_arguments do |keywords| - keywords << :from if legacy_from != NOT_GIVEN - keywords << :to if legacy_to != NOT_GIVEN - end - + def between(from:, to:) from = get_date_object(from) to = get_date_object(to) Faker::Base.rand_in_range(from, to) end - # rubocop:disable Metrics/ParameterLists - ## # Produce a random date between two dates. # @@ -46,17 +39,7 @@ def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from:, to:) # Faker::Date.between_except(from: 1.year.ago, to: 1.year.from_now, excepted: Date.today) #=> # # # @faker.version 1.6.2 - def between_except(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_excepted = NOT_GIVEN, from:, to:, excepted:) - warn_for_deprecated_arguments do |keywords| - keywords << :from if legacy_from != NOT_GIVEN - end - warn_for_deprecated_arguments do |keywords| - keywords << :to if legacy_to != NOT_GIVEN - end - warn_for_deprecated_arguments do |keywords| - keywords << :excepted if legacy_excepted != NOT_GIVEN - end - + def between_except(from:, to:, excepted:) raise ArgumentError, 'From date, to date and excepted date must not be the same' if from == to && to == excepted excepted = get_date_object(excepted) @@ -66,7 +49,6 @@ def between_except(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_except break date.to_date if date != excepted end end - # rubocop:enable Metrics/ParameterLists ## # Produce a random date in the future (up to N days). @@ -78,11 +60,7 @@ def between_except(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_except # Faker::Date.forward(days: 23) #=> # # # @faker.version 1.0.0 - def forward(legacy_days = NOT_GIVEN, days: 365) - warn_for_deprecated_arguments do |keywords| - keywords << :days if legacy_days != NOT_GIVEN - end - + def forward(days: 365) from = ::Date.today + 1 to = ::Date.today + days @@ -99,11 +77,7 @@ def forward(legacy_days = NOT_GIVEN, days: 365) # Faker::Date.backward(days: 14) #=> # # # @faker.version 1.0.0 - def backward(legacy_days = NOT_GIVEN, days: 365) - warn_for_deprecated_arguments do |keywords| - keywords << :days if legacy_days != NOT_GIVEN - end - + def backward(days: 365) from = ::Date.today - days to = ::Date.today - 1 @@ -121,14 +95,7 @@ def backward(legacy_days = NOT_GIVEN, days: 365) # Faker::Date.birthday(min_age: 18, max_age: 65) #=> # # # @faker.version 1.4.3 - def birthday(legacy_min_age = NOT_GIVEN, legacy_max_age = NOT_GIVEN, min_age: 18, max_age: 65) - warn_for_deprecated_arguments do |keywords| - keywords << :min_age if legacy_min_age != NOT_GIVEN - end - warn_for_deprecated_arguments do |keywords| - keywords << :max_age if legacy_max_age != NOT_GIVEN - end - + def birthday(min_age: 18, max_age: 65) t = ::Date.today from = birthday_date(t, max_age) diff --git a/lib/faker/default/demographic.rb b/lib/faker/default/demographic.rb index adf734a0ef..f5aec03007 100644 --- a/lib/faker/default/demographic.rb +++ b/lib/faker/default/demographic.rb @@ -80,11 +80,7 @@ def sex # Faker::Demographic.height(unit: :imperial) #=> "6 ft, 2 in" # # @faker.version 1.7.3 - def height(legacy_unit = NOT_GIVEN, unit: :metric) - warn_for_deprecated_arguments do |keywords| - keywords << :unit if legacy_unit != NOT_GIVEN - end - + def height(unit: :metric) case unit when :imperial inches = rand_in_range(57, 86) diff --git a/lib/faker/default/driving_licence.rb b/lib/faker/default/driving_licence.rb index 6210cb1422..0a004b4d4a 100644 --- a/lib/faker/default/driving_licence.rb +++ b/lib/faker/default/driving_licence.rb @@ -6,8 +6,6 @@ class DrivingLicence < Base NI_CHANCE = 0.03 # NI Pop is about 3% of total UK population class << self - # rubocop:disable Metrics/ParameterLists - ## # Produces a random British driving licence number. # @@ -25,14 +23,7 @@ class << self # date_of_birth: Date.parse("1986-10-24")) #=> "OCARR815246J91HT" # # @faker.version 1.9.2 - def british_driving_licence(legacy_last_name = NOT_GIVEN, legacy_initials = NOT_GIVEN, legacy_gender = NOT_GIVEN, legacy_date_of_birth = NOT_GIVEN, last_name: Faker::Name.last_name, initials: Faker::Name.initials, gender: random_gender, date_of_birth: Faker::Date.birthday(min_age: 18, max_age: 65)) - warn_for_deprecated_arguments do |keywords| - keywords << :last_name if legacy_last_name != NOT_GIVEN - keywords << :initials if legacy_initials != NOT_GIVEN - keywords << :gender if legacy_gender != NOT_GIVEN - keywords << :date_of_birth if legacy_date_of_birth != NOT_GIVEN - end - + def british_driving_licence(last_name: Faker::Name.last_name, initials: Faker::Name.initials, gender: random_gender, date_of_birth: Faker::Date.birthday(min_age: 18, max_age: 65)) [ gb_licence_padding(last_name, 5), gb_licence_year(date_of_birth, gender), @@ -40,7 +31,6 @@ def british_driving_licence(legacy_last_name = NOT_GIVEN, legacy_initials = NOT_ gb_licence_checksum ].join end - # rubocop:enable Metrics/ParameterLists ## # Produces a random Northern Irish licence number. diff --git a/lib/faker/default/file.rb b/lib/faker/default/file.rb index c5e2c977f7..af3b24a3ba 100644 --- a/lib/faker/default/file.rb +++ b/lib/faker/default/file.rb @@ -3,8 +3,6 @@ module Faker class File < Base class << self - # rubocop:disable Metrics/ParameterLists - ## # Produces a random directory name. # @@ -20,13 +18,7 @@ class << self # Faker::File.dir(segment_count: 3, root: nil, directory_separator: '\\') #=> "aut-ullam\\quia_quisquam\\ut-eos" # # @faker.version 1.6.4 - def dir(legacy_segment_count = NOT_GIVEN, legacy_root = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, segment_count: 3, root: nil, directory_separator: ::File::Separator) - warn_for_deprecated_arguments do |keywords| - keywords << :segment_count if legacy_segment_count != NOT_GIVEN - keywords << :root if legacy_root != NOT_GIVEN - keywords << :directory_separator if legacy_directory_separator != NOT_GIVEN - end - + def dir(segment_count: 3, root: nil, directory_separator: ::File::Separator) Array .new(segment_count) { Faker::Internet.slug } .unshift(root) @@ -34,7 +26,6 @@ def dir(legacy_segment_count = NOT_GIVEN, legacy_root = NOT_GIVEN, legacy_direct .join(directory_separator) .squeeze(directory_separator) end - # rubocop:enable Metrics/ParameterLists ## # Produces a random file extension. @@ -62,8 +53,6 @@ def mime_type(media_type: nil) media_type ? fetch("file.mime_type.#{media_type}") : sample(sample(translate('faker.file.mime_type').values)) end - # rubocop:disable Metrics/ParameterLists - ## # Produces a random file name. # @@ -80,21 +69,13 @@ def mime_type(media_type: nil) # Faker::File.file_name(dir: 'foo/bar', name: 'baz', ext: 'mp3', directory_separator: '\\') #=> "foo/bar\\baz.mp3" # # @faker.version 1.6.4 - def file_name(legacy_dir = NOT_GIVEN, legacy_name = NOT_GIVEN, legacy_ext = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, dir: nil, name: nil, ext: nil, directory_separator: ::File::Separator) - warn_for_deprecated_arguments do |keywords| - keywords << :dir if legacy_dir != NOT_GIVEN - keywords << :name if legacy_name != NOT_GIVEN - keywords << :ext if legacy_ext != NOT_GIVEN - keywords << :directory_separator if legacy_directory_separator != NOT_GIVEN - end - + def file_name(dir: nil, name: nil, ext: nil, directory_separator: ::File::Separator) dir ||= dir(segment_count: 1) name ||= Faker::Lorem.word.downcase ext ||= extension [dir, name].join(directory_separator) + ".#{ext}" end - # rubocop:enable Metrics/ParameterLists - end + end end end diff --git a/lib/faker/default/fillmurray.rb b/lib/faker/default/fillmurray.rb index b88dd5754c..e51fc037ca 100644 --- a/lib/faker/default/fillmurray.rb +++ b/lib/faker/default/fillmurray.rb @@ -3,8 +3,6 @@ module Faker class Fillmurray < Base class << self - # rubocop:disable Metrics/ParameterLists - ## # Produces the URL of an image from Fill Murray, a site which hosts # exclusively photographs of actor Bill Murray. @@ -26,20 +24,13 @@ class << self # #=> "https://fillmurray.com/200/400" # # @faker.version 1.7.1 - def image(legacy_grayscale = NOT_GIVEN, legacy_width = NOT_GIVEN, legacy_height = NOT_GIVEN, grayscale: false, width: 200, height: 200) - warn_for_deprecated_arguments do |keywords| - keywords << :grayscale if legacy_grayscale != NOT_GIVEN - keywords << :width if legacy_width != NOT_GIVEN - keywords << :height if legacy_height != NOT_GIVEN - end - + def image(grayscale: false, width: 200, height: 200) raise ArgumentError, 'Width should be a number' unless width.to_s =~ /^\d+$/ raise ArgumentError, 'Height should be a number' unless height.to_s =~ /^\d+$/ raise ArgumentError, 'Grayscale should be a boolean' unless [true, false].include?(grayscale) "https://www.fillmurray.com#{'/g' if grayscale == true}/#{width}/#{height}" end - # rubocop:enable Metrics/ParameterLists - end + end end end diff --git a/lib/faker/default/finance.rb b/lib/faker/default/finance.rb index 507a578ed1..9a847803f3 100644 --- a/lib/faker/default/finance.rb +++ b/lib/faker/default/finance.rb @@ -52,11 +52,7 @@ def credit_card(*types) # Faker::Finance.vat_number('ZA') #=> "ZA79494416181" # # @faker.version 1.9.2 - def vat_number(legacy_country = NOT_GIVEN, country: 'BR') - warn_for_deprecated_arguments do |keywords| - keywords << :country if legacy_country != NOT_GIVEN - end - + def vat_number(country: 'BR') numerify(fetch("finance.vat_number.#{country}")) rescue I18n::MissingTranslationData raise ArgumentError, "Could not find vat number for #{country}" diff --git a/lib/faker/default/hipster.rb b/lib/faker/default/hipster.rb index 7083097039..577826f079 100644 --- a/lib/faker/default/hipster.rb +++ b/lib/faker/default/hipster.rb @@ -17,8 +17,6 @@ def word random_word =~ /\s/ ? word : random_word end - # rubocop:disable Metrics/ParameterLists - ## # Produces a random hipster word. # @@ -34,13 +32,7 @@ def word # Faker::Hipster.words(number: 4, supplemental: true, spaces_allowed: true) #=> ["qui", "magni", "craft beer", "est"] # # @faker.version 1.6.0 - def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, number: 3, supplemental: false, spaces_allowed: false) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - keywords << :supplemental if legacy_supplemental != NOT_GIVEN - keywords << :spaces_allowed if legacy_spaces_allowed != NOT_GIVEN - end - + def words(number: 3, supplemental: false, spaces_allowed: false) resolved_num = resolve(number) word_list = ( translate('faker.hipster.words') + @@ -73,16 +65,9 @@ def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_spa # Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 0, open_compounds_allowed: false) #=> "Dreamcatcher umami fixie." # # @faker.version 1.6.0 - def sentence(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 6, open_compounds_allowed: true) - warn_for_deprecated_arguments do |keywords| - keywords << :word_count if legacy_word_count != NOT_GIVEN - keywords << :supplemental if legacy_supplemental != NOT_GIVEN - keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN - end - + def sentence(word_count: 4, supplemental: false, random_words_to_add: 6, open_compounds_allowed: true) "#{words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: open_compounds_allowed).join(' ').capitalize}." end - # rubocop:enable Metrics/ParameterLists ## # Produces random hipster sentences. @@ -97,12 +82,7 @@ def sentence(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, leg # Faker::Hipster.sentences(number: 1, supplemental: true) #=> ["Et sustainable optio aesthetic et."] # # @faker.version 1.6.0 - def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - keywords << :supplemental if legacy_supplemental != NOT_GIVEN - end - + def sentences(number: 3, supplemental: false) [].tap do |sentences| 1.upto(resolve(number)) do sentences << sentence(word_count: 3, supplemental: supplemental) @@ -110,8 +90,6 @@ def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number end end - # rubocop:disable Metrics/ParameterLists - ## # Produces a random hipster paragraph. # @@ -128,16 +106,9 @@ def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number # Faker::Hipster.paragraph(sentence_count: 2, supplemental: true, random_sentences_to_add: 4) #=> "Deep v gluten-free unde waistcoat aperiam migas voluptas dolorum. Aut drinking illo sustainable sapiente. Direct trade fanny pack kale chips ennui semiotics." # # @faker.version 1.6.0 - def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_sentences_to_add = NOT_GIVEN, sentence_count: 3, supplemental: false, random_sentences_to_add: 3) - warn_for_deprecated_arguments do |keywords| - keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN - keywords << :supplemental if legacy_supplemental != NOT_GIVEN - keywords << :random_sentences_to_add if legacy_random_sentences_to_add != NOT_GIVEN - end - + def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 3) sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ') end - # rubocop:enable Metrics/ParameterLists ## # Produces random hipster paragraphs. @@ -152,12 +123,7 @@ def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN # Faker::Hipster.paragraphs(number: 1, supplemental: true) #=> ["Quae direct trade pbr&b quo taxidermy autem loko. Umami quas ratione migas cardigan sriracha minima. Tenetur perspiciatis pickled sed eum doloribus truffaut. Excepturi dreamcatcher meditation."] # # @faker.version 1.6.0 - def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - keywords << :supplemental if legacy_supplemental != NOT_GIVEN - end - + def paragraphs(number: 3, supplemental: false) [].tap do |paragraphs| 1.upto(resolve(number)) do paragraphs << paragraph(sentence_count: 3, supplemental: supplemental) @@ -177,12 +143,7 @@ def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, numbe # Faker::Hipster.paragraph_by_chars(characters: 256, supplemental: false) #=> "Hella kogi blog narwhal sartorial selfies mustache schlitz. Bespoke normcore kitsch cred hella fixie. Park aesthetic fixie migas twee. Cliche mustache brunch tumblr fixie godard. Drinking pop-up synth hoodie dreamcatcher typewriter. Kitsch biodiesel green." # # @faker.version 1.6.0 - def paragraph_by_chars(legacy_characters = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, characters: 256, supplemental: false) - warn_for_deprecated_arguments do |keywords| - keywords << :characters if legacy_characters != NOT_GIVEN - keywords << :supplemental if legacy_supplemental != NOT_GIVEN - end - + def paragraph_by_chars(characters: 256, supplemental: false) paragraph = paragraph(sentence_count: 3, supplemental: supplemental) paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < characters diff --git a/lib/faker/default/id_number.rb b/lib/faker/default/id_number.rb index 73a4eef722..a85e05f602 100644 --- a/lib/faker/default/id_number.rb +++ b/lib/faker/default/id_number.rb @@ -146,11 +146,7 @@ def invalid_south_african_id_number # Faker::IDNumber.brazilian_citizen_number(formatted: true) #=> "535.405.422-21" # # @faker.version 1.9.2 - def brazilian_citizen_number(legacy_formatted = NOT_GIVEN, formatted: false) - warn_for_deprecated_arguments do |keywords| - keywords << :formatted if legacy_formatted != NOT_GIVEN - end - + def brazilian_citizen_number(formatted: false) digits = Faker::Number.leading_zero_number(digits: 9) until digits&.match(/(\d)((?!\1)\d)+/) first_digit = brazilian_citizen_number_checksum_digit(digits) second_digit = brazilian_citizen_number_checksum_digit(digits + first_digit) @@ -171,11 +167,7 @@ def brazilian_citizen_number(legacy_formatted = NOT_GIVEN, formatted: false) # Faker::IDNumber.brazilian_id(formatted: true) #=> "49.305.402-9" # # @faker.version 2.1.2 - def brazilian_id(legacy_formatted = NOT_GIVEN, formatted: false) - warn_for_deprecated_arguments do |keywords| - keywords << :formatted if legacy_formatted != NOT_GIVEN - end - + def brazilian_id(formatted: false) digits = Faker::Number.between(to: BRAZILIAN_ID_FROM, from: BRAZILIAN_ID_TO).to_s check_digit = brazilian_id_checksum_digit(digits) number = [digits, check_digit].join diff --git a/lib/faker/default/internet.rb b/lib/faker/default/internet.rb index e458c5186c..4cb017d5ac 100644 --- a/lib/faker/default/internet.rb +++ b/lib/faker/default/internet.rb @@ -29,12 +29,7 @@ class << self # Faker::Internet.email(name: 'smith') #=> "smith@faker.com" # Faker::Internet.email(name: 'sam smith', separators: ['-']) #=> "sam-smith@faker.com" # Faker::Internet.email(name: 'sam smith', separators: ['-'], domain: 'gmail') #=> "sam-smith@gmail.com" - def email(legacy_name = NOT_GIVEN, legacy_separators = NOT_GIVEN, name: nil, separators: nil, domain: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :name if legacy_name != NOT_GIVEN - keywords << :separators if legacy_separators != NOT_GIVEN - end - + def email(name: nil, separators: nil, domain: nil) local_part = if separators username(specifier: name, separators: separators) else @@ -55,11 +50,7 @@ def email(legacy_name = NOT_GIVEN, legacy_separators = NOT_GIVEN, name: nil, sep # @example # Faker::Internet.free_email #=> "samsmith@gmail.com" # Faker::Internet.free_email(name: 'smith') #=> "smith@yahoo.com" - def free_email(legacy_name = NOT_GIVEN, name: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :name if legacy_name != NOT_GIVEN - end - + def free_email(name: nil) construct_email( sanitize_email_local_part(username(specifier: name)), fetch('internet.free_email') @@ -76,11 +67,7 @@ def free_email(legacy_name = NOT_GIVEN, name: nil) # @example # Faker::Internet.safe_email #=> "samsmith@example.com" # Faker::Internet.safe_email(name: 'smith') #=> "smith@example.net" - def safe_email(legacy_name = NOT_GIVEN, name: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :name if legacy_name != NOT_GIVEN - end - + def safe_email(name: nil) construct_email( sanitize_email_local_part(username(specifier: name)), "example.#{sample(%w[org com net])}" @@ -100,12 +87,7 @@ def safe_email(legacy_name = NOT_GIVEN, name: nil) # Faker::Internet.username(specifier: 5..10) #=> "morris" # Faker::Internet.username(specifier: 5..10) #=> "berryberry" # Faker::Internet.username(specifier: 20, separators: ['-']) #=> "nikki_sawaynnikki_saway" - def username(legacy_specifier = NOT_GIVEN, legacy_separators = NOT_GIVEN, specifier: nil, separators: %w[. _]) - warn_for_deprecated_arguments do |keywords| - keywords << :specifier if legacy_specifier != NOT_GIVEN - keywords << :separators if legacy_separators != NOT_GIVEN - end - + def username(specifier: nil, separators: %w[. _]) with_locale(:en) do return shuffle(specifier.scan(/[[:word:]]+/)).join(sample(separators)).downcase if specifier.respond_to?(:scan) @@ -142,8 +124,6 @@ def username(legacy_specifier = NOT_GIVEN, legacy_separators = NOT_GIVEN, specif end end - # rubocop:disable Metrics/ParameterLists - ## # Produces a randomized string of characters suitable for passwords # @@ -166,14 +146,7 @@ def username(legacy_specifier = NOT_GIVEN, legacy_separators = NOT_GIVEN, specif # Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true, special_characters: true) #=> "*%NkOnJsH4" # # @faker.version 2.1.3 - def password(legacy_min_length = NOT_GIVEN, legacy_max_length = NOT_GIVEN, legacy_mix_case = NOT_GIVEN, legacy_special_characters = NOT_GIVEN, min_length: 8, max_length: 16, mix_case: true, special_characters: false) - warn_for_deprecated_arguments do |keywords| - keywords << :min_length if legacy_min_length != NOT_GIVEN - keywords << :max_length if legacy_max_length != NOT_GIVEN - keywords << :mix_case if legacy_mix_case != NOT_GIVEN - keywords << :special_characters if legacy_special_characters != NOT_GIVEN - end - + def password(min_length: 8, max_length: 16, mix_case: true, special_characters: false) raise ArgumentError, 'Password of length 1 can not have both mixed case and special characters' if min_length <= 1 && mix_case && special_characters min_alpha = mix_case && min_length > 1 ? 2 : 0 @@ -206,7 +179,6 @@ def password(legacy_min_length = NOT_GIVEN, legacy_max_length = NOT_GIVEN, legac temp end - # rubocop:enable Metrics/ParameterLists ## # Returns the domain name @@ -221,11 +193,7 @@ def password(legacy_min_length = NOT_GIVEN, legacy_max_length = NOT_GIVEN, legac # Faker::Internet.domain_name(subdomain: true) #=> "test.faker.io" # Faker::Internet.domain_name(subdomain: true, domain: 'example') #=> "faker.example.com" # Faker::Internet.domain_name(domain: 'faker') #=> "faker.org" - def domain_name(legacy_subdomain = NOT_GIVEN, subdomain: false, domain: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :subdomain if legacy_subdomain != NOT_GIVEN - end - + def domain_name(subdomain: false, domain: nil) with_locale(:en) do if domain domain @@ -254,11 +222,7 @@ def domain_name(legacy_subdomain = NOT_GIVEN, subdomain: false, domain: nil) # Faker::Internet.fix_umlauts #=> "" # Faker::Internet.fix_umlauts(string: 'faker') #=> "faker" # Faker::Internet.fix_umlauts(string: 'faküer') #=> "fakueer" - def fix_umlauts(legacy_string = NOT_GIVEN, string: '') - warn_for_deprecated_arguments do |keywords| - keywords << :string if legacy_string != NOT_GIVEN - end - + def fix_umlauts(string: '') Char.fix_umlauts(string) end @@ -294,11 +258,7 @@ def domain_suffix # Faker::Internet.mac_address(prefix: 'a') #=> "0a:91:ce:24:89:3b" # Faker::Internet.mac_address(prefix: 'aa') #=> "aa:38:a0:3e:e8:41" # Faker::Internet.mac_address(prefix: 'aa:44') #=> "aa:44:30:88:6e:95" - def mac_address(legacy_prefix = NOT_GIVEN, prefix: '') - warn_for_deprecated_arguments do |keywords| - keywords << :prefix if legacy_prefix != NOT_GIVEN - end - + def mac_address(prefix: '') prefix_digits = prefix.split(':').map { |d| d.to_i(16) } address_digits = Array.new((6 - prefix_digits.size)) { rand(256) } (prefix_digits + address_digits).map { |d| format('%02x', d) }.join(':') @@ -440,8 +400,6 @@ def ip_v6_cidr "#{ip_v6_address}/#{rand(1..127)}" end - # rubocop:disable Metrics/ParameterLists - ## # Returns URL # @@ -456,16 +414,9 @@ def ip_v6_cidr # Faker::Internet.url(host: 'faker') #=> "http://faker/shad" # Faker::Internet.url(host: 'faker', path: '/fake_test_path') #=> "http://faker/fake_test_path" # Faker::Internet.url(host: 'faker', path: '/fake_test_path', scheme: 'https') #=> "https://faker/fake_test_path" - def url(legacy_host = NOT_GIVEN, legacy_path = NOT_GIVEN, legacy_scheme = NOT_GIVEN, host: domain_name, path: "/#{username}", scheme: 'http') - warn_for_deprecated_arguments do |keywords| - keywords << :host if legacy_host != NOT_GIVEN - keywords << :path if legacy_path != NOT_GIVEN - keywords << :scheme if legacy_scheme != NOT_GIVEN - end - + def url(host: domain_name, path: "/#{username}", scheme: 'http') "#{scheme}://#{host}#{path}" end - # rubocop:enable Metrics/ParameterLists ## # Returns unique string in URL @@ -480,12 +431,7 @@ def url(legacy_host = NOT_GIVEN, legacy_path = NOT_GIVEN, legacy_scheme = NOT_GI # Faker::Internet.slug(words: 'test, faker') #=> "test-faker" # Faker::Internet.slug(words: 'test. faker') #=> "test-faker" # Faker::Internet.slug(words: 'test. faker', glue: '$') #=> "test$faker" - def slug(legacy_words = NOT_GIVEN, legacy_glue = NOT_GIVEN, words: nil, glue: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :words if legacy_words != NOT_GIVEN - keywords << :glue if legacy_glue != NOT_GIVEN - end - + def slug(words: nil, glue: nil) glue ||= sample(%w[- _]) return words.delete(',.').gsub(' ', glue).downcase unless words.nil? @@ -515,11 +461,7 @@ def device_token # Faker::Internet.user_agent(vendor: 'chrome') #=> "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36" # Faker::Internet.user_agent(vendor: 'safari') #=> "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A" # Faker::Internet.user_agent(vendor: 'faker') #=> "Mozilla/5.0 (Windows; U; Win 9x 4.90; SG; rv:1.9.2.4) Gecko/20101104 Netscape/9.1.0285" - def user_agent(legacy_vendor = NOT_GIVEN, vendor: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :vendor if legacy_vendor != NOT_GIVEN - end - + def user_agent(vendor: nil) agent_hash = translate('faker.internet.user_agent') agents = vendor.respond_to?(:to_sym) && agent_hash[vendor.to_sym] || agent_hash[sample(agent_hash.keys)] sample(agents) diff --git a/lib/faker/default/invoice.rb b/lib/faker/default/invoice.rb index 1d90b33196..b3a27f39a8 100644 --- a/lib/faker/default/invoice.rb +++ b/lib/faker/default/invoice.rb @@ -17,12 +17,7 @@ class << self # Faker::Finance.amount_between(0, 10) #=> 4.33 # # @faker.version 1.9.0 - def amount_between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 0, to: 0) - warn_for_deprecated_arguments do |keywords| - keywords << :from if legacy_from != NOT_GIVEN - keywords << :to if legacy_to != NOT_GIVEN - end - + def amount_between(from: 0, to: 0) Faker::Base.rand_in_range(from, to).round(2) end @@ -36,11 +31,7 @@ def amount_between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 0, to: # Faker::Invoice.creditor_reference #=> "RF34118592570724925498" # # @faker.version 1.9.0 - def creditor_reference(legacy_ref = NOT_GIVEN, ref: '') - warn_for_deprecated_arguments do |keywords| - keywords << :ref if legacy_ref != NOT_GIVEN - end - + def creditor_reference(ref: '') ref = reference if ref.empty? "RF#{iban_checksum('RF', ref)}#{ref}" @@ -56,11 +47,7 @@ def creditor_reference(legacy_ref = NOT_GIVEN, ref: '') # Faker::Invoice.reference #=> "45656646957845" # # @faker.version 1.9.0 - def reference(legacy_ref = NOT_GIVEN, ref: '') - warn_for_deprecated_arguments do |keywords| - keywords << :ref if legacy_ref != NOT_GIVEN - end - + def reference(ref: '') pattern = fetch('invoice.reference.pattern') ref = Base.regexify(/#{pattern}/) if ref.empty? diff --git a/lib/faker/default/json.rb b/lib/faker/default/json.rb index 04dfe4140b..797082a3af 100644 --- a/lib/faker/default/json.rb +++ b/lib/faker/default/json.rb @@ -20,12 +20,7 @@ class << self # something to eat - it's all been wrong."} # # @faker.version 1.9.2 - def shallow_json(legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' }) - warn_for_deprecated_arguments do |keywords| - keywords << :width if legacy_width != NOT_GIVEN - keywords << :options if legacy_options != NOT_GIVEN - end - + def shallow_json(width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' }) options[:key] = "Faker::#{options[:key]}" options[:value] = "Faker::#{options[:value]}" @@ -33,8 +28,6 @@ def shallow_json(legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, width: 3, JSON.generate(hash) end - # rubocop:disable Metrics/ParameterLists - ## # Produces a random nested JSON formatted string that can take JSON as an additional argument. # @@ -73,17 +66,7 @@ def shallow_json(legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, width: 3, # {"Rick":"Wiza","Bonita":"Bayer","Gardner":"Auer","Felicity":"Abbott"}}} # # @faker.version 1.9.2 - def add_depth_to_json(legacy_json = NOT_GIVEN, legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, json: shallow_json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' }) - warn_for_deprecated_arguments do |keywords| - keywords << :json if legacy_json != NOT_GIVEN - end - warn_for_deprecated_arguments do |keywords| - keywords << :width if legacy_width != NOT_GIVEN - end - warn_for_deprecated_arguments do |keywords| - keywords << :options if legacy_options != NOT_GIVEN - end - + def add_depth_to_json(json: shallow_json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' }) options[:key] = "Faker::#{options[:key]}" options[:value] = "Faker::#{options[:value]}" @@ -93,7 +76,6 @@ def add_depth_to_json(legacy_json = NOT_GIVEN, legacy_width = NOT_GIVEN, legacy_ end JSON.generate(hash) end - # rubocop:enable Metrics/ParameterLists private diff --git a/lib/faker/default/lorem.rb b/lib/faker/default/lorem.rb index 8867f4d282..903e5bcc44 100644 --- a/lib/faker/default/lorem.rb +++ b/lib/faker/default/lorem.rb @@ -30,12 +30,7 @@ def word # Faker::Lorem.words(number: 4, supplemental: true) #=> ["nisi", "sit", "allatus", "consequatur"] # # @faker.version 2.1.3 - def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - keywords << :supplemental if legacy_supplemental != NOT_GIVEN - end - + def words(number: 3, supplemental: false) resolved_num = resolve(number) word_list = ( translate('faker.lorem.words') + @@ -74,11 +69,7 @@ def character # Faker::Lorem.characters(number: 10, min_alpha: 4, min_numeric: 1) #=> "ang9cbhoa8" # # @faker.version 2.1.3 - def characters(legacy_number = NOT_GIVEN, number: 255, min_alpha: 0, min_numeric: 0) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - end - + def characters(number: 255, min_alpha: 0, min_numeric: 0) Alphanumeric.alphanumeric(number: number, min_alpha: min_alpha, min_numeric: min_numeric) end @@ -95,7 +86,6 @@ def characters(legacy_number = NOT_GIVEN, number: 255, min_alpha: 0, min_numeric def multibyte sample(translate('faker.lorem.multibyte')).pack('C*').force_encoding('utf-8') end - # rubocop:disable Metrics/ParameterLists ## # Generates sentence @@ -113,16 +103,9 @@ def multibyte # Faker::Lorem.sentence(word_count: 5, supplemental: true, random_words_to_add:2) #=> "Crinis quo cruentus velit animi vomer." # # @faker.version 2.1.3 - def sentence(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 0) - warn_for_deprecated_arguments do |keywords| - keywords << :word_count if legacy_word_count != NOT_GIVEN - keywords << :supplemental if legacy_supplemental != NOT_GIVEN - keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN - end - + def sentence(word_count: 4, supplemental: false, random_words_to_add: 0) words(number: word_count + rand(random_words_to_add.to_i), supplemental: supplemental).join(locale_space).capitalize + locale_period end - # rubocop:enable Metrics/ParameterLists ## # Generates three sentences @@ -138,17 +121,10 @@ def sentence(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, leg # Faker::Lorem.sentences(number: 2, supplemental: true) #=> ["Cito cena ad.", "Solvo animus allatus."] # # @faker.version 2.1.3 - def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - keywords << :supplemental if legacy_supplemental != NOT_GIVEN - end - + def sentences(number: 3, supplemental: false) 1.upto(resolve(number)).collect { sentence(word_count: 3, supplemental: supplemental) } end - # rubocop:disable Metrics/ParameterLists - ## # Generates three sentence paragraph # @@ -169,16 +145,9 @@ def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number # #=> "Texo tantillus tamisium. Tribuo amissio tamisium. Facere aut canis." # # @faker.version 2.1.3 - def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_sentences_to_add = NOT_GIVEN, sentence_count: 3, supplemental: false, random_sentences_to_add: 0) - warn_for_deprecated_arguments do |keywords| - keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN - keywords << :supplemental if legacy_supplemental != NOT_GIVEN - keywords << :random_sentences_to_add if legacy_random_sentences_to_add != NOT_GIVEN - end - + def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 0) sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i), supplemental: supplemental).join(locale_space) end - # rubocop:enable Metrics/ParameterLists ## # Generates three paragraphs @@ -194,14 +163,7 @@ def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN # Faker::Lorem.paragraphs(number:2, supplemental: true) # # @faker.version 2.1.3 - def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - end - warn_for_deprecated_arguments do |keywords| - keywords << :supplemental if legacy_supplemental != NOT_GIVEN - end - + def paragraphs(number: 3, supplemental: false) 1.upto(resolve(number)).collect { paragraph(sentence_count: 3, supplemental: supplemental) } end @@ -219,12 +181,7 @@ def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, numbe # Faker::Lorem.paragraph_by_chars(number: 20, supplemental: true) #=> "Certus aveho admove." # # @faker.version 2.1.3 - def paragraph_by_chars(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 256, supplemental: false) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - keywords << :supplemental if legacy_supplemental != NOT_GIVEN - end - + def paragraph_by_chars(number: 256, supplemental: false) paragraph = paragraph(sentence_count: 3, supplemental: supplemental) paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < number @@ -232,8 +189,6 @@ def paragraph_by_chars(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVE "#{paragraph[0...number - 1]}." end - # rubocop:disable Metrics/ParameterLists - ## # Returns the question with 4 words # @@ -250,16 +205,9 @@ def paragraph_by_chars(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVE # Faker::Lorem.question(word_count: 2, supplemental: true, random_words_to_add: 2) #=> "Depulso uter ut?" # # @faker.version 2.1.3 - def question(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 0) - warn_for_deprecated_arguments do |keywords| - keywords << :word_count if legacy_word_count != NOT_GIVEN - keywords << :supplemental if legacy_supplemental != NOT_GIVEN - keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN - end - + def question(word_count: 4, supplemental: false, random_words_to_add: 0) words(number: word_count + rand(random_words_to_add), supplemental: supplemental).join(' ').capitalize + locale_question_mark end - # rubocop:enable Metrics/ParameterLists ## # Generates array of three questions @@ -275,12 +223,7 @@ def question(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, leg # Faker::Lorem.questions(number: 2, supplemental: true) #=> ["Acceptus subito cetera?", "Aro sulum cubicularis?"] # # @faker.version 2.1.3 - def questions(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - keywords << :supplemental if legacy_supplemental != NOT_GIVEN - end - + def questions(number: 3, supplemental: false) 1.upto(resolve(number)).collect { question(word_count: 3, supplemental: supplemental) } end diff --git a/lib/faker/default/lorem_flickr.rb b/lib/faker/default/lorem_flickr.rb index 0c6bbe52f6..5f0f1f041b 100644 --- a/lib/faker/default/lorem_flickr.rb +++ b/lib/faker/default/lorem_flickr.rb @@ -5,8 +5,6 @@ class LoremFlickr < Base class << self SUPPORTED_COLORIZATIONS = %w[red green blue].freeze - # rubocop:disable Metrics/ParameterLists - ## # Produces a random image URL from loremflickr.com. # @@ -23,13 +21,7 @@ class << self # Faker::LoremFlickr.image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/50/60/sports,fitness/all" # # @faker.version 1.9.0 - def image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: [], match_all: false) - warn_for_deprecated_arguments do |keywords| - keywords << :size if legacy_size != NOT_GIVEN - keywords << :search_terms if legacy_search_terms != NOT_GIVEN - keywords << :match_all if legacy_match_all != NOT_GIVEN - end - + def image(size: '300x300', search_terms: [], match_all: false) build_url(size, nil, search_terms, match_all) end @@ -49,13 +41,7 @@ def image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match # Faker::LoremFlickr.grayscale_image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/g/50/60/sports,fitness/all" # # @faker.version 1.9.0 - def grayscale_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: ['all'], match_all: false) - warn_for_deprecated_arguments do |keywords| - keywords << :size if legacy_size != NOT_GIVEN - keywords << :search_terms if legacy_search_terms != NOT_GIVEN - keywords << :match_all if legacy_match_all != NOT_GIVEN - end - + def grayscale_image(size: '300x300', search_terms: ['all'], match_all: false) raise ArgumentError, 'Search terms must be specified for grayscale images' unless search_terms.any? build_url(size, 'g', search_terms, match_all) @@ -77,13 +63,7 @@ def grayscale_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, le # Faker::LoremFlickr.pixelated_image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/p/50/60/sports,fitness/all" # # @faker.version 1.9.0 - def pixelated_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: ['all'], match_all: false) - warn_for_deprecated_arguments do |keywords| - keywords << :size if legacy_size != NOT_GIVEN - keywords << :search_terms if legacy_search_terms != NOT_GIVEN - keywords << :match_all if legacy_match_all != NOT_GIVEN - end - + def pixelated_image(size: '300x300', search_terms: ['all'], match_all: false) raise ArgumentError, 'Search terms must be specified for pixelated images' unless search_terms.any? build_url(size, 'p', search_terms, match_all) @@ -106,20 +86,12 @@ def pixelated_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, le # Faker::LoremFlickr.image(size: "50x60", color: 'blue', search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/blue/50/60/sports,fitness/all" # # @faker.version 1.9.0 - def colorized_image(legacy_size = NOT_GIVEN, legacy_color = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', color: 'red', search_terms: ['all'], match_all: false) - warn_for_deprecated_arguments do |keywords| - keywords << :size if legacy_size != NOT_GIVEN - keywords << :color if legacy_color != NOT_GIVEN - keywords << :search_terms if legacy_search_terms != NOT_GIVEN - keywords << :match_all if legacy_match_all != NOT_GIVEN - end - + def colorized_image(size: '300x300', color: 'red', search_terms: ['all'], match_all: false) raise ArgumentError, 'Search terms must be specified for colorized images' unless search_terms.any? raise ArgumentError, "Supported colorizations are #{SUPPORTED_COLORIZATIONS.join(', ')}" unless SUPPORTED_COLORIZATIONS.include?(color) build_url(size, color, search_terms, match_all) end - # rubocop:enable Metrics/ParameterLists private diff --git a/lib/faker/default/lorem_pixel.rb b/lib/faker/default/lorem_pixel.rb index 7b22344894..e05266ea12 100644 --- a/lib/faker/default/lorem_pixel.rb +++ b/lib/faker/default/lorem_pixel.rb @@ -41,16 +41,7 @@ class << self # Faker::LoremPixel.image(secure: false) #=> "http://lorempixel.com/300/300" # # @faker.version 1.7.0 - def image(legacy_size = NOT_GIVEN, legacy_is_gray = NOT_GIVEN, legacy_category = NOT_GIVEN, legacy_number = NOT_GIVEN, legacy_text = NOT_GIVEN, legacy_secure = NOT_GIVEN, size: '300x300', is_gray: false, category: nil, number: nil, text: nil, secure: true) - warn_for_deprecated_arguments do |keywords| - keywords << :size if legacy_size != NOT_GIVEN - keywords << :is_gray if legacy_is_gray != NOT_GIVEN - keywords << :category if legacy_category != NOT_GIVEN - keywords << :number if legacy_number != NOT_GIVEN - keywords << :text if legacy_text != NOT_GIVEN - keywords << :secure if legacy_secure != NOT_GIVEN - end - + def image(size: '300x300', is_gray: false, category: nil, number: nil, text: nil, secure: true) raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/ raise ArgumentError, "Supported categories are #{SUPPORTED_CATEGORIES.join(', ')}" unless category.nil? || SUPPORTED_CATEGORIES.include?(category) raise ArgumentError, 'Category required when number is passed' if !number.nil? && category.nil? diff --git a/lib/faker/default/markdown.rb b/lib/faker/default/markdown.rb index 5f2a48b55b..63b3c75c54 100644 --- a/lib/faker/default/markdown.rb +++ b/lib/faker/default/markdown.rb @@ -150,12 +150,7 @@ def random(*args) # Faker::Markdown.sandwich(sentences: 6, repeat: 3) #=> returns newline separated content of 1 header, and then 3 sections consisting of, here, 1 6-sentence lorem paragraph and 1 random markdown element. The random markdown element is chosen at random in each iteration of the paragraph-markdown pairing. # # @faker.version 1.8.0 - def sandwich(legacy_sentences = NOT_GIVEN, legacy_repeat = NOT_GIVEN, sentences: 3, repeat: 1) - warn_for_deprecated_arguments do |keywords| - keywords << :sentences if legacy_sentences != NOT_GIVEN - keywords << :repeat if legacy_repeat != NOT_GIVEN - end - + def sandwich(sentences: 3, repeat: 1) text_block = [] text_block << headers repeat.times do diff --git a/lib/faker/default/measurement.rb b/lib/faker/default/measurement.rb index c2eeede946..173dd1b37f 100644 --- a/lib/faker/default/measurement.rb +++ b/lib/faker/default/measurement.rb @@ -19,11 +19,7 @@ class << self # Faker::Measurement.height(amount: "all") #=> "inches" # # @faker.version 1.7.3 - def height(legacy_amount = NOT_GIVEN, amount: rand(10)) - warn_for_deprecated_arguments do |keywords| - keywords << :amount if legacy_amount != NOT_GIVEN - end - + def height(amount: rand(10)) define_measurement_locale(amount, 'height') end @@ -38,11 +34,7 @@ def height(legacy_amount = NOT_GIVEN, amount: rand(10)) # Faker::Measurement.length(amount: 1.4) #=> "1.4 yards" # # @faker.version 1.7.3 - def length(legacy_amount = NOT_GIVEN, amount: rand(10)) - warn_for_deprecated_arguments do |keywords| - keywords << :amount if legacy_amount != NOT_GIVEN - end - + def length(amount: rand(10)) define_measurement_locale(amount, 'length') end @@ -57,11 +49,7 @@ def length(legacy_amount = NOT_GIVEN, amount: rand(10)) # Faker::Measurement.volume(amount: 1.4) #=> "1.4 cups" # # @faker.version 1.7.3 - def volume(legacy_amount = NOT_GIVEN, amount: rand(10)) - warn_for_deprecated_arguments do |keywords| - keywords << :amount if legacy_amount != NOT_GIVEN - end - + def volume(amount: rand(10)) define_measurement_locale(amount, 'volume') end @@ -76,11 +64,7 @@ def volume(legacy_amount = NOT_GIVEN, amount: rand(10)) # Faker::Measurement.weight(amount: 1.4) #=> "1.4 pounds" # # @faker.version 1.7.3 - def weight(legacy_amount = NOT_GIVEN, amount: rand(10)) - warn_for_deprecated_arguments do |keywords| - keywords << :amount if legacy_amount != NOT_GIVEN - end - + def weight(amount: rand(10)) define_measurement_locale(amount, 'weight') end @@ -95,11 +79,7 @@ def weight(legacy_amount = NOT_GIVEN, amount: rand(10)) # Faker::Measurement.metric_height(amount: 1.4) #=> "1.4 meters" # # @faker.version 1.7.3 - def metric_height(legacy_amount = NOT_GIVEN, amount: rand(10)) - warn_for_deprecated_arguments do |keywords| - keywords << :amount if legacy_amount != NOT_GIVEN - end - + def metric_height(amount: rand(10)) define_measurement_locale(amount, 'metric_height') end @@ -114,11 +94,7 @@ def metric_height(legacy_amount = NOT_GIVEN, amount: rand(10)) # Faker::Measurement.metric_length(amount: 1.4) #=> "1.4 decimeters" # # @faker.version 1.7.3 - def metric_length(legacy_amount = NOT_GIVEN, amount: rand(10)) - warn_for_deprecated_arguments do |keywords| - keywords << :amount if legacy_amount != NOT_GIVEN - end - + def metric_length(amount: rand(10)) define_measurement_locale(amount, 'metric_length') end @@ -133,11 +109,7 @@ def metric_length(legacy_amount = NOT_GIVEN, amount: rand(10)) # Faker::Measurement.metric_volume(amount: 1.4) #=> "1.4 liters" # # @faker.version 1.7.3 - def metric_volume(legacy_amount = NOT_GIVEN, amount: rand(10)) - warn_for_deprecated_arguments do |keywords| - keywords << :amount if legacy_amount != NOT_GIVEN - end - + def metric_volume(amount: rand(10)) define_measurement_locale(amount, 'metric_volume') end @@ -152,11 +124,7 @@ def metric_volume(legacy_amount = NOT_GIVEN, amount: rand(10)) # Faker::Measurement.metric_weight(amount: 1.4) #=> "1.4 grams" # # @faker.version 1.7.3 - def metric_weight(legacy_amount = NOT_GIVEN, amount: rand(10)) - warn_for_deprecated_arguments do |keywords| - keywords << :amount if legacy_amount != NOT_GIVEN - end - + def metric_weight(amount: rand(10)) define_measurement_locale(amount, 'metric_weight') end diff --git a/lib/faker/default/name.rb b/lib/faker/default/name.rb index 4a5a814574..7c3f886a49 100644 --- a/lib/faker/default/name.rb +++ b/lib/faker/default/name.rb @@ -144,11 +144,7 @@ def suffix # Faker::Name.initials(number: 2) #=> "NM" # # @faker.version 1.8.5 - def initials(legacy_number = NOT_GIVEN, number: 3) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - end - + def initials(number: 3) (0...number).map { rand(65..90).chr }.join end end diff --git a/lib/faker/default/nhs.rb b/lib/faker/default/nhs.rb index 298950184d..211e443a7c 100644 --- a/lib/faker/default/nhs.rb +++ b/lib/faker/default/nhs.rb @@ -34,11 +34,7 @@ def british_number # Faker::NationalHealthService.check_digit(number: 400_012_114) #=> 6 # # @faker.version 1.9.2 - def check_digit(legacy_number = NOT_GIVEN, number: 0) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - end - + def check_digit(number: 0) sum = 0 number.to_s.chars.each_with_index do |digit, idx| position = idx + 1 diff --git a/lib/faker/default/number.rb b/lib/faker/default/number.rb index 5ce20f7767..33564a2888 100644 --- a/lib/faker/default/number.rb +++ b/lib/faker/default/number.rb @@ -13,11 +13,7 @@ class << self # Faker::Number.number(digits: 10) #=> 1968353479 # # @faker.version 1.0.0 - def number(legacy_digits = NOT_GIVEN, digits: 10) - warn_for_deprecated_arguments do |keywords| - keywords << :digits if legacy_digits != NOT_GIVEN - end - + def number(digits: 10) return if digits < 1 return rand(0..9).round if digits == 1 @@ -35,11 +31,7 @@ def number(legacy_digits = NOT_GIVEN, digits: 10) # Faker::Number.leading_zero_number(digits: 10) #=> "0669336915" # # @faker.version 1.0.0 - def leading_zero_number(legacy_digits = NOT_GIVEN, digits: 10) - warn_for_deprecated_arguments do |keywords| - keywords << :digits if legacy_digits != NOT_GIVEN - end - + def leading_zero_number(digits: 10) "0#{(2..digits).collect { digit }.join}" end @@ -53,11 +45,7 @@ def leading_zero_number(legacy_digits = NOT_GIVEN, digits: 10) # Faker::Number.decimal_part(digits: 2) #=> "09" # # @faker.version 1.0.0 - def decimal_part(legacy_digits = NOT_GIVEN, digits: 10) - warn_for_deprecated_arguments do |keywords| - keywords << :digits if legacy_digits != NOT_GIVEN - end - + def decimal_part(digits: 10) num = '' if digits > 1 num = non_zero_digit @@ -78,12 +66,7 @@ def decimal_part(legacy_digits = NOT_GIVEN, digits: 10) # Faker::Number.decimal(l_digits: 3, r_digits: 3) #=> 181.843 # # @faker.version 1.0.0 - def decimal(legacy_l_digits = NOT_GIVEN, legacy_r_digits = NOT_GIVEN, l_digits: 5, r_digits: 2) - warn_for_deprecated_arguments do |keywords| - keywords << :l_digits if legacy_l_digits != NOT_GIVEN - keywords << :r_digits if legacy_r_digits != NOT_GIVEN - end - + def decimal(l_digits: 5, r_digits: 2) l_d = number(digits: l_digits) # Ensure the last digit is not zero @@ -129,11 +112,7 @@ def digit # Faker::Number.hexadecimal(digits: 3) #=> "e74" # # @faker.version 1.0.0 - def hexadecimal(legacy_digits = NOT_GIVEN, digits: 6) - warn_for_deprecated_arguments do |keywords| - keywords << :digits if legacy_digits != NOT_GIVEN - end - + def hexadecimal(digits: 6) hex = '' digits.times { hex += rand(15).to_s(16) } hex @@ -165,12 +144,7 @@ def binary(digits: 4) # Faker::Number.normal(mean: 50, standard_deviation: 3.5) #=> 47.14669604069156 # # @faker.version 1.0.0 - def normal(legacy_mean = NOT_GIVEN, legacy_standard_deviation = NOT_GIVEN, mean: 1, standard_deviation: 1) - warn_for_deprecated_arguments do |keywords| - keywords << :mean if legacy_mean != NOT_GIVEN - keywords << :standard_deviation if legacy_standard_deviation != NOT_GIVEN - end - + def normal(mean: 1, standard_deviation: 1) theta = 2 * Math::PI * rand rho = Math.sqrt(-2 * Math.log(1 - rand)) scale = standard_deviation * rho @@ -189,12 +163,7 @@ def normal(legacy_mean = NOT_GIVEN, legacy_standard_deviation = NOT_GIVEN, mean: # Faker::Number.between(from: 0.0, to: 1.0) #=> 0.7844640543957383 # # @faker.version 1.0.0 - def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 1.00, to: 5000.00) - warn_for_deprecated_arguments do |keywords| - keywords << :from if legacy_from != NOT_GIVEN - keywords << :to if legacy_to != NOT_GIVEN - end - + def between(from: 1.00, to: 5000.00) Faker::Base.rand_in_range(from, to) end @@ -209,11 +178,7 @@ def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 1.00, to: 5000 # Faker::Number.within(range: 0.0..1.0) #=> 0.7844640543957383 # # @faker.version 1.0.0 - def within(legacy_range = NOT_GIVEN, range: 1.00..5000.00) - warn_for_deprecated_arguments do |keywords| - keywords << :range if legacy_range != NOT_GIVEN - end - + def within(range: 1.00..5000.00) between(from: range.min, to: range.max) end @@ -228,12 +193,7 @@ def within(legacy_range = NOT_GIVEN, range: 1.00..5000.00) # Faker::Number.positive #=> 235.59238499107653 # # @faker.version 1.0.0 - def positive(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 1.00, to: 5000.00) - warn_for_deprecated_arguments do |keywords| - keywords << :from if legacy_from != NOT_GIVEN - keywords << :to if legacy_to != NOT_GIVEN - end - + def positive(from: 1.00, to: 5000.00) random_number = between(from: from, to: to) greater_than_zero(random_number) @@ -250,12 +210,7 @@ def positive(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 1.00, to: 500 # Faker::Number.negative #=> -4480.042585669558 # # @faker.version 1.0.0 - def negative(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: -5000.00, to: -1.00) - warn_for_deprecated_arguments do |keywords| - keywords << :from if legacy_from != NOT_GIVEN - keywords << :to if legacy_to != NOT_GIVEN - end - + def negative(from: -5000.00, to: -1.00) random_number = between(from: from, to: to) less_than_zero(random_number) diff --git a/lib/faker/default/omniauth.rb b/lib/faker/default/omniauth.rb index 6a8fb7a124..44b51bddfd 100644 --- a/lib/faker/default/omniauth.rb +++ b/lib/faker/default/omniauth.rb @@ -17,8 +17,6 @@ def initialize(name: nil, email: nil) end class << self - # rubocop:disable Metrics/ParameterLists - ## # Generate a mock Omniauth response from Google. # @@ -29,13 +27,7 @@ class << self # @return [Hash] An auth hash in the format provided by omniauth-google. # # @faker.version 1.8.0 - def google(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 9).to_s) - warn_for_deprecated_arguments do |keywords| - keywords << :name if legacy_name != NOT_GIVEN - keywords << :email if legacy_email != NOT_GIVEN - keywords << :uid if legacy_uid != NOT_GIVEN - end - + def google(name: nil, email: nil, uid: Number.number(digits: 9).to_s) auth = Omniauth.new(name: name, email: email) { provider: 'google_oauth2', @@ -95,14 +87,7 @@ def google(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_G # @return [Hash] An auth hash in the format provided by omniauth-facebook. # # @faker.version 1.8.0 - def facebook(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_username = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s) - warn_for_deprecated_arguments do |keywords| - keywords << :name if legacy_name != NOT_GIVEN - keywords << :email if legacy_email != NOT_GIVEN - keywords << :username if legacy_username != NOT_GIVEN - keywords << :uid if legacy_uid != NOT_GIVEN - end - + def facebook(name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s) auth = Omniauth.new(name: name, email: email) username ||= "#{auth.first_name.downcase[0]}#{auth.last_name.downcase}" { @@ -154,13 +139,7 @@ def facebook(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_username # @return [Hash] An auth hash in the format provided by omniauth-twitter. # # @faker.version 1.8.0 - def twitter(legacy_name = NOT_GIVEN, legacy_nickname = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, nickname: nil, uid: Number.number(digits: 6).to_s) - warn_for_deprecated_arguments do |keywords| - keywords << :name if legacy_name != NOT_GIVEN - keywords << :nickname if legacy_nickname != NOT_GIVEN - keywords << :uid if legacy_uid != NOT_GIVEN - end - + def twitter(name: nil, nickname: nil, uid: Number.number(digits: 6).to_s) auth = Omniauth.new(name: name) nickname ||= auth.name.downcase.delete(' ') location = city_state @@ -243,13 +222,7 @@ def twitter(legacy_name = NOT_GIVEN, legacy_nickname = NOT_GIVEN, legacy_uid = N # @return [Hash] An auth hash in the format provided by omniauth-linkedin. # # @faker.version 1.8.0 - def linkedin(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 6).to_s) - warn_for_deprecated_arguments do |keywords| - keywords << :name if legacy_name != NOT_GIVEN - keywords << :email if legacy_email != NOT_GIVEN - keywords << :uid if legacy_uid != NOT_GIVEN - end - + def linkedin(name: nil, email: nil, uid: Number.number(digits: 6).to_s) auth = Omniauth.new(name: name, email: email) first_name = auth.first_name.downcase last_name = auth.last_name.downcase @@ -322,13 +295,7 @@ def linkedin(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT # @return [Hash] An auth hash in the format provided by omniauth-github. # # @faker.version 1.8.0 - def github(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 8).to_s) - warn_for_deprecated_arguments do |keywords| - keywords << :name if legacy_name != NOT_GIVEN - keywords << :email if legacy_email != NOT_GIVEN - keywords << :uid if legacy_uid != NOT_GIVEN - end - + def github(name: nil, email: nil, uid: Number.number(digits: 8).to_s) auth = Omniauth.new(name: name, email: email) login = auth.name.downcase.tr(' ', '-') html_url = "https://github.com/#{login}" @@ -385,7 +352,6 @@ def github(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_G } } end - # rubocop:enable Metrics/ParameterLists ## # Generate a mock Omniauth response from Apple. diff --git a/lib/faker/default/phone_number.rb b/lib/faker/default/phone_number.rb index 2f812cffe5..273c871abf 100644 --- a/lib/faker/default/phone_number.rb +++ b/lib/faker/default/phone_number.rb @@ -123,11 +123,7 @@ def exchange_code # Faker::PhoneNumber.extension #=> "3764" # # @faker.version 1.3.0 - def subscriber_number(legacy_length = NOT_GIVEN, length: 4) - warn_for_deprecated_arguments do |keywords| - keywords << :length if legacy_length != NOT_GIVEN - end - + def subscriber_number(length: 4) rand.to_s[2..(1 + length)] end diff --git a/lib/faker/default/placeholdit.rb b/lib/faker/default/placeholdit.rb index d0be594cba..35dcd4e9a2 100644 --- a/lib/faker/default/placeholdit.rb +++ b/lib/faker/default/placeholdit.rb @@ -5,8 +5,6 @@ class Placeholdit < Base class << self SUPPORTED_FORMATS = %w[png jpg gif jpeg].freeze - # rubocop:disable Metrics/ParameterLists - ## # Produces a random placeholder image from https://via.placeholder.com. # @@ -28,15 +26,7 @@ class << self # Faker::Placeholdit.image(size: '50x50', format: 'jpg', background_color: 'ffffff', text_color: '000', text: 'Some Custom Text') #=> "https://via.placeholder.com/50x50.jpg/ffffff/000?text=Some Custom Text" # # @faker.version 1.6.0 - def image(legacy_size = NOT_GIVEN, legacy_format = NOT_GIVEN, legacy_background_color = NOT_GIVEN, legacy_text_color = NOT_GIVEN, legacy_text = NOT_GIVEN, size: '300x300', format: 'png', background_color: nil, text_color: nil, text: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :size if legacy_size != NOT_GIVEN - keywords << :format if legacy_format != NOT_GIVEN - keywords << :background_color if legacy_background_color != NOT_GIVEN - keywords << :text_color if legacy_text_color != NOT_GIVEN - keywords << :text if legacy_text != NOT_GIVEN - end - + def image(size: '300x300', format: 'png', background_color: nil, text_color: nil, text: nil) background_color = generate_color if background_color == :random text_color = generate_color if text_color == :random @@ -51,7 +41,6 @@ def image(legacy_size = NOT_GIVEN, legacy_format = NOT_GIVEN, legacy_background_ image_url += "?text=#{text}" if text image_url end - # rubocop:enable Metrics/ParameterLists private diff --git a/lib/faker/default/relationship.rb b/lib/faker/default/relationship.rb index b026db57b5..c989f3a2a3 100644 --- a/lib/faker/default/relationship.rb +++ b/lib/faker/default/relationship.rb @@ -14,11 +14,7 @@ class << self # Faker::Relationship.familial #=> "Grandfather" # # @faker.version 1.9.2 - def familial(legacy_connection = NOT_GIVEN, connection: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :connection if legacy_connection != NOT_GIVEN - end - + def familial(connection: nil) familial_connections = translate('faker.relationship.familial').keys if connection.nil? diff --git a/lib/faker/default/source.rb b/lib/faker/default/source.rb index c0cccf900d..e0d5024b56 100644 --- a/lib/faker/default/source.rb +++ b/lib/faker/default/source.rb @@ -17,11 +17,7 @@ class << self # #=> "alert('Hello World!');" # # @faker.version 1.9.0 - def hello_world(legacy_lang = NOT_GIVEN, lang: :ruby) - warn_for_deprecated_arguments do |keywords| - keywords << :lang if legacy_lang != NOT_GIVEN - end - + def hello_world(lang: :ruby) fetch("source.hello_world.#{lang}") end @@ -39,13 +35,7 @@ def hello_world(legacy_lang = NOT_GIVEN, lang: :ruby) # #=> "console.log('foo bar');" # # @faker.version 1.9.0 - def print(legacy_str = NOT_GIVEN, legacy_lang = NOT_GIVEN, str: 'some string', lang: :ruby) - warn_for_deprecated_arguments do |keywords| - keywords << :str if legacy_str != NOT_GIVEN - end - warn_for_deprecated_arguments do |keywords| - keywords << :lang if legacy_lang != NOT_GIVEN - end + def print(str: 'some string', lang: :ruby) code = fetch("source.print.#{lang}") code.gsub('faker_string_to_print', str) end @@ -65,10 +55,7 @@ def print(legacy_str = NOT_GIVEN, legacy_lang = NOT_GIVEN, str: 'some string', l # # }" # # @faker.version 1.9.0 - def print_1_to_10(legacy_lang = NOT_GIVEN, lang: :ruby) - warn_for_deprecated_arguments do |keywords| - keywords << :lang if legacy_lang != NOT_GIVEN - end + def print_1_to_10(lang: :ruby) fetch("source.print_1_to_10.#{lang}") end end diff --git a/lib/faker/default/string.rb b/lib/faker/default/string.rb index fff3923f96..25c7b837f6 100644 --- a/lib/faker/default/string.rb +++ b/lib/faker/default/string.rb @@ -17,11 +17,7 @@ class << self # Faker::String.random(length: [1, (2..5), [3, 6], nil]) #=> "葓L#ћ" # # @faker.version 1.9.0 - def random(legacy_length = NOT_GIVEN, length: 32) - warn_for_deprecated_arguments do |keywords| - keywords << :length if legacy_length != NOT_GIVEN - end - + def random(length: 32) utf8string select_a length end diff --git a/lib/faker/default/stripe.rb b/lib/faker/default/stripe.rb index 19a146ff21..372c598644 100644 --- a/lib/faker/default/stripe.rb +++ b/lib/faker/default/stripe.rb @@ -14,11 +14,7 @@ class << self # Faker::Stripe.valid_card(card_type: "visa_debit") #=> "4000056655665556" # # @faker.version 1.9.0 - def valid_card(legacy_card_type = NOT_GIVEN, card_type: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :card_type if legacy_card_type != NOT_GIVEN - end - + def valid_card(card_type: nil) valid_cards = translate('faker.stripe.valid_cards').keys if card_type.nil? @@ -44,11 +40,7 @@ def valid_card(legacy_card_type = NOT_GIVEN, card_type: nil) # Faker::Stripe.valid_token(card_type: "mc_debit") #=> "tok_mastercard_debit" # # @faker.version 1.9.0 - def valid_token(legacy_card_type = NOT_GIVEN, card_type: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :card_type if legacy_card_type != NOT_GIVEN - end - + def valid_token(card_type: nil) valid_tokens = translate('faker.stripe.valid_tokens').keys if card_type.nil? @@ -73,11 +65,7 @@ def valid_token(legacy_card_type = NOT_GIVEN, card_type: nil) # Faker::Stripe.invalid_card(card_error: "addressZipFail") #=> "4000000000000010" # # @faker.version 1.9.0 - def invalid_card(legacy_card_error = NOT_GIVEN, card_error: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :card_error if legacy_card_error != NOT_GIVEN - end - + def invalid_card(card_error: nil) invalid_cards = translate('faker.stripe.invalid_cards').keys if card_error.nil? @@ -130,11 +118,7 @@ def year # Faker::Stripe.ccv(card_type: "amex") #=> "1234" # # @faker.version 1.9.0 - def ccv(legacy_card_type = NOT_GIVEN, card_type: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :card_type if legacy_card_type != NOT_GIVEN - end - + def ccv(card_type: nil) (card_type.to_s == 'amex' ? rand_in_range(1000, 9999) : rand_in_range(100, 999)).to_s end end diff --git a/lib/faker/default/time.rb b/lib/faker/default/time.rb index a568a7ff34..d996c8a2ce 100644 --- a/lib/faker/default/time.rb +++ b/lib/faker/default/time.rb @@ -13,8 +13,6 @@ class Time < Base }.freeze class << self - # rubocop:disable Metrics/ParameterLists - ## # Produce a random time between two times. # @@ -37,13 +35,7 @@ class << self # Faker::Time.between(from: DateTime.now - 1, to: DateTime.now, format: :long) #=> "2018年10月16日(火) 10時48分27秒 -0500" # # @faker.version 1.5.0 - def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_format = NOT_GIVEN, from:, to:, format: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :from if legacy_from != NOT_GIVEN - keywords << :to if legacy_to != NOT_GIVEN - keywords << :format if legacy_format != NOT_GIVEN - end - + def between(from:, to:, format: nil) from = get_time_object(from) to = get_time_object(to) @@ -79,14 +71,7 @@ def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_format = NOT_ # #=> "Fri, 19 Oct 2018 15:17:46 -0500" # # @faker.version 1.0.0 - def between_dates(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, from:, to:, period: :all, format: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :from if legacy_from != NOT_GIVEN - keywords << :to if legacy_to != NOT_GIVEN - keywords << :period if legacy_period != NOT_GIVEN - keywords << :format if legacy_format != NOT_GIVEN - end - + def between_dates(from:, to:, period: :all, format: nil) date = Faker::Date.between(from: from, to: to) time = date_with_random_time(date, period) time_with_format(time, format) @@ -107,13 +92,7 @@ def between_dates(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_period # #=> "October 21, 2018 20:47" # # @faker.version 1.5.0 - def forward(legacy_days = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, days: 365, period: :all, format: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :days if legacy_days != NOT_GIVEN - keywords << :period if legacy_period != NOT_GIVEN - keywords << :format if legacy_format != NOT_GIVEN - end - + def forward(days: 365, period: :all, format: nil) time_with_format(date_with_random_time(Faker::Date.forward(days: days), period), format) end @@ -132,16 +111,9 @@ def forward(legacy_days = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = # #=> "14 Oct 07:44" # # @faker.version 1.5.0 - def backward(legacy_days = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, days: 365, period: :all, format: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :days if legacy_days != NOT_GIVEN - keywords << :period if legacy_period != NOT_GIVEN - keywords << :format if legacy_format != NOT_GIVEN - end - + def backward(days: 365, period: :all, format: nil) time_with_format(date_with_random_time(Faker::Date.backward(days: days), period), format) end - # rubocop:enable Metrics/ParameterLists private diff --git a/lib/faker/default/twitter.rb b/lib/faker/default/twitter.rb index e96145c796..a16a8eb3a3 100644 --- a/lib/faker/default/twitter.rb +++ b/lib/faker/default/twitter.rb @@ -16,12 +16,7 @@ class << self # Faker::Twitter.user(include_email: true) # Simulate an authenticated user with the email permission # # @faker.version 1.7.3 - def user(legacy_include_status = NOT_GIVEN, legacy_include_email = NOT_GIVEN, include_status: true, include_email: false) - warn_for_deprecated_arguments do |keywords| - keywords << :include_status if legacy_include_status != NOT_GIVEN - keywords << :include_email if legacy_include_email != NOT_GIVEN - end - + def user(include_status: true, include_email: false) user_id = id background_image_url = Faker::LoremPixel.image(size: '600x400') # TODO: Make the dimensions change profile_image_url = Faker::Avatar.image(slug: user_id, size: '48x48') @@ -85,12 +80,7 @@ def user(legacy_include_status = NOT_GIVEN, legacy_include_email = NOT_GIVEN, in # Faker::Twitter.status(include_photo: true) # Includes entities for an attached image # # @faker.version 1.7.3 - def status(legacy_include_user = NOT_GIVEN, legacy_include_photo = NOT_GIVEN, include_user: true, include_photo: false) - warn_for_deprecated_arguments do |keywords| - keywords << :include_user if legacy_include_user != NOT_GIVEN - keywords << :include_photo if legacy_include_photo != NOT_GIVEN - end - + def status(include_user: true, include_photo: false) status_id = id status = { id: status_id, @@ -161,11 +151,7 @@ def user_entities } end - def status_entities(legacy_include_photo = NOT_GIVEN, include_photo: false) - warn_for_deprecated_arguments do |keywords| - keywords << :include_photo if legacy_include_photo != NOT_GIVEN - end - + def status_entities(include_photo: false) entities = { hashtags: [], symbols: [], diff --git a/lib/faker/default/types.rb b/lib/faker/default/types.rb index 36bd2f1fc4..b1a60faa6b 100644 --- a/lib/faker/default/types.rb +++ b/lib/faker/default/types.rb @@ -16,11 +16,7 @@ class << self # Faker::Types.rb_string #=> "foobar" # # @faker.version 1.8.6 - def rb_string(legacy_words = NOT_GIVEN, words: 1) - warn_for_deprecated_arguments do |keywords| - keywords << :words if legacy_words != NOT_GIVEN - end - + def rb_string(words: 1) resolved_num = resolve(words) word_list = translate('faker.lorem.words') @@ -51,12 +47,7 @@ def character # Faker::Types.rb_integer #=> 1 # # @faker.version 1.8.6 - def rb_integer(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 0, to: 100) - warn_for_deprecated_arguments do |keywords| - keywords << :from if legacy_from != NOT_GIVEN - keywords << :to if legacy_to != NOT_GIVEN - end - + def rb_integer(from: 0, to: 100) rand(from..to).to_i end @@ -72,12 +63,7 @@ def rb_integer(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 0, to: 100) # Faker::Types.rb_hash(number: 2) #=> {name: "bob", last: "marley"} # # @faker.version 1.8.6 - def rb_hash(legacy_number = NOT_GIVEN, legacy_type = NOT_GIVEN, number: 1, type: -> { random_type }) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - keywords << :type if legacy_type != NOT_GIVEN - end - + def rb_hash(number: 1, type: -> { random_type }) {}.tap do |hsh| Lorem.words(number: number * 2).uniq.first(number).each do |s| value = type.is_a?(Proc) ? type.call : type @@ -98,11 +84,7 @@ def rb_hash(legacy_number = NOT_GIVEN, legacy_type = NOT_GIVEN, number: 1, type: # Faker::Types.complex_rb_hash(number: 2) #=> {user: {first: "bob", last: "marley"}, son: ["damien", "marley"]} # # @faker.version 1.8.6 - def complex_rb_hash(legacy_number = NOT_GIVEN, number: 1) - warn_for_deprecated_arguments do |keywords| - keywords << :number if legacy_number != NOT_GIVEN - end - + def complex_rb_hash(number: 1) rb_hash(number: number, type: -> { random_complex_type }) end @@ -117,11 +99,7 @@ def complex_rb_hash(legacy_number = NOT_GIVEN, number: 1) # Faker::Types.rb_array(len: 4) #=> ["a", 1, 2, "bob"] # # @faker.version 1.8.6 - def rb_array(legacy_len = NOT_GIVEN, len: 1) - warn_for_deprecated_arguments do |keywords| - keywords << :len if legacy_len != NOT_GIVEN - end - + def rb_array(len: 1) [].tap do |ar| len.times do ar.push random_type diff --git a/lib/faker/default/vehicle.rb b/lib/faker/default/vehicle.rb index 365abb37e6..4995606786 100644 --- a/lib/faker/default/vehicle.rb +++ b/lib/faker/default/vehicle.rb @@ -62,11 +62,7 @@ def make # Faker::Vehicle.model(make_of_model: 'Toyota') #=> "Prius" # # @faker.version 1.6.4 - def model(legacy_make_of_model = NOT_GIVEN, make_of_model: '') - warn_for_deprecated_arguments do |keywords| - keywords << :make_of_model if legacy_make_of_model != NOT_GIVEN - end - + def model(make_of_model: '') return fetch("vehicle.models_by_make.#{make}") if make_of_model.empty? fetch("vehicle.models_by_make.#{make_of_model}") @@ -249,12 +245,7 @@ def year # Faker::Vehicle.kilometrage #=> 35378 # # @faker.version 1.6.4 - def mileage(legacy_min = NOT_GIVEN, legacy_max = NOT_GIVEN, min: MILEAGE_MIN, max: MILEAGE_MAX) - warn_for_deprecated_arguments do |keywords| - keywords << :min if legacy_min != NOT_GIVEN - keywords << :max if legacy_max != NOT_GIVEN - end - + def mileage(min: MILEAGE_MIN, max: MILEAGE_MAX) rand_in_range(min, max) end @@ -271,11 +262,7 @@ def mileage(legacy_min = NOT_GIVEN, legacy_max = NOT_GIVEN, min: MILEAGE_MIN, ma # Faker::Vehicle.license_plate(state_abbreviation: 'FL') #=> "977 UNU" # # @faker.version 1.6.4 - def license_plate(legacy_state_abbreviation = NOT_GIVEN, state_abbreviation: '') - warn_for_deprecated_arguments do |keywords| - keywords << :state_abbreviation if legacy_state_abbreviation != NOT_GIVEN - end - + def license_plate(state_abbreviation: '') return regexify(bothify(fetch('vehicle.license_plate'))) if state_abbreviation.empty? key = "vehicle.license_plate_by_state.#{state_abbreviation}" diff --git a/lib/faker/default/world_cup.rb b/lib/faker/default/world_cup.rb index 02a91a76d4..5014faa896 100644 --- a/lib/faker/default/world_cup.rb +++ b/lib/faker/default/world_cup.rb @@ -53,11 +53,7 @@ def stadium # Faker::WorldCup.group #=> "Russia" # # @faker.version 2.13.0 - def group(legacy_group = NOT_GIVEN, group: 'group_A') - warn_for_deprecated_arguments do |keywords| - keywords << :group if legacy_group != NOT_GIVEN - end - + def group(group: 'group_A') fetch("world_cup.groups.#{group}") end @@ -73,12 +69,7 @@ def group(legacy_group = NOT_GIVEN, group: 'group_A') # Faker::WorldCup.roster(country: 'Spain', type: 'forwards') #=> "Diego Costa" # # @faker.version 2.13.0 - def roster(legacy_country = NOT_GIVEN, legacy_type = NOT_GIVEN, country: 'Egypt', type: 'coach') - warn_for_deprecated_arguments do |keywords| - keywords << :country if legacy_country != NOT_GIVEN - keywords << :type if legacy_type != NOT_GIVEN - end - + def roster(country: 'Egypt', type: 'coach') fetch("world_cup.rosters.#{country}.#{type}") end end diff --git a/lib/faker/games/dota.rb b/lib/faker/games/dota.rb index 3aeb066c98..a8ada9ea98 100644 --- a/lib/faker/games/dota.rb +++ b/lib/faker/games/dota.rb @@ -80,11 +80,7 @@ def player # Faker::Games::Dota.quote(hero: 'alchemist') #=> "Better living through alchemy!" # # @faker.version 1.9.0 - def quote(legacy_hero = NOT_GIVEN, hero: 'abaddon') - warn_for_deprecated_arguments do |keywords| - keywords << :hero if legacy_hero != NOT_GIVEN - end - + def quote(hero: 'abaddon') fetch("games.dota.#{hero}.quote") end end diff --git a/lib/faker/movies/star_wars.rb b/lib/faker/movies/star_wars.rb index 9fd5c7336b..279870eb58 100644 --- a/lib/faker/movies/star_wars.rb +++ b/lib/faker/movies/star_wars.rb @@ -138,11 +138,7 @@ def wookiee_sentence # #=> "Aren't you a little short for a Stormtrooper?" # # @faker.version 1.6.2 - def quote(legacy_character = NOT_GIVEN, character: nil) - warn_for_deprecated_arguments do |keywords| - keywords << :character if legacy_character != NOT_GIVEN - end - + def quote(character: nil) quoted_characters = translate('faker.star_wars.quotes') if character.nil?