rubocop-faker 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fe127b93b5b4fc49045b8e50afa3ad7283c62e1cbc94e644e7ca56f245d931e
4
- data.tar.gz: b6d5f9c5ad6eae68439cc5aa1bd3bac928b990f6df6a3a2e1c1687dd9d8be8cc
3
+ metadata.gz: 4fefc520bc2c3f5e85c7b2f31a55f524dc4a5a2456485b769e34028514b302c0
4
+ data.tar.gz: e4273cf0dcc43e125821a694a208d6a4cf0140fc76fb49e80456bb3f018d5265
5
5
  SHA512:
6
- metadata.gz: dfc8a9afb128e2231d46206d34e41e29ea59cc28c0f7d25215b764454d42da2cb4f49bcbd717bb165f87c588a929915a091d64bfa6f48e02e47845fa2eb92796
7
- data.tar.gz: 310d47e5ebe089f5bce8d9f2ea6e72cb02229786a21fe9ffee452a7e98c738971ff0a00c314cacf784410ff899d54de877979b69d6b7c7e7b33257c765a7c35b
6
+ metadata.gz: 76fed47690e635e7b4ee4b01480154887ddb8ead6a6fec28df504d73280f2e85be33f08b5856a3b201102548a8b5c9a05e735ab18f94d8e9276663eb5ce8038b
7
+ data.tar.gz: e69bba8304c3b045e348840dabe447bfe3128e33b3076ba856cf8233413540ee0a7bc96c5463aed5c3a9fcf572c111602b3f55d92f9b58e0730cc52ed5f2c7c5
data/.circleci/config.yml CHANGED
@@ -24,23 +24,20 @@ workflows:
24
24
  build:
25
25
  jobs:
26
26
  - rake_default:
27
- name: Ruby 2.3
28
- image: circleci/ruby:2.3
27
+ name: Ruby 2.7
28
+ image: cimg/ruby:2.7
29
29
  - rake_default:
30
- name: Ruby 2.4
31
- image: circleci/ruby:2.4
30
+ name: Ruby 3.0
31
+ image: cimg/ruby:3.0
32
32
  - rake_default:
33
- name: Ruby 2.5
34
- image: circleci/ruby:2.5
33
+ name: Ruby 3.1
34
+ image: cimg/ruby:3.1
35
35
  - rake_default:
36
- name: Ruby 2.6
37
- image: circleci/ruby:2.6
36
+ name: Ruby 3.2
37
+ image: cimg/ruby:3.2
38
38
  - rake_default:
39
- name: Ruby 2.7
40
- image: circleci/ruby:2.7
39
+ name: Ruby 3.3
40
+ image: cimg/ruby:3.3
41
41
  - rake_default:
42
42
  name: Ruby HEAD
43
43
  image: rubocophq/circleci-ruby-snapshot:latest # Nightly snapshot build
44
- - rake_default:
45
- name: JRuby 9.2
46
- image: circleci/jruby:9.2
@@ -0,0 +1 @@
1
+ github: koic
data/.rubocop.yml CHANGED
@@ -7,7 +7,9 @@ require:
7
7
  - rubocop-performance
8
8
 
9
9
  AllCops:
10
- TargetRubyVersion: 2.3
10
+ NewCops: enable
11
+ TargetRubyVersion: 2.7
12
+ SuggestExtensions: false
11
13
 
12
14
  Naming/PredicateName:
13
15
  # Method define macros for dynamically generated method.
@@ -82,3 +84,6 @@ Metrics/ModuleLength:
82
84
 
83
85
  Performance/ChainArrayAllocation:
84
86
  Enabled: false
87
+
88
+ InternalAffairs/UndefinedConfig:
89
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -2,7 +2,28 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
- ## 1.0.0 (2019-03-14)
5
+ ## 1.2.0 (2024-10-22)
6
+
7
+ ### Bug fixes
8
+
9
+ * [#7](https://github.com/koic/rubocop-faker/issues/7): Suppress RuboCop's deprecation warning. ([@koic][])
10
+
11
+ ### Changes
12
+
13
+ * Drop support for Ruby 2.6 and lower. ([@koic][])
14
+
15
+ ## 1.1.0 (2020-06-11)
16
+
17
+ ### Bug fixes
18
+
19
+ * Fix a typo for `Faker::Vehicle`'s `state_abbreviation` kwarg. ([@koic][])
20
+
21
+ ### Changes
22
+
23
+ * Require Faker 2.1.2 or higher. ([@koic][])
24
+ * Drop support for RuboCop 0.81 or lower. ([@koic][])
25
+
26
+ ## 1.0.0 (2020-03-14)
6
27
 
7
28
  ### New features
8
29
 
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ gemspec
9
9
  gem 'rake'
10
10
  gem 'rspec'
11
11
  gem 'rubocop', github: 'rubocop-hq/rubocop'
12
- gem 'rubocop-performance', '~> 1.5.0'
12
+ gem 'rubocop-performance', '~> 1.22.0'
13
13
  # Workaround for YARD 0.9.20 or lower.
14
14
  # It specifies `github` until the release that includes the following changes:
15
15
  # https://github.com/lsegal/yard/pull/1290
data/README.md CHANGED
@@ -54,7 +54,17 @@ Check positional argument style before Faker 2.
54
54
  Auto-correction to keyword argument style on Faker 2.
55
55
 
56
56
  ```console
57
- % rubocop --require rubocop-faker --only Faker/DeprecatedArguments --auto-correct
57
+ % rubocop --require rubocop-faker --only Faker/DeprecatedArguments --autocorrect
58
+ ```
59
+
60
+ ### RuboCop configuration file
61
+
62
+ Add `rubocop-faker` to required extension.
63
+
64
+ ```yaml
65
+ # .rubocop.yml
66
+ require:
67
+ - rubocop-faker
58
68
  ```
59
69
 
60
70
  ## Contributing
data/config/default.yml CHANGED
@@ -435,7 +435,7 @@ Faker/DeprecatedArguments:
435
435
  - min
436
436
  - max
437
437
  license_plate:
438
- - state_abreviation
438
+ - state_abbreviation
439
439
  Faker::WorldCup:
440
440
  group:
441
441
  - group
@@ -3,7 +3,6 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Faker
6
- #
7
6
  # Checks that Faker arguments style is based on Faker 2.
8
7
  # Use keyword arguments instead of positional arguments.
9
8
  #
@@ -14,8 +13,9 @@ module RuboCop
14
13
  # # good
15
14
  # Avatar.image(slug: slug, size: size, format: format)
16
15
  #
17
- class DeprecatedArguments < Cop
16
+ class DeprecatedArguments < Base
18
17
  include RangeHelp
18
+ extend AutoCorrector
19
19
 
20
20
  MSG = 'Passing `%<arg>s` with the %<index>s argument of ' \
21
21
  '`%<class_name>s.%<method_name>s` is deprecated. ' \
@@ -46,21 +46,10 @@ module RuboCop
46
46
  end
47
47
  end
48
48
 
49
- def autocorrect(node)
50
- methods = argument_keywords[faker_class_name(node)]
51
- keywords = methods[node.method_name.to_s]
52
-
53
- kwargs = build_kwargs_style(node, keywords)
54
-
55
- lambda do |corrector|
56
- corrector.replace(arguments_range(node), kwargs)
57
- end
58
- end
59
-
60
49
  private
61
50
 
62
51
  def unique_generator_method?(node)
63
- node.method?(:unique) && node.arguments.size.zero?
52
+ node.method?(:unique) && node.arguments.empty?
64
53
  end
65
54
 
66
55
  def format_message(keyword:, arg:, index:, class_name:, method_name:)
@@ -82,10 +71,20 @@ module RuboCop
82
71
 
83
72
  def add_offense_for_arguments(node, argument, message)
84
73
  add_offense(
85
- node,
86
- location: argument.source_range,
74
+ argument,
87
75
  message: message
88
- )
76
+ ) do |corrector|
77
+ autocorrect(corrector, node)
78
+ end
79
+ end
80
+
81
+ def autocorrect(corrector, node)
82
+ methods = argument_keywords[faker_class_name(node)]
83
+ keywords = methods[node.method_name.to_s]
84
+
85
+ kwargs = build_kwargs_style(node, keywords)
86
+
87
+ corrector.replace(arguments_range(node), kwargs)
89
88
  end
90
89
 
91
90
  def build_kwargs_style(node, keywords)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Faker
5
- VERSION = '1.0.0'
5
+ VERSION = '1.2.0'
6
6
  end
7
7
  end
data/manual/cops_faker.md CHANGED
@@ -23,7 +23,7 @@ Avatar.image(slug: slug, size: size, format: format)
23
23
 
24
24
  Name | Default value | Configurable values
25
25
  --- | --- | ---
26
- ArgumentKeywords | `{"Faker::Dune"=>{"quote"=>["character"], "saying"=>["source"]}, "Faker::Books::Lovecraft"=>{"fhtagn"=>["number"], "sentence"=>["word_count", "random_words_to_add"], "words"=>["number", "spaces_allowed"], "sentences"=>["number"], "paragraph"=>["sentence_count", "random_sentences_to_add"], "paragraphs"=>["number"], "paragraph_by_chars"=>["characters"]}, "Faker::Address"=>{"city"=>["options"], "street_address"=>["include_secondary"], "zip_code"=>["state_abbreviation"], "country_by_code"=>["code"], "country_name_to_code"=>["name"]}, "Faker::Alphanumeric"=>{"alpha"=>["number"], "alphanumeric"=>["number"]}, "Faker::App"=>{"semantic_version"=>["major", "minor", "patch"]}, "Faker::Avatar"=>{"image"=>["slug", "size", "format", "set", "bgset"]}, "Faker::Bank"=>{"account_number"=>["digits"], "iban"=>["country_code"]}, "Faker::Boolean"=>{"boolean"=>["true_ratio"]}, "Faker::ChileRut"=>{"rut"=>["min_rut", "fixed"], "full_rut"=>["min_rut", "fixed"]}, "Faker::Code"=>{"isbn"=>["base"], "ean"=>["base"], "nric"=>["min_age", "max_age"]}, "Faker::Commerce"=>{"promotion_code"=>["digits"], "department"=>["max", "fixed_amount"], "price"=>["range", "as_string"]}, "Faker::Company"=>{"polish_register_of_national_economy"=>["length"], "brazilian_company_number"=>["formatted"]}, "Faker::CryptoCoin"=>{"coin_name"=>["coin"], "acronym"=>["coin"], "url_logo"=>["coin"]}, "Faker::Date"=>{"between"=>["from", "to"], "between_except"=>["from", "to", "excepted"], "forward"=>["days"], "backward"=>["days"], "birthday"=>["min_age", "max_age"]}, "Faker::Demographic"=>{"height"=>["unit"]}, "Faker::DrivingLicence"=>{"british_driving_licence"=>["last_name", "initials", "gender", "date_of_birth"]}, "Faker::File"=>{"dir"=>["segment_count", "root", "directory_separator"], "file_name"=>["dir", "name", "ext", "directory_separator"]}, "Faker::Fillmurray"=>{"image"=>["grayscale", "width", "height"]}, "Faker::Finance"=>{"vat_number"=>["country"]}, "Faker::Hipster"=>{"words"=>["number", "supplemental", "spaces_allowed"], "sentence"=>["word_count", "supplemental", "random_words_to_add"], "sentences"=>["number", "supplemental"], "paragraph"=>["sentence_count", "supplemental", "random_sentences_to_add"], "paragraphs"=>["number", "supplemental"], "paragraph_by_chars"=>["characters", "supplemental"]}, "Faker::IDNumber"=>{"brazilian_citizen_number"=>["formatted"], "brazilian_id"=>["formatted"]}, "Faker::Internet"=>{"email"=>["name", "separators"], "free_email"=>["name"], "safe_email"=>["name"], "username"=>["specifier", "separators"], "password"=>["min_length", "max_length", "mix_case", "special_characters"], "domain_name"=>["subdomain"], "fix_umlauts"=>["string"], "mac_address"=>["prefix"], "url"=>["host", "path", "scheme"], "slug"=>["words", "glue"], "user_agent"=>["vendor"]}, "Faker::Invoice"=>{"amount_between"=>["from", "to"], "creditor_reference"=>["ref"], "reference"=>["ref"]}, "Faker::Json"=>{"shallow_json"=>["width", "options"], "add_depth_to_json"=>["json", "width", "options"]}, "Faker::Lorem"=>{"words"=>["number", "supplemental"], "characters"=>["number"], "sentence"=>["word_count", "supplemental", "random_words_to_add"], "sentences"=>["number", "supplemental"], "paragraph"=>["sentence_count", "supplemental", "random_sentences_to_add"], "paragraphs"=>["number", "supplemental"], "paragraph_by_chars"=>["number", "supplemental"], "question"=>["word_count", "supplemental", "random_words_to_add"], "questions"=>["number", "supplemental"]}, "Faker::LoremFlickr"=>{"image"=>["size", "search_terms", "match_all"], "grayscale_image"=>["size", "search_terms", "match_all"], "pixelated_image"=>["size", "search_terms", "match_all"], "colorized_image"=>["size", "color", "search_terms", "match_all"]}, "Faker::LoremPixel"=>{"image"=>["size", "is_gray", "category", "number", "text", "secure"]}, "Faker::Markdown"=>{"sandwich"=>["sentences", "repeat"]}, "Faker::Measurement"=>{"height"=>["amount"], "length"=>["amount"], "volume"=>["amount"], "weight"=>["amount"], "metric_height"=>["amount"], "metric_length"=>["amount"], "metric_volume"=>["amount"], "metric_weight"=>["amount"]}, "Faker::Name"=>{"initials"=>["number"]}, "Faker::NationalHealthService"=>{"check_digit"=>["number"]}, "Faker::Number"=>{"number"=>["digits"], "leading_zero_number"=>["digits"], "decimal_part"=>["digits"], "decimal"=>["l_digits", "r_digits"], "hexadecimal"=>["digits"], "normal"=>["mean", "standard_deviation"], "between"=>["from", "to"], "within"=>["range"], "positive"=>["from", "to"], "negative"=>["from", "to"]}, "Faker::Omniauth"=>{"google"=>["name", "email", "uid"], "facebook"=>["name", "email", "username", "uid"], "twitter"=>["name", "nickname", "uid"], "linkedin"=>["name", "email", "uid"], "github"=>["name", "email", "uid"]}, "Faker::PhoneNumber"=>{"subscriber_number"=>["length"]}, "Faker::Placeholdit"=>{"image"=>["size", "format", "background_color", "text_color", "text"]}, "Faker::Relationship"=>{"familial"=>["connection"]}, "Faker::Source"=>{"hello_world"=>["lang"], "print"=>["str", "lang"], "print_1_to_10"=>["lang"]}, "Faker::String"=>{"random"=>["length"]}, "Faker::Stripe"=>{"valid_card"=>["card_type"], "valid_token"=>["card_type"], "invalid_card"=>["card_error"], "ccv"=>["card_type"]}, "Faker::Time"=>{"between"=>["from", "to", "format"], "between_dates"=>["from", "to", "period", "format"], "forward"=>["days", "period", "format"], "backward"=>["days", "period", "format"]}, "Faker::Twitter"=>{"user"=>["include_status", "include_email"], "status"=>["include_user", "include_photo"], "status_entities"=>["include_photo"]}, "Faker::Types"=>{"rb_string"=>["words"], "rb_integer"=>["from", "to"], "rb_hash"=>["number", "type"], "complex_rb_hash"=>["number"], "rb_array"=>["len"]}, "Faker::Vehicle"=>{"model"=>["make_of_model"], "mileage"=>["min", "max"], "license_plate"=>["state_abreviation"]}, "Faker::WorldCup"=>{"group"=>["group"], "roster"=>["country", "type"]}, "Faker::Dota"=>{"quote"=>["hero"]}, "Faker::Movies::StarWars"=>{"quote"=>["character"]}}` |
26
+ ArgumentKeywords | `{"Faker::Dune"=>{"quote"=>["character"], "saying"=>["source"]}, "Faker::Books::Lovecraft"=>{"fhtagn"=>["number"], "sentence"=>["word_count", "random_words_to_add"], "words"=>["number", "spaces_allowed"], "sentences"=>["number"], "paragraph"=>["sentence_count", "random_sentences_to_add"], "paragraphs"=>["number"], "paragraph_by_chars"=>["characters"]}, "Faker::Address"=>{"city"=>["options"], "street_address"=>["include_secondary"], "zip_code"=>["state_abbreviation"], "country_by_code"=>["code"], "country_name_to_code"=>["name"]}, "Faker::Alphanumeric"=>{"alpha"=>["number"], "alphanumeric"=>["number"]}, "Faker::App"=>{"semantic_version"=>["major", "minor", "patch"]}, "Faker::Avatar"=>{"image"=>["slug", "size", "format", "set", "bgset"]}, "Faker::Bank"=>{"account_number"=>["digits"], "iban"=>["country_code"]}, "Faker::Boolean"=>{"boolean"=>["true_ratio"]}, "Faker::ChileRut"=>{"rut"=>["min_rut", "fixed"], "full_rut"=>["min_rut", "fixed"]}, "Faker::Code"=>{"isbn"=>["base"], "ean"=>["base"], "nric"=>["min_age", "max_age"]}, "Faker::Commerce"=>{"promotion_code"=>["digits"], "department"=>["max", "fixed_amount"], "price"=>["range", "as_string"]}, "Faker::Company"=>{"polish_register_of_national_economy"=>["length"], "brazilian_company_number"=>["formatted"]}, "Faker::CryptoCoin"=>{"coin_name"=>["coin"], "acronym"=>["coin"], "url_logo"=>["coin"]}, "Faker::Date"=>{"between"=>["from", "to"], "between_except"=>["from", "to", "excepted"], "forward"=>["days"], "backward"=>["days"], "birthday"=>["min_age", "max_age"]}, "Faker::Demographic"=>{"height"=>["unit"]}, "Faker::DrivingLicence"=>{"british_driving_licence"=>["last_name", "initials", "gender", "date_of_birth"]}, "Faker::File"=>{"dir"=>["segment_count", "root", "directory_separator"], "file_name"=>["dir", "name", "ext", "directory_separator"]}, "Faker::Fillmurray"=>{"image"=>["grayscale", "width", "height"]}, "Faker::Finance"=>{"vat_number"=>["country"]}, "Faker::Hipster"=>{"words"=>["number", "supplemental", "spaces_allowed"], "sentence"=>["word_count", "supplemental", "random_words_to_add"], "sentences"=>["number", "supplemental"], "paragraph"=>["sentence_count", "supplemental", "random_sentences_to_add"], "paragraphs"=>["number", "supplemental"], "paragraph_by_chars"=>["characters", "supplemental"]}, "Faker::IDNumber"=>{"brazilian_citizen_number"=>["formatted"], "brazilian_id"=>["formatted"]}, "Faker::Internet"=>{"email"=>["name", "separators"], "free_email"=>["name"], "safe_email"=>["name"], "username"=>["specifier", "separators"], "password"=>["min_length", "max_length", "mix_case", "special_characters"], "domain_name"=>["subdomain"], "fix_umlauts"=>["string"], "mac_address"=>["prefix"], "url"=>["host", "path", "scheme"], "slug"=>["words", "glue"], "user_agent"=>["vendor"]}, "Faker::Invoice"=>{"amount_between"=>["from", "to"], "creditor_reference"=>["ref"], "reference"=>["ref"]}, "Faker::Json"=>{"shallow_json"=>["width", "options"], "add_depth_to_json"=>["json", "width", "options"]}, "Faker::Lorem"=>{"words"=>["number", "supplemental"], "characters"=>["number"], "sentence"=>["word_count", "supplemental", "random_words_to_add"], "sentences"=>["number", "supplemental"], "paragraph"=>["sentence_count", "supplemental", "random_sentences_to_add"], "paragraphs"=>["number", "supplemental"], "paragraph_by_chars"=>["number", "supplemental"], "question"=>["word_count", "supplemental", "random_words_to_add"], "questions"=>["number", "supplemental"]}, "Faker::LoremFlickr"=>{"image"=>["size", "search_terms", "match_all"], "grayscale_image"=>["size", "search_terms", "match_all"], "pixelated_image"=>["size", "search_terms", "match_all"], "colorized_image"=>["size", "color", "search_terms", "match_all"]}, "Faker::LoremPixel"=>{"image"=>["size", "is_gray", "category", "number", "text", "secure"]}, "Faker::Markdown"=>{"sandwich"=>["sentences", "repeat"]}, "Faker::Measurement"=>{"height"=>["amount"], "length"=>["amount"], "volume"=>["amount"], "weight"=>["amount"], "metric_height"=>["amount"], "metric_length"=>["amount"], "metric_volume"=>["amount"], "metric_weight"=>["amount"]}, "Faker::Name"=>{"initials"=>["number"]}, "Faker::NationalHealthService"=>{"check_digit"=>["number"]}, "Faker::Number"=>{"number"=>["digits"], "leading_zero_number"=>["digits"], "decimal_part"=>["digits"], "decimal"=>["l_digits", "r_digits"], "hexadecimal"=>["digits"], "normal"=>["mean", "standard_deviation"], "between"=>["from", "to"], "within"=>["range"], "positive"=>["from", "to"], "negative"=>["from", "to"]}, "Faker::Omniauth"=>{"google"=>["name", "email", "uid"], "facebook"=>["name", "email", "username", "uid"], "twitter"=>["name", "nickname", "uid"], "linkedin"=>["name", "email", "uid"], "github"=>["name", "email", "uid"]}, "Faker::PhoneNumber"=>{"subscriber_number"=>["length"]}, "Faker::Placeholdit"=>{"image"=>["size", "format", "background_color", "text_color", "text"]}, "Faker::Relationship"=>{"familial"=>["connection"]}, "Faker::Source"=>{"hello_world"=>["lang"], "print"=>["str", "lang"], "print_1_to_10"=>["lang"]}, "Faker::String"=>{"random"=>["length"]}, "Faker::Stripe"=>{"valid_card"=>["card_type"], "valid_token"=>["card_type"], "invalid_card"=>["card_error"], "ccv"=>["card_type"]}, "Faker::Time"=>{"between"=>["from", "to", "format"], "between_dates"=>["from", "to", "period", "format"], "forward"=>["days", "period", "format"], "backward"=>["days", "period", "format"]}, "Faker::Twitter"=>{"user"=>["include_status", "include_email"], "status"=>["include_user", "include_photo"], "status_entities"=>["include_photo"]}, "Faker::Types"=>{"rb_string"=>["words"], "rb_integer"=>["from", "to"], "rb_hash"=>["number", "type"], "complex_rb_hash"=>["number"], "rb_array"=>["len"]}, "Faker::Vehicle"=>{"model"=>["make_of_model"], "mileage"=>["min", "max"], "license_plate"=>["state_abbreviation"]}, "Faker::WorldCup"=>{"group"=>["group"], "roster"=>["country", "type"]}, "Faker::Dota"=>{"quote"=>["hero"]}, "Faker::Movies::StarWars"=>{"quote"=>["character"]}}` |
27
27
 
28
28
  ### References
29
29
 
@@ -12,9 +12,12 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'A RuboCop extension for Faker.'
13
13
  spec.homepage = 'https://github.com/koic/rubocop-faker'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
16
16
 
17
- spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata = {
18
+ 'homepage_uri' => spec.homepage,
19
+ 'rubygems_mfa_required' => 'true'
20
+ }
18
21
 
19
22
  # Specify which files should be added to the gem when it is released.
20
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -25,5 +28,6 @@ Gem::Specification.new do |spec|
25
28
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
29
  spec.require_paths = ['lib']
27
30
 
28
- spec.add_runtime_dependency 'rubocop', '>= 0.74'
31
+ spec.add_dependency 'faker', '>= 2.12.0'
32
+ spec.add_dependency 'rubocop', '>= 1.13.0'
29
33
  end
@@ -40,7 +40,7 @@ task generate_cops_documentation: :yard_for_generate_documentation do
40
40
  ]
41
41
  config = config.for_cop(cop)
42
42
  safe_auto_correct = config.fetch('SafeAutoCorrect', true)
43
- autocorrect = if cop.new.support_autocorrect?
43
+ autocorrect = if cop.support_autocorrect?
44
44
  "Yes #{'(Unsafe)' unless safe_auto_correct}"
45
45
  else
46
46
  'No'
@@ -52,7 +52,7 @@ task generate_cops_documentation: :yard_for_generate_documentation do
52
52
  config.fetch('VersionAdded', '-'),
53
53
  config.fetch('VersionChanged', '-')
54
54
  ]]
55
- to_table(header, content) + "\n"
55
+ "#{to_table(header, content)}\n"
56
56
  end
57
57
  # rubocop:enable Metrics/MethodLength
58
58
 
@@ -131,7 +131,7 @@ task generate_cops_documentation: :yard_for_generate_documentation do
131
131
  Array.new(header.size, '---').join(' | ')
132
132
  ]
133
133
  table.concat(content.map { |c| c.join(' | ') })
134
- table.join("\n") + "\n"
134
+ "#{table.join("\n")}\n"
135
135
  end
136
136
 
137
137
  def format_table_value(val)
@@ -175,7 +175,7 @@ task generate_cops_documentation: :yard_for_generate_documentation do
175
175
  file_name = "#{Dir.pwd}/manual/cops_#{department.downcase}.md"
176
176
  File.open(file_name, 'w') do |file|
177
177
  puts "* generated #{file_name}"
178
- file.write(content.strip + "\n")
178
+ file.write("#{content.strip}\n")
179
179
  end
180
180
  end
181
181
 
@@ -203,7 +203,7 @@ task generate_cops_documentation: :yard_for_generate_documentation do
203
203
  end
204
204
  return if selected_cops.empty?
205
205
 
206
- type_title = department[0].upcase + department[1..-1]
206
+ type_title = department[0].upcase + department[1..]
207
207
  filename = "cops_#{department.downcase}.md"
208
208
  content = +"#### Department [#{type_title}](#{filename})\n\n"
209
209
  selected_cops.each do |cop|
@@ -223,13 +223,11 @@ task generate_cops_documentation: :yard_for_generate_documentation do
223
223
 
224
224
  content << "\n<!-- END_COP_LIST -->"
225
225
 
226
- content = if original.empty?
227
- content
228
- else
229
- original.sub(
230
- /<!-- START_COP_LIST -->.+<!-- END_COP_LIST -->/m, content
231
- )
232
- end
226
+ unless original.empty?
227
+ content = original.sub(
228
+ /<!-- START_COP_LIST -->.+<!-- END_COP_LIST -->/m, content
229
+ )
230
+ end
233
231
  File.write(path, content)
234
232
  end
235
233
 
@@ -238,8 +236,7 @@ task generate_cops_documentation: :yard_for_generate_documentation do
238
236
  .departments
239
237
  .map(&:to_s)
240
238
  .sort
241
- .map { |department| table_of_content_for_department(cops, department) }
242
- .reject(&:nil?)
239
+ .filter_map { |department| table_of_content_for_department(cops, department) }
243
240
  .join("\n")
244
241
  end
245
242
 
@@ -252,13 +249,13 @@ task generate_cops_documentation: :yard_for_generate_documentation do
252
249
  sh('GIT_PAGER=cat git diff manual')
253
250
 
254
251
  warn 'The manual directory is out of sync. ' \
255
- 'Run `rake generate_cops_documentation` and commit the results.'
252
+ 'Run `rake generate_cops_documentation` and commit the results.'
256
253
  exit!
257
254
  end
258
255
  end
259
256
 
260
257
  def main
261
- cops = RuboCop::Cop::Cop.registry
258
+ cops = RuboCop::Cop::Registry.global
262
259
  config = RuboCop::ConfigLoader.load_file('config/default.yml')
263
260
 
264
261
  YARD::Registry.load!
@@ -282,7 +279,7 @@ task documentation_syntax_check: :yard_for_generate_documentation do
282
279
 
283
280
  ok = true
284
281
  YARD::Registry.load!
285
- cops = RuboCop::Cop::Cop.registry
282
+ cops = RuboCop::Cop::Registry.global
286
283
  cops.each do |cop|
287
284
  examples = YARD::Registry.all(:class).find do |code_object|
288
285
  next unless RuboCop::Cop::Badge.for(code_object.to_s) == cop.badge
@@ -291,17 +288,15 @@ task documentation_syntax_check: :yard_for_generate_documentation do
291
288
  end
292
289
 
293
290
  examples.to_a.each do |example|
294
- begin
295
- buffer = Parser::Source::Buffer.new('<code>', 1)
296
- buffer.source = example.text
297
- parser = Parser::Ruby25.new(RuboCop::AST::Builder.new)
298
- parser.diagnostics.all_errors_are_fatal = true
299
- parser.parse(buffer)
300
- rescue Parser::SyntaxError => e
301
- path = example.object.file
302
- puts "#{path}: Syntax Error in an example. #{e}"
303
- ok = false
304
- end
291
+ buffer = Parser::Source::Buffer.new('<code>', 1)
292
+ buffer.source = example.text
293
+ parser = Parser::Ruby25.new(RuboCop::AST::Builder.new)
294
+ parser.diagnostics.all_errors_are_fatal = true
295
+ parser.parse(buffer)
296
+ rescue Parser::SyntaxError => e
297
+ path = example.object.file
298
+ puts "#{path}: Syntax Error in an example. #{e}"
299
+ ok = false
305
300
  end
306
301
  end
307
302
  abort unless ok
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-faker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koichi ITO
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-14 00:00:00.000000000 Z
11
+ date: 2024-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faker
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.12.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.12.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rubocop
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - ">="
18
32
  - !ruby/object:Gem::Version
19
- version: '0.74'
33
+ version: 1.13.0
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - ">="
25
39
  - !ruby/object:Gem::Version
26
- version: '0.74'
40
+ version: 1.13.0
27
41
  description: A RuboCop extension for Faker.
28
42
  email:
29
43
  - koic.ito@gmail.com
@@ -32,6 +46,7 @@ extensions: []
32
46
  extra_rdoc_files: []
33
47
  files:
34
48
  - ".circleci/config.yml"
49
+ - ".github/FUNDING.yml"
35
50
  - ".gitignore"
36
51
  - ".rspec"
37
52
  - ".rubocop.yml"
@@ -59,7 +74,8 @@ licenses:
59
74
  - MIT
60
75
  metadata:
61
76
  homepage_uri: https://github.com/koic/rubocop-faker
62
- post_install_message:
77
+ rubygems_mfa_required: 'true'
78
+ post_install_message:
63
79
  rdoc_options: []
64
80
  require_paths:
65
81
  - lib
@@ -67,15 +83,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
67
83
  requirements:
68
84
  - - ">="
69
85
  - !ruby/object:Gem::Version
70
- version: 2.3.0
86
+ version: 2.7.0
71
87
  required_rubygems_version: !ruby/object:Gem::Requirement
72
88
  requirements:
73
89
  - - ">="
74
90
  - !ruby/object:Gem::Version
75
91
  version: '0'
76
92
  requirements: []
77
- rubygems_version: 3.1.2
78
- signing_key:
93
+ rubygems_version: 3.1.6
94
+ signing_key:
79
95
  specification_version: 4
80
96
  summary: A RuboCop extension for Faker.
81
97
  test_files: []