From ff20c9ba6f756af16d00894e6e1c4d23135c2783 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 29 Mar 2017 11:07:09 -0700 Subject: [PATCH] Remove FC023 which is no longer considered best practice Signed-off-by: Tim Smith --- ...heck_for_condition_around_resource.feature | 52 ------------------- features/support/command_helpers.rb | 2 +- lib/foodcritic/rules/fc023.rb | 11 ---- spec/regression/expected-output.txt | 12 ----- 4 files changed, 1 insertion(+), 76 deletions(-) delete mode 100644 features/023_check_for_condition_around_resource.feature delete mode 100644 lib/foodcritic/rules/fc023.rb diff --git a/features/023_check_for_condition_around_resource.feature b/features/023_check_for_condition_around_resource.feature deleted file mode 100644 index 6146784c..00000000 --- a/features/023_check_for_condition_around_resource.feature +++ /dev/null @@ -1,52 +0,0 @@ -Feature: Check for condition around resource - - In order to express conditions in a idiomatic way - As a developer - I want to identify resources nested in a condition that would be better expressed as a conditional attribute - - Scenario: No conditions - Given a cookbook recipe that declares a resource with no conditions at all - When I check the cookbook - Then the prefer conditional attributes warning 023 should not be displayed - - Scenario Outline: Resource wrapped in condition - Given a cookbook recipe that declares a resource nested in a condition with - When I check the cookbook - Then the prefer conditional attributes warning 023 - - Examples: - | wrapping_condition | condition_attribute | warning | - | if | no condition attribute | should be displayed | - | unless | no condition attribute | should be displayed | - | if_else | no condition attribute | should not be displayed | - | unless_else | no condition attribute | should not be displayed | - | if_elsif | no condition attribute | should not be displayed | - | if_elsif_else | no condition attribute | should not be displayed | - | if | only_if block | should not be displayed | - | if | only_if string | should not be displayed | - | unless | only_if block | should not be displayed | - | unless | only_if string | should not be displayed | - | if | not_if block | should not be displayed | - | if | not_if string | should not be displayed | - | unless | not_if block | should not be displayed | - | unless | not_if string | should not be displayed | - - Scenario: Wrapped condition includes Ruby statements - Given a cookbook recipe that has a wrapping condition containing a resource with no condition attribute and a Ruby statement - When I check the cookbook - Then the prefer conditional attributes warning 023 should not be displayed - - Scenario: Wrapped condition includes resource in a loop - Given a cookbook recipe that has a wrapping condition containing a resource with no condition attribute within a loop - When I check the cookbook - Then the prefer conditional attributes warning 023 should not be displayed - - Scenario Outline: Multiple nested resources - Given a cookbook recipe that declares multiple resources nested in a condition with no condition attribute - When I check the cookbook - Then the prefer conditional attributes warning 023 should not be displayed - - Examples: - | wrapping_condition | - | if | - | unless | diff --git a/features/support/command_helpers.rb b/features/support/command_helpers.rb index 24dee077..a68b0600 100644 --- a/features/support/command_helpers.rb +++ b/features/support/command_helpers.rb @@ -35,7 +35,7 @@ def assertions "FC019" => "Access node attributes in a consistent manner", "FC021" => "Resource condition in provider may not behave as expected", "FC022" => "Resource condition within loop may not behave as expected", - "FC023" => "Prefer conditional attributes", + # FC023 was yanked and is considered reserved, do not reuse it "FC024" => "Consider adding platform equivalents", "FC025" => "Prefer chef_gem to compile-time gem install", "FC026" => "Conditional execution block attribute contains only string", diff --git a/lib/foodcritic/rules/fc023.rb b/lib/foodcritic/rules/fc023.rb deleted file mode 100644 index 625a8044..00000000 --- a/lib/foodcritic/rules/fc023.rb +++ /dev/null @@ -1,11 +0,0 @@ -rule "FC023", "Prefer conditional attributes" do - tags %w{style} - recipe do |ast| - ast.xpath(%q{//method_add_block[command/ident][count(descendant::ident - [@value='only_if' or @value='not_if']) = 0]/ancestor::*[self::if or - self::unless][count(descendant::method_add_block[command/ident]) = 1] - [count(stmts_add/method_add_block/call) = 0] - [count(stmts_add/stmts_add) = 0] - [count(descendant::*[self::else or self::elsif]) = 0]}) - end -end diff --git a/spec/regression/expected-output.txt b/spec/regression/expected-output.txt index 417ab83a..c143ed32 100644 --- a/spec/regression/expected-output.txt +++ b/spec/regression/expected-output.txt @@ -292,18 +292,6 @@ FC019: Access node attributes in a consistent manner: perl/recipes/default.rb:26 FC019: Access node attributes in a consistent manner: powershell/recipes/default.rb:69 FC019: Access node attributes in a consistent manner: ufw/attributes/default.rb:1 FC019: Access node attributes in a consistent manner: ufw/attributes/default.rb:2 -FC023: Prefer conditional attributes: ./apt/providers/repository.rb:26 -FC023: Prefer conditional attributes: ./apt/providers/repository.rb:68 -FC023: Prefer conditional attributes: ./chef-client/recipes/config.rb:62 -FC023: Prefer conditional attributes: ./database/recipes/ebs_backup.rb:81 -FC023: Prefer conditional attributes: ./gecode/recipes/package.rb:29 -FC023: Prefer conditional attributes: ./homebrew/providers/tap.rb:14 -FC023: Prefer conditional attributes: ./homebrew/providers/tap.rb:22 -FC023: Prefer conditional attributes: ./lvm/providers/volume_group.rb:12 -FC023: Prefer conditional attributes: ./passenger_apache2/recipes/mod_rails.rb:27 -FC023: Prefer conditional attributes: ./users/providers/manage.rb:70 -FC023: Prefer conditional attributes: ./users/providers/manage.rb:101 -FC023: Prefer conditional attributes: ./yum/providers/key.rb:59 FC024: Consider adding platform equivalents: ./mysql/recipes/server.rb:130 FC024: Consider adding platform equivalents: ./mysql/recipes/server.rb:132 FC024: Consider adding platform equivalents: ./transmission/recipes/default.rb:42