/vendor/bundle/ruby/2.4.0/gems/reek-4.8.0/docs/Uncommunicative-Method-Name.md

https://bitbucket.org/deeparaman/api-sample-app · Markdown · 55 lines · 41 code · 14 blank · 0 comment · 0 complexity · 3b51022a611ae433e46641b16fb640de MD5 · raw file

  1. # Uncommunicative Method Name
  2. ## Introduction
  3. An _Uncommunicative Method Name_ is a method name that doesn't communicate its
  4. intent well enough. This code smell is a case of
  5. [Uncommunicative Name](Uncommunicative-Name.md).
  6. ## Current Support in Reek
  7. _Uncommunicative Method Name_ checks for:
  8. * single-character names
  9. * any name ending with a number
  10. * camelCaseMethodNames
  11. ## Configuration
  12. Reek's _Uncommunicative Method Name_ detector supports the
  13. [Basic Smell Options](Basic-Smell-Options.md), plus:
  14. | Option | Value | Effect |
  15. | ---------------|-------------|---------|
  16. | `reject` | array of regular expressions or strings | The set of patterns / names that Reek uses to check for bad names. Defaults to `[/^[a-z]$/, /[0-9]$/, /[A-Z]/]`. |
  17. | `accept` | array of regular expressions or strings | The set of patterns / names that Reek will accept (and not report) even if they match one of the `reject` expressions. |
  18. An example configuration could look like this:
  19. ```Yaml
  20. ---
  21. UncommunicativeMethodName:
  22. accept:
  23. - !ruby/regexp /x/
  24. - meth1
  25. reject:
  26. - !ruby/regexp /helper/
  27. - foobar
  28. ```
  29. Applying a configuration to a source file like this:
  30. ```Ruby
  31. def x; end # Should not be reported
  32. def meth1; end # Should not be reported
  33. def foobar; end # Should be reported
  34. def awesome_helper; end # Should be reported
  35. ```
  36. Reek would report:
  37. ```
  38. smelly.rb -- 2 warnings:
  39. [4]:UncommunicativeMethodName: awesome_helper has the name 'awesome_helper' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
  40. [3]:UncommunicativeMethodName: foobar has the name 'foobar' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
  41. ```