Skip to content

Commit

Permalink
Added a check for credo pipeline initial argument (#200)
Browse files Browse the repository at this point in the history
I often tell people in PRs to "commit to the pipeline", this credo
check will do it for me.

Also cleaned up instances where we don't do that in code.
  • Loading branch information
scohen authored Jun 2, 2023
1 parent 50ad0a8 commit b6cdbed
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 11 deletions.
5 changes: 3 additions & 2 deletions .credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
parse_timeout: 5000,
color: true,
checks: [
{Credo.Check.Design.AliasUsage, if_nested_deeper_than: 3, if_called_more_often_than: 1},
{Credo.Check.Readability.AliasOrder, []},
{Credo.Check.Readability.ModuleDoc, false},
{Credo.Check.Readability.PreferImplicitTry, false},
{Credo.Check.Readability.AliasOrder, []},
{Credo.Check.Refactor.CyclomaticComplexity, max_complexity: 10},
{Credo.Check.Refactor.Nesting, max_nesting: 3},
{Credo.Check.Design.AliasUsage, if_nested_deeper_than: 3, if_called_more_often_than: 1}
{Credo.Check.Refactor.PipeChainStart, []}
]
}
]
Expand Down
3 changes: 2 additions & 1 deletion apps/proto/lib/lexical/proto/macros/struct.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ defmodule Lexical.Proto.Macros.Struct do
end

defp required_keys(opts) do
Enum.filter(opts, fn
opts
|> Enum.filter(fn
# ignore the splat, it's always optional
{:.., _} -> false
# an optional signifier tuple
Expand Down
3 changes: 2 additions & 1 deletion apps/proto/lib/mix/tasks/namespace/abstract.ex
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ defmodule Mix.Tasks.Namespace.Abstract do
:LXRelease

["Elixir" | rest] ->
Enum.map(rest, fn
rest
|> Enum.map(fn
"Lexical" -> "LXRelease"
other -> other
end)
Expand Down
3 changes: 2 additions & 1 deletion apps/remote_control/lib/lexical/remote_control/bootstrap.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ defmodule Lexical.RemoteControl.Bootstrap do
hex_ebin = Path.join(["hex-*", "**", "ebin"])

[hex_path] =
Mix.path_for(:archives)
:archives
|> Mix.path_for()
|> Path.join(hex_ebin)
|> Path.wildcard()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ defmodule Lexical.RemoteControl.Build.Error do
end

defp find_location(lines) do
Enum.find(lines, fn
lines
|> Enum.find(fn
line when is_binary(line) ->
Regex.scan(@location_re, line) != [] or Regex.scan(@file_and_line_re, line) != []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ defmodule Lexical.RemoteControl.ProjectNodeTest do
test "it should be able to stop a project node and won't restart", %{project: project} do
{:ok, _node_name, _} = RemoteControl.start_link(project, self())

assert ProjectNode.name(project) |> Process.whereis() |> Process.alive?()
project_alive? = project |> ProjectNode.name() |> Process.whereis() |> Process.alive?()

assert project_alive?
assert :ok = ProjectNode.stop(project, 500)
assert Process.whereis(ProjectNode.name(project)) == nil
end
Expand Down
6 changes: 5 additions & 1 deletion apps/server/lib/lexical/server/json_rpc_backend.ex
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ defmodule Lexical.Server.JsonRpc.Backend do
defp init(config, state) do
level = Keyword.get(config, :level)
format = Logger.Formatter.compile(Keyword.get(config, :format))
metadata = Keyword.get(config, :metadata, []) |> configure_metadata()

metadata =
config
|> Keyword.get(:metadata, [])
|> configure_metadata()

%{
state
Expand Down
3 changes: 2 additions & 1 deletion apps/server/test/document_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ defmodule Lexical.DocumentTest do

def position_after_substring(text, sub_text) do
index = index_of(text, sub_text)
position_at(text, index + (String.to_charlist(sub_text) |> length))

position_at(text, index + (sub_text |> String.to_charlist() |> length))
end

def range_for_substring(doc, sub_text) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ defmodule Lexical.Project.Diagnostics.StateTest do

describe "clear_all_flushed/1" do
test "it should not clear a dirty open file", %{state: state} do
document = document("hello") |> change_with("hello2")
document =
"hello"
|> document()
|> change_with("hello2")

state = State.add(state, compiler_diagnostic(message: "The code is awful"))

Expand Down
4 changes: 3 additions & 1 deletion apps/server/test/lexical/server/project/node_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ defmodule Lexical.Server.Project.NodeTest do
end

defp node_pid(project) do
RemoteControl.ProjectNode.name(project) |> Process.whereis()
project
|> RemoteControl.ProjectNode.name()
|> Process.whereis()
end
end

0 comments on commit b6cdbed

Please sign in to comment.