src/rules/style/blank.bend checks
raw source on the hub · import bolt@1.43.0.0/src/rules/style/blank.bend as Blank
rule blank: a named String compared to the empty literal. Among the
significant tokens (spaces, newlines and comments dropped): a dotted
String.eq, (, a plain name x, ,, the string literal "" and ), or
String.eq, (, "", ,, x and ), right after one another. One
finding, on the String.eq token, for each such call.
The test asks whether x is empty; String.is_empty(x) (Base) says so and
gives the same Bool for every x. It looks at one cell where String.eq
builds a pair of the two strings to hand to a comparison (bend 2.0.40, 2M
tests: the same on the native lane, 0.136 s against 0.094 s on JS when
the test is x's only use, 0.29 s against 0.26 s when x is read again; no
case slower). The rule's case is the plainer word, not the time.
Only a plain name is read. Where the other argument is a call
(String.eq(lines(""), "")), the "" is as often the value a test
expects as a question of emptiness, beside rows that expect "a" and
"\n": half of 30 such sites read by hand were that, so they are left
alone. So is a literal of anything but nothing (String.eq(x, " ")), a
qualified or aliased eq, and the shape written inside a string or a
comment. A LAWS.bend or a PROOF.bend is exempt, and so is a law and a
def that is a proof (def f(x):, or one that returns -> {..}) in any
file, from its keyword to the next def, type or import
(src/rules/suspicious/empty.bend's reading of one): a law states the test
as it means it.
9 imports
import Base import ../../src.bend as Src import ../../paths.bend as Paths import ../../role.bend as Role import ../../lazy/lazy.bend as Lazy import ../../finding.bend as F import ../../syntax/lex.bend as Lex import ../tokens.bend as T import ../suspicious/empty.bend as Empty
Definitions
def lit source · line 34 · raw
@kk:0x75fe3f17e84b61b6da22079fa6674983/src/syntax/lex.TokKind -> @tt:String -> Bool
the string literal "": a string token whose text is its two quotes
def name source · line 43 · raw
@+ka:0x75fe3f17e84b61b6da22079fa6674983/src/syntax/lex.TokKind -> @+ta:String -> @+kb:0x75fe3f17e84b61b6da22079fa6674983/src/syntax/lex.TokKind -> @+tb:String -> Maybe<&2, String>
the name compared, when one of the two arguments is a plain name and the
other ""
def at.go source · line 48 · raw
@ok:Bool -> @mm:Maybe<&2, String> -> Maybe<&2, String>
the name, when the brackets and the comma are where they belong
def at source · line 57 · raw
@toks:List<&2, 0x75fe3f17e84b61b6da22079fa6674983/src/syntax/lex.Tok> -> Maybe<&2, String>
the tokens after a String.eq: (, two arguments and ), one argument a
plain name and the other ""? Then the name
def named source · line 67 · raw
@kk:0x75fe3f17e84b61b6da22079fa6674983/src/syntax/lex.TokKind -> @tt:String -> Bool
a dotted String.eq?
def found.go source · line 75 · raw
@name:Bool -> @rest:List<&2, 0x75fe3f17e84b61b6da22079fa6674983/src/syntax/lex.Tok> -> Maybe<&2, String>
the test a token opens, if it is String.eq
def found source · line 83 · raw
@skip:Bool -> @kk:0x75fe3f17e84b61b6da22079fa6674983/src/syntax/lex.TokKind -> @tt:String -> @rest:List<&2, 0x75fe3f17e84b61b6da22079fa6674983/src/syntax/lex.Tok> -> Maybe<&2, String>
the name a token's test compares, outside a law and a def that is a proof
def say source · line 91 · raw
@+xx:String -> String
what a finding says: the test, and the word for it
def hit source · line 95 · raw
@mm:Maybe<&2, String> -> @+path:String -> @ll:U32 -> @cc:U32 -> @more:List<&2, 0x75fe3f17e84b61b6da22079fa6674983/src/finding.Finding> -> List<&2, 0x75fe3f17e84b61b6da22079fa6674983/src/finding.Finding>
the finding a test makes, if any, before the rest
def walk source · line 104 · raw
@toks:List<&2, 0x75fe3f17e84b61b6da22079fa6674983/src/syntax/lex.Tok> -> @+path:String -> @skip:Bool -> List<&2, 0x75fe3f17e84b61b6da22079fa6674983/src/finding.Finding>
every test among the tokens, in order; skip says whether the tokens so far sit in a law or a def that is a proof
def check source · line 113 · raw
@ss:0x75fe3f17e84b61b6da22079fa6674983/src/src.Src -> List<&2, 0x75fe3f17e84b61b6da22079fa6674983/src/finding.Finding>
the rule
def check.role source · line 119 · raw
@rr:0x75fe3f17e84b61b6da22079fa6674983/src/role.Role -> @ss:0x75fe3f17e84b61b6da22079fa6674983/src/src.Src -> List<&2, 0x75fe3f17e84b61b6da22079fa6674983/src/finding.Finding>
the rule, told the file's role (src/role.bend): a law or proof file is skipped