src/rules/style/space.bend checks
raw source on the hub · import 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/rules/style/space.bend as Space
rule space: trailing whitespace, a tab, or a line over 120 characters. The
width counts a string literal as two characters: a long message or a test
fixture does not make a line hard to read, code does. A comment counts at
its full width. Expectation trailers (#| lines) are data and exempt from
the width only: trailing whitespace on a #| line is still reported. A tab
is reported wherever it sits, inside a string literal included. A line
with both trailing whitespace and a tab is reported once, for the
whitespace.
5 imports
import Base import ../../src.bend as Src import ../../finding.bend as F import ../../syntax/lex.bend as Lex import ../../lazy/lazy.bend as Lazy
Definitions
def has_tab source · line 16 · raw
@cs:List<&2, Char> -> Bool
is there a tab among the chars?
def trailing source · line 24 · raw
@cs:List<&2, Char> -> Bool
does the line end in whitespace?
def width_of source · line 34 · raw
@kk:0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/lex.TokKind -> @+tt:String -> U32
a token's share of its line's width; a #| trailer line counts nothing
def too_wide source · line 46 · raw
@+width:U32 -> @+path:String -> @+nn:U32 -> @+more:List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding> -> List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>
a finding when the width is over 120
def widths source · line 51 · raw
@toks:List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/lex.Tok> -> @+path:String -> @+nn:U32 -> @+acc:U32 -> List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>
one pass over the tokens: a newline closes a line's width
def check.line source · line 61 · raw
@+path:String -> @+nn:U32 -> @+cs:List<&2, Char> -> @+more:List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding> -> List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>
def check.go source · line 68 · raw
@lines:List<&2, String> -> @+path:String -> @+nn:U32 -> List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>
def check source · line 76 · raw
@ss:0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/src.Src -> List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>
the rule