Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix rubocop#8229] Fix faulty calculation in UncommunicativeName
`UncommunicativeName#check` does faulty calculation of location when a parameter has a prefix like `_`, `*`. As for the file below, ```ruby def test1(_a); end def test2(__a); end def test3(*a); end def test4(**a); end def test5(**__a); end ``` it shows offenses with faulty locations. ```shell $ rubocop test.rb Inspecting 1 file C Offenses: test.rb:3:11: C: Naming/MethodParameterName: Method parameter must be at least 3 characters long. def test1(_a); end ^ test.rb:5:11: C: Naming/MethodParameterName: Method parameter must be at least 3 characters long. def test2(__a); end ^ test.rb:7:11: C: Naming/MethodParameterName: Method parameter must be at least 3 characters long. def test3(*a); end ^ test.rb:9:11: C: Naming/MethodParameterName: Method parameter must be at least 3 characters long. def test4(**a); end ^ test.rb:11:11: C: Naming/MethodParameterName: Method parameter must be at least 3 characters long. def test5(**__a); end ^ 1 file inspected, 5 offenses detected ``` This commit fixed the behavior and make it show the correct locations. ```shell $ rubocop test.rb Inspecting 1 file C Offenses: test.rb:3:11: C: Naming/MethodParameterName: Method parameter must be at least 3 characters long. def test1(_a); end ^^ test.rb:5:11: C: Naming/MethodParameterName: Method parameter must be at least 3 characters long. def test2(__a); end ^^^ test.rb:7:11: C: Naming/MethodParameterName: Method parameter must be at least 3 characters long. def test3(*a); end ^^ test.rb:9:11: C: Naming/MethodParameterName: Method parameter must be at least 3 characters long. def test4(**a); end ^^^ test.rb:11:11: C: Naming/MethodParameterName: Method parameter must be at least 3 characters long. def test5(**__a); end ^^^^^ 1 file inspected, 5 offenses detected ```
- Loading branch information