Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the metadata cops to ChefModernize #426

Merged
merged 3 commits into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
# Don't use the deprecated 'attribute' metadata value
module ChefModernize
# The attribute metadata.rb method is not used and is unnecessary in cookbooks.
#
# @example
#
Expand All @@ -33,7 +33,7 @@ module ChefDeprecations
# default: '"127.0.0.1:2181"'
#
class AttributeMetadata < Cop
MSG = "Don't use the deprecated 'attribute' metadata value".freeze
MSG = 'The attribute 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 == :attribute
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 'conflicts' metadata value
module ChefModernize
# The conflicts metadata.rb method is not used and is unnecessary in cookbooks.
#
# @example
#
Expand All @@ -28,7 +28,7 @@ module ChefDeprecations
# conflicts "another_cookbook"
#
class ConflictsMetadata < Cop
MSG = "Don't use the deprecated 'conflicts' metadata value".freeze
MSG = 'The conflicts 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 == :conflicts
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,13 +16,13 @@

require 'spec_helper'

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

it 'registers an offense when metadata uses "attribute"' do
expect_offense(<<~RUBY)
attribute 'foo'
^^^^^^^^^^^^^^^ Don't use the deprecated 'attribute' metadata value
^^^^^^^^^^^^^^^ The attribute 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::ConflictsMetadata, :config do
describe RuboCop::Cop::Chef::ChefModernize::ConflictsMetadata, :config do
subject(:cop) { described_class.new(config) }

it 'registers an offense when metadata uses "conflicts"' do
expect_offense(<<~RUBY)
conflicts 'foo'
^^^^^^^^^^^^^^^ Don't use the deprecated 'conflicts' metadata value
^^^^^^^^^^^^^^^ The conflicts 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,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