rails_best_practices 0.2.16 → 0.3.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.
data/README.textile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
h1. rails_best_practices
|
2
2
|
|
3
|
-
rails_best_practices is a gem to check quality of rails app files according to ihower's presentation Rails Best Practices.
|
4
|
-
rails_best_practices is a code static parser tool
|
3
|
+
rails_best_practices is a gem to check quality of rails app files according to ihower's presentation Rails Best Practices from Kungfu RailsConf in Shanghai China.
|
4
|
+
rails_best_practices is a code static parser tool.
|
5
5
|
|
6
6
|
*************************************************
|
7
7
|
|
@@ -104,8 +104,8 @@ h2. Progress
|
|
104
104
|
## Move code into model
|
105
105
|
## [-Move code into helper-]
|
106
106
|
## [-Replace instance variable with local variable-]
|
107
|
-
## Use Form Builder
|
108
|
-
## Organize Helper files
|
107
|
+
## [-Use Form Builder-] # not implement, use http://github.com/justinfrench/formtastic
|
108
|
+
## [-Organize Helper files-] # not implement, it's rails default behaviour
|
109
109
|
|
110
110
|
*************************************************
|
111
111
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -28,8 +28,10 @@ module RailsBestPractices
|
|
28
28
|
def remember_method(method_node)
|
29
29
|
method_name = method_node.message_name
|
30
30
|
first_call = method_node.body[1]
|
31
|
-
|
32
|
-
|
31
|
+
unless first_call == s(:nil)
|
32
|
+
@methods[first_call] ||= []
|
33
|
+
@methods[first_call] << method_name
|
34
|
+
end
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
@@ -69,6 +69,9 @@ end
|
|
69
69
|
files.each { |file| runner.check_file(file) }
|
70
70
|
|
71
71
|
runner.errors.each {|error| puts error}
|
72
|
-
|
72
|
+
if runner.errors.size > 0
|
73
|
+
puts "\ngo to http://wiki.github.com/flyerhzm/rails_best_practices to see how to solve these errors."
|
74
|
+
puts "\nFound #{runner.errors.size} errors."
|
75
|
+
end
|
73
76
|
|
74
77
|
exit runner.errors.size
|
@@ -59,4 +59,27 @@ describe RailsBestPractices::Checks::UseFilterCheck do
|
|
59
59
|
errors = @runner.errors
|
60
60
|
errors.should be_empty
|
61
61
|
end
|
62
|
+
|
63
|
+
it "should not use filter by nil" do
|
64
|
+
content = <<-EOF
|
65
|
+
class PostsController < ApplicationController
|
66
|
+
|
67
|
+
def show
|
68
|
+
end
|
69
|
+
|
70
|
+
def edit
|
71
|
+
end
|
72
|
+
|
73
|
+
def update
|
74
|
+
end
|
75
|
+
|
76
|
+
def destroy
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
EOF
|
81
|
+
@runner.check('app/controllers/posts_controller.rb', content)
|
82
|
+
errors = @runner.errors
|
83
|
+
errors.should be_empty
|
84
|
+
end
|
62
85
|
end
|