foodcritic 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -333,6 +333,10 @@ module FoodCritic
333
333
  atts
334
334
  end
335
335
 
336
+ def block_depth(resource)
337
+ resource.path.split('/').group_by{|e|e}['method_add_block'].size
338
+ end
339
+
336
340
  # Recurse the nested arrays provided by Ripper to create a tree we can more
337
341
  # easily apply expressions to.
338
342
  def build_xml(node, doc = nil, xml_node=nil)
@@ -393,12 +397,8 @@ module FoodCritic
393
397
  atts = {}
394
398
  resource.xpath('do_block/descendant::*[self::command or
395
399
  self::method_add_arg][count(ancestor::do_block) >= 1]').each do |att|
396
- next unless %w{block not_if only_if restart_command before_migrate
397
- before_symlink before_restart after_restart}.all? do |block_att|
398
- att.xpath("count(ancestor::method_add_block/method_add_arg/
399
- fcall[ident/@value='#{block_att}']) = 0")
400
- end
401
-
400
+ blocks = att.xpath('ancestor::method_add_block/method_add_arg/fcall')
401
+ next if blocks.any?{|a| block_depth(a) > block_depth(resource)}
402
402
  att_name = att.xpath('string(ident/@value |
403
403
  fcall/ident[@value="variables"]/@value)')
404
404
  unless att_name.empty?
@@ -99,8 +99,9 @@ module FoodCritic
99
99
 
100
100
  def remove_ignored(matches, rule, file)
101
101
  matches.reject do |m|
102
- (line = m[:line]) && File.exist?(file) &&
103
- ignore_line_match?(File.readlines(file)[line-1], rule)
102
+ matched_file = m[:filename] || file
103
+ (line = m[:line]) && File.exist?(matched_file) &&
104
+ ignore_line_match?(File.readlines(matched_file)[line-1], rule)
104
105
  end
105
106
  end
106
107
 
@@ -1,4 +1,4 @@
1
1
  module FoodCritic
2
2
  # The current version of foodcritic
3
- VERSION = '2.0.0'
3
+ VERSION = '2.0.1'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foodcritic
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-24 00:00:00.000000000 Z
12
+ date: 2013-03-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gherkin
@@ -153,11 +153,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  version: '0'
154
154
  segments:
155
155
  - 0
156
- hash: 3521344391599734133
156
+ hash: 118769465480030125
157
157
  requirements: []
158
158
  rubyforge_project:
159
159
  rubygems_version: 1.8.25
160
160
  signing_key:
161
161
  specification_version: 3
162
- summary: foodcritic-2.0.0
162
+ summary: foodcritic-2.0.1
163
163
  test_files: []