rails_best_practices 0.2.16 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
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 based on ruby_parser.
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.2.16
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
- @methods[first_call] ||= []
32
- @methods[first_call] << method_name
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
- puts "\nFound #{runner.errors.size} errors."
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rails_best_practices}
8
- s.version = "0.2.16"
8
+ s.version = "0.3.0"
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"]
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_best_practices
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.16
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang