Skip to content

Commit

Permalink
Rename check to UnecessaryIfUnless
Browse files Browse the repository at this point in the history
  • Loading branch information
sodapopcan committed Jun 29, 2024
1 parent 3094ae0 commit 38bcceb
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 36 deletions.
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ on `sourceror`.
> mix recode.help

Design tasks:
TagFIXME # Checker - Checks if there are FIXME tags in the sources.
TagTODO # Checker - Checks if there are TODO tags in the sources.
Readability tasks:
AliasExpansion # Corrector - Exapnds multi aliases to separate aliases.
AliasOrder # Corrector - Checks if aliases are sorted alphabetically.
EnforceLineLength # Corrector - Forces expressions to one line.
Format # Corrector - Does the same as `mix format`.
PipeFunOne # Corrector - Add parentheses to one-arity functions.
SinglePipe # Corrector - Pipes should only be used when piping data through multiple calls.
Specs # Checker - Checks for specs.
TagFIXME # Checker - Checks if there are FIXME tags in the sources.
TagTODO # Checker - Checks if there are TODO tags in the sources.
Readability tasks:
AliasExpansion # Corrector - Exapnds multi aliases to separate aliases.
AliasOrder # Corrector - Checks if aliases are sorted alphabetically.
EnforceLineLength # Corrector - Forces expressions to one line.
Format # Corrector - Does the same as `mix format`.
PipeFunOne # Corrector - Add parentheses to one-arity functions.
SinglePipe # Corrector - Pipes should only be used when piping data through multiple calls.
Specs # Checker - Checks for specs.
Refactor tasks:
FilterCount # Corrector - Checks calls like Enum.filter(...) |> Enum.count().
Nesting # Checker - Checks code nesting depth in functions and macros.
RedundantBooleans # Corrector - Removes `do: true, else: false`
FilterCount # Corrector - Checks calls like Enum.filter(...) |> Enum.count().
Nesting # Checker - Checks code nesting depth in functions and macros.
UnnecessaryIfUnless # Corrector - Changes `if expr, do: true, else: false` to `expr`
Warning tasks:
Dbg # Corrector - There should be no calls to dbg.
IOInspect # Corrector - There should be no calls to IO.inspect.
TestFileExt # Corrector - Checks the file extension of test files.
UnusedVariable # Corrector - Checks if unused variables occur.
Dbg # Corrector - There should be no calls to dbg.
IOInspect # Corrector - There should be no calls to IO.inspect.
TestFileExt # Corrector - Checks the file extension of test files.
UnusedVariable # Corrector - Checks if unused variables occur.
```

It is also possible to run `recode` in a none-autocorrect mode to just lint your
Expand Down Expand Up @@ -110,7 +110,7 @@ This mix task generates the config file `.recode.exs`.
{Recode.Task.IOInspect, [autocorrect: false]},
{Recode.Task.Nesting, []},
{Recode.Task.PipeFunOne, []},
{Recode.Task.RedundantBooleans, []},
{Recode.Task.UnnecessaryIfUnless, []},
{Recode.Task.SinglePipe, []},
{Recode.Task.Specs, [exclude: "test/**/*.{ex,exs}", config: [only: :visible]]},
{Recode.Task.TagFIXME, [exit_code: 2]},
Expand Down
2 changes: 1 addition & 1 deletion lib/recode/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule Recode.Config do
# {Recode.Task.Moduledoc, []},
{Recode.Task.Nesting, []},
{Recode.Task.PipeFunOne, []},
{Recode.Task.RedundantBooleans, []},
{Recode.Task.UnnecessaryIfUnless, []},
{Recode.Task.SinglePipe, []},
{Recode.Task.Specs, [exclude: ["test/**/*.{ex,exs}", "mix.exs"], config: [only: :visible]]},
{Recode.Task.TagFIXME, exit_code: 2},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Recode.Task.RedundantBooleans do
defmodule Recode.Task.UnnecessaryIfUnless do
@shortdoc "Removes redundant booleans"

@moduledoc """
Expand All @@ -20,7 +20,7 @@ defmodule Recode.Task.RedundantBooleans do
use Recode.Task, corrector: true, category: :readability

alias Recode.Issue
alias Recode.Task.RedundantBooleans
alias Recode.Task.UnnecessaryIfUnless
alias Rewrite.Source
alias Sourceror.Zipper

Expand All @@ -36,7 +36,7 @@ defmodule Recode.Task.RedundantBooleans do

case opts[:autocorrect] do
true ->
Source.update(source, RedundantBooleans, :quoted, Zipper.root(zipper))
Source.update(source, UnnecessaryIfUnless, :quoted, Zipper.root(zipper))

false ->
Source.add_issues(source, issues)
Expand Down Expand Up @@ -70,7 +70,7 @@ defmodule Recode.Task.RedundantBooleans do
case extract(body, conditional) do
{:ok, _expr} ->
message = "Avoid `do: true, else: false`"
issue = Issue.new(RedundantBooleans, message, meta)
issue = Issue.new(UnnecessaryIfUnless, message, meta)
[issue | issues]

:error ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Recode.Task.RedundantBooleansTest do
defmodule Recode.Task.UnnecessaryIfUnlessTest do
use RecodeCase

alias Recode.Task.RedundantBooleans
alias Recode.Task.UnnecessaryIfUnless

describe "run/1" do
test "equals" do
Expand All @@ -18,7 +18,7 @@ defmodule Recode.Task.RedundantBooleansTest do
"""

code
|> run_task(RedundantBooleans, autocorrect: true)
|> run_task(UnnecessaryIfUnless, autocorrect: true)
|> assert_code(expected)
end

Expand All @@ -36,7 +36,7 @@ defmodule Recode.Task.RedundantBooleansTest do
"""

code
|> run_task(RedundantBooleans, autocorrect: true)
|> run_task(UnnecessaryIfUnless, autocorrect: true)
|> assert_code(expected)
end

Expand All @@ -50,7 +50,7 @@ defmodule Recode.Task.RedundantBooleansTest do
"""

code
|> run_task(RedundantBooleans, autocorrect: true)
|> run_task(UnnecessaryIfUnless, autocorrect: true)
|> assert_code(expected)
end

Expand All @@ -68,7 +68,7 @@ defmodule Recode.Task.RedundantBooleansTest do
"""

code
|> run_task(RedundantBooleans, autocorrect: true)
|> run_task(UnnecessaryIfUnless, autocorrect: true)
|> assert_code(expected)
end

Expand All @@ -88,7 +88,7 @@ defmodule Recode.Task.RedundantBooleansTest do
"""

code
|> run_task(RedundantBooleans, autocorrect: true)
|> run_task(UnnecessaryIfUnless, autocorrect: true)
|> assert_code(expected)
end

Expand All @@ -110,7 +110,7 @@ defmodule Recode.Task.RedundantBooleansTest do
"""

code
|> run_task(RedundantBooleans, autocorrect: true)
|> run_task(UnnecessaryIfUnless, autocorrect: true)
|> assert_code(expected)
end

Expand All @@ -128,7 +128,7 @@ defmodule Recode.Task.RedundantBooleansTest do
"""

code
|> run_task(RedundantBooleans, autocorrect: true)
|> run_task(UnnecessaryIfUnless, autocorrect: true)
|> assert_code(expected)
end

Expand All @@ -146,15 +146,15 @@ defmodule Recode.Task.RedundantBooleansTest do
"""

code
|> run_task(RedundantBooleans, autocorrect: true)
|> run_task(UnnecessaryIfUnless, autocorrect: true)
|> assert_code(expected)
end

test "reports no issues" do
"""
foo == bar
"""
|> run_task(RedundantBooleans, autocorrect: false)
|> run_task(UnnecessaryIfUnless, autocorrect: false)
|> refute_issues()
end

Expand All @@ -166,8 +166,8 @@ defmodule Recode.Task.RedundantBooleansTest do
false
end
"""
|> run_task(RedundantBooleans, autocorrect: false)
|> assert_issue_with(reporter: RedundantBooleans)
|> run_task(UnnecessaryIfUnless, autocorrect: false)
|> assert_issue_with(reporter: UnnecessaryIfUnless)
end
end
end

0 comments on commit 38bcceb

Please sign in to comment.