rails_best_practices 1.22.1 → 1.23.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: 36bdd893273a363e797a90d58df2426f0429f94637171cdf803d4cfe3a3c0033
4
- data.tar.gz: c2fc8eb82530d50615ecfd423da421c056fb309fd4edcdde91ea5cbe4c9ed2c2
3
+ metadata.gz: 6130c27d1f5ad49baeed9bd6595188a99f77e10260f709e7b2dc49bce191d06e
4
+ data.tar.gz: 856313c260d0e66d2625885bdb6f4f1614fa2184303a182d7fb016fb76dac304
5
5
  SHA512:
6
- metadata.gz: 158478715edfea916abf0666e24665ac0da4aa5e6784df370a78f44654f2b817d415866ec363503bb7081011ace66edb0e32197d9d384c394f59cb429dc8d0ee
7
- data.tar.gz: c785c39a4050af719e2513241dcff648dec9fe0d6c8bda3717e50da991fbc8d0d03cc1159fff946ad06d2c7378a5b9247146266e1e94d7d85178cbe50181e067
6
+ metadata.gz: 66c463631584235d020ea1ee12d748119827de1c9347660ccf5fde82191038ab75cd07f9266933c199a2fd6c722abf566eb75ec906f1c717a557c4e19e327278
7
+ data.tar.gz: 453991a40ccdf9f0549dbe6842e8823034a41e5b253efdccde0e4442a0ea17b654046747dea4de54ac4312eae89bd4ec946c45ded98c356d7f12465294b34d8d
@@ -0,0 +1,31 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: CI
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+ runs-on: ubuntu-latest
19
+ strategy:
20
+ matrix:
21
+ ruby-version: ['2.6', '2.7', '3.0', '3.1']
22
+
23
+ steps:
24
+ - uses: actions/checkout@v2
25
+ - name: Set up Ruby
26
+ uses: ruby/setup-ruby@v1
27
+ with:
28
+ ruby-version: ${{ matrix.ruby-version }}
29
+ bundler-cache: true
30
+ - name: Run tests
31
+ run: bundle exec rspec spec
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Next Release
2
2
 
3
+ ## 1.23.0 (2022-01-31)
4
+
5
+ * Support hash short syntax
6
+
3
7
  ## 1.22.0 (2021-10-27)
4
8
 
5
9
  * Support atom editor
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_best_practices (1.22.1)
5
- activesupport
6
- code_analyzer (>= 0.5.2)
4
+ rails_best_practices (1.23.0)
5
+ activesupport (~> 6.1.4)
6
+ code_analyzer (~> 0.5.5)
7
7
  erubis
8
8
  i18n
9
9
  json
@@ -13,14 +13,14 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- activesupport (6.1.4.1)
16
+ activesupport (6.1.4.4)
17
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
18
  i18n (>= 1.6, < 2)
19
19
  minitest (>= 5.1)
20
20
  tzinfo (~> 2.0)
21
21
  zeitwerk (~> 2.3)
22
22
  awesome_print (1.8.0)
23
- code_analyzer (0.5.2)
23
+ code_analyzer (0.5.5)
24
24
  sexp_processor
25
25
  coderay (1.1.3)
26
26
  concurrent-ruby (1.1.9)
@@ -52,7 +52,7 @@ GEM
52
52
  haml (5.1.2)
53
53
  temple (>= 0.8.0)
54
54
  tilt
55
- i18n (1.8.10)
55
+ i18n (1.9.1)
56
56
  concurrent-ruby (~> 1.0)
57
57
  json (2.3.0)
58
58
  listen (3.7.0)
@@ -60,7 +60,7 @@ GEM
60
60
  rb-inotify (~> 0.9, >= 0.9.10)
61
61
  lumberjack (1.2.8)
62
62
  method_source (1.0.0)
63
- minitest (5.14.4)
63
+ minitest (5.15.0)
64
64
  nenv (0.3.0)
65
65
  notiffany (0.1.3)
66
66
  nenv (~> 0.1)
@@ -87,7 +87,7 @@ GEM
87
87
  rspec-support (~> 3.10.0)
88
88
  rspec-support (3.10.2)
89
89
  ruby-progressbar (1.11.0)
90
- sexp_processor (4.15.3)
90
+ sexp_processor (4.16.0)
91
91
  shellany (0.0.1)
92
92
  simplecov (0.16.1)
93
93
  docile (~> 1.1)
@@ -105,7 +105,7 @@ GEM
105
105
  tins (1.22.2)
106
106
  tzinfo (2.0.4)
107
107
  concurrent-ruby (~> 1.0)
108
- zeitwerk (2.5.1)
108
+ zeitwerk (2.5.4)
109
109
 
110
110
  PLATFORMS
111
111
  ruby
data/README.md CHANGED
@@ -284,7 +284,7 @@ Follow us on twitter: <http://twitter.com/railsbp>
284
284
  Send us email: <team@railsbp.com>
285
285
 
286
286
 
287
- Copyright © 2009 - 2013 Richard Huang (flyerhzm@gmail.com), released under the MIT license
287
+ Copyright © 2009 - 2022 Richard Huang (flyerhzm@gmail.com), released under the MIT license
288
288
 
289
289
 
290
290
  [1]: https://github.com/railsbp/rails_best_practices/wiki/How-to-write-your-own-check-list
@@ -204,7 +204,7 @@ module RailsBestPractices
204
204
  :command_call,
205
205
  :command,
206
206
  :alias,
207
- :bare_assoc_hash,
207
+ :assoc_new,
208
208
  :method_add_arg
209
209
 
210
210
  # remembe the message of call node.
@@ -269,9 +269,12 @@ module RailsBestPractices
269
269
  # def to_xml(options = {})
270
270
  # super options.merge(exclude: :visible, methods: [:is_discussion_conversation])
271
271
  # end
272
- add_callback :start_bare_assoc_hash do |node|
273
- if node.hash_keys.include? 'methods'
274
- mark_used(node.hash_value('methods'))
272
+ add_callback :start_assoc_new do |node|
273
+ if node.key == 'methods'
274
+ mark_used(node.value)
275
+ end
276
+ if node.value.nil?
277
+ mark_used(node.key)
275
278
  end
276
279
  end
277
280
 
@@ -294,7 +297,9 @@ module RailsBestPractices
294
297
  def mark_used(method_node)
295
298
  return if method_node == :call
296
299
 
297
- if method_node.sexp_type == :bare_assoc_hash
300
+ if method_node.is_a?(String)
301
+ method_name = method_node
302
+ elsif method_node.sexp_type == :bare_assoc_hash
298
303
  method_node.hash_values.each { |value_node| mark_used(value_node) }
299
304
  elsif method_node.sexp_type == :array
300
305
  method_node.array_values.each { |value_node| mark_used(value_node) }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsBestPractices
4
- VERSION = '1.22.1'
4
+ VERSION = '1.23.0'
5
5
  end
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.required_ruby_version = '>= 1.9.0'
19
19
  spec.required_rubygems_version = '>= 1.3.6'
20
20
 
21
- spec.add_runtime_dependency('activesupport')
22
- spec.add_runtime_dependency('code_analyzer', '>= 0.5.2')
21
+ spec.add_runtime_dependency('activesupport', '~> 6.1.4')
22
+ spec.add_runtime_dependency('code_analyzer', '~> 0.5.5')
23
23
  spec.add_runtime_dependency('erubis')
24
24
  spec.add_runtime_dependency('i18n')
25
25
  spec.add_runtime_dependency('json')
@@ -556,6 +556,28 @@ module RailsBestPractices
556
556
  end
557
557
  end
558
558
 
559
+ if RUBY_VERSION.to_f > 3.0
560
+ context 'short syntax value' do
561
+ it 'does not remove unused method' do
562
+ content = <<-EOF
563
+ class Post < ActiveRecord::Base
564
+ def build
565
+ new(value:)
566
+ end
567
+
568
+ def value
569
+ 'value'
570
+ end
571
+ end
572
+ EOF
573
+ runner.prepare('app/models/post.rb', content)
574
+ runner.review('app/models/post.rb', content)
575
+ runner.after_review
576
+ expect(runner.errors.size).to eq(1)
577
+ end
578
+ end
579
+ end
580
+
559
581
  context 'callbacks' do
560
582
  it 'does not remove unused method' do
561
583
  content = <<-EOF
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_best_practices
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.22.1
4
+ version: 1.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-27 00:00:00.000000000 Z
11
+ date: 2022-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 6.1.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 6.1.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: code_analyzer
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.5.2
33
+ version: 0.5.5
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.5.2
40
+ version: 0.5.5
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: erubis
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -200,9 +200,10 @@ executables:
200
200
  extensions: []
201
201
  extra_rdoc_files: []
202
202
  files:
203
+ - ".github/workflows/main.yml"
203
204
  - ".gitignore"
204
205
  - ".rspec"
205
- - ".travis.yml"
206
+ - ".ruby-version"
206
207
  - CHANGELOG.md
207
208
  - Gemfile
208
209
  - Gemfile.lock
@@ -403,7 +404,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
403
404
  - !ruby/object:Gem::Version
404
405
  version: 1.3.6
405
406
  requirements: []
406
- rubygems_version: 3.2.22
407
+ rubygems_version: 3.3.3
407
408
  signing_key:
408
409
  specification_version: 4
409
410
  summary: a code metric tool for rails codes.
data/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.6.4
4
- script: bundle exec rspec spec