Skip to content

Commit

Permalink
Fix false positive for UnusedKeywordOperation
Browse files Browse the repository at this point in the history
Refs #1128
  • Loading branch information
rrrene committed May 8, 2024
1 parent ba4f622 commit 2cfb9f9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
44 changes: 43 additions & 1 deletion lib/credo/check/warning/unused_keyword_operation.ex
Expand Up @@ -34,7 +34,49 @@ defmodule Credo.Check.Warning.UnusedKeywordOperation do
alias Credo.Check.Warning.UnusedOperation

@checked_module :Keyword
@funs_with_return_value nil
@funs_with_return_value [
:delete,
:delete_first,
:drop,
:equal?,
:fetch,
:fetch!,
:filter,
:from_keys,
:get,
:get_and_update,
:get_and_update!,
:get_lazy,
:get_values,
:has_key?,
:keys,
:keyword?,
:merge,
:merge,
:new,
:new,
:new,
:pop,
:pop!,
:pop_first,
:pop_lazy,
:pop_values,
:put,
:put_new,
:put_new_lazy,
:reject,
:replace,
:replace!,
:replace_lazy,
:split,
:split_with,
:take,
:to_list,
:update,
:update!,
:validate,
:values
]

@doc false
@impl true
Expand Down
2 changes: 2 additions & 0 deletions test/credo/check/warning/unused_keyword_operation_test.exs
Expand Up @@ -11,6 +11,8 @@ defmodule Credo.Check.Warning.UnusedKeywordOperationTest do
"""
defmodule CredoSampleModule do
def some_function(parameter1, parameter2) do
Keyword.validate!(opts, [:base_url, :meta, :receive_timeout])
Keyword.values(parameter1) + parameter2
end
Expand Down

0 comments on commit 2cfb9f9

Please sign in to comment.