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