rails_best_practices 0.3.24 → 0.3.25

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -22,8 +22,8 @@ end
22
22
 
23
23
  Jeweler::Tasks.new do |gemspec|
24
24
  gemspec.name = "rails_best_practices"
25
- gemspec.summary = "check rails files according to ihower's presentation 'rails best practices'"
26
- gemspec.description = "check rails files according to ihower's presentation 'rails best practices'"
25
+ gemspec.summary = "a code metric tool for rails codes.'"
26
+ gemspec.description = "a code metric tool for rails codes.'"
27
27
  gemspec.email = "flyerhzm@gmail.com"
28
28
  gemspec.homepage = "http://rails-bestpractices.com"
29
29
  gemspec.authors = ["Richard Huang"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.24
1
+ 0.3.25
@@ -7,7 +7,6 @@ module RailsBestPractices
7
7
  def analyze_files(dir = '.', options = {})
8
8
  files = expand_dirs_to_files(dir)
9
9
  files = model_first_sort(files)
10
- files = add_duplicate_migrations(files)
11
10
  ['vendor', 'spec', 'test', 'stories', 'features'].each do |pattern|
12
11
  files = ignore_files(files, "#{pattern}/") unless options[pattern]
13
12
  end
@@ -39,14 +38,8 @@ module RailsBestPractices
39
38
  }
40
39
  end
41
40
 
42
- # for always_add_db_index_check
43
- def add_duplicate_migrations files
44
- migration_files = files.select { |file| file.index("db/migrate") }
45
- (files << migration_files).flatten
46
- end
47
-
48
41
  def ignore_files files, pattern
49
42
  files.reject { |file| file.index(pattern) }
50
43
  end
51
44
  end
52
- end
45
+ end
@@ -8,7 +8,7 @@ module RailsBestPractices
8
8
  class IsolateSeedDataCheck < Check
9
9
 
10
10
  def interesting_nodes
11
- [:defs, :call, :lasgn]
11
+ [:call, :lasgn]
12
12
  end
13
13
 
14
14
  def interesting_files
@@ -18,28 +18,15 @@ module RailsBestPractices
18
18
  def initialize
19
19
  super
20
20
  @new_variables = []
21
- @files = []
22
- @parse = false
23
21
  end
24
22
 
25
23
  def evaluate_start(node)
26
- # check duplicate migration because of always_add_db_index_check.
27
- if :defs == node.node_type
28
- if @files.include? node.file
29
- @parse = true if :up == node.message
30
- else
31
- @files << node.file
32
- end
33
- end
34
-
35
- if @parse
36
- if [:create, :create!].include? node.message
37
- add_error("isolate seed data")
38
- elsif :lasgn == node.node_type
39
- remember_new_variable(node)
40
- elsif [:save, :save!].include? node.message
41
- add_error("isolate seed data") if new_record?(node)
42
- end
24
+ if [:create, :create!].include? node.message
25
+ add_error("isolate seed data")
26
+ elsif :lasgn == node.node_type
27
+ remember_new_variable(node)
28
+ elsif [:save, :save!].include? node.message
29
+ add_error("isolate seed data") if new_record?(node)
43
30
  end
44
31
  end
45
32
 
@@ -5,13 +5,13 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rails_best_practices}
8
- s.version = "0.3.24"
8
+ s.version = "0.3.25"
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
12
  s.date = %q{2010-07-25}
13
13
  s.default_executable = %q{rails_best_practices}
14
- s.description = %q{check rails files according to ihower's presentation 'rails best practices'}
14
+ s.description = %q{a code metric tool for rails codes.'}
15
15
  s.email = %q{flyerhzm@gmail.com}
16
16
  s.executables = ["rails_best_practices"]
17
17
  s.extra_rdoc_files = [
@@ -89,7 +89,7 @@ Gem::Specification.new do |s|
89
89
  s.rdoc_options = ["--charset=UTF-8"]
90
90
  s.require_paths = ["lib"]
91
91
  s.rubygems_version = %q{1.3.6}
92
- s.summary = %q{check rails files according to ihower's presentation 'rails best practices'}
92
+ s.summary = %q{a code metric tool for rails codes.'}
93
93
  s.test_files = [
94
94
  "spec/rails_best_practices/checks/isolate_seed_data_check_spec.rb",
95
95
  "spec/rails_best_practices/checks/move_model_logic_into_model_check_spec.rb",
@@ -24,7 +24,6 @@ describe RailsBestPractices::Checks::IsolateSeedDataCheck do
24
24
  end
25
25
  EOF
26
26
  @runner.check('db/migrate/20090818130258_create_roles.rb', content)
27
- @runner.check('db/migrate/20090818130258_create_roles.rb', content)
28
27
  errors = @runner.errors
29
28
  errors.should_not be_empty
30
29
  errors[0].to_s.should == "db/migrate/20090818130258_create_roles.rb:8 - isolate seed data"
@@ -51,7 +50,6 @@ describe RailsBestPractices::Checks::IsolateSeedDataCheck do
51
50
  end
52
51
  EOF
53
52
  @runner.check('db/migrate/20090818130258_create_roles.rb', content)
54
- @runner.check('db/migrate/20090818130258_create_roles.rb', content)
55
53
  errors = @runner.errors
56
54
  errors.should_not be_empty
57
55
  errors[0].to_s.should == "db/migrate/20090818130258_create_roles.rb:9 - isolate seed data"
@@ -72,7 +70,6 @@ describe RailsBestPractices::Checks::IsolateSeedDataCheck do
72
70
  end
73
71
  EOF
74
72
  @runner.check('db/migrate/20090818130258_create_roles.rb', content)
75
- @runner.check('db/migrate/20090818130258_create_roles.rb', content)
76
73
  errors = @runner.errors
77
74
  errors.should be_empty
78
75
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 24
9
- version: 0.3.24
8
+ - 25
9
+ version: 0.3.25
10
10
  platform: ruby
11
11
  authors:
12
12
  - Richard Huang
@@ -45,7 +45,7 @@ dependencies:
45
45
  version: 1.2.4
46
46
  type: :runtime
47
47
  version_requirements: *id002
48
- description: check rails files according to ihower's presentation 'rails best practices'
48
+ description: a code metric tool for rails codes.'
49
49
  email: flyerhzm@gmail.com
50
50
  executables:
51
51
  - rails_best_practices
@@ -149,7 +149,7 @@ rubyforge_project:
149
149
  rubygems_version: 1.3.6
150
150
  signing_key:
151
151
  specification_version: 3
152
- summary: check rails files according to ihower's presentation 'rails best practices'
152
+ summary: a code metric tool for rails codes.'
153
153
  test_files:
154
154
  - spec/rails_best_practices/checks/isolate_seed_data_check_spec.rb
155
155
  - spec/rails_best_practices/checks/move_model_logic_into_model_check_spec.rb