diff --git a/changelog/change_mark_style_struct_inheritance_as_unsafe_auto_correction.md b/changelog/change_mark_style_struct_inheritance_as_unsafe_auto_correction.md new file mode 100644 index 00000000000..f31ee706dab --- /dev/null +++ b/changelog/change_mark_style_struct_inheritance_as_unsafe_auto_correction.md @@ -0,0 +1 @@ +* [#10036](https://github.com/rubocop/rubocop/issues/10036): Mark `Style/StructInheritance` as unsafe auto-correction. ([@koic][]) diff --git a/config/default.yml b/config/default.yml index 19b36715d67..7bf7514ba4a 100644 --- a/config/default.yml +++ b/config/default.yml @@ -4694,8 +4694,9 @@ Style/StructInheritance: Description: 'Checks for inheritance from Struct.new.' StyleGuide: '#no-extend-struct-new' Enabled: true + SafeAutoCorrect: false VersionAdded: '0.29' - VersionChanged: '0.86' + VersionChanged: '<>' Style/SwapValues: Description: 'This cop enforces the use of shorthand-style swapping of 2 variables.' diff --git a/lib/rubocop/cop/style/struct_inheritance.rb b/lib/rubocop/cop/style/struct_inheritance.rb index a367e06c688..e463243ebca 100644 --- a/lib/rubocop/cop/style/struct_inheritance.rb +++ b/lib/rubocop/cop/style/struct_inheritance.rb @@ -5,6 +5,9 @@ module Cop module Style # This cop checks for inheritance from Struct.new. # + # It is marked as unsafe auto-correction because it will change the + # inheritance tree (e.g. return value of `Module#ancestors`). + # # @example # # bad # class Person < Struct.new(:first_name, :last_name)