Skip to content

Commit fbea27a

Browse files
authored
Fix SplitTooLongLine breaking long keyword names (#315)
1 parent 528dd8e commit fbea27a

File tree

8 files changed

+54
-3
lines changed

8 files changed

+54
-3
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
## 2.3.1
6+
7+
Fix for ``SplitTooLongLine`` transformer breaking keywords with veeery long names ([#314](https://github.com/MarketSquare/robotframework-tidy/issues/314))
8+
59
### Extra ``--indent`` option
610

711
Robotidy normalizes all whitespaces using the same fixed amount of spaces (configurable via ``--spacecount``).

robotidy/transformers/SplitTooLongLine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ def is_inline(node):
8787
def visit_KeywordCall(self, node): # noqa
8888
if all(line[-1].end_col_offset < self.line_length for line in node.lines):
8989
return node
90+
if not len(node.data_tokens) > 1: # nothing to split anyway
91+
return node
9092
if self.disablers.is_node_disabled(node, full_match=False):
9193
return node
9294
return self.split_keyword_call(node)
@@ -113,11 +115,9 @@ def split_keyword_call(self, node):
113115
separator = Token(Token.SEPARATOR, self.formatting_config.separator)
114116
indent = node.tokens[0]
115117

116-
split_every_arg = self.split_on_every_arg
117118
keyword = node.get_token(Token.KEYWORD)
118119
line = [indent, *self.join_on_separator(node.get_tokens(Token.ASSIGN), separator), keyword]
119120
if not self.col_fit_in_line(line):
120-
split_every_arg
121121
head = [
122122
*self.split_to_multiple_lines(node.get_tokens(Token.ASSIGN), indent=indent, separator=separator),
123123
indent,

robotidy/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.4"
1+
__version__ = "2.4.1"

tests/atest/transformers/SplitTooLongLine/expected/feed_until_line_length.robot

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,13 @@ If - else if - else clause
153153

154154
Too long inline IF # shall be handled by InlineIf transformer
155155
${var} ${var2} IF $condition != $condition2 Longer Keyword Name ${argument} values ELSE IF $condition2 Short Keyword ${arg} # comment
156+
157+
Keyword name over the limit
158+
Enter "${VNFname}" in the field with XPath "//label[contains(text(), 'Product Name')]/../mat-form-field/div/div/div/textarea"
159+
160+
${assign}
161+
... Enter "${VNFname}" in the field with XPath "//label[contains(text(), 'Product Name')]/../mat-form-field/div/div/div/textarea"
162+
163+
${assign}
164+
... ${assign}
165+
... Enter "${VNFname}" in the field with XPath "//label[contains(text(), 'Product Name')]/../mat-form-field/div/div/div/textarea"

tests/atest/transformers/SplitTooLongLine/expected/feed_until_line_length_4.robot

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,13 @@ Too long inline IF # shall be handled by InlineIf transformer
156156
${var} ${var2} IF $condition != $condition2 Longer Keyword Name
157157
... ${argument} values ELSE IF $condition2 Short Keyword
158158
... ${arg}
159+
160+
Keyword name over the limit
161+
Enter "${VNFname}" in the field with XPath "//label[contains(text(), 'Product Name')]/../mat-form-field/div/div/div/textarea"
162+
163+
${assign}
164+
... Enter "${VNFname}" in the field with XPath "//label[contains(text(), 'Product Name')]/../mat-form-field/div/div/div/textarea"
165+
166+
${assign}
167+
... ${assign}
168+
... Enter "${VNFname}" in the field with XPath "//label[contains(text(), 'Product Name')]/../mat-form-field/div/div/div/textarea"

tests/atest/transformers/SplitTooLongLine/expected/split_on_every_arg.robot

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,13 @@ If - else if - else clause
324324

325325
Too long inline IF # shall be handled by InlineIf transformer
326326
${var} ${var2} IF $condition != $condition2 Longer Keyword Name ${argument} values ELSE IF $condition2 Short Keyword ${arg} # comment
327+
328+
Keyword name over the limit
329+
Enter "${VNFname}" in the field with XPath "//label[contains(text(), 'Product Name')]/../mat-form-field/div/div/div/textarea"
330+
331+
${assign}
332+
... Enter "${VNFname}" in the field with XPath "//label[contains(text(), 'Product Name')]/../mat-form-field/div/div/div/textarea"
333+
334+
${assign}
335+
... ${assign}
336+
... Enter "${VNFname}" in the field with XPath "//label[contains(text(), 'Product Name')]/../mat-form-field/div/div/div/textarea"

tests/atest/transformers/SplitTooLongLine/expected/split_on_every_arg_4.robot

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,3 +333,13 @@ Too long inline IF # shall be handled by InlineIf transformer
333333
... $condition2
334334
... Short Keyword
335335
... ${arg}
336+
337+
Keyword name over the limit
338+
Enter "${VNFname}" in the field with XPath "//label[contains(text(), 'Product Name')]/../mat-form-field/div/div/div/textarea"
339+
340+
${assign}
341+
... Enter "${VNFname}" in the field with XPath "//label[contains(text(), 'Product Name')]/../mat-form-field/div/div/div/textarea"
342+
343+
${assign}
344+
... ${assign}
345+
... Enter "${VNFname}" in the field with XPath "//label[contains(text(), 'Product Name')]/../mat-form-field/div/div/div/textarea"

tests/atest/transformers/SplitTooLongLine/source/tests.robot

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,10 @@ If - else if - else clause
127127

128128
Too long inline IF # shall be handled by InlineIf transformer
129129
${var} ${var2} IF $condition != $condition2 Longer Keyword Name ${argument} values ELSE IF $condition2 Short Keyword ${arg} # comment
130+
131+
Keyword name over the limit
132+
Enter "${VNFname}" in the field with XPath "//label[contains(text(), 'Product Name')]/../mat-form-field/div/div/div/textarea"
133+
134+
${assign} Enter "${VNFname}" in the field with XPath "//label[contains(text(), 'Product Name')]/../mat-form-field/div/div/div/textarea"
135+
136+
${assign} ${assign} Enter "${VNFname}" in the field with XPath "//label[contains(text(), 'Product Name')]/../mat-form-field/div/div/div/textarea"

0 commit comments

Comments
 (0)