mirror of
https://github.com/joshuaclayton/unused.git
synced 2024-09-11 04:45:28 +03:00
Why? ==== Dynamic languages, and Rails in particular, support some fun method creation. One common pattern is, within RSpec, to create matchers dynamically based on predicate methods. Two common examples are: * `#admin?` gets converted to the matcher `#be_admin` * `#has_active_todos?` gets converted to the matcher `#have_active_todos` This especially comes into play when writing page objects with predicate methods. This change introduces the concept of aliases, a way to describe the before/after for these transformations. This introduces a direct swap with a wildcard value (%s), although this may change in the future to support other transformations for pluralization, camel-casing, etc. Externally, aliases are not grouped together by term; however, the underlying counts are summed together, increasing the total occurrences and likely pushing the individual method out of "high" likelihood into "medium" or "low" likelihood. Closes #19.
85 lines
1.7 KiB
YAML
85 lines
1.7 KiB
YAML
- name: Rails
|
|
aliases:
|
|
- from: "%s?"
|
|
to: "be_%s"
|
|
- from: "has_%s?"
|
|
to: "have_%s"
|
|
allowedTerms:
|
|
# serialization
|
|
- as_json
|
|
# inflection
|
|
- Inflector
|
|
# Concerns
|
|
- ClassMethods
|
|
- class_methods
|
|
- included
|
|
# rendering
|
|
- to_partial_path
|
|
autoLowLikelihood:
|
|
- name: Migration
|
|
pathStartsWith: db/migrate/
|
|
classOrModule: true
|
|
appOccurrences: 1
|
|
- name: Migration Helper
|
|
pathStartsWith: db/migrate/
|
|
allowedTerms:
|
|
- up
|
|
- down
|
|
- change
|
|
- index
|
|
- name: i18n
|
|
allowedTerms:
|
|
- t
|
|
- l
|
|
pathEndsWith: .rb
|
|
- name: Controller
|
|
pathStartsWith: app/controllers
|
|
termEndsWith: Controller
|
|
classOrModule: true
|
|
- name: Helper
|
|
pathStartsWith: app/helpers
|
|
termEndsWith: Helper
|
|
classOrModule: true
|
|
- name: Phoenix
|
|
allowedTerms:
|
|
- Mixfile
|
|
- __using__
|
|
autoLowLikelihood:
|
|
- name: Migration
|
|
pathStartsWith: priv/repo/migrations
|
|
classOrModule: true
|
|
- name: View
|
|
pathStartsWith: web/views/
|
|
termEndsWith: View
|
|
classOrModule: true
|
|
- name: Test
|
|
pathStartsWith: test/
|
|
termEndsWith: Test
|
|
classOrModule: true
|
|
- name: Controller actions
|
|
pathStartsWith: web/controllers
|
|
allowedTerms:
|
|
- index
|
|
- new
|
|
- create
|
|
- show
|
|
- edit
|
|
- update
|
|
- destroy
|
|
- name: Haskell
|
|
allowedTerms: []
|
|
autoLowLikelihood:
|
|
- name: Spec
|
|
pathStartsWith: test/
|
|
termEndsWith: Spec
|
|
classOrModule: true
|
|
- name: Cabalfile
|
|
pathEndsWith: .cabal
|
|
appOccurrences: 1
|
|
- name: TypeClasses
|
|
termEquals: instance
|
|
pathEndsWith: .hs
|
|
- name: Spec functions
|
|
termEquals: spec
|
|
pathStartsWith: test/
|