From 91e75c272a23886e5923917ea9c61aa34c978b0f Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Mon, 26 Sep 2022 18:42:45 -0700 Subject: [PATCH] Mark autocorrection for Lint/UnusedMethodArgument as unsafe. --- changelog/fix_mark_autocorrection_for.md | 1 + config/default.yml | 3 ++- lib/rubocop/cop/lint/unused_method_argument.rb | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelog/fix_mark_autocorrection_for.md diff --git a/changelog/fix_mark_autocorrection_for.md b/changelog/fix_mark_autocorrection_for.md new file mode 100644 index 00000000000..f0c0220f826 --- /dev/null +++ b/changelog/fix_mark_autocorrection_for.md @@ -0,0 +1 @@ +* [#11020](https://github.com/rubocop/rubocop/pull/11020): Mark autocorrection for Lint/UnusedMethodArgument as unsafe. ([@dduugg][]) diff --git a/config/default.yml b/config/default.yml index 4da5ba3c263..125dbdd6735 100644 --- a/config/default.yml +++ b/config/default.yml @@ -2366,8 +2366,9 @@ Lint/UnusedMethodArgument: Description: 'Checks for unused method arguments.' StyleGuide: '#underscore-unused-vars' Enabled: true + SafeAutoCorrect: false VersionAdded: '0.21' - VersionChanged: '0.81' + VersionChanged: '<>' AllowUnusedKeywordArguments: false IgnoreEmptyMethods: true IgnoreNotImplementedMethods: true diff --git a/lib/rubocop/cop/lint/unused_method_argument.rb b/lib/rubocop/cop/lint/unused_method_argument.rb index f305f3be4ba..c66a5399a25 100644 --- a/lib/rubocop/cop/lint/unused_method_argument.rb +++ b/lib/rubocop/cop/lint/unused_method_argument.rb @@ -5,6 +5,11 @@ module Cop module Lint # Checks for unused method arguments. # + # @safety + # Autocorrection for this cop is not safe. There may be metaprogramming attached to the + # method (such as a Sorbet `sig`), YARD annoations, and type signtures in RBI or RBS files, + # which will retain the previous argument names under autocorrection. + # # @example # # bad # def some_method(used, unused, _unused_but_allowed)