rails_best_practices 1.19.2 → 1.20.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +0 -1
- data/.travis.yml +2 -3
- data/CHANGELOG.md +7 -7
- data/Gemfile +3 -5
- data/Gemfile.lock +125 -0
- data/Guardfile +2 -0
- data/README.md +6 -6
- data/Rakefile +2 -17
- data/assets/result.html.erb +2 -0
- data/lib/rails_best_practices.rb +3 -2
- data/lib/rails_best_practices/analyzer.rb +61 -49
- data/lib/rails_best_practices/cli.rb +22 -0
- data/lib/rails_best_practices/command.rb +1 -131
- data/lib/rails_best_practices/core/check.rb +64 -56
- data/lib/rails_best_practices/core/checks_loader.rb +24 -23
- data/lib/rails_best_practices/core/configs.rb +1 -2
- data/lib/rails_best_practices/core/controllers.rb +1 -2
- data/lib/rails_best_practices/core/error.rb +1 -1
- data/lib/rails_best_practices/core/helpers.rb +1 -2
- data/lib/rails_best_practices/core/mailers.rb +1 -2
- data/lib/rails_best_practices/core/methods.rb +27 -21
- data/lib/rails_best_practices/core/model_associations.rb +10 -5
- data/lib/rails_best_practices/core/models.rb +1 -2
- data/lib/rails_best_practices/core/modules.rb +1 -1
- data/lib/rails_best_practices/core/routes.rb +2 -2
- data/lib/rails_best_practices/core/runner.rb +67 -73
- data/lib/rails_best_practices/lexicals/long_line_check.rb +7 -3
- data/lib/rails_best_practices/option_parser.rb +156 -0
- data/lib/rails_best_practices/prepares.rb +1 -1
- data/lib/rails_best_practices/prepares/controller_prepare.rb +24 -17
- data/lib/rails_best_practices/prepares/gemfile_prepare.rb +2 -2
- data/lib/rails_best_practices/prepares/helper_prepare.rb +6 -1
- data/lib/rails_best_practices/prepares/initializer_prepare.rb +3 -3
- data/lib/rails_best_practices/prepares/mailer_prepare.rb +2 -1
- data/lib/rails_best_practices/prepares/model_prepare.rb +63 -23
- data/lib/rails_best_practices/prepares/route_prepare.rb +28 -21
- data/lib/rails_best_practices/prepares/schema_prepare.rb +1 -1
- data/lib/rails_best_practices/reviews/add_model_virtual_attribute_review.rb +38 -34
- data/lib/rails_best_practices/reviews/always_add_db_index_review.rb +94 -89
- data/lib/rails_best_practices/reviews/check_destroy_return_value_review.rb +15 -5
- data/lib/rails_best_practices/reviews/check_save_return_value_review.rb +20 -8
- data/lib/rails_best_practices/reviews/default_scope_is_evil_review.rb +1 -1
- data/lib/rails_best_practices/reviews/dry_bundler_in_capistrano_review.rb +1 -1
- data/lib/rails_best_practices/reviews/hash_syntax_review.rb +16 -16
- data/lib/rails_best_practices/reviews/isolate_seed_data_review.rb +12 -12
- data/lib/rails_best_practices/reviews/keep_finders_on_their_own_model_review.rb +10 -11
- data/lib/rails_best_practices/reviews/law_of_demeter_review.rb +25 -24
- data/lib/rails_best_practices/reviews/move_code_into_controller_review.rb +4 -4
- data/lib/rails_best_practices/reviews/move_code_into_helper_review.rb +9 -10
- data/lib/rails_best_practices/reviews/move_finder_to_named_scope_review.rb +10 -11
- data/lib/rails_best_practices/reviews/needless_deep_nesting_review.rb +24 -22
- data/lib/rails_best_practices/reviews/not_rescue_exception_review.rb +1 -1
- data/lib/rails_best_practices/reviews/not_use_default_route_review.rb +1 -2
- data/lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb +1 -1
- data/lib/rails_best_practices/reviews/overuse_route_customizations_review.rb +8 -8
- data/lib/rails_best_practices/reviews/protect_mass_assignment_review.rb +35 -32
- data/lib/rails_best_practices/reviews/remove_empty_helpers_review.rb +4 -4
- data/lib/rails_best_practices/reviews/remove_unused_methods_in_controllers_review.rb +26 -19
- data/lib/rails_best_practices/reviews/remove_unused_methods_in_helpers_review.rb +12 -10
- data/lib/rails_best_practices/reviews/remove_unused_methods_in_models_review.rb +38 -18
- data/lib/rails_best_practices/reviews/replace_complex_creation_with_factory_method_review.rb +11 -11
- data/lib/rails_best_practices/reviews/restrict_auto_generated_routes_review.rb +77 -74
- data/lib/rails_best_practices/reviews/review.rb +2 -1
- data/lib/rails_best_practices/reviews/simplify_render_in_controllers_review.rb +2 -3
- data/lib/rails_best_practices/reviews/simplify_render_in_views_review.rb +12 -12
- data/lib/rails_best_practices/reviews/use_before_filter_review.rb +18 -15
- data/lib/rails_best_practices/reviews/use_model_association_review.rb +15 -15
- data/lib/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review.rb +24 -22
- data/lib/rails_best_practices/reviews/use_observer_review.rb +28 -28
- data/lib/rails_best_practices/reviews/use_parentheses_in_method_def_review.rb +6 -6
- data/lib/rails_best_practices/reviews/use_query_attribute_review.rb +68 -66
- data/lib/rails_best_practices/reviews/use_say_with_time_in_migrations_review.rb +9 -8
- data/lib/rails_best_practices/reviews/use_scope_access_review.rb +16 -14
- data/lib/rails_best_practices/reviews/use_turbo_sprockets_rails3_review.rb +2 -1
- data/lib/rails_best_practices/version.rb +1 -1
- data/rails_best_practices.gemspec +38 -43
- data/spec/fixtures/lib/rails_best_practices/plugins/reviews/not_use_rails_root_review.rb +1 -2
- data/spec/rails_best_practices/analyzer_spec.rb +73 -42
- data/spec/rails_best_practices/core/check_spec.rb +5 -5
- data/spec/rails_best_practices/core/checks_loader_spec.rb +3 -3
- data/spec/rails_best_practices/core/configs_spec.rb +1 -1
- data/spec/rails_best_practices/core/controllers_spec.rb +1 -1
- data/spec/rails_best_practices/core/error_spec.rb +21 -18
- data/spec/rails_best_practices/core/except_methods_spec.rb +7 -7
- data/spec/rails_best_practices/core/gems_spec.rb +4 -4
- data/spec/rails_best_practices/core/helpers_spec.rb +1 -1
- data/spec/rails_best_practices/core/klasses_spec.rb +3 -3
- data/spec/rails_best_practices/core/mailers_spec.rb +1 -1
- data/spec/rails_best_practices/core/methods_spec.rb +6 -6
- data/spec/rails_best_practices/core/model_associations_spec.rb +10 -6
- data/spec/rails_best_practices/core/model_attributes_spec.rb +4 -4
- data/spec/rails_best_practices/core/models_spec.rb +1 -1
- data/spec/rails_best_practices/core/modules_spec.rb +5 -5
- data/spec/rails_best_practices/core/routes_spec.rb +5 -5
- data/spec/rails_best_practices/core/runner_spec.rb +9 -7
- data/spec/rails_best_practices/core_ext/erubis_spec.rb +10 -10
- data/spec/rails_best_practices/lexicals/long_line_check_spec.rb +32 -31
- data/spec/rails_best_practices/lexicals/remove_tab_check_spec.rb +6 -6
- data/spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb +6 -6
- data/spec/rails_best_practices/prepares/config_prepare_spec.rb +2 -2
- data/spec/rails_best_practices/prepares/controller_prepare_spec.rb +18 -10
- data/spec/rails_best_practices/prepares/gemfile_prepare_spec.rb +17 -17
- data/spec/rails_best_practices/prepares/helper_prepare_spec.rb +3 -3
- data/spec/rails_best_practices/prepares/initializer_prepare_spec.rb +3 -3
- data/spec/rails_best_practices/prepares/mailer_prepare_spec.rb +2 -2
- data/spec/rails_best_practices/prepares/model_prepare_spec.rb +79 -43
- data/spec/rails_best_practices/prepares/route_prepare_spec.rb +141 -76
- data/spec/rails_best_practices/prepares/schema_prepare_spec.rb +2 -2
- data/spec/rails_best_practices/reviews/add_model_virtual_attribute_review_spec.rb +18 -12
- data/spec/rails_best_practices/reviews/always_add_db_index_review_spec.rb +28 -22
- data/spec/rails_best_practices/reviews/check_destroy_return_value_review_spec.rb +15 -13
- data/spec/rails_best_practices/reviews/check_save_return_value_review_spec.rb +31 -21
- data/spec/rails_best_practices/reviews/default_scope_is_evil_review_spec.rb +6 -6
- data/spec/rails_best_practices/reviews/dry_bundler_in_capistrano_review_spec.rb +5 -5
- data/spec/rails_best_practices/reviews/hash_syntax_review_spec.rb +13 -13
- data/spec/rails_best_practices/reviews/isolate_seed_data_review_spec.rb +7 -7
- data/spec/rails_best_practices/reviews/keep_finders_on_their_own_model_review_spec.rb +9 -9
- data/spec/rails_best_practices/reviews/law_of_demeter_review_spec.rb +29 -22
- data/spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb +6 -6
- data/spec/rails_best_practices/reviews/move_code_into_helper_review_spec.rb +11 -6
- data/spec/rails_best_practices/reviews/move_code_into_model_review_spec.rb +32 -22
- data/spec/rails_best_practices/reviews/move_finder_to_named_scope_review_spec.rb +7 -7
- data/spec/rails_best_practices/reviews/move_model_logic_into_model_review_spec.rb +9 -7
- data/spec/rails_best_practices/reviews/needless_deep_nesting_review_spec.rb +9 -9
- data/spec/rails_best_practices/reviews/not_rescue_exception_review_spec.rb +9 -9
- data/spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb +5 -5
- data/spec/rails_best_practices/reviews/not_use_time_ago_in_words_review_spec.rb +7 -7
- data/spec/rails_best_practices/reviews/overuse_route_customizations_review_spec.rb +7 -7
- data/spec/rails_best_practices/reviews/protect_mass_assignment_review_spec.rb +24 -17
- data/spec/rails_best_practices/reviews/remove_empty_helpers_review_spec.rb +6 -6
- data/spec/rails_best_practices/reviews/remove_unused_methods_in_controllers_review_spec.rb +64 -31
- data/spec/rails_best_practices/reviews/remove_unused_methods_in_helpers_review_spec.rb +21 -14
- data/spec/rails_best_practices/reviews/remove_unused_methods_in_models_review_spec.rb +57 -53
- data/spec/rails_best_practices/reviews/replace_complex_creation_with_factory_method_review_spec.rb +10 -8
- data/spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb +20 -14
- data/spec/rails_best_practices/reviews/restrict_auto_generated_routes_review_spec.rb +54 -31
- data/spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb +9 -9
- data/spec/rails_best_practices/reviews/simplify_render_in_views_review_spec.rb +13 -13
- data/spec/rails_best_practices/reviews/use_before_filter_review_spec.rb +11 -9
- data/spec/rails_best_practices/reviews/use_model_association_review_spec.rb +7 -7
- data/spec/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review_spec.rb +35 -31
- data/spec/rails_best_practices/reviews/use_observer_review_spec.rb +6 -6
- data/spec/rails_best_practices/reviews/use_parentheses_in_method_def_review_spec.rb +10 -8
- data/spec/rails_best_practices/reviews/use_query_attribute_review_spec.rb +31 -24
- data/spec/rails_best_practices/reviews/use_say_with_time_in_migrations_review_spec.rb +15 -11
- data/spec/rails_best_practices/reviews/use_scope_access_review_spec.rb +14 -14
- data/spec/rails_best_practices/reviews/use_turbo_sprockets_rails3_review_spec.rb +61 -59
- metadata +16 -18
@@ -5,9 +5,9 @@ require 'spec_helper'
|
|
5
5
|
module RailsBestPractices
|
6
6
|
module Reviews
|
7
7
|
describe UseSayWithTimeInMigrationsReview do
|
8
|
-
let(:runner) { Core::Runner.new(reviews:
|
8
|
+
let(:runner) { Core::Runner.new(reviews: described_class.new) }
|
9
9
|
|
10
|
-
it '
|
10
|
+
it 'uses say with time in migrations' do
|
11
11
|
content = <<-EOF
|
12
12
|
def self.up
|
13
13
|
User.find_each do |user|
|
@@ -18,10 +18,12 @@ module RailsBestPractices
|
|
18
18
|
EOF
|
19
19
|
runner.review('db/migrate/20101010080658_update_users.rb', content)
|
20
20
|
expect(runner.errors.size).to eq(1)
|
21
|
-
expect(runner.errors[0].to_s).to eq(
|
21
|
+
expect(runner.errors[0].to_s).to eq(
|
22
|
+
'db/migrate/20101010080658_update_users.rb:2 - use say with time in migrations'
|
23
|
+
)
|
22
24
|
end
|
23
25
|
|
24
|
-
it '
|
26
|
+
it 'uses say with time in migrations with create_table' do
|
25
27
|
content = <<-EOF
|
26
28
|
def self.up
|
27
29
|
create_table :users do |t|
|
@@ -37,10 +39,12 @@ module RailsBestPractices
|
|
37
39
|
EOF
|
38
40
|
runner.review('db/migrate/20101010080658_update_users.rb', content)
|
39
41
|
expect(runner.errors.size).to eq(1)
|
40
|
-
expect(runner.errors[0].to_s).to eq(
|
42
|
+
expect(runner.errors[0].to_s).to eq(
|
43
|
+
'db/migrate/20101010080658_update_users.rb:7 - use say with time in migrations'
|
44
|
+
)
|
41
45
|
end
|
42
46
|
|
43
|
-
it '
|
47
|
+
it 'does not use say with time in migrations' do
|
44
48
|
content = <<-EOF
|
45
49
|
def self.up
|
46
50
|
say_with_time("Initialize first_name and last_name for users") do
|
@@ -56,7 +60,7 @@ module RailsBestPractices
|
|
56
60
|
expect(runner.errors.size).to eq(0)
|
57
61
|
end
|
58
62
|
|
59
|
-
it '
|
63
|
+
it 'does not use say with time in migrations when not first code line' do
|
60
64
|
content = <<-EOF
|
61
65
|
def self.up
|
62
66
|
User.find_each do |user|
|
@@ -70,7 +74,7 @@ module RailsBestPractices
|
|
70
74
|
expect(runner.errors.size).to eq(0)
|
71
75
|
end
|
72
76
|
|
73
|
-
it '
|
77
|
+
it 'does not use say with time when default migration message' do
|
74
78
|
content = <<-EOF
|
75
79
|
def self.up
|
76
80
|
create_table :users do |t|
|
@@ -84,7 +88,7 @@ module RailsBestPractices
|
|
84
88
|
expect(runner.errors.size).to eq(0)
|
85
89
|
end
|
86
90
|
|
87
|
-
it '
|
91
|
+
it 'does not raise an error' do
|
88
92
|
content = <<-EOF
|
89
93
|
class AddAdmin < ActiveRecord::Migration
|
90
94
|
|
@@ -120,8 +124,8 @@ module RailsBestPractices
|
|
120
124
|
expect(runner.errors.size).to eq(3)
|
121
125
|
end
|
122
126
|
|
123
|
-
it '
|
124
|
-
runner = Core::Runner.new(reviews:
|
127
|
+
it 'does not check ignored files' do
|
128
|
+
runner = Core::Runner.new(reviews: described_class.new(ignored_files: /20101010080658_update_users/))
|
125
129
|
content = <<-EOF
|
126
130
|
def self.up
|
127
131
|
User.find_each do |user|
|
@@ -5,10 +5,10 @@ require 'spec_helper'
|
|
5
5
|
module RailsBestPractices
|
6
6
|
module Reviews
|
7
7
|
describe UseScopeAccessReview do
|
8
|
-
let(:runner) { Core::Runner.new(reviews:
|
8
|
+
let(:runner) { Core::Runner.new(reviews: described_class.new) }
|
9
9
|
|
10
10
|
context 'if' do
|
11
|
-
it '
|
11
|
+
it 'uses scope access' do
|
12
12
|
content = <<-EOF
|
13
13
|
class PostsController < ApplicationController
|
14
14
|
def edit
|
@@ -26,7 +26,7 @@ module RailsBestPractices
|
|
26
26
|
expect(runner.errors[0].to_s).to eq('app/controllers/posts_controller.rb:5 - use scope access')
|
27
27
|
end
|
28
28
|
|
29
|
-
it '
|
29
|
+
it 'uses scope access with if in one line' do
|
30
30
|
content = <<-EOF
|
31
31
|
class PostsController < ApplicationController
|
32
32
|
def edit
|
@@ -41,7 +41,7 @@ module RailsBestPractices
|
|
41
41
|
expect(runner.errors[0].to_s).to eq('app/controllers/posts_controller.rb:5 - use scope access')
|
42
42
|
end
|
43
43
|
|
44
|
-
it "
|
44
|
+
it "uses scope access with '? :'" do
|
45
45
|
content = <<-EOF
|
46
46
|
class PostsController < ApplicationController
|
47
47
|
def edit
|
@@ -56,7 +56,7 @@ module RailsBestPractices
|
|
56
56
|
expect(runner.errors[0].to_s).to eq('app/controllers/posts_controller.rb:5 - use scope access')
|
57
57
|
end
|
58
58
|
|
59
|
-
it '
|
59
|
+
it 'uses scope access by comparing with id' do
|
60
60
|
content = <<-EOF
|
61
61
|
class PostsController < ApplicationController
|
62
62
|
def edit
|
@@ -74,7 +74,7 @@ module RailsBestPractices
|
|
74
74
|
expect(runner.errors[0].to_s).to eq('app/controllers/posts_controller.rb:5 - use scope access')
|
75
75
|
end
|
76
76
|
|
77
|
-
it '
|
77
|
+
it 'uses scope access with current_user ==' do
|
78
78
|
content = <<-EOF
|
79
79
|
class PostsController < ApplicationController
|
80
80
|
def edit
|
@@ -92,7 +92,7 @@ module RailsBestPractices
|
|
92
92
|
expect(runner.errors[0].to_s).to eq('app/controllers/posts_controller.rb:5 - use scope access')
|
93
93
|
end
|
94
94
|
|
95
|
-
it '
|
95
|
+
it 'uses scope access by current_user.id ==' do
|
96
96
|
content = <<-EOF
|
97
97
|
class PostsController < ApplicationController
|
98
98
|
def edit
|
@@ -112,7 +112,7 @@ module RailsBestPractices
|
|
112
112
|
end
|
113
113
|
|
114
114
|
context 'unless' do
|
115
|
-
it '
|
115
|
+
it 'uses scope access' do
|
116
116
|
content = <<-EOF
|
117
117
|
class PostsController < ApplicationController
|
118
118
|
def edit
|
@@ -130,7 +130,7 @@ module RailsBestPractices
|
|
130
130
|
expect(runner.errors[0].to_s).to eq('app/controllers/posts_controller.rb:5 - use scope access')
|
131
131
|
end
|
132
132
|
|
133
|
-
it '
|
133
|
+
it 'uses scope access by comparing with id' do
|
134
134
|
content = <<-EOF
|
135
135
|
class PostsController < ApplicationController
|
136
136
|
def edit
|
@@ -148,7 +148,7 @@ module RailsBestPractices
|
|
148
148
|
expect(runner.errors[0].to_s).to eq('app/controllers/posts_controller.rb:5 - use scope access')
|
149
149
|
end
|
150
150
|
|
151
|
-
it '
|
151
|
+
it 'uses scope access with current_user ==' do
|
152
152
|
content = <<-EOF
|
153
153
|
class PostsController < ApplicationController
|
154
154
|
def edit
|
@@ -166,7 +166,7 @@ module RailsBestPractices
|
|
166
166
|
expect(runner.errors[0].to_s).to eq('app/controllers/posts_controller.rb:5 - use scope access')
|
167
167
|
end
|
168
168
|
|
169
|
-
it '
|
169
|
+
it 'uses scope access by current_user.id ==' do
|
170
170
|
content = <<-EOF
|
171
171
|
class PostsController < ApplicationController
|
172
172
|
def edit
|
@@ -184,7 +184,7 @@ module RailsBestPractices
|
|
184
184
|
expect(runner.errors[0].to_s).to eq('app/controllers/posts_controller.rb:5 - use scope access')
|
185
185
|
end
|
186
186
|
|
187
|
-
it '
|
187
|
+
it 'noes error in use_scope_access_review' do
|
188
188
|
content = <<-EOF
|
189
189
|
class CommentsController < ApplicationController
|
190
190
|
def add_comment
|
@@ -206,8 +206,8 @@ module RailsBestPractices
|
|
206
206
|
expect(runner.errors.size).to eq(0)
|
207
207
|
end
|
208
208
|
|
209
|
-
it '
|
210
|
-
runner = Core::Runner.new(reviews:
|
209
|
+
it 'does not check ignored files' do
|
210
|
+
runner = Core::Runner.new(reviews: described_class.new(ignored_files: /posts_controller/))
|
211
211
|
content = <<-EOF
|
212
212
|
class PostsController < ApplicationController
|
213
213
|
def edit
|
@@ -5,21 +5,21 @@ require 'spec_helper'
|
|
5
5
|
module RailsBestPractices
|
6
6
|
module Reviews
|
7
7
|
describe UseTurboSprocketsRails3Review do
|
8
|
-
let(:runner) { Core::Runner.new(prepares: Prepares::GemfilePrepare.new, reviews:
|
8
|
+
let(:runner) { Core::Runner.new(prepares: Prepares::GemfilePrepare.new, reviews: described_class.new) }
|
9
9
|
|
10
|
-
it '
|
11
|
-
content =
|
12
|
-
GEM
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
10
|
+
it 'uses turbo-sprockets-rails3' do
|
11
|
+
content = <<~EOF
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org
|
14
|
+
specs:
|
15
|
+
rails (3.2.13)
|
16
|
+
actionmailer (= 3.2.13)
|
17
|
+
actionpack (= 3.2.13)
|
18
|
+
activerecord (= 3.2.13)
|
19
|
+
activeresource (= 3.2.13)
|
20
|
+
activesupport (= 3.2.13)
|
21
|
+
bundler (~> 1.0)
|
22
|
+
railties (= 3.2.13)
|
23
23
|
EOF
|
24
24
|
runner.prepare('Gemfile.lock', content)
|
25
25
|
content = <<-EOF
|
@@ -32,22 +32,22 @@ GEM
|
|
32
32
|
expect(runner.errors[0].to_s).to eq('Capfile:2 - speed up assets precompile with turbo-sprockets-rails3')
|
33
33
|
end
|
34
34
|
|
35
|
-
it '
|
36
|
-
content =
|
37
|
-
GEM
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
35
|
+
it 'does not use turbo-sprockets-rails3 with turbo-sprockets-rails3 gem' do
|
36
|
+
content = <<~EOF
|
37
|
+
GEM
|
38
|
+
remote: https://rubygems.org
|
39
|
+
specs:
|
40
|
+
rails (3.2.13)
|
41
|
+
actionmailer (= 3.2.13)
|
42
|
+
actionpack (= 3.2.13)
|
43
|
+
activerecord (= 3.2.13)
|
44
|
+
activeresource (= 3.2.13)
|
45
|
+
activesupport (= 3.2.13)
|
46
|
+
bundler (~> 1.0)
|
47
|
+
railties (= 3.2.13)
|
48
|
+
turbo-sprockets-rails3 (0.3.6)
|
49
|
+
railties (> 3.2.8, < 4.0.0)
|
50
|
+
sprockets (>= 2.0.0)
|
51
51
|
EOF
|
52
52
|
runner.prepare('Gemfile.lock', content)
|
53
53
|
content = <<-EOF
|
@@ -59,7 +59,7 @@ GEM
|
|
59
59
|
expect(runner.errors.size).to eq(0)
|
60
60
|
end
|
61
61
|
|
62
|
-
it '
|
62
|
+
it 'does not use turbo-sprockets-rails3 without deploy/assets' do
|
63
63
|
content = <<-EOF
|
64
64
|
load 'deploy' if respond_to?(:namespace)
|
65
65
|
#load 'deploy/assets'
|
@@ -69,19 +69,19 @@ GEM
|
|
69
69
|
expect(runner.errors.size).to eq(0)
|
70
70
|
end
|
71
71
|
|
72
|
-
it '
|
73
|
-
content =
|
74
|
-
GEM
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
72
|
+
it 'does not use turbo-sprockets-rails3 with rails4 gem' do
|
73
|
+
content = <<~EOF
|
74
|
+
GEM
|
75
|
+
remote: https://rubygems.org
|
76
|
+
specs:
|
77
|
+
rails (4.0.0)
|
78
|
+
actionmailer (= 4.0.0)
|
79
|
+
actionpack (= 4.0.0)
|
80
|
+
activerecord (= 4.0.0)
|
81
|
+
activeresource (= 4.0.0)
|
82
|
+
activesupport (= 4.0.0)
|
83
|
+
bundler (~> 1.0)
|
84
|
+
railties (= 3.2.13)
|
85
85
|
EOF
|
86
86
|
runner.prepare('Gemfile.lock', content)
|
87
87
|
content = <<-EOF
|
@@ -93,21 +93,23 @@ GEM
|
|
93
93
|
expect(runner.errors.size).to eq(0)
|
94
94
|
end
|
95
95
|
|
96
|
-
it '
|
97
|
-
runner =
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
96
|
+
it 'does not check ignored files' do
|
97
|
+
runner =
|
98
|
+
Core::Runner.new(
|
99
|
+
prepares: Prepares::GemfilePrepare.new, reviews: described_class.new(ignored_files: /Capfile/)
|
100
|
+
)
|
101
|
+
content = <<~EOF
|
102
|
+
GEM
|
103
|
+
remote: https://rubygems.org
|
104
|
+
specs:
|
105
|
+
rails (3.2.13)
|
106
|
+
actionmailer (= 3.2.13)
|
107
|
+
actionpack (= 3.2.13)
|
108
|
+
activerecord (= 3.2.13)
|
109
|
+
activeresource (= 3.2.13)
|
110
|
+
activesupport (= 3.2.13)
|
111
|
+
bundler (~> 1.0)
|
112
|
+
railties (= 3.2.13)
|
111
113
|
EOF
|
112
114
|
runner.prepare('Gemfile.lock', content)
|
113
115
|
content = <<-EOF
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.20.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.5.2
|
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.
|
40
|
+
version: 0.5.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: erubis
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '3.0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '3.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: ruby-progressbar
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,16 +154,16 @@ dependencies:
|
|
154
154
|
name: rake
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - "
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
159
|
+
version: '0'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - "
|
164
|
+
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
166
|
+
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: rspec
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -205,6 +205,7 @@ files:
|
|
205
205
|
- ".travis.yml"
|
206
206
|
- CHANGELOG.md
|
207
207
|
- Gemfile
|
208
|
+
- Gemfile.lock
|
208
209
|
- Guardfile
|
209
210
|
- MIT_LICENSE
|
210
211
|
- README.md
|
@@ -213,6 +214,7 @@ files:
|
|
213
214
|
- bin/rails_best_practices
|
214
215
|
- lib/rails_best_practices.rb
|
215
216
|
- lib/rails_best_practices/analyzer.rb
|
217
|
+
- lib/rails_best_practices/cli.rb
|
216
218
|
- lib/rails_best_practices/colorize.rb
|
217
219
|
- lib/rails_best_practices/command.rb
|
218
220
|
- lib/rails_best_practices/core.rb
|
@@ -237,6 +239,7 @@ files:
|
|
237
239
|
- lib/rails_best_practices/lexicals/long_line_check.rb
|
238
240
|
- lib/rails_best_practices/lexicals/remove_tab_check.rb
|
239
241
|
- lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb
|
242
|
+
- lib/rails_best_practices/option_parser.rb
|
240
243
|
- lib/rails_best_practices/prepares.rb
|
241
244
|
- lib/rails_best_practices/prepares/config_prepare.rb
|
242
245
|
- lib/rails_best_practices/prepares/controller_prepare.rb
|
@@ -376,10 +379,6 @@ post_install_message: |
|
|
376
379
|
|
377
380
|
http://rails-bestpractices.com
|
378
381
|
|
379
|
-
Please also try our online service
|
380
|
-
|
381
|
-
http://railsbp.com
|
382
|
-
|
383
382
|
Enjoy!
|
384
383
|
|
385
384
|
Richard Huang (flyerhzm@gmail.com)
|
@@ -400,9 +399,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
400
399
|
- !ruby/object:Gem::Version
|
401
400
|
version: 1.3.6
|
402
401
|
requirements: []
|
403
|
-
|
404
|
-
|
405
|
-
signing_key:
|
402
|
+
rubygems_version: 3.1.6
|
403
|
+
signing_key:
|
406
404
|
specification_version: 4
|
407
405
|
summary: a code metric tool for rails codes.
|
408
406
|
test_files:
|