You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Could we document how to add a basic custom credo warning for open_browser?
Or even add a ready-to-use check to this library?
The following is my crude attempt, I'm sure it can be vastly improved:
defmoduleMyProject.Credo.NoOpenBrowserdo@moduledocfalseuseCredo.Check,base_priority: :normal,category: :warningdefrun(source_file,params\\[])doissue_meta=IssueMeta.for(source_file,params)Credo.Code.prewalk(source_file,&traverse(&1,&2,issue_meta))enddefptraverse({:open_browser,meta,_}=ast,issues,issue_meta)do{ast,issues++[issue_for(meta[:line],issue_meta)]}enddefptraverse(ast,issues,_issue_meta)do{ast,issues}enddefpissue_for(line_no,issue_meta)doformat_issue(issue_meta,message: "There should be no `open_browser` calls.",line_no: line_no)endend
The text was updated successfully, but these errors were encountered:
I think that's a really cool idea! I wouldn't mind that being documented in the docs (maybe by the open_browser docs) or included in the library. I wonder... is there prior art here that we can lean on? Do other libraries create their own custom credo checks? (I can't recall using one from a library. Typically use the standard stuff + things we roll on our own).
Could we document how to add a basic custom credo warning for
open_browser
?Or even add a ready-to-use check to this library?
The following is my crude attempt, I'm sure it can be vastly improved:
The text was updated successfully, but these errors were encountered: