Skip to content

Commit

Permalink
Move the metadata cops to ChefModernize
Browse files Browse the repository at this point in the history
These cops really aren't deprecations. They're just not necessary
anymore. We shouldn't be alerting in chef-analyze that every customer
needs to drop everything and remove long_description from their
metadata. It doesn't warrant that, but if they're already in a cookbook
they should def clean it up.

Signed-off-by: Tim Smith <tsmith@chef.io>
  • Loading branch information
tas50 committed Dec 6, 2019
1 parent 0e56c7d commit e4741cf
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 78 deletions.
105 changes: 56 additions & 49 deletions config/cookstyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -304,55 +304,6 @@ ChefDeprecations/CookbookDependsOnPoise:
Include:
- '**/metadata.rb'

ChefDeprecations/ConflictsMetadata:
Description: Don't use the deprecated 'conflicts' metadata value
Enabled: true
VersionAdded: '5.1.0'
Include:
- '**/metadata.rb'

ChefDeprecations/SuggestsMetadata:
Description: Don't use the deprecated 'suggests' metadata value
Enabled: true
VersionAdded: '5.1.0'
Include:
- '**/metadata.rb'

ChefDeprecations/ProvidesMetadata:
Description: Don't use the deprecated 'provides' metadata value
Enabled: true
VersionAdded: '5.1.0'
Include:
- '**/metadata.rb'

ChefDeprecations/ReplacesMetadata:
Description: Don't use the deprecated 'replaces' metadata value
Enabled: true
VersionAdded: '5.1.0'
Include:
- '**/metadata.rb'

ChefDeprecations/AttributeMetadata:
Description: Don't use the deprecated 'attribute' metadata value
Enabled: true
VersionAdded: '5.1.0'
Include:
- '**/metadata.rb'

ChefDeprecations/LongDescriptionMetadata:
Description: The long_description metadata.rb method is not used and is unnecessary in cookbooks
Enabled: true
VersionAdded: '5.2.0'
Include:
- '**/metadata.rb'

ChefDeprecations/RecipeMetadata:
Description: The recipe metadata.rb method is not used and is unnecessary in cookbooks. Recipes should be documented in the README.md file instead.
Enabled: true
VersionAdded: '5.6.0'
Include:
- '**/metadata.rb'

ChefDeprecations/CookbookDependsOnCompatResource:
Description: Don't depend on the deprecated compat_resource cookbook made obsolete by Chef 12.19+
Enabled: true
Expand Down Expand Up @@ -944,6 +895,62 @@ ChefModernize/ChefGemNokogiri:
- '**/metadata.rb'
- '**/attributes/*.rb'

ChefModernize/ConflictsMetadata:
Description: Don't use the deprecated 'conflicts' metadata value
Enabled: true
VersionAdded: '5.1.0'
VersionChanged: '5.15.0'
Include:
- '**/metadata.rb'

ChefModernize/SuggestsMetadata:
Description: Don't use the deprecated 'suggests' metadata value
Enabled: true
VersionAdded: '5.1.0'
VersionChanged: '5.15.0'
Include:
- '**/metadata.rb'

ChefModernize/ProvidesMetadata:
Description: Don't use the deprecated 'provides' metadata value
Enabled: true
VersionAdded: '5.1.0'
VersionChanged: '5.15.0'
Include:
- '**/metadata.rb'

ChefModernize/ReplacesMetadata:
Description: Don't use the deprecated 'replaces' metadata value
Enabled: true
VersionAdded: '5.1.0'
VersionChanged: '5.15.0'
Include:
- '**/metadata.rb'

ChefModernize/AttributeMetadata:
Description: Don't use the deprecated 'attribute' metadata value
Enabled: true
VersionAdded: '5.1.0'
VersionChanged: '5.15.0'
Include:
- '**/metadata.rb'

ChefModernize/LongDescriptionMetadata:
Description: The long_description metadata.rb method is not used and is unnecessary in cookbooks
Enabled: true
VersionAdded: '5.2.0'
VersionChanged: '5.15.0'
Include:
- '**/metadata.rb'

ChefModernize/RecipeMetadata:
Description: The recipe metadata.rb method is not used and is unnecessary in cookbooks. Recipes should be documented in the README.md file instead.
Enabled: true
VersionAdded: '5.6.0'
VersionChanged: '5.15.0'
Include:
- '**/metadata.rb'

###############################
# Migrating to new patterns
###############################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
module RuboCop
module Cop
module Chef
module ChefDeprecations
# The long_description metadata.rb method is not used and is unnecessary in cookbooks
module ChefModernize
# The long_description metadata.rb method is not used and is unnecessary in cookbooks.
#
# @example
#
Expand All @@ -30,7 +30,7 @@ module ChefDeprecations
class LongDescriptionMetadata < Cop
include RangeHelp

MSG = 'The long_description metadata.rb method is not used and is unnecessary in cookbooks'.freeze
MSG = 'The long_description metadata.rb method is not used and is unnecessary in cookbooks.'.freeze

def on_send(node)
add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :long_description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
module RuboCop
module Cop
module Chef
module ChefDeprecations
# Don't use the deprecated 'provides' metadata value
module ChefModernize
# The provides metadata.rb method is not used and is unnecessary in cookbooks.
#
# @example
#
Expand All @@ -28,7 +28,7 @@ module ChefDeprecations
# provides "some_thing"
#
class ProvidesMetadata < Cop
MSG = "Don't use the deprecated 'provides' metadata value".freeze
MSG = "The provides metadata.rb method is not used and is unnecessary in cookbooks.".freeze

def on_send(node)
add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
module RuboCop
module Cop
module Chef
module ChefDeprecations
# The recipe metadata.rb method is not used and is unnecessary in cookbooks. Recipes should be documented
# in the README.md file instead.
module ChefModernize
# The recipe metadata.rb method is not used and is unnecessary in cookbooks. Recipes should be documented in the cookbook's README.md file instead.
#
# @example
#
Expand All @@ -29,7 +28,7 @@ module ChefDeprecations
#
#
class RecipeMetadata < Cop
MSG = 'The recipe metadata.rb method is not used and is unnecessary in cookbooks. Recipes should be documented in the README.md file instead.'.freeze
MSG = "The recipe metadata.rb method is not used and is unnecessary in cookbooks. Recipes should be documented in the cookbook's README.md file instead.".freeze

def on_send(node)
add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :recipe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
module RuboCop
module Cop
module Chef
module ChefDeprecations
# Don't use the deprecated 'replaces' metadata value
module ChefModernize
# The replaces metadata.rb method is not used and is unnecessary in cookbooks. Replacements for existing cookbooks should be documented in the cookbook's README.md file instead.
#
# @example
#
Expand All @@ -28,7 +28,7 @@ module ChefDeprecations
# replaces "another_cookbook"
#
class ReplacesMetadata < Cop
MSG = "Don't use the deprecated 'replaces' metadata value".freeze
MSG = "The replaces metadata.rb method is not used and is unnecessary in cookbooks.".freeze

def on_send(node)
add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :replaces
Expand Down
4 changes: 1 addition & 3 deletions lib/rubocop/cop/chef/modernize/respond_to_resource_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ module RuboCop
module Cop
module Chef
module ChefModernize
# Chef 12.5 introduced the resource_name method for resources. Many cookbooks used
# respond_to?(:resource_name) to provide backwards compatibility with older chef-client
# releases. This backwards compatibility is no longer necessary.
# Chef Infra Client 12.5 introduced the resource_name method for resources. Many cookbooks used respond_to?(:resource_name) to provide backwards compatibility with older chef-client releases. This backwards compatibility is no longer necessary.
#
# @example
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
module RuboCop
module Cop
module Chef
module ChefDeprecations
# Don't use the deprecated 'suggests' metadata value
module ChefModernize
# The suggests metadata.rb method is not used and is unnecessary in cookbooks.
#
# @example
#
Expand All @@ -28,7 +28,7 @@ module ChefDeprecations
# suggests "another_cookbook"
#
class SuggestsMetadata < Cop
MSG = "Don't use the deprecated 'suggests' metadata value".freeze
MSG = "The suggests metadata.rb method is not used and is unnecessary in cookbooks.".freeze

def on_send(node)
add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :suggests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

require 'spec_helper'

describe RuboCop::Cop::Chef::ChefDeprecations::LongDescriptionMetadata, :config do
describe RuboCop::Cop::Chef::ChefModernize::LongDescriptionMetadata, :config do
subject(:cop) { described_class.new(config) }

it 'registers an offense when metadata uses "long_description"' do
expect_offense(<<~RUBY)
description 'foo'
long_description 'foo'
^^^^^^^^^^^^^^^^^^^^^^ The long_description metadata.rb method is not used and is unnecessary in cookbooks
^^^^^^^^^^^^^^^^^^^^^^ The long_description metadata.rb method is not used and is unnecessary in cookbooks.
version '1.0.0'
RUBY

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

require 'spec_helper'

describe RuboCop::Cop::Chef::ChefDeprecations::ProvidesMetadata, :config do
describe RuboCop::Cop::Chef::ChefModernize::ProvidesMetadata, :config do
subject(:cop) { described_class.new(config) }

it 'registers an offense when metadata uses "provides"' do
expect_offense(<<~RUBY)
provides 'foo'
^^^^^^^^^^^^^^ Don't use the deprecated 'provides' metadata value
^^^^^^^^^^^^^^ The provides metadata.rb method is not used and is unnecessary in cookbooks.
RUBY

expect_correction("\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

require 'spec_helper'

describe RuboCop::Cop::Chef::ChefDeprecations::RecipeMetadata, :config do
describe RuboCop::Cop::Chef::ChefModernize::RecipeMetadata, :config do
subject(:cop) { described_class.new(config) }

it 'registers an offense when metadata uses "recipe"' do
expect_offense(<<~RUBY)
recipe 'chef-client::config', 'Configures the client.rb from a template.'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The recipe metadata.rb method is not used and is unnecessary in cookbooks. Recipes should be documented in the README.md file instead.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The recipe metadata.rb method is not used and is unnecessary in cookbooks. Recipes should be documented in the cookbook's README.md file instead.
RUBY

expect_correction("\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

require 'spec_helper'

describe RuboCop::Cop::Chef::ChefDeprecations::ReplacesMetadata, :config do
describe RuboCop::Cop::Chef::ChefModernize::ReplacesMetadata, :config do
subject(:cop) { described_class.new(config) }

it 'registers an offense when metadata uses "replaces"' do
expect_offense(<<~RUBY)
replaces 'foo'
^^^^^^^^^^^^^^ Don't use the deprecated 'replaces' metadata value
^^^^^^^^^^^^^^ The replaces metadata.rb method is not used and is unnecessary in cookbooks.
RUBY

expect_correction("\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

require 'spec_helper'

describe RuboCop::Cop::Chef::ChefDeprecations::SuggestsMetadata, :config do
describe RuboCop::Cop::Chef::ChefModernize::SuggestsMetadata, :config do
subject(:cop) { described_class.new(config) }

it 'registers an offense when metadata uses "suggests"' do
expect_offense(<<~RUBY)
suggests 'foo'
^^^^^^^^^^^^^^ Don't use the deprecated 'suggests' metadata value
^^^^^^^^^^^^^^ The suggests metadata.rb method is not used and is unnecessary in cookbooks.
RUBY

expect_correction("\n")
Expand Down

0 comments on commit e4741cf

Please sign in to comment.