~/bend-docscommunity

dead/def.bend relies on unsafe/foreign

raw source on the hub · import bend-lint-pack@0.1.1.0/dead/def.bend as Def

dead/def: warn about a def that no entry point reaches.

Entry points: main, every law and the def that proves it (laws are specs, so what they mention is live), and the names in the entries option. Everything reachable from an entry through references (in bodies and in types) is live; every other def is dead, so a chain of defs that only call each other is reported whole. Self-references do not count.

Bend has no export keyword, so a def meant for outside callers (a library API, a def a JS host calls) is named in entries: a comma-separated list of names, where name* is a prefix and a name matches with or without its file's namespace (helper or util:helper). * alone makes every def an entry.

The program is the linted file and what it imports, so lint the entry file. By default only the linted file's own defs are reported; imports reports the defs of every local file of the program (set it when the imports are your own modules and the linted file is the whole application). Not reported: types and constructors, foreign effect defs (they have no checked body), and hub packages. With no main, no law and no entries, there is nothing to measure from: one hint says so. Options: entries (default ""), imports (default false).

3 imports
import Base
import ../vendor/lint.bend as Lint
import ../common.bend as Common

Definitions

def id source · line 24 · raw

String

def facts source · line 27 · raw

0x7294c9a1db4be6346e88202032984e02/vendor/lint.Want

def is_root source · line 32 · raw

@+laws:Set -> @+entries:List<&2, String> -> @+owner:String -> Bool

Entry points ============

def roots source · line 38 · raw

@seen:List<&2, 0x7294c9a1db4be6346e88202032984e02/common.Seen> -> @+laws:Set -> @+entries:List<&2, String> -> @+out:List<&2, String> -> List<&2, String>

def reach.go source · line 67 · raw

@known:Bool -> @+name:String -> @rest:List<&2, String> -> @+edges:Map<&2, List<&2, String>> -> @+seen:Set -> Set

def message source · line 86 · raw

@+owner:String -> @referenced:Bool -> String

Findings ========

def is_dead source · line 94 · raw

@+nodes:Set -> @+reached:Set -> @+owner:String -> Bool

def report source · line 97 · raw

@seen:List<&2, 0x7294c9a1db4be6346e88202032984e02/common.Seen> -> @+nodes:Set -> @+reached:Set -> @+into:Map<&2, List<&2, String>> -> @out:List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Diag> -> List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Diag>

def nothing source · line 129 · raw

0x7294c9a1db4be6346e88202032984e02/vendor/lint.Diag

def verdict.go source · line 137 · raw

@none:Bool -> @+rs:List<&2, String> -> @shown:List<&2, 0x7294c9a1db4be6346e88202032984e02/common.Seen> -> @nodes:Set -> @+edges:Map<&2, List<&2, String>> -> @into:Map<&2, List<&2, String>> -> List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Diag>

none: there is no entry point. shown: the owners reported on.

def verdict.roots source · line 155 · raw

@+rs:List<&2, String> -> @shown:List<&2, 0x7294c9a1db4be6346e88202032984e02/common.Seen> -> @nodes:Set -> @edges:Map<&2, List<&2, String>> -> @into:Map<&2, List<&2, String>> -> List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Diag>

def verdict.laws source · line 164 · raw

@+laws:Set -> @entries:String -> @+seen:List<&2, 0x7294c9a1db4be6346e88202032984e02/common.Seen> -> @scope:0x7294c9a1db4be6346e88202032984e02/common.Scope -> @nodes:Set -> @edges:Map<&2, List<&2, String>> -> @into:Map<&2, List<&2, String>> -> List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Diag>

def verdict source · line 181 · raw

@p:0x7294c9a1db4be6346e88202032984e02/common.Prog -> @entries:String -> @scope:0x7294c9a1db4be6346e88202032984e02/common.Scope -> List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Diag>

def run source · line 186 · raw

@input:0x7294c9a1db4be6346e88202032984e02/vendor/lint.Input -> IO(List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Diag>)

def main source · line 198 · raw

IO(Unit)

Unsafe

unsafe reach source · line 60 · raw

@work:List<&2, String> -> @+edges:Map<&2, List<&2, String>> -> @+seen:Set -> Set

Reachability ============ The names reachable from work through edges. Each name is expanded once, and the names are finite, so this terminates; Bend cannot see that, hence @unsafe.