Skip to content

Commit 66f300a

Browse files
authored
Merge pull request #52 from olehermanse/main
cfengine format: Added newline before comment in more places
2 parents 339c69d + bed1713 commit 66f300a

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/cfengine_cli/format.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,13 @@ def autoformat(node, fmt, line_length, macro_indent, indent=0):
338338
fmt.print("", 0)
339339
elif child.type == "comment":
340340
prev = child.prev_named_sibling
341-
if prev and prev.type in ["promise", "half_promise"]:
341+
if prev and prev.type in [
342+
"promise",
343+
"half_promise",
344+
"class_guarded_promises",
345+
"class_guarded_body_attributes",
346+
"class_guarded_promise_block_attributes",
347+
]:
342348
parent = child.parent
343349
if parent and parent.type in [
344350
"bundle_section",

tests/format/004_comments.expected.cf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ bundle agent main
99
# Inside promise, next to attributes
1010
string => "value";
1111

12+
# Before next promise
1213
"some_list"
1314
slist => {
1415
"Strings that go in a list which would be long",
@@ -24,4 +25,12 @@ bundle agent main
2425
if => "something",
2526
# Inside promise, next to attributes
2627
string => "value";
28+
29+
# A class guard shifts everything over 2 spaces:
30+
class_guard::
31+
# Inside promise type
32+
"some_var"
33+
if => "something",
34+
# Inside promise, next to attributes
35+
string => "value";
2736
}

tests/format/004_comments.input.cf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if => "something",
99
# Inside promise, next to attributes
1010
string => "value";
1111

12+
# Before next promise
1213
"some_list"
1314
slist => {
1415
"Strings that go in a list which would be long",
@@ -17,6 +18,13 @@ slist => {
1718
"More and more and more and more",
1819
};
1920

21+
# A class guard shifts everything over 2 spaces:
22+
class_guard::
23+
# Inside promise type
24+
"some_var"
25+
if => "something",
26+
# Inside promise, next to attributes
27+
string => "value";
2028
# A class guard shifts everything over 2 spaces:
2129
class_guard::
2230
# Inside promise type

0 commit comments

Comments
 (0)