~/bend-docscommunity

src/rules/style/space.bend checks

raw source on the hub · import bolt@1.36.0.0/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. An import line has no width: it cannot be broken, and its length is its path's and alias's. 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 17 · raw

@cs:List<&2, Char> -> Bool

is there a tab among the chars?

def trailing source · line 25 · raw

@cs:List<&2, Char> -> Bool

does the line end in whitespace?

def width_of source · line 35 · raw

@kk:0x3bd54602f7aee9aad0e9a8dd478fb82e/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 47 · raw

@+width:U32 -> @+path:String -> @+nn:U32 -> @+more:List<&2, 0x3bd54602f7aee9aad0e9a8dd478fb82e/src/finding.Finding> -> List<&2, 0x3bd54602f7aee9aad0e9a8dd478fb82e/src/finding.Finding>

a finding when the width is over 120

def widths source · line 52 · raw

@toks:List<&2, 0x3bd54602f7aee9aad0e9a8dd478fb82e/src/syntax/lex.Tok> -> @+path:String -> @+nn:U32 -> @+acc:U32 -> List<&2, 0x3bd54602f7aee9aad0e9a8dd478fb82e/src/finding.Finding>

one pass over the tokens: a newline closes a line's width

def unimported source · line 65 · raw

@toks:List<&2, 0x3bd54602f7aee9aad0e9a8dd478fb82e/src/syntax/lex.Tok> -> @start:Bool -> @cutting:Bool -> List<&2, 0x3bd54602f7aee9aad0e9a8dd478fb82e/src/syntax/lex.Tok>

the tokens with every import line cut to its newline, so the width counts no import; start is whether the token opens its line, and cutting whether it is on an import line

def check.line source · line 76 · raw

@+path:String -> @+nn:U32 -> @+cs:List<&2, Char> -> @+more:List<&2, 0x3bd54602f7aee9aad0e9a8dd478fb82e/src/finding.Finding> -> List<&2, 0x3bd54602f7aee9aad0e9a8dd478fb82e/src/finding.Finding>

def check.go source · line 83 · raw

@lines:List<&2, String> -> @+path:String -> @+nn:U32 -> List<&2, 0x3bd54602f7aee9aad0e9a8dd478fb82e/src/finding.Finding>

def check source · line 91 · raw

@ss:0x3bd54602f7aee9aad0e9a8dd478fb82e/src/src.Src -> List<&2, 0x3bd54602f7aee9aad0e9a8dd478fb82e/src/finding.Finding>

the rule