chef / cookstyle

A linting tool that helps you to write better Chef Infra cookbooks and InSpec profiles by detecting and automatically correcting style, syntax, and logic mistakes in your code.
Apache License 2.0
107 stars 54 forks source link

Detect single line do/end style blocks #931

Open tas50 opened 2 years ago

tas50 commented 2 years ago
execute 'execute-scheduled-karaf-restart' do
  command 'rm -f /tmp/karaf-restart'
  action :run

  notifies :stop, 'service[karaf-deploy-stop]', :immediately
  # notifies cache folders deletion
  $karaf_cache.each do |cache_folder|
    notifies :delete, "directory[#{cache_folder}]", :immediately
  end
  notifies :start, 'service[karaf]', :immediately

  only_if do
    ::File.exist?('/tmp/karaf-restart')
  end
end

The only_if here should just be a single line

dafyddcrosby commented 2 months ago

Looks like this is handled in RuboCop, and I could see this conflicting with a rubocop config if it was done separately from within Cookstyle. The Chefstyle config has Style/BlockDelimiters disabled, and while I don't have a strong opinion on the Chefstyle config (since it's only Chef-internal code), it'd be downstream code churn if it was enabled in Cookstyle. Unless there's a use-case I'm missing, this should probably be closed