rails_best_practices 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rails_best_practices/checks/always_add_db_index_check.rb +7 -7
- data/lib/rails_best_practices/checks/law_of_demeter_check.rb +1 -1
- data/lib/rails_best_practices/checks/use_observer_check.rb +1 -1
- data/lib/rails_best_practices/core/visitable_sexp.rb +5 -0
- data/rails_best_practices.gemspec +4 -3
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.9
|
@@ -51,22 +51,22 @@ module RailsBestPractices
|
|
51
51
|
def remember_references(node)
|
52
52
|
create_table_node = node.grep_nodes({:node_type => :call, :message => :create_table}).first
|
53
53
|
if create_table_node
|
54
|
-
table_name =
|
54
|
+
table_name = create_table_node.arguments[1].to_ruby_string
|
55
55
|
node.grep_nodes({:node_type => :call, :message => :integer}).each do |integer_node|
|
56
|
-
column_name =
|
56
|
+
column_name = integer_node.arguments[1].to_ruby_string
|
57
57
|
if column_name =~ /_id$/
|
58
58
|
@references[table_name] ||= []
|
59
59
|
@references[table_name] << column_name
|
60
60
|
end
|
61
61
|
end
|
62
62
|
node.grep_nodes({:node_type => :call, :message => :references}).each do |references_node|
|
63
|
-
column_name =
|
63
|
+
column_name = references_node.arguments[1].to_ruby_string + "_id"
|
64
64
|
@references[table_name] ||= []
|
65
65
|
@references[table_name] << column_name
|
66
66
|
end
|
67
67
|
node.grep_nodes({:node_type => :call, :message => :column}).each do |column_node|
|
68
|
-
if 'integer' ==
|
69
|
-
column_name =
|
68
|
+
if 'integer' == column_node.arguments[2].to_ruby_string
|
69
|
+
column_name = column_node.arguments[1].to_ruby_string
|
70
70
|
if column_name =~ /_id$/
|
71
71
|
@references[table_name] ||= []
|
72
72
|
@references[table_name] << column_name
|
@@ -79,8 +79,8 @@ module RailsBestPractices
|
|
79
79
|
def remember_indexes(node)
|
80
80
|
add_index_nodes = node.grep_nodes({:node_type => :call, :message => :add_index})
|
81
81
|
add_index_nodes.each do |add_index_node|
|
82
|
-
table_name =
|
83
|
-
column_name =
|
82
|
+
table_name = add_index_node.arguments[1].to_ruby_string
|
83
|
+
column_name = add_index_node.arguments[2].to_ruby_string
|
84
84
|
@indexes[table_name] ||= []
|
85
85
|
@indexes[table_name] << column_name
|
86
86
|
end
|
@@ -32,7 +32,7 @@ module RailsBestPractices
|
|
32
32
|
node.body.grep_nodes(:message => :belongs_to).collect do |body_node|
|
33
33
|
class_name = node.subject.to_s.underscore
|
34
34
|
@associations[class_name] ||= []
|
35
|
-
@associations[class_name] <<
|
35
|
+
@associations[class_name] << body_node.arguments[1].to_ruby_string
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rails_best_practices}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.9"
|
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"]
|
@@ -116,3 +116,4 @@ Gem::Specification.new do |s|
|
|
116
116
|
s.add_dependency(%q<ruby2ruby>, [">= 0"])
|
117
117
|
end
|
118
118
|
end
|
119
|
+
|