Skip to content

Commit

Permalink
Merge pull request #1103 from bradhanks/credo
Browse files Browse the repository at this point in the history
refactoring opp: [F] ↗  is more efficient than
  • Loading branch information
rrrene committed Jan 4, 2024
2 parents c30a1a5 + ab10d78 commit 16b47de
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions lib/credo/check/consistency/space_around_operators.ex
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@ defmodule Credo.Check.Consistency.SpaceAroundOperators do
typed_after?,
typed_before?
]
|> Enum.filter(& &1)
|> Enum.count()
|> Enum.count(& &1)

heuristics_met_count >= 2
end
Expand Down
3 changes: 1 addition & 2 deletions lib/credo/cli/command/diff/diff_summary.ex
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ defmodule Credo.CLI.Command.Diff.DiffSummary do

defp category_count(issues, category) do
issues
|> Enum.filter(&(&1.category == category))
|> Enum.count()
|> Enum.count(&(&1.category == category))
end

defp summary_parts_new(_source_files, issues) do
Expand Down
3 changes: 1 addition & 2 deletions lib/credo/cli/output/first_run_hint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ defmodule Credo.CLI.Output.FirstRunHint do

readability_issue_count =
issues
|> Enum.filter(&(&1.category == :readability))
|> Enum.count()
|> Enum.count(&(&1.category == :readability))

relative_issue_count_per_category = div(issue_count, @category_count)

Expand Down
3 changes: 1 addition & 2 deletions lib/credo/cli/output/summary.ex
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ defmodule Credo.CLI.Output.Summary do

defp category_count(issues, category) do
issues
|> Enum.filter(&(&1.category == category))
|> Enum.count()
|> Enum.count(&(&1.category == category))
end

defp summary_parts(source_files, issues) do
Expand Down
3 changes: 1 addition & 2 deletions test/credo/config_file_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,7 @@ defmodule Credo.ConfigFileTest do

config_subdir_count =
dirs
|> Enum.filter(&String.ends_with?(&1, "config"))
|> Enum.count()
|> Enum.count(&String.ends_with?(&1, "config"))

assert config_subdir_count > 1
end
Expand Down

0 comments on commit 16b47de

Please sign in to comment.