From 2eb3844d70fd4d69b78dabdb4cad86c56ba46181 Mon Sep 17 00:00:00 2001 From: Kaiti Thoma Date: Wed, 15 Jun 2022 10:34:40 +0300 Subject: [PATCH] [Fix rubocop#10245] Add deprecated attributes Add specification_version and rubygems_version to Gemspec/DeprecatedAttributeAssignment --- changelog/new_add_deprecated_attributes.md | 1 + lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb | 2 +- .../rubocop/cop/gemspec/deprecated_attribute_assignment_spec.rb | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelog/new_add_deprecated_attributes.md diff --git a/changelog/new_add_deprecated_attributes.md b/changelog/new_add_deprecated_attributes.md new file mode 100644 index 00000000000..35d2e374be2 --- /dev/null +++ b/changelog/new_add_deprecated_attributes.md @@ -0,0 +1 @@ +* [#10245](https://github.com/rubocop/rubocop/pull/10245): Add specification_version and rubygems_version to `Gemspec/DeprecatedAttributeAssignment`. ([@kaitielth][]) diff --git a/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb b/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb index 938d9f872f4..f68ea281c5d 100644 --- a/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb +++ b/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb @@ -70,7 +70,7 @@ def node_and_method_name(node, attribute) end def use_deprecated_attributes?(node, block_parameter) - %i[test_files date].each do |attribute| + %i[test_files date specification_version rubygems_version].each do |attribute| node, method_name = node_and_method_name(node, attribute) unless node.send_type? && node.receiver&.source == block_parameter && node.method?(method_name) diff --git a/spec/rubocop/cop/gemspec/deprecated_attribute_assignment_spec.rb b/spec/rubocop/cop/gemspec/deprecated_attribute_assignment_spec.rb index 6e1ecfa1f43..45df9c94801 100644 --- a/spec/rubocop/cop/gemspec/deprecated_attribute_assignment_spec.rb +++ b/spec/rubocop/cop/gemspec/deprecated_attribute_assignment_spec.rb @@ -92,6 +92,8 @@ end it_behaves_like 'deprecated attributes', 'date', "Time.now.strftime('%Y-%m-%d')" + it_behaves_like 'deprecated attributes', 'rubygems_version', '2.5' + it_behaves_like 'deprecated attributes', 'specification_version', '2.5' it_behaves_like 'deprecated attributes', 'test_files', "Dir.glob('test/**/*')" it_behaves_like 'deprecated attributes with addition', 'test_files', "Dir.glob('test/**/*')" end