Codes d’erreur › fenced-body

Codes d’erreur

fenced-body

indice Style: how the model reads (archec vet)

Ce que cela signifie#

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.

Exemple#

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.

Comment le corriger#

Le message dit ce qui ne va pas et où, et souvent ce qui était voulu (Did you mean …?). Modifiez le modèle pour que ce que décrit cette page ne soit plus vrai, puis vérifiez à nouveau : archec check main.arche.

Un indice : une suggestion ; le modèle se construit tel quel.

Une remarque de style : archec vet la signale, archec check non ; archec fmt --write corrige celles de mise en page.

archec check --beginner reformule les messages les plus courants en mots simples, avec les noms qui existent.

La correction automatique#

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.

Dans VS Code, l’ampoule sur la ligne (Quick Fix) l’applique. Dans le terminal, archec fix main.arche l’applique avec les autres corrections, puis vérifie à nouveau.

Dans le terminal#

archec explain fenced-body affiche cette explication ; archec explain style liste les codes de son domaine.