Skip to content
This repository has been archived by the owner on Sep 19, 2020. It is now read-only.

Commit

Permalink
Remove FC003 from Foodcritic
Browse files Browse the repository at this point in the history
It no longer makes sense now that solo uses local mode and search works with that. Update the test helper to no longer use FC003 since we tested with that in several places

Signed-off-by: Tim Smith <[email protected]>
  • Loading branch information
tas50 committed Mar 2, 2017
1 parent 340bb4c commit 72c634c
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 136 deletions.
61 changes: 0 additions & 61 deletions features/003_check_for_chef_server.feature

This file was deleted.

40 changes: 19 additions & 21 deletions features/choose_rules_to_apply.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ Feature: Choose rules to apply

Examples:
| cookbook_matches | tag_arguments | warnings_shown |
| FC002,FC003,FC004 | | FC002,FC003,FC004 |
| FC002,FC004,FC005 | | FC002,FC004,FC005 |
| FC002 | -t FC002 | FC002 |
| FC002,FC003,FC004 | --tags FC002 | FC002 |
| FC002,FC003,FC004 | --tags fc002 | |
| FC002,FC003,FC004 | --tags FC005 | |
| FC002,FC003,FC004 | --tags ~FC002 | FC003,FC004 |
| FC002,FC004,FC005 | --tags FC002 | FC002 |
| FC002,FC004,FC005 | --tags fc002 | |
| FC002,FC004,FC005 | --tags FC006 | |
| FC002,FC004,FC005 | --tags ~FC002 | FC004,FC005 |
| | --tags FC002 | |
| FC002,FC003,FC004 | --tags @FC002 | |
| FC002,FC003,FC004 | --tags style | FC002,FC004 |
| FC002,FC003,FC004 | --tags FC002 --tags FC003 | |
| FC002,FC003,FC004 | --tags style --tags services | FC004 |
| FC002,FC003,FC004 | --tags style,services | FC002,FC004 |
| FC002,FC004,FC005 | --tags @FC002 | |
| FC002,FC004,FC005 | --tags style | FC002,FC004 |
| FC002,FC004,FC005 | --tags FC002 --tags FC004 | |
| FC002,FC004,FC005 | --tags style --tags services | FC004 |
| FC002,FC004,FC005 | --tags style,services | FC002,FC004 |

Scenario Outline: Specified tags in cookbook .foodcritic file
Given a cookbook that matches rules <cookbook_matches>
Expand All @@ -32,18 +32,16 @@ Feature: Choose rules to apply

Examples:
| cookbook_matches | tag_file | tag_arguments | warnings_shown |
| FC002,FC003,FC004 | | | FC002,FC003,FC004 |
| FC002,FC004 | | | FC002,FC004 |
| FC002 | FC002 | | FC002 |
| FC002 | ~FC002 | --tags FC002 | FC002 |
| FC002 | fc002 | | |
| FC002,FC003,FC004 | FC005 | | |
| FC002,FC003,FC004 | FC005 | -t FC002 | FC002 |
| FC002,FC003,FC004 | FC002 | -t FC003 | FC003 |
| FC002,FC003,FC004 | ~FC002 | | FC003,FC004 |
| FC002,FC003,FC004 | ~FC002 | -t FC002,FC003 | FC002,FC003 |
| FC002,FC004 | FC005 | | |
| FC002,FC004 | FC005 | -t FC002 | FC002 |
| FC002,FC004 | ~FC002 | | FC004 |
| FC002,FC004 | ~FC002 | -t FC002 | FC002 |
| | FC002 | | |
| FC002,FC003,FC004 | @FC002 | | |
| FC002,FC003,FC004 | style | | FC002,FC004 |
| FC002,FC003,FC004 | FC002 FC003 | | |
| FC002,FC003,FC004 | style,services | | FC002,FC004 |

| FC002,FC004 | @FC002 | | |
| FC002,FC004 | style | | FC002,FC004 |
| FC002,FC004 | FC002 | | |
| FC002,FC004 | style,services | | FC002,FC004 |
26 changes: 13 additions & 13 deletions features/continuous_integration_support.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ Feature: Continuous Integration Support

Examples:
| cookbook_matches | tag_arguments | warnings_shown | build_status |
| FC002,FC003,FC004 | | FC002,FC003,FC004 | failed |
| FC002,FC003,FC004 | -t style | FC002,FC004 | failed |
| FC002,FC003,FC004 | -t style -f ~any | FC002,FC004 | successful |
| FC002,FC003,FC004 | -f FC005 | FC002,FC003,FC004 | successful |
| FC002,FC003,FC004 | -f FC003,FC004 | FC002,FC003,FC004 | failed |
| FC002,FC003,FC004 | --epic-fail FC003 | FC002,FC003,FC004 | failed |
| FC002,FC003 | -f ~any | FC002,FC003 | successful |
| FC002,FC003 | -f any -f ~FC014 | FC002,FC003 | failed |
| FC002,FC003 | -f any,~FC014 | FC002,FC003 | failed |
| FC002,FC004 | | FC002,FC004 | failed |
| FC002,FC004 | -t style | FC002,FC004 | failed |
| FC002,FC004 | -t style -f ~any | FC002,FC004 | successful |
| FC002,FC004 | -f FC005 | FC002,FC004 | successful |
| FC002,FC004 | -f FC004 | FC002,FC004 | failed |
| FC002,FC004 | --epic-fail FC002 | FC002,FC004 | failed |
| FC002,FC005 | -f ~any | FC002,FC005 | successful |
| FC002,FC005 | -f any -f ~FC014 | FC002,FC005 | failed |
| FC002,FC005 | -f any,~FC014 | FC002,FC005 | failed |
| FC002 | -f ~FC002 | FC002 | successful |
| FC002,FC003 | -f ~FC002 | FC002,FC003 | failed |
| FC002,FC003 | -f any -f ~FC002 | FC002,FC003 | failed |
| FC002,FC005 | -f ~FC002 | FC002,FC005 | failed |
| FC002,FC005 | -f any -f ~FC002 | FC002,FC005 | failed |
| FC002 | -f any,~FC002 | FC002 | failed |
| FC002 | -f any -f ~FC002 | FC002 | successful |
| FC002,FC003 | -f any,~FC002 | FC002,FC003 | failed |
| FC002,FC003 | -f ~FC002 -f ~FC004 | FC002,FC003 | failed |
| FC002,FC005 | -f any,~FC002 | FC002,FC005 | failed |
| FC002,FC005 | -f ~FC002 -f ~FC004 | FC002,FC005 | failed |
8 changes: 4 additions & 4 deletions features/ignore_via_line_comments.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Feature: Ignoring rules on per line basis
| #~FC006 | not be shown |
| #~FC022 | be shown |
| # ~FC006 | not be shown |
| # ~FC003,~FC006,~FC009 | not be shown |
| # ~FC003 ~FC006 ~FC009 | not be shown |
| # ~FC003, ~FC006, ~FC009 | not be shown |
| # ~FC003,~FC009 | be shown |
| # ~FC006,~FC009 | not be shown |
| # ~FC006 ~FC009 | not be shown |
| # ~FC006, ~FC009 | not be shown |
| # ~FC009 | be shown |
| # FC006 | be shown |
| # ~ FC006 | be shown |
| # fc006 | be shown |
Expand Down
13 changes: 0 additions & 13 deletions features/step_definitions/cookbook_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2158,19 +2158,6 @@ def search(bag_name, query=nil, sort=nil, start=0, rows=1000, &block)
assert_build_result(build_outcome == "succeed", warnings.delete(" ").split(","))
end

Then "the check for server warning 003 should not be displayed against the condition" do
expect_warning("FC003", :line => nil, :expect_warning => false)
end

Then /^the check for server warning 003 should not be displayed against the search after the (.*) conditional$/ do |format|
line = format == "oneline" ? 2 : 4
expect_warning("FC003", :line => line, :expect_warning => false)
end

Then "the check for server warning 003 should not be displayed given we have checked" do
expect_warning("FC003", :line => 4, :expect_warning => false)
end

Then /^the consider adding platform warning 024 should( not)? be shown$/ do |should_not|
expect_warning("FC024", :line => should_not.nil? ? @expected_line : nil, :expect_warning => should_not.nil?)
end
Expand Down
2 changes: 1 addition & 1 deletion features/support/command_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def assertions
WARNINGS = {
"FC001" => "Use strings in preference to symbols to access node attributes",
"FC002" => "Avoid string interpolation where not required",
"FC003" => "Check whether you are running with chef server before using server-specific features",
# FC003 was yanked and is considered reserved, do not reuse it
"FC004" => "Use a service resource to start and stop services",
"FC005" => "Avoid repetition of resource declarations",
"FC006" => "Mode should be quoted or fully specified when setting file permissions",
Expand Down
13 changes: 10 additions & 3 deletions features/support/cookbook_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def cookbook_declares_dependencies(declaration_type)

# Create a cookbook that will match the specified rules.
#
# @param [Array] codes The codes to match. Only FC002, FC003 and FC004 are supported.
# @param [Array] codes The codes to match. Only FC002, FC004 and FC005 and FC006 are supported.
def cookbook_that_matches_rules(codes)
recipe = ""
codes.each do |code|
Expand All @@ -53,15 +53,22 @@ def cookbook_that_matches_rules(codes)
action :create
end
}
elsif code == "FC003"
recipe += %Q{nodes = search(:node, "hostname:[* TO *]")\n}
elsif code == "FC004"
recipe += %q{
execute "stop-jetty" do
command "/etc/init.d/jetty6 stop"
action :run
end
}
elsif code == "FC005"
recipe += %q{
package 'erlang-base' do
action :upgrade
end
package 'erlang-corba' do
action :upgrade
end
}
elsif code == "FC006"
recipe += %q{
directory "/var/lib/foo" do
Expand Down
11 changes: 1 addition & 10 deletions lib/foodcritic/rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,7 @@
end
end

rule "FC003",
"Check whether you are running with chef server before using"\
" server-specific features" do
tags %w{portability solo}
recipe do |ast, filename|
unless checks_for_chef_solo?(ast) || chef_solo_search_supported?(filename)
searches(ast)
end
end
end
# FC003 was yanked and the number should not be reused

rule "FC004", "Use a service resource to start and stop services" do
tags %w{style services}
Expand Down
10 changes: 0 additions & 10 deletions spec/regression/expected-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,6 @@ FC002: Avoid string interpolation where not required: ./windows/libraries/regist
FC002: Avoid string interpolation where not required: ./windows/libraries/registry_helper.rb:173
FC002: Avoid string interpolation where not required: ./windows/libraries/windows_privileged.rb:42
FC002: Avoid string interpolation where not required: ./windows/libraries/windows_privileged.rb:56
FC003: Check whether you are running with chef server before using server-specific features: ./database/recipes/ebs_backup.rb:33
FC003: Check whether you are running with chef server before using server-specific features: ./database/recipes/ebs_volume.rb:49
FC003: Check whether you are running with chef server before using server-specific features: ./database/recipes/master.rb:30
FC003: Check whether you are running with chef server before using server-specific features: ./database/recipes/master.rb:57
FC003: Check whether you are running with chef server before using server-specific features: ./drbd/recipes/pair.rb:31
FC003: Check whether you are running with chef server before using server-specific features: ./heartbeat/providers/default.rb:22
FC003: Check whether you are running with chef server before using server-specific features: ./partial_search/libraries/partial_search.rb:65
FC003: Check whether you are running with chef server before using server-specific features: ./resolver/recipes/from_server_role.rb:21
FC003: Check whether you are running with chef server before using server-specific features: ./ssh_known_hosts/recipes/default.rb:23
FC003: Check whether you are running with chef server before using server-specific features: ./ufw/recipes/databag.rb:32
FC007: Ensure recipe dependencies are reflected in cookbook metadata: ./boost/recipes/source.rb:1
FC007: Ensure recipe dependencies are reflected in cookbook metadata: ./build-essential/recipes/default.rb:65
FC007: Ensure recipe dependencies are reflected in cookbook metadata: ./chef-client/recipes/service.rb:197
Expand Down

0 comments on commit 72c634c

Please sign in to comment.