Skip to content

Commit 75460d3

Browse files
olehermanseclaude
andcommitted
cfengine format: Dropped empty lines between consecutive 0-attribute single line promises
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
1 parent ba5b71a commit 75460d3

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/cfengine_cli/format.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,20 @@ def can_single_line_promise(node, indent, line_length):
215215
attr_children = [c for c in children if c.type == "attribute"]
216216
next_sib = node.next_named_sibling
217217
has_continuation = next_sib and next_sib.type == "half_promise"
218-
if len(attr_children) != 1 or has_continuation:
218+
if len(attr_children) > 1 or has_continuation:
219219
return False
220220
promiser_node = next((c for c in children if c.type == "promiser"), None)
221221
if not promiser_node:
222222
return False
223-
line = (
224-
text(promiser_node) + " " + stringify_single_line_node(attr_children[0]) + ";"
225-
)
223+
if attr_children:
224+
line = (
225+
text(promiser_node)
226+
+ " "
227+
+ stringify_single_line_node(attr_children[0])
228+
+ ";"
229+
)
230+
else:
231+
line = text(promiser_node) + ";"
226232
return indent + len(line) <= line_length
227233

228234

0 commit comments

Comments
 (0)