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.
Test Setup Failed
Push — master ( d0e1fe...39ef5b )
by Leonardo
01:32
created

IbanBic.clear_cache()   A

Complexity

Conditions 1

Size

Total Lines 4

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 4
rs 10
1
# frozen_string_literal: true
2
3
require "regexp-examples"
4
5
module IbanBic
6
  module_function
7
8
  def random_iban(options = {})
9
    country = options[:country]
10
    searched_tags = options[:tags]
11
    non_searched_tags = options[:not_tags]
12
13
    unless country
14
      possible_countries = random_generator.keys
15
      possible_countries -= IbanBic.tags.select { |_country, country_tags| (searched_tags - country_tags).any? } .keys if searched_tags.present?
16
      possible_countries -= IbanBic.tags.select { |_country, country_tags| (non_searched_tags & country_tags).any? } .keys if non_searched_tags.present?
17
      country = possible_countries.sample
18
    end
19
    IbanBic.fix(random_generator[country].random_example)
20
  end
21
22
  def random_generator
23
    @random_generator ||= Hash[
24
      iban_meta.map do |country, meta|
25
        [country, /^#{country}#{meta["parts"].delete(" ").gsub(/\(\?\<\w+\>([^\)]*)\)/, "\\1")}$/]
26
      end
27
    ].freeze
28
  end
29
30
  alias _clear_cache clear_cache
31
  def clear_cache
32
    _clear_cache
33
    @random_generator = nil
34
  end
35
end
36