Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactoring opp: [F] ↗ is more efficient than #1103

Merged
merged 1 commit into from Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/credo/check/consistency/space_around_operators.ex
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
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
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
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
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