Skip to content

Commit

Permalink
Fix ChefStyle offenses
Browse files Browse the repository at this point in the history
You have to love `chefstyle -a` - It is your friend! :)

Before:
```
129 files inspected, 911 offenses detected
```

After:
```
129 files inspected, 16 offenses detected
```
Signed-off-by: Salim Afiune <afiune@chef.io>
  • Loading branch information
Salim Afiune committed Dec 9, 2016
1 parent 40f4a74 commit 12bc00a
Show file tree
Hide file tree
Showing 124 changed files with 3,387 additions and 4,172 deletions.
2 changes: 1 addition & 1 deletion Berksfile
@@ -1,3 +1,3 @@
source "https://supermarket.chef.io"

cookbook "test_cookbook", :path => "./test/cookbooks/test_cookbook"
cookbook "test_cookbook", path: "./test/cookbooks/test_cookbook"
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -11,5 +11,5 @@ group :integration do
end

group :test do
gem "codeclimate-test-reporter", "~> 1.0", ">= 1.0.3", :require => nil
gem "codeclimate-test-reporter", "~> 1.0", ">= 1.0.3", require: nil
end
10 changes: 5 additions & 5 deletions Guardfile
Expand Up @@ -2,29 +2,29 @@
ignore %r{^\.gem/}

def rubocop_opts
{ :all_on_start => false, :keep_failed => false, :cli => "-r finstyle" }
{ all_on_start: false, keep_failed: false, cli: "-r finstyle" }
end

def cucumber_opts
cucumber_cli = "--no-profile --color --format progress --strict"
cucumber_cli += " --tags ~@spawn" if RUBY_PLATFORM =~ /mswin|mingw|windows/

{ :all_on_start => false, :cli => cucumber_cli }
{ all_on_start: false, cli: cucumber_cli }
end

def yard_opts
{ :port => "8808" }
{ port: "8808" }
end

group :red_green_refactor, :halt_on_fail => true do
group :red_green_refactor, halt_on_fail: true do
guard :minitest do
watch(%r{^spec/(.*)_spec\.rb})
watch(%r{^lib/(.*)([^/]+)\.rb}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^spec/spec_helper\.rb}) { "spec" }
end

guard :rubocop, rubocop_opts do
watch(%r{.+\.rb$})
watch(/.+\.rb$/)
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
end
end
Expand Down
8 changes: 4 additions & 4 deletions Rakefile
Expand Up @@ -20,7 +20,7 @@ rescue LoadError
end

desc "Run all test suites"
task :test => [:unit, :features]
task test: [:unit, :features]

desc "Display LOC stats"
task :stats do
Expand All @@ -41,7 +41,7 @@ rescue LoadError
end

desc "Run all quality tasks"
task :quality => [:style, :stats]
task quality: [:style, :stats]

begin
require "yard"
Expand All @@ -50,7 +50,7 @@ rescue LoadError
puts "yard is not available. (sudo) gem install yard to generate yard documentation."
end

task :default => [:test, :quality]
task default: [:test, :quality]

begin
require "github_changelog_generator/task"
Expand All @@ -60,7 +60,7 @@ begin
config.future_release = "v#{Kitchen::VERSION}"
config.enhancement_labels = "enhancement,Enhancement,New Feature,Feature,Improvement".split(",")
config.bug_labels = "bug,Bug".split(",")
config.exclude_labels = %w[Duplicate Question Discussion No_Changelog]
config.exclude_labels = %w{Duplicate Question Discussion No_Changelog}
end
rescue LoadError
puts "github_changelog_generator is not available." \
Expand Down
2 changes: 1 addition & 1 deletion bin/kitchen
Expand Up @@ -5,7 +5,7 @@
# https://twitter.com/mitchellh/status/283014103189053442
Signal.trap("INT") { exit 1 }

$LOAD_PATH.unshift File.join(File.dirname(__FILE__), %w[.. lib])
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), %w{.. lib})
require "rubygems"
require "kitchen/cli"
require "kitchen/errors"
Expand Down
12 changes: 6 additions & 6 deletions features/step_definitions/gem_steps.rb
Expand Up @@ -19,18 +19,18 @@
unbundlerize do
run_simple(
sanitize_text("gem list #{name} --version #{version} -i"),
:fail_on_error => true,
:exit_timeout => nil
)
fail_on_error: true,
exit_timeout: nil
)
end
end

Then(/^a gem named "(.*?)" is installed$/) do |name|
unbundlerize do
run_simple(
sanitize_text("gem list #{name} -i"),
:fail_on_error => true,
:exit_timeout => nil
)
fail_on_error: true,
exit_timeout: nil
)
end
end
13 changes: 6 additions & 7 deletions features/support/env.rb
Expand Up @@ -8,7 +8,6 @@
require "kitchen/cli"

class ArubaHelper

def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel)
@argv = argv
@stdin = stdin
Expand Down Expand Up @@ -48,11 +47,11 @@ def execute!
# Restore environment variables to their original settings, if they have
# been saved off
env = aruba.environment
env.to_h.keys.select { |key| key =~ /^_CUKE_/ }.
each do |backup_key|
env[backup_key.sub(/^_CUKE_/, "")] = env[backup_key]
env.delete(backup_key)
end
env.to_h.keys.select { |key| key =~ /^_CUKE_/ }
.each do |backup_key|
env[backup_key.sub(/^_CUKE_/, "")] = env[backup_key]
env.delete(backup_key)
end

@cleanup_dirs.each { |dir| FileUtils.rm_rf(dir) }
end
Expand All @@ -67,7 +66,7 @@ def restore_envvar(key)
end

def unbundlerize
keys = %w[BUNDLER_EDITOR BUNDLE_BIN_PATH BUNDLE_GEMFILE RUBYOPT]
keys = %w{BUNDLER_EDITOR BUNDLE_BIN_PATH BUNDLE_GEMFILE RUBYOPT}

keys.each { |key| backup_envvar(key); aruba.environment.delete(key) }
yield
Expand Down
12 changes: 5 additions & 7 deletions lib/kitchen.rb
Expand Up @@ -53,9 +53,7 @@
#
# @author Fletcher Nichol <fnichol@nichol.ca>
module Kitchen

class << self

# @return [Logger] the common Kitchen logger
attr_accessor :logger

Expand All @@ -73,7 +71,7 @@ def source_root
#
# @return [Logger] a logger
def default_logger
Logger.new(:stdout => $stdout, :level => Util.to_logger_level(env_log))
Logger.new(stdout: $stdout, level: Util.to_logger_level(env_log))
end

# Returns a default file logger which emits on standard output and to a
Expand All @@ -89,10 +87,10 @@ def default_file_logger(level = nil, log_overwrite = nil)
log_location = log_location.to_s

Logger.new(
:stdout => $stdout,
:logdev => log_location,
:level => Util.to_logger_level(level),
:log_overwrite => log_overwrite
stdout: $stdout,
logdev: log_location,
level: Util.to_logger_level(level),
log_overwrite: log_overwrite
)
end

Expand Down
10 changes: 2 additions & 8 deletions lib/kitchen/base64_stream.rb
Expand Up @@ -17,13 +17,11 @@
# limitations under the License.

module Kitchen

# Base64 encoder/decoder that operates on IO objects so as to minimize
# memory allocations on large payloads.
#
# @author Fletcher Nichol <fnichol@nichol.ca>
module Base64Stream

# Encodes an input stream into a Base64 output stream. The input and ouput
# objects must be opened IO resources. In other words, opening and closing
# the resources are not the responsibilty of this method.
Expand All @@ -32,9 +30,7 @@ module Base64Stream
# @param io_out [#write] output stream
def self.strict_encode(io_in, io_out)
buffer = ""
while io_in.read(3 * 1000, buffer)
io_out.write([buffer].pack("m0"))
end
io_out.write([buffer].pack("m0")) while io_in.read(3 * 1000, buffer)
buffer = nil # rubocop:disable Lint/UselessAssignment
end

Expand All @@ -46,9 +42,7 @@ def self.strict_encode(io_in, io_out)
# @param io_out [#write] output stream
def self.strict_decode(io_in, io_out)
buffer = ""
while io_in.read(3 * 1000, buffer)
io_out.write(buffer.unpack("m0").first)
end
io_out.write(buffer.unpack("m0").first) while io_in.read(3 * 1000, buffer)
buffer = nil # rubocop:disable Lint/UselessAssignment
end
end
Expand Down

0 comments on commit 12bc00a

Please sign in to comment.