GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

IbanBic.random_generator()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
1
# frozen_string_literal: true
2
3
module IbanBic
4
  module_function
5
6
  def random_iban(options = {})
7
    country = options[:country]
8
    searched_tags = options[:tags]
9
    non_searched_tags = options[:not_tags]
10
11
    unless country
12
      possible_countries = random_generator.keys
13
      possible_countries -= IbanBic.tags.select { |_country, country_tags| (searched_tags - country_tags).any? } .keys if searched_tags.present?
14
      possible_countries -= IbanBic.tags.select { |_country, country_tags| (non_searched_tags & country_tags).any? } .keys if non_searched_tags.present?
15
      country = possible_countries.sample
16
    end
17
    IbanBic.fix(random_generator[country].random_example)
18
  end
19
20
  def random_generator
21
    @random_generator ||= begin
22
      @cached_variables << :@random_generator
23
      Hash[
24
        iban_meta.map do |country, meta|
25
          [country, /^#{country}#{meta["parts"].delete(" ").gsub(/\(\?\<\w+\>([^\)]*)\)/, "\\1")}$/]
26
        end
27
      ].freeze
28
    end
29
  end
30
end
31