common.bend relies on unsafe/foreign
raw source on the hub · import bend-lint-pack@0.1.1.0/common.bend as Common
Helpers shared by the rules in this repo. A rule file imports this as ../common.bend.
2 imports
import Base import ./vendor/lint.bend as Lint
Types
type Seen source · line 8 · raw
Data
Owners of facts =============== A global name that owns facts (a def, a law, a type, a constructor), and where its first fact sits.
Seen@owner:String -> @span:Maybe<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Span> -> Seen
type Owners source · line 12 · raw
Data
The owners of the facts read so far: in reverse order of first appearance, and as a set.
Owners@list:List<&2, Seen> -> @set:Set -> Owners
type Graph source · line 129 · raw
Data
What the facts say: the owners, edges (owner -> names it references, with repeats), and into
(name -> owners that reference it, with repeats). A name an owner uses for itself is no edge.
Graph@owners:Owners -> @edges:Map<&2, List<&2, String>> -> @into:Map<&2, List<&2, String>> -> Graph
type Prog source · line 341 · raw
Data
Everything a graph rule reads: the owners in order, the reference maps, the set of defs, and the local names of the laws.
Prog@seen:List<&2, Seen> -> @edges:Map<&2, List<&2, String>> -> @into:Map<&2, List<&2, String>> -> @nodes:Set -> @laws:Set -> Prog
type Count source · line 392 · raw
Data
Degrees ======= A count of the different names that are defs, and the names counted.
Count@seen:Set -> @n:U32 -> Count
type Scope source · line 435 · raw
Data
Where to report
===============
By default a rule reports only in the linted file, though it reads the whole program: the
imported files are libraries to it. The imports option widens that to every file of the program.
Scope@imports:Bool -> @root:String -> Scope
Definitions
def Owners.empty source · line 15 · raw
Owners
def Owners.pick source · line 18 · raw
@list:List<&2, Seen> -> @+set:Set -> @had:Bool -> @+owner:String -> @inst:Bool -> @span:Maybe<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Span> -> Owners
def Owners.seen source · line 32 · raw
@list:List<&2, Seen> -> @r:Pair(Set, Bool) -> @+owner:String -> @inst:Bool -> @span:Maybe<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Span> -> Owners
def Owners.note source · line 44 · raw
@acc:Owners -> @+owner:String -> @inst:Bool -> @span:Maybe<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Span> -> Owners
Template instances are skipped, so a template is seen once, as itself.
def Owners.add source · line 49 · raw
@acc:Owners -> @v:0x7294c9a1db4be6346e88202032984e02/vendor/lint.View -> Owners
def Owners.collect source · line 55 · raw
@acc:Owners -> @+f:0x7294c9a1db4be6346e88202032984e02/vendor/lint.Fact -> IO(Owners)
A fold_facts step: records each fact's owner.
def Owners.ordered source · line 61 · raw
@o:Owners -> List<&2, Seen>
The owners in order of first appearance.
def diag source · line 68 · raw
@sev:0x7294c9a1db4be6346e88202032984e02/vendor/lint.Severity -> @message:String -> @span:Maybe<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Span> -> 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Diag
Diagnostics ===========
def when source · line 72 · raw
@hit:Bool -> @d:0x7294c9a1db4be6346e88202032984e02/vendor/lint.Diag -> List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Diag>
One diagnostic when hit, else none.
def onto source · line 79 · raw
@xs:List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Diag> -> @out:List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Diag> -> List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Diag>
def local source · line 89 · raw
@+name:String -> String
Names
=====
The part of a global name after its file's namespace: b:helper is helper.
def is_package source · line 93 · raw
@name:String -> Bool
Whether a global name comes from a BendHub package (0x<hash>/file:name): not this project's code.
def has source · line 97 · raw
@s:Set -> @name:String -> Bool
Whether a name is in a set.
def Edges.add.of source · line 103 · raw
@got:Pair(Map<&2, List<&2, String>>, List<&2, String>) -> @key:String -> @x:String -> Map<&2, List<&2, String>>
Graph of references between globals ==================================== Lists of names under a name, last added first.
def Edges.add source · line 112 · raw
@m:Map<&2, List<&2, String>> -> @+key:String -> @x:String -> Map<&2, List<&2, String>>
def Edges.of source · line 120 · raw
@+m:Map<&2, List<&2, String>> -> @key:String -> List<&2, String>
The names under key, last added first; the map is only read.
def Graph.empty source · line 132 · raw
Graph
def Graph.link source · line 135 · raw
@hit:Bool -> @+owner:String -> @+name:String -> @owners:Owners -> @edges:Map<&2, List<&2, String>> -> @into:Map<&2, List<&2, String>> -> Graph
def Graph.add.of source · line 149 · raw
@g:Graph -> @+owner:String -> @+inst:Bool -> @+kind:String -> @+name:String -> @span:Maybe<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Span> -> Graph
def base.of source · line 174 · raw
@parts:List<&2, String> -> @name:String -> String
def base source · line 183 · raw
@+name:String -> String
A template call refers to an instance, twice~0, and a template's own parameter is twice~f: both
are the template, twice.
def Graph.add source · line 186 · raw
@g:Graph -> @v:0x7294c9a1db4be6346e88202032984e02/vendor/lint.View -> Graph
def Graph.collect source · line 192 · raw
@g:Graph -> @+f:0x7294c9a1db4be6346e88202032984e02/vendor/lint.Fact -> IO(Graph)
A fold_facts step.
def Laws.name source · line 201 · raw
@parts:List<&2, String> -> List<&2, String>
Laws
====
Laws are specs, not code: a def that fills one is a proof. They are found in the text (law name:
at the start of a line), as the checker gives a law and its proof one owner and no flag.
def Laws.line source · line 208 · raw
@+line:String -> List<&2, String>
def Laws.add source · line 216 · raw
@names:List<&2, String> -> @out:Set -> Set
def Laws.lines source · line 223 · raw
@ls:List<&2, String> -> @out:Set -> Set
def Laws.scan source · line 231 · raw
@read:Bool -> @text:String -> @out:Set -> Set
The names of the laws written in the sources whose paths are in paths.
def Laws.sources source · line 239 · raw
@sources:List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Source> -> @+paths:Set -> @out:Set -> Set
A call evaluates its arguments, so a file is split into lines only through a match: Base is long.
def Paths.of source · line 247 · raw
@seen:List<&2, Seen> -> @out:Set -> Set
The paths the owners' spans are in.
def Laws.of source · line 257 · raw
@sources:List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Source> -> @owners:Owners -> Set
The local names of every law in the program's own files.
def Laws.has source · line 261 · raw
@laws:Set -> @owner:String -> Bool
Whether owner is a law or the proof that fills one.
def Bodies.put source · line 267 · raw
@b:Maybe<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Node> -> @owner:String -> @out:Set -> Set
Owners that have a checked body =============================== Defs and laws have one; types and constructors do not.
def Bodies.of source · line 274 · raw
@seen:List<&2, Seen> -> @out:Set -> IO(Set)
def Entry.hit source · line 286 · raw
@+e:String -> @+name:String -> Bool
Entry lists: a, b, prefix*
============================
Whether the entry e names name: the same, or, if it ends in *, a prefix of it.
def Entry.any source · line 295 · raw
@entries:List<&2, String> -> @+owner:String -> Bool
Whether some entry names owner, as written or without its namespace.
def Entry.trim source · line 305 · raw
@xs:List<&2, String> -> List<&2, String>
def Entry.parse source · line 313 · raw
@text:String -> List<&2, String>
A comma-separated option as a list.
def Nodes.put source · line 319 · raw
@hit:Bool -> @owner:String -> @out:Set -> Set
The program's own code ====================== The defs of the program: owners with a checked body that are not laws, proofs or package code.
def Nodes.is source · line 326 · raw
@+bodies:Set -> @+laws:Set -> @+owner:String -> Bool
def Nodes.of source · line 332 · raw
@seen:List<&2, Seen> -> @+bodies:Set -> @+laws:Set -> @out:Set -> Set
def Prog.with source · line 350 · raw
@+laws:Set -> @+seen:List<&2, Seen> -> @edges:Map<&2, List<&2, String>> -> @into:Map<&2, List<&2, String>> -> @bodies:Set -> Prog
def Prog.build source · line 359 · raw
@sources:List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Source> -> @+seen:List<&2, Seen> -> @edges:Map<&2, List<&2, String>> -> @into:Map<&2, List<&2, String>> -> @bodies:Set -> Prog
def Prog.owners source · line 374 · raw
@sources:List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Source> -> @+seen:List<&2, Seen> -> @edges:Map<&2, List<&2, String>> -> @into:Map<&2, List<&2, String>> -> IO(Prog)
def Prog.of source · line 384 · raw
@sources:List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Source> -> @g:Graph -> IO(Prog)
def Count.put source · line 395 · raw
@hit:Bool -> @+x:String -> @seen:Set -> @n:U32 -> Count
def Count.add source · line 402 · raw
@is_def:Bool -> @+x:String -> @c:Count -> Count
def Count.n source · line 407 · raw
@c:Count -> U32
def distinct source · line 412 · raw
@names:List<&2, String> -> @+nodes:Set -> @c:Count -> Count
def degree.go source · line 419 · raw
@is_def:Bool -> @names:List<&2, String> -> @nodes:Set -> U32
def degree source · line 428 · raw
@+m:Map<&2, List<&2, String>> -> @+nodes:Set -> @+owner:String -> U32
The number of different defs of the program that owner has under it in m (the defs it uses,
for edges; the defs that use it, for into). 0 for what is not a def.
def root_path source · line 438 · raw
@sources:List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Source> -> String
def Scope.of source · line 445 · raw
@sources:List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Source> -> @options:List<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Option> -> Scope
def in_root source · line 448 · raw
@+root:String -> @span:Maybe<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Span> -> Bool
def Scope.has source · line 455 · raw
@scope:Scope -> @span:Maybe<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Span> -> Bool
def scoped.put source · line 460 · raw
@hit:Bool -> @owner:String -> @span:Maybe<&2, 0x7294c9a1db4be6346e88202032984e02/vendor/lint.Span> -> @out:List<&2, Seen> -> List<&2, Seen>
def scoped source · line 468 · raw
@+scope:Scope -> @seen:List<&2, Seen> -> List<&2, Seen>
The owners a rule reports on.