Class: RuboCop::Cop::Chef::ChefModernize::LegacyBerksfileSource
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Chef::ChefModernize::LegacyBerksfileSource
- Defined in:
- lib/rubocop/cop/chef/modernize/berksfile_source.rb
Overview
Over the course of years there have been many different valid community site / Supermarket URLs to use in a cookbook’s Berksfile. These old URLs continue to function via redirects, but should be updated to point to the latest Supermarket URL.
Constant Summary collapse
- MSG =
'Do not use legacy Berksfile community sources. Use Chef Supermarket instead.'.freeze
Instance Method Summary collapse
Instance Method Details
#autocorrect(node) ⇒ Object
52 53 54 55 56 |
# File 'lib/rubocop/cop/chef/modernize/berksfile_source.rb', line 52 def autocorrect(node) lambda do |corrector| corrector.replace(node.loc.expression, "source 'https://supermarket.chef.io'") end end |
#old_berkshelf_url?(url) ⇒ Boolean
42 43 44 |
# File 'lib/rubocop/cop/chef/modernize/berksfile_source.rb', line 42 def old_berkshelf_url?(url) %w(http://community.opscode.com/api/v3 https://supermarket.getchef.com https://api.berkshelf.com).include?(url) end |
#on_send(node) ⇒ Object
46 47 48 49 50 |
# File 'lib/rubocop/cop/chef/modernize/berksfile_source.rb', line 46 def on_send(node) berksfile_source?(node) do add_offense(node, location: :expression, message: MSG, severity: :refactor) end end |