Real Vim ninjas count every keystroke - do you?

Pick a challenge, fire up Vim, and show us what you got.

Changelog, Rules & FAQ, updates: @vimgolf, RSS.

Your VimGolf key: please sign in

$ gem install vimgolf
$ vimgolf setup
$ vimgolf put 56704157109fb85a6d017d08

FoodCritic023: Prefer conditional attributes

FoodCritic (www.foodcritic.io) is a lint tool for your Chef (learn.chef.io) cookbooks. FC023 indicates that you should prefer Chef guards over Ruby conditions. This challenge expects you to be able to fix this issue in a sample cookbook, given the FoodCritic output: ================================================================ FC023: Prefer conditional attributes: cookbooks/foo/recipes/default.rb:25 ================================================================ See http://www.foodcritic.io/#FC023 for more details about the changes being made.

Start file
# Cookbook Name:: foo
# Recipe:: default
#
# Copyright 2015, Foo Inc.
#
# All rights reserved - Do Not Redistribute
#

directory "/opt/foo" do
end

remote_file "/tmp/foo.rpm" do
  source "http://foo.inc/packages/foo.rpm"
  action :create
end

rpm_package "/tmp/foo.rpm" do
  action :install
end

service "foo" do
  action :start
end

if node["foo"] == "bar"
  execute "bar my foo" do
    command "foo < bar"
  end
end
End file
# Cookbook Name:: foo
# Recipe:: default
#
# Copyright 2015, Foo Inc.
#
# All rights reserved - Do Not Redistribute
#

directory "/opt/foo" do
end

remote_file "/tmp/foo.rpm" do
  source "http://foo.inc/packages/foo.rpm"
  action :create
end

rpm_package "/tmp/foo.rpm" do
  action :install
end

service "foo" do
  action :start
end

execute "bar my foo" do
  command "foo < bar"
  only_if { node["foo"] == "bar" }
end

View Diff

25,28c25,27
< if node["foo"] == "bar"
<   execute "bar my foo" do
<     command "foo < bar"
<   end
---
> execute "bar my foo" do
>   command "foo < bar"
>   only_if { node["foo"] == "bar" }

Solutions by @DHM29978992:

Unlock 9 remaining solutions by signing in and submitting your own entry
Created by: @bbbco

53 active golfers, 181 entries

Solutions by @DHM29978992:
25
#4 - DHM / @DHM29978992

05/20/2018 at 12:36AM

26
#>17 - DHM / @DHM29978992

05/20/2018 at 12:34AM

27
#>18 - DHM / @DHM29978992

05/20/2018 at 12:33AM

28
#>21 - DHM / @DHM29978992

05/20/2018 at 12:32AM

30
#>29 - DHM / @DHM29978992

05/20/2018 at 12:30AM

32
#>33 - DHM / @DHM29978992

05/20/2018 at 12:30AM

33
#>36 - DHM / @DHM29978992

05/20/2018 at 12:24AM

35
#>44 - DHM / @DHM29978992

05/20/2018 at 12:21AM

40
#>50 - DHM / @DHM29978992

05/20/2018 at 12:17AM