Linting rules
E035: create-message-body-to-cell
Warns about `MyMessage { ... }.toCell()` inside `createMessage({ body: ... })` initializer.
Metadata
Code:E035Rule:create-message-body-to-cellStatus: Stable sincev0.0.1Quick fix: not available
What it does
Warns about MyMessage { ... }.toCell() inside createMessage({ body: ... }) initializer.
Why is this bad?
createMessage already accepts a serializable object as body and decides whether to inline it
or wrap it into a reference cell automatically. Calling .toCell() manually is usually
unnecessary and can be worse for performance because it forces an extra cell creation even
when the compiler could inline a small body directly.
Example
struct Transfer {
amount: int32
}
fun send(dest: address) {
val msg = createMessage({
bounce: false,
value: ton("0.1"),
dest,
body: Transfer { amount: 1 }.toCell(), });
}Use instead:
struct Transfer {
amount: int32
}
fun send(dest: address) {
val msg = createMessage({
bounce: false,
value: ton("0.1"),
dest,
body: Transfer { amount: 1 },
});
}Last updated on