rails_best_practices 1.22.1 → 1.23.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 +4 -4
- data/.github/workflows/main.yml +31 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +9 -9
- data/README.md +1 -1
- data/lib/rails_best_practices/core/check.rb +10 -5
- data/lib/rails_best_practices/version.rb +1 -1
- data/rails_best_practices.gemspec +2 -2
- data/spec/rails_best_practices/reviews/remove_unused_methods_in_models_review_spec.rb +22 -0
- metadata +13 -12
- data/.travis.yml +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6130c27d1f5ad49baeed9bd6595188a99f77e10260f709e7b2dc49bce191d06e
|
4
|
+
data.tar.gz: 856313c260d0e66d2625885bdb6f4f1614fa2184303a182d7fb016fb76dac304
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rails_best_practices (1.
|
5
|
-
activesupport
|
6
|
-
code_analyzer (
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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 -
|
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
|
-
:
|
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 :
|
273
|
-
if node.
|
274
|
-
mark_used(node.
|
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.
|
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) }
|
@@ -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', '
|
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.
|
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:
|
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:
|
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:
|
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.
|
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.
|
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
|
-
- ".
|
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.
|
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