<div dir="ltr"><div dir="ltr">Hi,<span class="gmail-im"><br><br><div>> But it's also telling me that my cowboy callbacks are unused exports:</div><div>><br></div></span><div><span class="gmail-im">> Warning: init_handler:allowed_methods/2 is unused export (Xref)<br>> Warning: init_handler:content_types_acc<wbr>epted/2 is unused export (Xref)<br></span>> ...<br><br></div><div>Based
 on the list of callbacks, I'm assuming these are rest handlers. 
Unfortunately, almost all of the rest handler callback functions are 
optional[1] and not part of a particular behavior (as of cowboy 1.x, 
anyway.) As the calling-back itself is done dynamically - either using 
apply/3 or M:F(A, ...), with M only known at runtime - and the functions
 are not part of any explicitly defined behavior, there's no way xref 
can know or assume the callback functions are actually going to be used.<br><br></div><div>I
 usually use '-ignore_xref({F,Arity})' directives as a workaround. 
Perhaps defining a cowboy rest handler behavior with all optional 
callbacks marked as such would do the trick, but if I recall correctly 
optional callback annotations are a fairly recent feature.<br><br></div><div>Regards,<br><br><br>[1]: <a href="https://ninenines.eu/docs/en/cowboy/1.0/manual/cowboy_rest/" target="_blank">https://ninenines.eu/docs/en/c<wbr>owboy/1.0/manual/cowboy_rest/</a><br></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 3 May 2017 at 17:06,  <span dir="ltr"><<a href="mailto:duncan@sfractal.com" target="_blank">duncan@sfractal.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><span style="font-family:Verdana;color:#000;font-size:10pt"><div>I'm new at using xref and must be missing something obvious. I did some refactoring of my app and decided to run xref to find where I'd forgot to delete/add something. It worked great and I found mistakes I'd made and fixed them, But it's also telling me that my cowboy callbacks are unused exports:</div><div><br></div><div>Warning: init_handler:allowed_methods/2 is unused export (Xref)<br>Warning: init_handler:content_types_<wbr>accepted/2 is unused export (Xref)<br>Warning: init_handler:handle_json/2 is unused export (Xref)<br>Warning: init_handler:init/3 is unused export (Xref)<br>Warning: init_handler:rest_init/2 is unused export (Xref)<br>Warning: openc2_handler:allowed_<wbr>methods/2 is unused export (Xref)<br>Warning: openc2_handler:content_types_<wbr>accepted/2 is unused export (Xref)<br>Warning: openc2_handler:handle_json/2 is unused export (Xref)<br>Warning: openc2_handler:init/3 is unused export (Xref)<br>Warning: openc2_handler:rest_init/2 is unused export (Xref)<br>Warning: status_handler:allowed_<wbr>methods/2 is unused export (Xref)<br>Warning: status_handler:init/3 is unused export (Xref)<br>Warning: status_handler:rest_init/2 is unused export (Xref)<br>Warning: status_handler:to_html/2 is unused export (Xref)<br>Warning: status_ok_handler:allowed_<wbr>methods/2 is unused export (Xref)<br>Warning: status_ok_handler:content_<wbr>types_provided/2 is unused export (Xref)<br>Warning: status_ok_handler:init/3 is unused export (Xref)<br></div><div><br></div><div>init_handler, openc2_handler, status_handler, and status_ok_handler are all modules in the cowboy routes:</div><div><br></div><div>Routes =<br>    [<br>      {<br>        '_'  %virtual hostname (any host name)<br>      , [<br>          {"/status", status_handler, []}<br>        , {"/ok", status_ok_handler, []}  % returns ok if service working<br>        , {"/openc2", openc2_handler, []}    % handles the meat of openc2<br>        , {"/init", init_handler, []}    % handles starting/restarting the sim<br>        ]<br>      }<br>    ],<br></div><div><br></div><div>I assume I'm not configuring xref correctly to let it know about cowboy. I run xref using rebar 3 from the app directory. I assumed rebar3's knowledge about dependencies would inform xref (which it must or I'd get a host of other errors) - but then why do these warnings appear?<br></div><div><br></div><div>Not sure if related but I also get:<br></div><div>Warning: ocas_app:start/0 is unused export (Xref)<br></div><div>This is the main start routine so I guess it makes sense it isn't called from anything else.<br></div><div><br></div><div>Duncan Sparrell</div><div>sFractal Consulting LLC</div><div>iPhone, iTypo, iApologize</div></span></div>
<br>______________________________<wbr>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Guilherme<br></div></div></div></div></div></div>
</div>