src/rules/correctness/put.bend checks
raw source on the hub · import 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/rules/correctness/put.bend as Put
rule put: a call to Map.put(: among the significant tokens, a Map.put
token with a ( token right after it. Base's Map.put is an internal helper
of Map.set: on a leaf it keeps the old key and replaces the value without
comparing keys, so putting a new key silently overwrites another entry
(bend-http c91bdf8: "b" into a map of "a" replaced "a"). Use Map.set. A
file that defines Map.put itself (Base's source), a def keyword with a
Map.put token right after it, is exempt.
6 imports
import Base import ../../src.bend as Src import ../../lazy/lazy.bend as Lazy import ../../finding.bend as F import ../../syntax/lex.bend as Lex import ../tokens.bend as T
Definitions
def defines.named source · line 16 · raw
@toks:List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/lex.Tok> -> Bool
is the first token Map.put?
def defines.key source · line 24 · raw
@kk:0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/lex.TokKind -> Bool
a keyword? a token's kind is read here, its text in the tests beside it
def calls.dotted source · line 32 · raw
@kk:0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/lex.TokKind -> Bool
a dotted name?
def defines source · line 40 · raw
@toks:List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/lex.Tok> -> Bool
does the file define Map.put: a def keyword right before a Map.put?
def calls.one source · line 49 · raw
@+tt:String -> @+oo:String -> @+ll:U32 -> @+cc:U32 -> @+path:String -> @+more:List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding> -> List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>
a dotted name then an open bracket: a finding when they are Map.put and
(, before what the rest reports
def calls source · line 63 · raw
@toks:List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/lex.Tok> -> @+path:String -> List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>
every Map.put( among the significant tokens
def check.on source · line 75 · raw
@+toks:List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/lex.Tok> -> @path:String -> List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>
def check source · line 79 · raw
@ss:0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/src.Src -> List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>
the rule