fenced-body
What it means#
A ```arche fence around a fn’s body, or around a property’s (on-enter, on-receive, on-timeout …) (archec vet): an arche body is written as it is in the fn’s block, from its first statement to the block’s }, and a property’s in braces, on-enter { … }. Computed only when asked for: archec fix --only fenced-body removes the fences, and keeps one where the fn would not read back the same.
Example#
An arche body needs no fence: its statements are written in the fn's block,
after its properties, and the first statement opens the body (if, return,
var, send …, or a name followed by =, +=, (, . or [). A property
whose value is a body (on-enter, on-exit, on-receive, on-deadline,
on-timeout, on-init, on-start, on-stop, on-release) takes it in braces:
on-enter { count += 1 }, or on-enter { then its lines then }. A
```arche fence is still read, so models written before 0.25.0 stay
clean: this finding is computed only when asked for.
archec fix --only fenced-body --write removes the fences: on-enter ```arche
… ``` becomes on-enter { … }. It keeps a fence
where the element would not read back the same: a property written after a
fn's fence, or a body whose first line is not a statement.
How to fix it#
The message says what is wrong and where, and often what was meant (Did you mean …?). Change the model so that what this page describes no longer holds, then check again: archec check main.arche.
A hint: a suggestion; the model builds as it is.
A style finding: archec vet reports it, archec check does not; archec fmt --write writes the layout ones.
archec check --beginner says the most common messages in plain words, with the names that exist.
The automatic fix#
The ```arche fence around a fn's body is removed, the body written in the fn's block; fn f() ```arche … ``` becomes fn f() { … }, on-enter ```arche … ``` (and on-exit, on-receive, on-deadline, on-timeout, on-init, on-start, on-stop, on-release) becomes on-enter { … }. Kept where the element would not read back with the same body and properties. Computed only by archec fix --only fenced-body.
In VS Code, the light bulb on the line (Quick Fix) applies it. In the terminal, archec fix main.arche applies it with the other fixes, then checks again.
In the terminal#
archec explain fenced-body prints this explanation; archec explain style lists the codes of its area.