diff --git a/changelog/change_enforced_style_for_lint_inherit_exception.md b/changelog/change_enforced_style_for_lint_inherit_exception.md new file mode 100644 index 00000000000..3db910ae623 --- /dev/null +++ b/changelog/change_enforced_style_for_lint_inherit_exception.md @@ -0,0 +1 @@ +* [#10407](https://github.com/rubocop/rubocop/pull/10407): Change `EnforcedStyle` from `runtime_error` to `standard_error` for `Lint/InheritException`. ([@koic][]) diff --git a/config/default.yml b/config/default.yml index ade37e44762..7dd3d931e19 100644 --- a/config/default.yml +++ b/config/default.yml @@ -1820,10 +1820,10 @@ Lint/InheritException: VersionAdded: '0.41' VersionChanged: '<>' # The default base class in favour of `Exception`. - EnforcedStyle: runtime_error + EnforcedStyle: standard_error SupportedStyles: - - runtime_error - standard_error + - runtime_error Lint/InterpolationCheck: Description: 'Raise warning for interpolation in single q strs.' diff --git a/lib/rubocop/cop/lint/inherit_exception.rb b/lib/rubocop/cop/lint/inherit_exception.rb index 06e45f01f6b..53b406c1c0a 100644 --- a/lib/rubocop/cop/lint/inherit_exception.rb +++ b/lib/rubocop/cop/lint/inherit_exception.rb @@ -6,14 +6,14 @@ module Lint # This cop looks for error classes inheriting from `Exception` # and its standard library subclasses, excluding subclasses of # `StandardError`. It is configurable to suggest using either - # `RuntimeError` (default) or `StandardError` instead. + # `StandardError` (default) or `RuntimeError` instead. # # @safety # This cop's autocorrection is unsafe because `rescue` that omit # exception class handle `StandardError` and its subclasses, # but not `Exception` and its subclasses. # - # @example EnforcedStyle: runtime_error (default) + # @example EnforcedStyle: standard_error (default) # # bad # # class C < Exception; end @@ -22,11 +22,11 @@ module Lint # # # good # - # class C < RuntimeError; end + # class C < StandardError; end # - # C = Class.new(RuntimeError) + # C = Class.new(StandardError) # - # @example EnforcedStyle: standard_error + # @example EnforcedStyle: runtime_error # # bad # # class C < Exception; end @@ -35,9 +35,9 @@ module Lint # # # good # - # class C < StandardError; end + # class C < RuntimeError; end # - # C = Class.new(StandardError) + # C = Class.new(RuntimeError) class InheritException < Base include ConfigurableEnforcedStyle extend AutoCorrector