View Source ExactoKnife
Refactoring tools for elixir!
refactorings
Refactorings
refactoring-sort-aliases
Refactoring: Sort aliases
> mix refactor sort_aliases [FILE]
Sort all aliases in a file:
alias Alpha
alias Alpha.Bravo
alias Alpha.Charlie
alias Delta
refactoring-expand-aliases
Refactoring: Expand aliases
> mix refactor expand_aliases [FILE]
Expand out all aliases in a file:
alias Foo.Bar.Baz
alias Foo.Bar.Boom
refactoring-consolidate-aliases
Refactoring: Consolidate aliases
> mix refactor consolidate_aliases [FILE]
Sort and combine all aliases in a file:
alias Foo.Bar.{Baz, Boom}
refactoring-rename-variable
Refactoring: Rename Variable
> mix refactor rename [FILE] [LINE] [COLUMN]
Renames a variable (currently this is a fairly naive implementation - issues welcome!)
More to come...
running-against-an-entire-codebase
Running against an entire codebase
Find is your friend
> find lib -type f -name "*.ex*" | xargs -n1 mix refactor sort_aliases
installation
Installation
Exacto Knife can be installed by adding exacto_knife
to your list of dependencies in mix.exs
:
def deps do
[
{:exacto_knife, "~> 0.1.5"}
]
end
Docs can be found at https://hexdocs.pm/exacto_knife.
contributing
Contributing
- Clone the repo
- Write a failing test for your change
- Make sure all tests pass
- Submit a PR
- We all win!!!
releasing
Releasing
- bump the version in
mix.exs
andREADME.md
- commit
- make sure github ci passes
- run
mix hex.publish
links
Links
- Elixir Syntax Reference has a good intro to the AST.
- Sourceror Docs are pretty great, understanding their zippers is essential.
- AST Ninja will show you the ast for specific code.