Merge pull request #4256 from inspec/cw/update-style-to-rubocop-0.72

Automated chefstyle application for rubocop 0.72 compatibility
This commit is contained in:
Miah Johnson 2019-07-08 11:39:14 -07:00 committed by GitHub
commit fdf5f6f133
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 122 additions and 122 deletions

View file

@ -295,19 +295,19 @@ module Inspec
def validate_reporters!(reporters) def validate_reporters!(reporters)
return if reporters.nil? return if reporters.nil?
# TODO: move this into a reporter plugin type system # TODO: move this into a reporter plugin type system
valid_types = [ valid_types = %w{
"automate", automate
"cli", cli
"documentation", documentation
"html", html
"json", json
"json-automate", json-automate
"json-min", json-min
"json-rspec", json-rspec
"junit", junit
"progress", progress
"yaml", yaml
] }
reporters.each do |reporter_name, reporter_config| reporters.each do |reporter_name, reporter_config|
raise NotImplementedError, "'#{reporter_name}' is not a valid reporter type." unless valid_types.include?(reporter_name) raise NotImplementedError, "'#{reporter_name}' is not a valid reporter type." unless valid_types.include?(reporter_name)

View file

@ -463,7 +463,7 @@ module Inspec::Plugin::V2
Gem::Resolver.compose_sets( Gem::Resolver.compose_sets(
installed_plugins_gem_set, # The gems that are in the plugin gem path directory tree installed_plugins_gem_set, # The gems that are in the plugin gem path directory tree
InstalledVendorSet.new, InstalledVendorSet.new,
*extra_request_sets, # Anything else our caller wanted to include *extra_request_sets # Anything else our caller wanted to include
) )
end end

View file

@ -14,7 +14,7 @@ module Inspec::Plugin::V2
:loaded, # true, false False could mean not attempted or failed :loaded, # true, false False could mean not attempted or failed
:load_exception, # Exception class if it failed to load :load_exception, # Exception class if it failed to load
:name, # String name :name, # String name
:version, # three-digit version. Core / bundled plugins use InSpec version here. :version # three-digit version. Core / bundled plugins use InSpec version here.
) do ) do
def initialize(*) def initialize(*)
super super

View file

@ -127,7 +127,7 @@ module Inspec
cli_input_files: options[:runner_conf][:input_file], # From CLI --input-file cli_input_files: options[:runner_conf][:input_file], # From CLI --input-file
profile_metadata: metadata, profile_metadata: metadata,
# TODO: deprecation checks here # TODO: deprecation checks here
runner_api: options[:runner_conf][:attributes], # This is the route the audit_cookbook and kitchen-inspec take runner_api: options[:runner_conf][:attributes] # This is the route the audit_cookbook and kitchen-inspec take
) )
@runner_context = @runner_context =

View file

@ -102,7 +102,7 @@ module Inspec::Resources
components: parse_repo[4].chomp.split(" "), components: parse_repo[4].chomp.split(" "),
active: active, active: active,
} }
next unless ["deb", "deb-src"].include? repo[:type] next unless %w{deb deb-src}.include? repo[:type]
lines.push(repo) lines.push(repo)
end end

View file

@ -233,10 +233,10 @@ class PluginManagerCliSearch < Minitest::Test
result = run_inspec_process("plugin search --include-test-fixture inspec-") result = run_inspec_process("plugin search --include-test-fixture inspec-")
assert_equal 0, result.exit_status, "Search should exit 0" assert_equal 0, result.exit_status, "Search should exit 0"
assert_includes result.stdout, "inspec-test-fixture", "Search result should contain the test gem" assert_includes result.stdout, "inspec-test-fixture", "Search result should contain the test gem"
[ %w{
"inspec-core", inspec-core
"inspec-multi-server", inspec-multi-server
].each do |plugin_name| }.each do |plugin_name|
refute_includes result.stdout, plugin_name, "Search result should not contain excluded gems" refute_includes result.stdout, plugin_name, "Search result should not contain excluded gems"
end end
end end
@ -555,11 +555,11 @@ class PluginManagerCliInstall < Minitest::Test
# are the names of real rubygems. They are not InSpec/Train plugins, though, # are the names of real rubygems. They are not InSpec/Train plugins, though,
# and installing them would be a jam-up. # and installing them would be a jam-up.
# This is configured in 'etc/plugin-filter.json'. # This is configured in 'etc/plugin-filter.json'.
[ %w{
"inspec-core", inspec-core
"inspec-multi-server", inspec-multi-server
"train-tax-calculator", train-tax-calculator
].each do |plugin_name| }.each do |plugin_name|
install_result = run_inspec_process_with_this_plugin("plugin install #{plugin_name}") install_result = run_inspec_process_with_this_plugin("plugin install #{plugin_name}")
assert_empty install_result.stderr assert_empty install_result.stderr
assert_equal 2, install_result.exit_status, "Exit status should be 2" assert_equal 2, install_result.exit_status, "Exit status should be 2"

View file

@ -95,7 +95,7 @@ end
end end
it "constructs a resource+argument block without a property call" do it "constructs a resource+argument block without a property call" do
obj.qualifier = [["service", "avahi-daemon"]] obj.qualifier = [%w{service avahi-daemon}]
obj.qualifier.push(["info['properties']['UnitFileState']"]) obj.qualifier.push(["info['properties']['UnitFileState']"])
obj.add_test(nil, "eq", "enabled") obj.add_test(nil, "eq", "enabled")
obj.to_ruby.must_equal ' obj.to_ruby.must_equal '

View file

@ -144,7 +144,7 @@ end
end end
it "constructs a resource+argument block without a property call" do it "constructs a resource+argument block without a property call" do
obj.qualifier = [["service", "avahi-daemon"]] obj.qualifier = [%w{service avahi-daemon}]
obj.qualifier.push(["info['properties']['UnitFileState']"]) obj.qualifier.push(["info['properties']['UnitFileState']"])
obj.expectation = "enabled" obj.expectation = "enabled"
obj.matcher = "eq" obj.matcher = "eq"

View file

@ -248,11 +248,11 @@ class PluginInstallerInstallationTests < Minitest::Test
# are the names of real rubygems. They are not InSpec/Train plugins, though, # are the names of real rubygems. They are not InSpec/Train plugins, though,
# and installing them would be a jam-up. # and installing them would be a jam-up.
# This is configured in 'etc/plugin-filter.json'. # This is configured in 'etc/plugin-filter.json'.
[ %w{
"inspec-core", inspec-core
"inspec-multi-server", inspec-multi-server
"train-tax-calculator", train-tax-calculator
].each do |plugin_name| }.each do |plugin_name|
ex = assert_raises(Inspec::Plugin::V2::InstallError) { @installer.install(plugin_name) } ex = assert_raises(Inspec::Plugin::V2::InstallError) { @installer.install(plugin_name) }
assert_includes(ex.message, "on the Plugin Exclusion List") assert_includes(ex.message, "on the Plugin Exclusion List")
assert_includes(ex.message, "Rationale:") assert_includes(ex.message, "Rationale:")
@ -490,10 +490,10 @@ class PluginInstallerSearchTests < Minitest::Test
# are the names of real rubygems. They are not InSpec/Train plugins, though, # are the names of real rubygems. They are not InSpec/Train plugins, though,
# and installing them would be a jam-up. # and installing them would be a jam-up.
# This is configured in 'etc/plugin_filters.json'. # This is configured in 'etc/plugin_filters.json'.
[ %w{
"inspec-core", inspec-core
"inspec-multi-server", inspec-multi-server
].each do |plugin_name| }.each do |plugin_name|
refute results.key(plugin_name) refute results.key(plugin_name)
end end
end end

View file

@ -154,10 +154,10 @@ module MAESB
data = Aws::ElasticLoadBalancing::Types::DescribeAccessPointsOutput.new( data = Aws::ElasticLoadBalancing::Types::DescribeAccessPointsOutput.new(
load_balancer_descriptions: [ load_balancer_descriptions: [
Aws::ElasticLoadBalancing::Types::LoadBalancerDescription.new( Aws::ElasticLoadBalancing::Types::LoadBalancerDescription.new(
availability_zones: [ availability_zones: %w{
"us-east-1a", us-east-1a
"us-east-1c", us-east-1c
], },
dns_name: "12345678.us-east-1.aws.amazon.com", dns_name: "12345678.us-east-1.aws.amazon.com",
load_balancer_name: "kang-the-alien", load_balancer_name: "kang-the-alien",
listener_descriptions: [ listener_descriptions: [
@ -174,22 +174,22 @@ module MAESB
Aws::ElasticLoadBalancing::Types::Instance.new(instance_id: "i-12345678"), Aws::ElasticLoadBalancing::Types::Instance.new(instance_id: "i-12345678"),
Aws::ElasticLoadBalancing::Types::Instance.new(instance_id: "i-aaaabbbb"), Aws::ElasticLoadBalancing::Types::Instance.new(instance_id: "i-aaaabbbb"),
], ],
security_groups: [ security_groups: %w{
"sg-12345678", sg-12345678
"sg-aaaabbbb", sg-aaaabbbb
"sg-99998888", sg-99998888
], },
subnets: [ subnets: %w{
"subnet-12345678", subnet-12345678
"subnet-aaaabbbb", subnet-aaaabbbb
], },
vpc_id: "vpc-12345678" vpc_id: "vpc-12345678"
), ),
Aws::ElasticLoadBalancing::Types::LoadBalancerDescription.new( Aws::ElasticLoadBalancing::Types::LoadBalancerDescription.new(
availability_zones: [ availability_zones: %w{
"us-east-1b", us-east-1b
"us-east-1c", us-east-1c
], },
dns_name: "12345678.us-east-2.aws.amazon.com", dns_name: "12345678.us-east-2.aws.amazon.com",
load_balancer_name: "kangaroo", load_balancer_name: "kangaroo",
listener_descriptions: [ listener_descriptions: [
@ -205,21 +205,21 @@ module MAESB
instances: [ instances: [
Aws::ElasticLoadBalancing::Types::Instance.new(instance_id: "i-87654321"), Aws::ElasticLoadBalancing::Types::Instance.new(instance_id: "i-87654321"),
], ],
security_groups: [ security_groups: %w{
"sg-12345678", sg-12345678
"sg-99998888", sg-99998888
], },
subnets: [ subnets: %w{
"subnet-12345678", subnet-12345678
"subnet-aaaabbbb", subnet-aaaabbbb
], },
vpc_id: "vpc-12345678" vpc_id: "vpc-12345678"
), ),
Aws::ElasticLoadBalancing::Types::LoadBalancerDescription.new( Aws::ElasticLoadBalancing::Types::LoadBalancerDescription.new(
availability_zones: [ availability_zones: %w{
"us-east-1a", us-east-1a
"us-east-1e", us-east-1e
], },
dns_name: "999999.us-east-1.aws.amazon.com", dns_name: "999999.us-east-1.aws.amazon.com",
load_balancer_name: "gamma", load_balancer_name: "gamma",
listener_descriptions: [ listener_descriptions: [
@ -234,15 +234,15 @@ module MAESB
], ],
instances: [ instances: [
], ],
security_groups: [ security_groups: %w{
"sg-12345678", sg-12345678
"sg-99998888", sg-99998888
"sg-01010101", sg-01010101
], },
subnets: [ subnets: %w{
"subnet-ccccdddd", subnet-ccccdddd
"subnet-aaaabbbb", subnet-aaaabbbb
], },
vpc_id: "vpc-87654321" vpc_id: "vpc-87654321"
) )
] ]

View file

@ -213,10 +213,10 @@ module MAEPB
Aws::ElasticLoadBalancing::Types::DescribeAccessPointsOutput.new( Aws::ElasticLoadBalancing::Types::DescribeAccessPointsOutput.new(
load_balancer_descriptions: [ load_balancer_descriptions: [
Aws::ElasticLoadBalancing::Types::LoadBalancerDescription.new( Aws::ElasticLoadBalancing::Types::LoadBalancerDescription.new(
availability_zones: [ availability_zones: %w{
"us-east-1a", us-east-1a
"us-east-1c", us-east-1c
], },
dns_name: "12345678.us-east-1.aws.amazon.com", dns_name: "12345678.us-east-1.aws.amazon.com",
load_balancer_name: "kang-the-alien", load_balancer_name: "kang-the-alien",
listener_descriptions: [ listener_descriptions: [
@ -233,22 +233,22 @@ module MAEPB
Aws::ElasticLoadBalancing::Types::Instance.new(instance_id: "i-12345678"), Aws::ElasticLoadBalancing::Types::Instance.new(instance_id: "i-12345678"),
Aws::ElasticLoadBalancing::Types::Instance.new(instance_id: "i-aaaabbbb"), Aws::ElasticLoadBalancing::Types::Instance.new(instance_id: "i-aaaabbbb"),
], ],
security_groups: [ security_groups: %w{
"sg-12345678", sg-12345678
"sg-aaaabbbb", sg-aaaabbbb
"sg-99998888", sg-99998888
], },
subnets: [ subnets: %w{
"subnet-12345678", subnet-12345678
"subnet-aaaabbbb", subnet-aaaabbbb
], },
vpc_id: "vpc-12345678" vpc_id: "vpc-12345678"
), ),
Aws::ElasticLoadBalancing::Types::LoadBalancerDescription.new( Aws::ElasticLoadBalancing::Types::LoadBalancerDescription.new(
availability_zones: [ availability_zones: %w{
"us-east-1b", us-east-1b
"us-east-1c", us-east-1c
], },
dns_name: "12345678.us-east-2.aws.amazon.com", dns_name: "12345678.us-east-2.aws.amazon.com",
load_balancer_name: "kangaroo", load_balancer_name: "kangaroo",
listener_descriptions: [ listener_descriptions: [
@ -264,21 +264,21 @@ module MAEPB
instances: [ instances: [
Aws::ElasticLoadBalancing::Types::Instance.new(instance_id: "i-87654321"), Aws::ElasticLoadBalancing::Types::Instance.new(instance_id: "i-87654321"),
], ],
security_groups: [ security_groups: %w{
"sg-12345678", sg-12345678
"sg-99998888", sg-99998888
], },
subnets: [ subnets: %w{
"subnet-12345678", subnet-12345678
"subnet-aaaabbbb", subnet-aaaabbbb
], },
vpc_id: "vpc-12345678" vpc_id: "vpc-12345678"
), ),
Aws::ElasticLoadBalancing::Types::LoadBalancerDescription.new( Aws::ElasticLoadBalancing::Types::LoadBalancerDescription.new(
availability_zones: [ availability_zones: %w{
"us-east-1a", us-east-1a
"us-east-1e", us-east-1e
], },
dns_name: "999999.us-east-1.aws.amazon.com", dns_name: "999999.us-east-1.aws.amazon.com",
load_balancer_name: "gamma", load_balancer_name: "gamma",
listener_descriptions: [ listener_descriptions: [
@ -293,15 +293,15 @@ module MAEPB
], ],
instances: [ instances: [
], ],
security_groups: [ security_groups: %w{
"sg-12345678", sg-12345678
"sg-99998888", sg-99998888
"sg-01010101", sg-01010101
], },
subnets: [ subnets: %w{
"subnet-ccccdddd", subnet-ccccdddd
"subnet-aaaabbbb", subnet-aaaabbbb
], },
vpc_id: "vpc-87654321" vpc_id: "vpc-87654321"
) )
] ]

View file

@ -327,7 +327,7 @@ module MAIUB
policy_names: [] policy_names: []
), ),
"leslie" => Aws::IAM::Types::ListUserPoliciesResponse.new( "leslie" => Aws::IAM::Types::ListUserPoliciesResponse.new(
policy_names: ["leslie-inline-01", "leslie-inline-02"] policy_names: %w{leslie-inline-01 leslie-inline-02}
), ),
"jared" => Aws::IAM::Types::ListUserPoliciesResponse.new( "jared" => Aws::IAM::Types::ListUserPoliciesResponse.new(
policy_names: ["jared-inline-01"] policy_names: ["jared-inline-01"]

View file

@ -236,7 +236,7 @@ module Maiusb
policy_names: [] policy_names: []
), ),
"bob" => Aws::IAM::Types::ListUserPoliciesResponse.new( "bob" => Aws::IAM::Types::ListUserPoliciesResponse.new(
policy_names: ["bob-inline-01", "bob-inline-02"] policy_names: %w{bob-inline-01 bob-inline-02}
), ),
"carol" => Aws::IAM::Types::ListUserPoliciesResponse.new( "carol" => Aws::IAM::Types::ListUserPoliciesResponse.new(
policy_names: ["carol-inline-01"] policy_names: ["carol-inline-01"]

View file

@ -22,7 +22,7 @@ describe "Inspec::Resources::EtcGroup" do
www_filter = resource.where(name: "www-data") www_filter = resource.where(name: "www-data")
_(www_filter.gids).must_equal [33] _(www_filter.gids).must_equal [33]
_(www_filter.groups).must_equal ["www-data"] _(www_filter.groups).must_equal ["www-data"]
_(www_filter.users).must_equal ["www-data", "root"] _(www_filter.users).must_equal %w{www-data root}
end end
it "verify group filter with wrong group" do it "verify group filter with wrong group" do
@ -36,7 +36,7 @@ describe "Inspec::Resources::EtcGroup" do
www_filter = resource.where(gid: 33) www_filter = resource.where(gid: 33)
_(www_filter.gids).must_equal [33] _(www_filter.gids).must_equal [33]
_(www_filter.groups).must_equal ["www-data"] _(www_filter.groups).must_equal ["www-data"]
_(www_filter.users).must_equal ["www-data", "root"] _(www_filter.users).must_equal %w{www-data root}
end end
it "verify group filter with wrong gid" do it "verify group filter with wrong gid" do
@ -50,7 +50,7 @@ describe "Inspec::Resources::EtcGroup" do
www_filter = resource.where(users: "www-data,root") www_filter = resource.where(users: "www-data,root")
_(www_filter.gids).must_equal [33] _(www_filter.gids).must_equal [33]
_(www_filter.groups).must_equal ["www-data"] _(www_filter.groups).must_equal ["www-data"]
_(www_filter.users).must_equal ["www-data", "root"] _(www_filter.users).must_equal %w{www-data root}
end end
it "verify group filter with no group members" do it "verify group filter with no group members" do

View file

@ -58,8 +58,8 @@ describe "groups resource on windows platform" do
it "finds no group domains" do it "finds no group domains" do
_(resource.domains.count).must_equal 4 _(resource.domains.count).must_equal 4
_(resource.domains).must_equal ["WIN-CIV7VMLVHLD", "WIN-CIV7VMLVHLD", _(resource.domains).must_equal %w{WIN-CIV7VMLVHLD WIN-CIV7VMLVHLD
"WIN-CIV7VMLVHLD", "WIN-CIV7VMLVHLD"] WIN-CIV7VMLVHLD WIN-CIV7VMLVHLD}
end end
end end

View file

@ -54,7 +54,7 @@ describe "Inspec::Resources::Processes" do
it "verify processes resource using where filters on linux os. String match regex" do it "verify processes resource using where filters on linux os. String match regex" do
resource = MockLoader.new(:centos6).load_resource("processes", ".+") resource = MockLoader.new(:centos6).load_resource("processes", ".+")
_(resource.entries.length).must_equal 8 _(resource.entries.length).must_equal 8
_(resource.where { pid < 11663 && cpu == "0.0" }.users).must_equal(["opscode-pgsql", "opscode", "root", "httpd"]) _(resource.where { pid < 11663 && cpu == "0.0" }.users).must_equal(%w{opscode-pgsql opscode root httpd})
_(resource.where { user =~ /opscode-.*/ }.entries[0].to_h).must_equal({ _(resource.where { user =~ /opscode-.*/ }.entries[0].to_h).must_equal({
label: "system_u:system_r:init_t:s0", label: "system_u:system_r:init_t:s0",
pid: 5127, pid: 5127,