ueberauth / guardian

Elixir Authentication
MIT License
3.43k stars 382 forks source link

Fixes Dialyzer error for Guardian.Plug.Pipeline.implementation/0 #572

Closed holsee closed 5 years ago

holsee commented 5 years ago

Addresses issue whereby dialyzer will warn that "Type specification is a supertype of the success typing." on the generated implementation/0 function when using Guardian.Plug.Pipeline.

This is technically an "underspecification" error. See: http://erlang.org/doc/man/dialyzer.html -Wunderspecs

Full Dialyzer Warning:

lib/my_app/authorisation/guardian.ex:2:contract_supertype
Type specification is a supertype of the success typing.

Function:
MyApp.Authorisation.Guardian.Plug.implementation/0

Type specification:
@spec implementation() :: module()

Success typing:
@spec implementation() :: MyApp.Authorisation.Guardian

Usage:

defmodule MyApp.Authorisation.Pipeline do
  use Guardian.Plug.Pipeline,
    otp_app: :my_app,
    error_handler: MyApp.Authorisation.ErrorHandler,
    module: MyApp.Authorisation.Guardian  # <- where implementation is passed, that is supertype of `module()`

  plug Guardian.Plug.VerifyHeader, realm: "Bearer"
  plug Guardian.Plug.EnsureAuthenticated
  plug Guardian.Plug.LoadResource
end

I feel this is a minor issue, but given the fact this code is generated for the specific "module" the direct use of the unquoted module name (in this case MyApp.Authorisation.Guardian) should be fine.

codecov-io commented 5 years ago

Codecov Report

Merging #572 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #572   +/-   ##
=======================================
  Coverage   85.57%   85.57%           
=======================================
  Files          18       18           
  Lines         423      423           
=======================================
  Hits          362      362           
  Misses         61       61
Impacted Files Coverage Δ
lib/guardian/plug.ex 83.78% <ø> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 8930f7b...95b3452. Read the comment docs.