|
4 | 4 |
|
5 | 5 | # Styler |
6 | 6 |
|
7 | | -Styler is an Elixir formatter plugin that's a combination of `mix format` and `mix credo`, but instead of _telling_ |
8 | | -you what's wrong, it just fixes the code for you to fit its style rules. |
| 7 | +Styler is an Elixir formatter plugin that goes beyond formatting by rewriting your code for consistency, readability, and optimization. |
9 | 8 |
|
10 | 9 | ## Features |
11 | 10 |
|
@@ -86,11 +85,13 @@ However, Smartrent has a fork of Styler named [Quokka](https://github.com/smartr |
86 | 85 |
|
87 | 86 | Ultimately Styler is @adobe's internal tool that we're happy to share with the world. We're delighted if you like it as is, and just as excited if it's a starting point for you to make something even better for yourself. |
88 | 87 |
|
89 | | -## WARNING: Styler can change the behaviour of your program! |
| 88 | +## WARNING: Styler can change the behaviour of your program |
90 | 89 |
|
91 | | -In some cases, this can introduce bugs. It goes without saying, but look over your changes before committing to main :) |
| 90 | +While Styler endeavors to never purposefully create bugs, some of its rewrites can introduce them in obscure cases. |
92 | 91 |
|
93 | | -A simple example of a way Styler changes the behaviour of code is the following rewrite: |
| 92 | +It goes without saying, but look over any changes Styler writes before committing to main. |
| 93 | + |
| 94 | +A simple example of a way Styler rewrite can introduce a bug is the following case statement: |
94 | 95 |
|
95 | 96 | ```elixir |
96 | 97 | # Before: this case statement... |
|
109 | 110 |
|
110 | 111 | These programs are not semantically equivalent. The former would raise if `foo` returned any value other than `true` or `false`, while the latter blissfully completes. |
111 | 112 |
|
112 | | -However, Styler is about _style_, and the `if` statement is (in our opinion) of much better style. If the exception behaviour was intentional on the code author's part, they should have written the program like this: |
113 | | - |
114 | | -```elixir |
115 | | -case foo do |
116 | | - true -> :ok |
117 | | - false -> :error |
118 | | - other -> raise "expected `true` or `false`, got: #{inspect other}" |
119 | | -end |
120 | | -``` |
121 | | - |
122 | | -Also good style! But Styler assumes that most of the time people just meant the `if` equivalent of the code, and so makes that change. If issues like this bother you, Styler probably isn't the tool you're looking for. |
| 113 | +If issues like this bother you, Styler probably isn't the tool you're looking for. |
123 | 114 |
|
124 | | -Other ways Styler can change your program: |
| 115 | +Other ways Styler _could_ introduce runtime bugs: |
125 | 116 |
|
126 | 117 | - [`with` statement rewrites](https://github.com/adobe/elixir-styler/issues/186) |
127 | 118 | - [config file sorting](https://hexdocs.pm/styler/mix_configs.html#this-can-break-your-program) |
|
0 commit comments