rails_best_practices 0.3.26 → 0.3.27
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.27
|
@@ -40,13 +40,15 @@ module RailsBestPractices
|
|
40
40
|
def find_index_columns(node)
|
41
41
|
node.grep_nodes({:node_type => :call, :message => :add_index}).each do |index_node|
|
42
42
|
table_name = index_node.arguments[1].to_ruby_string
|
43
|
-
|
44
|
-
@index_columns << [table_name,
|
43
|
+
reference_column = eval(index_node.arguments[2].to_ruby)
|
44
|
+
@index_columns << [table_name, reference_column]
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
def indexed?(table_name, column_name)
|
49
|
-
!!@index_columns.find
|
49
|
+
!!@index_columns.find do |reference|
|
50
|
+
reference[0] == table_name and reference[1].class == String ? reference[1] == column_name : reference[1].include?(column_name)
|
51
|
+
end
|
50
52
|
end
|
51
53
|
end
|
52
54
|
end
|
@@ -14,6 +14,11 @@ OptionParser.new do |opts|
|
|
14
14
|
options[pattern] = true
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
opts.on_tail('-v', '--version', 'Show this version') do
|
19
|
+
puts File.read(File.dirname(__FILE__) + '/../../VERSION')
|
20
|
+
exit
|
21
|
+
end
|
17
22
|
|
18
23
|
opts.on_tail("-h", "--help", "Show this message") do
|
19
24
|
puts opts
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rails_best_practices}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.27"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Richard Huang"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-08-13}
|
13
13
|
s.default_executable = %q{rails_best_practices}
|
14
14
|
s.description = %q{a code metric tool for rails codes.}
|
15
15
|
s.email = %q{flyerhzm@gmail.com}
|
@@ -91,28 +91,28 @@ Gem::Specification.new do |s|
|
|
91
91
|
s.rubygems_version = %q{1.3.6}
|
92
92
|
s.summary = %q{a code metric tool for rails codes.}
|
93
93
|
s.test_files = [
|
94
|
-
"spec/rails_best_practices/checks/
|
95
|
-
"spec/rails_best_practices/checks/move_model_logic_into_model_check_spec.rb",
|
96
|
-
"spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb",
|
97
|
-
"spec/rails_best_practices/checks/move_code_into_controller_check_spec.rb",
|
98
|
-
"spec/rails_best_practices/checks/use_observer_check_spec.rb",
|
99
|
-
"spec/rails_best_practices/checks/overuse_route_customizations_check_spec.rb",
|
100
|
-
"spec/rails_best_practices/checks/nested_model_forms_check_spec.rb",
|
94
|
+
"spec/rails_best_practices/checks/add_model_virtual_attribute_check_spec.rb",
|
101
95
|
"spec/rails_best_practices/checks/always_add_db_index_check_spec.rb",
|
102
|
-
"spec/rails_best_practices/checks/
|
103
|
-
"spec/rails_best_practices/checks/
|
96
|
+
"spec/rails_best_practices/checks/isolate_seed_data_check_spec.rb",
|
97
|
+
"spec/rails_best_practices/checks/keep_finders_on_their_own_model_check_spec.rb",
|
104
98
|
"spec/rails_best_practices/checks/law_of_demeter_check_spec.rb",
|
105
|
-
"spec/rails_best_practices/checks/
|
106
|
-
"spec/rails_best_practices/checks/
|
107
|
-
"spec/rails_best_practices/checks/
|
99
|
+
"spec/rails_best_practices/checks/many_to_many_collection_check_spec.rb",
|
100
|
+
"spec/rails_best_practices/checks/move_code_into_controller_check_spec.rb",
|
101
|
+
"spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb",
|
102
|
+
"spec/rails_best_practices/checks/move_code_into_model_check_spec.rb",
|
108
103
|
"spec/rails_best_practices/checks/move_finder_to_named_scope_check_spec.rb",
|
109
|
-
"spec/rails_best_practices/checks/
|
110
|
-
"spec/rails_best_practices/checks/
|
104
|
+
"spec/rails_best_practices/checks/move_model_logic_into_model_check_spec.rb",
|
105
|
+
"spec/rails_best_practices/checks/needless_deep_nesting_check_spec.rb",
|
106
|
+
"spec/rails_best_practices/checks/nested_model_forms_check_spec.rb",
|
107
|
+
"spec/rails_best_practices/checks/not_use_default_route_check_spec.rb",
|
108
|
+
"spec/rails_best_practices/checks/overuse_route_customizations_check_spec.rb",
|
109
|
+
"spec/rails_best_practices/checks/replace_complex_creation_with_factory_method_check_spec.rb",
|
111
110
|
"spec/rails_best_practices/checks/replace_instance_variable_with_local_variable_check_spec.rb",
|
111
|
+
"spec/rails_best_practices/checks/use_before_filter_check_spec.rb",
|
112
112
|
"spec/rails_best_practices/checks/use_model_association_check_spec.rb",
|
113
|
-
"spec/rails_best_practices/checks/
|
114
|
-
"spec/rails_best_practices/checks/
|
115
|
-
"spec/rails_best_practices/checks/
|
113
|
+
"spec/rails_best_practices/checks/use_model_callback_check_spec.rb",
|
114
|
+
"spec/rails_best_practices/checks/use_observer_check_spec.rb",
|
115
|
+
"spec/rails_best_practices/checks/use_scope_access_check_spec.rb",
|
116
116
|
"spec/spec_helper.rb"
|
117
117
|
]
|
118
118
|
|
@@ -53,4 +53,21 @@ describe RailsBestPractices::Checks::AlwaysAddDbIndexCheck do
|
|
53
53
|
errors = @runner.errors
|
54
54
|
errors.should be_empty
|
55
55
|
end
|
56
|
+
|
57
|
+
it "should not always add db index with multi-column index" do
|
58
|
+
content = <<-EOF
|
59
|
+
ActiveRecord::Schema.define(:version => 20100603080629) do
|
60
|
+
create_table "versions", :force => true do |t|
|
61
|
+
t.integer "versioned_id"
|
62
|
+
t.string "versioned_type"
|
63
|
+
t.string "tag"
|
64
|
+
end
|
65
|
+
|
66
|
+
add_index "versions", ["versioned_id", "versioned_type"], :name => "index_versions_on_versioned_id_and_versioned_type"
|
67
|
+
end
|
68
|
+
EOF
|
69
|
+
@runner.check('db/schema.rb', content)
|
70
|
+
errors = @runner.errors
|
71
|
+
errors.should be_empty
|
72
|
+
end
|
56
73
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 27
|
9
|
+
version: 0.3.27
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Richard Huang
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-08-13 00:00:00 +08:00
|
18
18
|
default_executable: rails_best_practices
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -151,26 +151,26 @@ signing_key:
|
|
151
151
|
specification_version: 3
|
152
152
|
summary: a code metric tool for rails codes.
|
153
153
|
test_files:
|
154
|
+
- spec/rails_best_practices/checks/add_model_virtual_attribute_check_spec.rb
|
155
|
+
- spec/rails_best_practices/checks/always_add_db_index_check_spec.rb
|
154
156
|
- spec/rails_best_practices/checks/isolate_seed_data_check_spec.rb
|
155
|
-
- spec/rails_best_practices/checks/
|
156
|
-
- spec/rails_best_practices/checks/
|
157
|
+
- spec/rails_best_practices/checks/keep_finders_on_their_own_model_check_spec.rb
|
158
|
+
- spec/rails_best_practices/checks/law_of_demeter_check_spec.rb
|
159
|
+
- spec/rails_best_practices/checks/many_to_many_collection_check_spec.rb
|
157
160
|
- spec/rails_best_practices/checks/move_code_into_controller_check_spec.rb
|
158
|
-
- spec/rails_best_practices/checks/
|
159
|
-
- spec/rails_best_practices/checks/
|
161
|
+
- spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
|
162
|
+
- spec/rails_best_practices/checks/move_code_into_model_check_spec.rb
|
163
|
+
- spec/rails_best_practices/checks/move_finder_to_named_scope_check_spec.rb
|
164
|
+
- spec/rails_best_practices/checks/move_model_logic_into_model_check_spec.rb
|
165
|
+
- spec/rails_best_practices/checks/needless_deep_nesting_check_spec.rb
|
160
166
|
- spec/rails_best_practices/checks/nested_model_forms_check_spec.rb
|
161
|
-
- spec/rails_best_practices/checks/always_add_db_index_check_spec.rb
|
162
|
-
- spec/rails_best_practices/checks/many_to_many_collection_check_spec.rb
|
163
|
-
- spec/rails_best_practices/checks/use_before_filter_check_spec.rb
|
164
|
-
- spec/rails_best_practices/checks/law_of_demeter_check_spec.rb
|
165
|
-
- spec/rails_best_practices/checks/use_scope_access_check_spec.rb
|
166
|
-
- spec/rails_best_practices/checks/replace_complex_creation_with_factory_method_check_spec.rb
|
167
167
|
- spec/rails_best_practices/checks/not_use_default_route_check_spec.rb
|
168
|
-
- spec/rails_best_practices/checks/
|
169
|
-
- spec/rails_best_practices/checks/
|
170
|
-
- spec/rails_best_practices/checks/add_model_virtual_attribute_check_spec.rb
|
168
|
+
- spec/rails_best_practices/checks/overuse_route_customizations_check_spec.rb
|
169
|
+
- spec/rails_best_practices/checks/replace_complex_creation_with_factory_method_check_spec.rb
|
171
170
|
- spec/rails_best_practices/checks/replace_instance_variable_with_local_variable_check_spec.rb
|
171
|
+
- spec/rails_best_practices/checks/use_before_filter_check_spec.rb
|
172
172
|
- spec/rails_best_practices/checks/use_model_association_check_spec.rb
|
173
|
-
- spec/rails_best_practices/checks/
|
174
|
-
- spec/rails_best_practices/checks/
|
175
|
-
- spec/rails_best_practices/checks/
|
173
|
+
- spec/rails_best_practices/checks/use_model_callback_check_spec.rb
|
174
|
+
- spec/rails_best_practices/checks/use_observer_check_spec.rb
|
175
|
+
- spec/rails_best_practices/checks/use_scope_access_check_spec.rb
|
176
176
|
- spec/spec_helper.rb
|