Skip to content

[UnnecessaryFunctionArguments] Warning on callback implementations #71

@pbrudnick

Description

@pbrudnick

Bug Description

The UnnecessaryFunctionArguments rule is analyzing callback implementations which don't have set @impl before.

To Reproduce

I have this module implementing Plug:

defmodule CoophubWeb.Plug.SubdomainMatcher do
  @behaviour Plug
  import Plug.Conn, only: [put_private: 3, halt: 1]
  import Phoenix.Controller, only: [redirect: 2]

  @spec init(Keyword.t()) :: Keyword.t()
  def init(_opts) do
    Application.get_env(:coophub, CoophubWeb.Endpoint)[:url][:host]
  end

REDACTED
end

And I get:

lib/coophub_web/plug/subdomain_matcher.ex:7 - In module CoophubWeb.Plug.SubdomainMatcher: Argument in position 1 of CoophubWeb.Plug.SubdomainMatcher.init/1 is ignored in all of its clauses

Expected Behavior

Ignore callback implementations without @impl (maybe functions with same name/arity used in the module) or suggest to add it. Besides, e.g, the Plug docs don't suggest that thing https://hexdocs.pm/plug/readme.html#hello-world

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions