rubocop-faker 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e905846c9989294b1dfd34c9ebf8224d319476103bed10f3aa939c2b242739b3
4
- data.tar.gz: 0d4e63a90bf719a39380830d716097f90acefeb63149bf2f3f870ad0aa82d45a
3
+ metadata.gz: 4fefc520bc2c3f5e85c7b2f31a55f524dc4a5a2456485b769e34028514b302c0
4
+ data.tar.gz: e4273cf0dcc43e125821a694a208d6a4cf0140fc76fb49e80456bb3f018d5265
5
5
  SHA512:
6
- metadata.gz: ed10d5471a325618fb0c8f5ce32e5c193a5e683b12e673f7bbb19e3c47870c34e79d6a1aa6748a5568963a4d94d1be063379fbba6036115a1707f0fcb404d4f4
7
- data.tar.gz: bdcbc64672f446a338a7848cf400618646fdcfcf573c786255feb6afbab999b8af38962b62c278e313668ffc65d3669194f285cd772f0fb8844e47c3c2f516b7
6
+ metadata.gz: 76fed47690e635e7b4ee4b01480154887ddb8ead6a6fec28df504d73280f2e85be33f08b5856a3b201102548a8b5c9a05e735ab18f94d8e9276663eb5ce8038b
7
+ data.tar.gz: e69bba8304c3b045e348840dabe447bfe3128e33b3076ba856cf8233413540ee0a7bc96c5463aed5c3a9fcf572c111602b3f55d92f9b58e0730cc52ed5f2c7c5
data/.circleci/config.yml CHANGED
@@ -24,20 +24,20 @@ workflows:
24
24
  build:
25
25
  jobs:
26
26
  - rake_default:
27
- name: Ruby 2.4
28
- image: circleci/ruby:2.4
27
+ name: Ruby 2.7
28
+ image: cimg/ruby:2.7
29
29
  - rake_default:
30
- name: Ruby 2.5
31
- image: circleci/ruby:2.5
30
+ name: Ruby 3.0
31
+ image: cimg/ruby:3.0
32
32
  - rake_default:
33
- name: Ruby 2.6
34
- image: circleci/ruby:2.6
33
+ name: Ruby 3.1
34
+ image: cimg/ruby:3.1
35
35
  - rake_default:
36
- name: Ruby 2.7
37
- image: circleci/ruby:2.7
36
+ name: Ruby 3.2
37
+ image: cimg/ruby:3.2
38
+ - rake_default:
39
+ name: Ruby 3.3
40
+ image: cimg/ruby:3.3
38
41
  - rake_default:
39
42
  name: Ruby HEAD
40
43
  image: rubocophq/circleci-ruby-snapshot:latest # Nightly snapshot build
41
- - rake_default:
42
- name: JRuby 9.2
43
- image: circleci/jruby:9.2
@@ -0,0 +1 @@
1
+ github: koic
data/.rubocop.yml CHANGED
@@ -8,7 +8,8 @@ require:
8
8
 
9
9
  AllCops:
10
10
  NewCops: enable
11
- TargetRubyVersion: 2.4
11
+ TargetRubyVersion: 2.7
12
+ SuggestExtensions: false
12
13
 
13
14
  Naming/PredicateName:
14
15
  # Method define macros for dynamically generated method.
@@ -83,3 +84,6 @@ Metrics/ModuleLength:
83
84
 
84
85
  Performance/ChainArrayAllocation:
85
86
  Enabled: false
87
+
88
+ InternalAffairs/UndefinedConfig:
89
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
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
+
5
15
  ## 1.1.0 (2020-06-11)
6
16
 
7
17
  ### Bug fixes
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
@@ -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.1.0'
5
+ VERSION = '1.2.0'
6
6
  end
7
7
  end
@@ -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.4.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,6 +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 'faker', '>= 2.12.0'
29
- spec.add_runtime_dependency 'rubocop', '>= 0.82.0'
31
+ spec.add_dependency 'faker', '>= 2.12.0'
32
+ spec.add_dependency 'rubocop', '>= 1.13.0'
30
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-faker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.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-06-11 00:00:00.000000000 Z
11
+ date: 2024-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faker
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.82.0
33
+ version: 1.13.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.82.0
40
+ version: 1.13.0
41
41
  description: A RuboCop extension for Faker.
42
42
  email:
43
43
  - koic.ito@gmail.com
@@ -46,6 +46,7 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - ".circleci/config.yml"
49
+ - ".github/FUNDING.yml"
49
50
  - ".gitignore"
50
51
  - ".rspec"
51
52
  - ".rubocop.yml"
@@ -73,7 +74,8 @@ licenses:
73
74
  - MIT
74
75
  metadata:
75
76
  homepage_uri: https://github.com/koic/rubocop-faker
76
- post_install_message:
77
+ rubygems_mfa_required: 'true'
78
+ post_install_message:
77
79
  rdoc_options: []
78
80
  require_paths:
79
81
  - lib
@@ -81,15 +83,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
83
  requirements:
82
84
  - - ">="
83
85
  - !ruby/object:Gem::Version
84
- version: 2.4.0
86
+ version: 2.7.0
85
87
  required_rubygems_version: !ruby/object:Gem::Requirement
86
88
  requirements:
87
89
  - - ">="
88
90
  - !ruby/object:Gem::Version
89
91
  version: '0'
90
92
  requirements: []
91
- rubygems_version: 3.1.2
92
- signing_key:
93
+ rubygems_version: 3.1.6
94
+ signing_key:
93
95
  specification_version: 4
94
96
  summary: A RuboCop extension for Faker.
95
97
  test_files: []