-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore run keyword alignment in misaligned-continuation-row rule (#1105)
- Loading branch information
Showing
7 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Allow to ignore run keywords in misaligned-continuation-row rule (#1065) | ||
------------------------------------------------------------------------ | ||
|
||
W1015 ``misaligned-continuation-row`` detects if statements have misaligned rows:: | ||
|
||
*** Keywords *** | ||
Misaligned example | ||
Keyword Call | ||
... first argument | ||
... second argument # should be executed | ||
|
||
This rules contradicts with how Robotidy aligns nested keywords with ``IndentNestedKeywords`` tranformer to provide | ||
extra alignment for readability purposes:: | ||
|
||
SSH Wait For Device To Close SSH | ||
[Documentation] Wait until SSH connection is closed by device. | ||
Wait Until Keyword Succeeds 2min 2s | ||
... Run Keyword And Expect Error SSHException: SSH session not active | ||
... SSH Log FW Version level=DEBUG | ||
|
||
It is now possible to ignore run keywords by setting ignore_run_keywords to True:: | ||
|
||
robocop -c misaligned-continuation-row:ignore_run_keywords:True src | ||
|
||
By default it is disabled and run keywords are not ignored. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/atest/rules/spacing/misaligned_continuation_row/expected_output_run_kw.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
run_keyword.robot:5:8 [W] 1015 Each next continuation line should be aligned with the previous one |
2 changes: 2 additions & 0 deletions
2
tests/atest/rules/spacing/misaligned_continuation_row/expected_output_run_kw_off.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
run_keyword.robot:5:8 [W] 1015 Each next continuation line should be aligned with the previous one | ||
run_keyword.robot:11:8 [W] 1015 Each next continuation line should be aligned with the previous one |
11 changes: 11 additions & 0 deletions
11
tests/atest/rules/spacing/misaligned_continuation_row/run_keyword.robot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
*** Keywords *** | ||
Keyword with run keyword | ||
Other Keyword | ||
... first argument | ||
... second argument | ||
Other Keyword 2 | ||
... first argument | ||
... second argument | ||
Wait Until Keyword Succeeds 2min 2s | ||
... Run Keyword And Expect Error SSHException: SSH session not active | ||
... SSH Log FW Version level=DEBUG |
15 changes: 14 additions & 1 deletion
15
tests/atest/rules/spacing/misaligned_continuation_row/test_rule.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,26 @@ | ||
import pytest | ||
|
||
from tests.atest.utils import RuleAcceptance | ||
|
||
|
||
class TestRuleAcceptance(RuleAcceptance): | ||
def test_rule(self): | ||
self.check_rule(expected_file="expected_output.txt") | ||
self.check_rule(src_files=["test.robot"], expected_file="expected_output.txt") | ||
|
||
def test_ignore_docs(self): | ||
self.check_rule( | ||
config="-c misaligned-continuation-row:ignore_docs:False", | ||
src_files=["test.robot"], | ||
expected_file="expected_output_ignore_docs.txt", | ||
) | ||
|
||
@pytest.mark.parametrize( | ||
"ignore_run_keywords, expected_file", | ||
[(True, "expected_output_run_kw.txt"), (False, "expected_output_run_kw_off.txt")], | ||
) | ||
def test_run_keyword(self, ignore_run_keywords, expected_file): | ||
self.check_rule( | ||
config=f"-c misaligned-continuation-row:ignore_run_keywords:{ignore_run_keywords}", | ||
src_files=["run_keyword.robot"], | ||
expected_file=expected_file, | ||
) |