rails_best_practices 1.17.0 → 1.18.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0b67ef3e8abe665b14bf2dd398755f5b1d84e05
4
- data.tar.gz: 4ea8cfbcb9a26b10b070e86b2deac14e2f9ea751
3
+ metadata.gz: 4eb57bfb18f02e91c08dbfef14f970acc55e3a3a
4
+ data.tar.gz: f7f14c66689cf3cc3bd3a1efd7ea1b533b41d2c7
5
5
  SHA512:
6
- metadata.gz: c032c3904c6f27437c7b8be4a728c74ab543d6f14d1c2d620d8dac8dda029de46aa15f52c31b86d07e45dee2544f7165d991c7dc652731c7227e76970574eefe
7
- data.tar.gz: dada2172b41c479b90ec443f8a99a9a04bf68833ceea23b5f39ba5e9c572b8686797079c1c15eead93c2a7ea066fe40970f4257342055215574b804e6049e0a9
6
+ metadata.gz: d2d1f2d5ed8eb36cdcdfb3936c81c6e75eb50565751d3489dac9f36aa6575715f8044c9728a3c1a33171d476d099f86fcfe7486ee7480d01073c5bfcd61d9553
7
+ data.tar.gz: 22aa1432ef5b0ce38a69f9ea2b14344e967a00b1f7f2ddbcc4c67ba7ee67e3dd657ba176acdd492185ec980345c03ef4c063c3791a8fb06ae6ac345462cec28c
data/.rubocop_todo.yml CHANGED
@@ -71,7 +71,7 @@ Metrics/BlockNesting:
71
71
  # Offense count: 4
72
72
  # Configuration parameters: CountComments.
73
73
  Metrics/ClassLength:
74
- Max: 223
74
+ Max: 224
75
75
 
76
76
  # Offense count: 3
77
77
  Metrics/CyclomaticComplexity:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Next Release
2
2
 
3
+ ## 1.18.0 (2017-03-01)
4
+
5
+ * Add --config option
6
+
3
7
  ## 1.17.0 (2016-07-14)
4
8
 
5
9
  * Detect index option in column creation
data/README.md CHANGED
@@ -80,6 +80,7 @@ To see the full list of command-line options, run:
80
80
  -o, --only PATTERNS analyze files only matching a pattern
81
81
  (comma-separated regexp list)
82
82
  -g, --generate Generate configuration yaml
83
+ -c, --config CONFIG_PATH configuration file location (defaults to config/rails_best_practices.yml)
83
84
  -v, --version Show this version
84
85
  -h, --help Show this message
85
86
 
@@ -113,6 +114,12 @@ or add it to the Gemfile
113
114
 
114
115
  Install <https://github.com/asuth/subl-handler>
115
116
 
117
+ ## Editor Integration
118
+
119
+ #### TextMate 2
120
+
121
+ If you use `TextMate 2`, you can install the [RailsBestPractices.tmbundle](https://github.com/jjuliano/RailsBestPractices.tmbundle) bundle.
122
+
116
123
  ## Issues
117
124
 
118
125
  If you install the rails_best_practices with bundler-installed GitHub-sourced gem, please use the following command instead.
@@ -138,6 +145,7 @@ Now you can customize this configuration file. The default configuration is as f
138
145
  AddModelVirtualAttributeCheck: { }
139
146
  AlwaysAddDbIndexCheck: { }
140
147
  #CheckSaveReturnValueCheck: { }
148
+ #CheckDestroyReturnValueCheck: { }
141
149
  DefaultScopeIsEvilCheck: { }
142
150
  DryBundlerInCapistranoCheck: { }
143
151
  #HashSyntaxCheck: { }
@@ -152,12 +160,12 @@ Now you can customize this configuration file. The default configuration is as f
152
160
  MoveModelLogicIntoModelCheck: { use_count: 4 }
153
161
  NeedlessDeepNestingCheck: { nested_count: 2 }
154
162
  NotRescueExceptionCheck: { }
155
- NotUseDefaultRouteCheck: { }
156
- NotUseTimeAgoInWordsCheck: {}
163
+ NotUseDefaultRouteCheck: { }
164
+ NotUseTimeAgoInWordsCheck: { }
157
165
  OveruseRouteCustomizationsCheck: { customize_count: 3 }
158
- ProtectMassAssignmentCheck: {}
159
- RemoveEmptyHelpersCheck: {}
160
- #RemoveTabCheck: {}
166
+ ProtectMassAssignmentCheck: { }
167
+ RemoveEmptyHelpersCheck: { }
168
+ #RemoveTabCheck: { }
161
169
  RemoveTrailingWhitespaceCheck: { }
162
170
  RemoveUnusedMethodsInControllersCheck: { except_methods: [] }
163
171
  RemoveUnusedMethodsInHelpersCheck: { except_methods: [] }
@@ -165,18 +173,19 @@ Now you can customize this configuration file. The default configuration is as f
165
173
  ReplaceComplexCreationWithFactoryMethodCheck: { attribute_assignment_count: 2 }
166
174
  ReplaceInstanceVariableWithLocalVariableCheck: { }
167
175
  RestrictAutoGeneratedRoutesCheck: { }
168
- SimplifyRenderInControllersCheck: {}
169
- SimplifyRenderInViewsCheck: {}
176
+ SimplifyRenderInControllersCheck: { }
177
+ SimplifyRenderInViewsCheck: { }
170
178
  #UseBeforeFilterCheck: { customize_count: 2 }
171
179
  UseModelAssociationCheck: { }
172
- UseMultipartAlternativeAsContentTypeOfEmailCheck: {}
180
+ UseMultipartAlternativeAsContentTypeOfEmailCheck: { }
173
181
  UseObserverCheck: { }
174
- #UseParenthesesInMethodDefCheck: {}
182
+ #UseParenthesesInMethodDefCheck: { }
175
183
  UseQueryAttributeCheck: { }
176
184
  UseSayWithTimeInMigrationsCheck: { }
177
185
  UseScopeAccessCheck: { }
178
186
  UseTurboSprocketsRails3Check: { }
179
187
 
188
+
180
189
  You can remove or comment a review to disable it, and you can change the options.
181
190
 
182
191
  You can apply the `ignored_files` option on any rule by giving a regexp or array of regexps describing the path of the files you don't want to be checked:
@@ -211,6 +220,7 @@ Model
211
220
  4. Use query attribute
212
221
  5. Remove unused methods in models
213
222
  6. Protect mass assignment
223
+ 7. Destroy return value (disabled by default)
214
224
 
215
225
  Mailer
216
226
 
@@ -50,6 +50,7 @@ module RailsBestPractices
50
50
  # @param [Hash] options
51
51
  def analyze
52
52
  Core::Runner.base_path = @path
53
+ Core::Runner.config_path = @options['config']
53
54
  @runner = Core::Runner.new
54
55
 
55
56
  analyze_source_codes
@@ -121,6 +121,13 @@ OptionParser.new do |opts|
121
121
  options["generate"] = true
122
122
  end
123
123
 
124
+ opts.on(
125
+ '-c',
126
+ '--config CONFIG_PATH', 'configuration file location (defaults to config/rails_best_practices.yml)'
127
+ ) do |config_path|
128
+ options['config'] = config_path
129
+ end
130
+
124
131
  opts.parse!
125
132
  end
126
133
 
@@ -135,5 +142,5 @@ else
135
142
  analyzer = RailsBestPractices::Analyzer.new(ARGV.first, options)
136
143
  analyzer.analyze
137
144
  analyzer.output
138
- exit analyzer.runner.errors.size
145
+ exit analyzer.runner.errors.size > 0 ? 1 : 0
139
146
  end
@@ -33,12 +33,26 @@ module RailsBestPractices
33
33
  @base_path || "."
34
34
  end
35
35
 
36
+ # set the configuration path
37
+ #
38
+ # @param path [String] path to rbc config file
39
+ def self.config_path=(path)
40
+ @config_path = path
41
+ end
42
+
43
+ # get the configuration path, if will default to config/rails_best_practices.yml
44
+ #
45
+ # @return [String] the config path
46
+ def self.config_path
47
+ custom_config = @config_path || File.join(Runner.base_path, 'config/rails_best_practices.yml')
48
+ File.exists?(custom_config) ? custom_config : RailsBestPractices::Analyzer::DEFAULT_CONFIG
49
+ end
50
+
36
51
  # initialize the runner.
37
52
  #
38
53
  # @param [Hash] options pass the prepares and reviews.
39
54
  def initialize(options={})
40
- custom_config = File.join(Runner.base_path, 'config/rails_best_practices.yml')
41
- @config = File.exists?(custom_config) ? custom_config : RailsBestPractices::Analyzer::DEFAULT_CONFIG
55
+ @config = self.class.config_path
42
56
 
43
57
  lexicals = Array(options[:lexicals])
44
58
  prepares = Array(options[:prepares])
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module RailsBestPractices
3
- VERSION = "1.17.0"
3
+ VERSION = "1.18.0"
4
4
  end
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.add_dependency("ruby-progressbar")
24
24
  s.add_dependency("json")
25
25
 
26
- s.add_development_dependency("rake")
26
+ s.add_development_dependency("rake", '< 11.0')
27
27
  s.add_development_dependency("rspec")
28
28
  s.add_development_dependency("haml")
29
29
  s.add_development_dependency("slim")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_best_practices
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.0
4
+ version: 1.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-14 00:00:00.000000000 Z
11
+ date: 2017-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -112,16 +112,16 @@ dependencies:
112
112
  name: rake
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "<"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: '11.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "<"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: '11.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rspec
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -343,8 +343,8 @@ files:
343
343
  - spec/rails_best_practices/prepares/schema_prepare_spec.rb
344
344
  - spec/rails_best_practices/reviews/add_model_virtual_attribute_review_spec.rb
345
345
  - spec/rails_best_practices/reviews/always_add_db_index_review_spec.rb
346
- - spec/rails_best_practices/reviews/check_destroy_return_value_spec.rb
347
- - spec/rails_best_practices/reviews/check_save_return_value_spec.rb
346
+ - spec/rails_best_practices/reviews/check_destroy_return_value_review_spec.rb
347
+ - spec/rails_best_practices/reviews/check_save_return_value_review_spec.rb
348
348
  - spec/rails_best_practices/reviews/default_scope_is_evil_review_spec.rb
349
349
  - spec/rails_best_practices/reviews/dry_bundler_in_capistrano_review_spec.rb
350
350
  - spec/rails_best_practices/reviews/hash_syntax_review_spec.rb
@@ -357,9 +357,9 @@ files:
357
357
  - spec/rails_best_practices/reviews/move_finder_to_named_scope_review_spec.rb
358
358
  - spec/rails_best_practices/reviews/move_model_logic_into_model_review_spec.rb
359
359
  - spec/rails_best_practices/reviews/needless_deep_nesting_review_spec.rb
360
- - spec/rails_best_practices/reviews/not_rescue_exception_spec.rb
360
+ - spec/rails_best_practices/reviews/not_rescue_exception_review_spec.rb
361
361
  - spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
362
- - spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb
362
+ - spec/rails_best_practices/reviews/not_use_time_ago_in_words_review_spec.rb
363
363
  - spec/rails_best_practices/reviews/overuse_route_customizations_review_spec.rb
364
364
  - spec/rails_best_practices/reviews/protect_mass_assignment_review_spec.rb
365
365
  - spec/rails_best_practices/reviews/remove_empty_helpers_review_spec.rb
@@ -375,7 +375,7 @@ files:
375
375
  - spec/rails_best_practices/reviews/use_model_association_review_spec.rb
376
376
  - spec/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review_spec.rb
377
377
  - spec/rails_best_practices/reviews/use_observer_review_spec.rb
378
- - spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb
378
+ - spec/rails_best_practices/reviews/use_parentheses_in_method_def_review_spec.rb
379
379
  - spec/rails_best_practices/reviews/use_query_attribute_review_spec.rb
380
380
  - spec/rails_best_practices/reviews/use_say_with_time_in_migrations_review_spec.rb
381
381
  - spec/rails_best_practices/reviews/use_scope_access_review_spec.rb
@@ -419,7 +419,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
419
419
  version: 1.3.6
420
420
  requirements: []
421
421
  rubyforge_project:
422
- rubygems_version: 2.5.1
422
+ rubygems_version: 2.5.2
423
423
  signing_key:
424
424
  specification_version: 4
425
425
  summary: a code metric tool for rails codes.
@@ -458,8 +458,8 @@ test_files:
458
458
  - spec/rails_best_practices/prepares/schema_prepare_spec.rb
459
459
  - spec/rails_best_practices/reviews/add_model_virtual_attribute_review_spec.rb
460
460
  - spec/rails_best_practices/reviews/always_add_db_index_review_spec.rb
461
- - spec/rails_best_practices/reviews/check_destroy_return_value_spec.rb
462
- - spec/rails_best_practices/reviews/check_save_return_value_spec.rb
461
+ - spec/rails_best_practices/reviews/check_destroy_return_value_review_spec.rb
462
+ - spec/rails_best_practices/reviews/check_save_return_value_review_spec.rb
463
463
  - spec/rails_best_practices/reviews/default_scope_is_evil_review_spec.rb
464
464
  - spec/rails_best_practices/reviews/dry_bundler_in_capistrano_review_spec.rb
465
465
  - spec/rails_best_practices/reviews/hash_syntax_review_spec.rb
@@ -472,9 +472,9 @@ test_files:
472
472
  - spec/rails_best_practices/reviews/move_finder_to_named_scope_review_spec.rb
473
473
  - spec/rails_best_practices/reviews/move_model_logic_into_model_review_spec.rb
474
474
  - spec/rails_best_practices/reviews/needless_deep_nesting_review_spec.rb
475
- - spec/rails_best_practices/reviews/not_rescue_exception_spec.rb
475
+ - spec/rails_best_practices/reviews/not_rescue_exception_review_spec.rb
476
476
  - spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
477
- - spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb
477
+ - spec/rails_best_practices/reviews/not_use_time_ago_in_words_review_spec.rb
478
478
  - spec/rails_best_practices/reviews/overuse_route_customizations_review_spec.rb
479
479
  - spec/rails_best_practices/reviews/protect_mass_assignment_review_spec.rb
480
480
  - spec/rails_best_practices/reviews/remove_empty_helpers_review_spec.rb
@@ -490,7 +490,7 @@ test_files:
490
490
  - spec/rails_best_practices/reviews/use_model_association_review_spec.rb
491
491
  - spec/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review_spec.rb
492
492
  - spec/rails_best_practices/reviews/use_observer_review_spec.rb
493
- - spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb
493
+ - spec/rails_best_practices/reviews/use_parentheses_in_method_def_review_spec.rb
494
494
  - spec/rails_best_practices/reviews/use_query_attribute_review_spec.rb
495
495
  - spec/rails_best_practices/reviews/use_say_with_time_in_migrations_review_spec.rb
496
496
  - spec/rails_best_practices/reviews/use_scope_access_review_spec.rb