Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[codespell]
ignore-words-list = ba
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unreleased

## 1.6.2

### Fixes
- `AddMissingEnd` transformer now properly handles IFs without indented block of code ([#226](https://github.com/MarketSquare/robotframework-tidy/issues/226))
- Paths passed from command line are now checked against excluded paths (previously it was only checked when iterating over directories) ([#227](https://github.com/MarketSquare/robotframework-tidy/issues/227))

## 1.6.1

### Fixes
- Trailing whitespace is no longer added to blank lines in multiline statements when using align transformers ([#219](https://github.com/MarketSquare/robotframework-tidy/issues/219))
- `*** Tasks ***` is no longer converted to `*** Test Cases ***` by NormalizeSectionHeaderName ([#218](https://github.com/MarketSquare/robotframework-tidy/issues/218))
Expand Down
22 changes: 11 additions & 11 deletions robotidy/transformers/AddMissingEnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ def visit_If(self, node): # noqa
self.fix_header_name(node, node.type)
if node.type != Token.IF:
return node
node.body, outside = self.collect_inside_statements(node)
if node.orelse:
orelse = node.orelse
while orelse.orelse:
orelse = orelse.orelse
orelse.body, outside_orelse = self.collect_inside_statements(orelse)
outside += outside_orelse
outside = []
if not node.end:
node.body, outside = self.collect_inside_statements(node)
or_else = self.get_last_or_else(node)
if or_else:
or_else.body, outside_or_else = self.collect_inside_statements(or_else)
outside += outside_or_else
self.fix_end(node)
return (node, *outside)

Expand Down Expand Up @@ -95,7 +95,7 @@ def get_column(node):
def get_last_or_else(node):
if not node.orelse:
return None
orelse = node.orelse
while orelse.orelse:
orelse = orelse.orelse
return orelse
or_else = node.orelse
while or_else.orelse:
or_else = or_else.orelse
return or_else
16 changes: 16 additions & 0 deletions tests/atest/transformers/AddMissingEnd/expected/test.robot
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ Mixed For and If
END
END

Bad Indent
IF ${i}==1
Log "one"
END

*** Keywords ***
Missing In For
FOR ${x} IN foo bar
Expand Down Expand Up @@ -268,3 +273,14 @@ Nested For With Identical Indent
Log ${x}${y}${z}
END
END

Bad Indent
IF ${i}==1
Log "one"
END

IF ${i}>5
Log ${i}
ELSE
Log ${i}+1
END
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ Mixed For and If
IF ${condition}
Log foo${x}

Bad Indent
IF ${i}==1
Log "one"
END

*** Keywords ***
Missing In For
FOR ${x} IN foo bar
Expand Down Expand Up @@ -235,3 +240,14 @@ Nested For With Identical Indent
Log ${x}${y}${z}
END
END

Bad Indent
IF ${i}==1
Log "one"
END

IF ${i}>5
Log ${i}
ELSE
Log ${i}+1
END
16 changes: 16 additions & 0 deletions tests/atest/transformers/AddMissingEnd/source/test.robot
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ Mixed For and If
IF ${condition}
Log foo${x}

Bad Indent
IF ${i}==1
Log "one"
END

*** Keywords ***
Missing In For
FOR ${x} IN foo bar
Expand Down Expand Up @@ -231,3 +236,14 @@ Nested For With Identical Indent
Log ${x}${y}${z}
END
END

Bad Indent
IF ${i}==1
Log "one"
END

IF ${i}>5
Log ${i}
ELSE
Log ${i}+1
END
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ def test_selected(self):
self.TRANSFORMER_NAME,
source='test.robot',
expected='test_selected.robot',
config=' --startline 161 --endline 183'
config=' --startline 166 --endline 188'
)