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
4 changes: 2 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

### Features
- New option ``--configure`` or ``-c`` for configuring transformer parameters. It works the same way configuring through ``--transform`` works. The benefit of using ``--configure`` is that you can configure selected transformers and still run all transformers [#96](https://github.com/MarketSquare/robotframework-tidy/issues/96)
- Transformers can now be disabled by default if you add ``ENABLED = False`` class attribute to your class. Those transformers will be only run when selected explictly with ``--transform`` option [#10](https://github.com/MarketSquare/robotframework-tidy/issues/10)
- Transformers can now be disabled by default if you add ``ENABLED = False`` class attribute to your class. Those transformers will be only run when selected explicitly with ``--transform`` option [#10](https://github.com/MarketSquare/robotframework-tidy/issues/10)
- Support for ``pyproject.toml`` configuration files. Because of the required changes there are backward incompatible changes done to ``robotidy.toml`` syntax. See example from [README](https://github.com/MarketSquare/robotframework-tidy/blob/main/README.rst#configuration-file) [#66](https://github.com/MarketSquare/robotframework-tidy/issues/66)
- ``--list-transformers`` output is now ordered. Also transformers themselves will always run in the same predefined order [#69](https://github.com/MarketSquare/robotframework-tidy/issues/69)
- ``--describe-transformer`` output is now pre-formatted (removed rst formatting) [#83](https://github.com/MarketSquare/robotframework-tidy/issues/83)
Expand Down Expand Up @@ -85,7 +85,7 @@
### Transformers

- DiscardEmptySections - empty sections are removed
- SplitTooLongLine - keywords with too long lines are splitted
- SplitTooLongLine - keywords with too long lines are split
- NormalizeSettingName - ensure that setting names are Title Case - Test Template, Library
- AssignmentNormalizer - use only one type of assignment
- NormalizeNewLines - ensure proper number of empty lines between keywords, test cases and sections
Expand Down
2 changes: 1 addition & 1 deletion docs/source/configuration/configuring_transformers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Configuring Transformers
========================

Transformers can be configured through two diffrent options: ``--transform`` and ``--configure``. They share the same
Transformers can be configured through two different options: ``--transform`` and ``--configure``. They share the same
syntax for parameter names and values. The main difference is that ``--transform`` is also used to select what
transformers will be used. For example::

Expand Down
2 changes: 1 addition & 1 deletion docs/source/transformers/ReplaceRunKeywordIf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Any return value will be applied to every ELSE/ELSE IF branch.
${var} Keyword2
END

Run Keywords inside Run Keyword If will be splitted into separate keywords.
Run Keywords inside Run Keyword If will be split into separate keywords.

.. tabs::

Expand Down
2 changes: 1 addition & 1 deletion docs/source/transformers/SmartSortKeywords.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SmartSortKeywords is not included in default transformers that's why you need to

robotidy --transform SmartSortKeywords src

By default sorting is case insensitve, but keywords with leading underscore go to the bottom. Other underscores are
By default sorting is case insensitive, but keywords with leading underscore go to the bottom. Other underscores are
treated as spaces.
Empty lines (or lack of them) between keywords are preserved.

Expand Down
2 changes: 1 addition & 1 deletion robotidy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def print_description(name: str):
def print_transformers_list():
transformers = load_transformers(None, {}, allow_disabled=True)
click.echo('To see detailed docs run --desc <transformer_name> or --desc all. '
'Transformers with (disabled) tag \nare executed only when selected explictly with --transform. '
'Transformers with (disabled) tag \nare executed only when selected explicitly with --transform. '
'Available transformers:\n')
transformer_names = []
for transformer in transformers:
Expand Down
6 changes: 3 additions & 3 deletions robotidy/transformers/MergeAndOrderSections.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def parse_order(order):
)
if not order:
return default_order
splitted = order.lower().split(',')
parts = order.lower().split(',')
map = {
'comments': Token.COMMENT_HEADER,
'comment': Token.COMMENT_HEADER,
Expand All @@ -70,8 +70,8 @@ def parse_order(order):
'keyword': Token.KEYWORD_HEADER
}
parsed_order = []
for split in splitted:
parsed_order.append(map.get(split, None))
for part in parts:
parsed_order.append(map.get(part, None))
if any(header not in parsed_order for header in default_order) and len(parsed_order) != len(default_order):
raise click.BadOptionUsage(
option_name='transform',
Expand Down
14 changes: 7 additions & 7 deletions robotidy/transformers/NormalizeSeparators.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ def parse_sections(sections):
return default
if not sections:
return {}
splitted = sections.split(',')
parts = sections.split(',')
parsed_sections = set()
for split in splitted:
split = split.replace('_', '')
if split and split[-1] != 's':
split += 's'
if split not in default:
for part in parts:
part = part.replace('_', '')
if part and part[-1] != 's':
part += 's'
if part not in default:
raise click.BadOptionUsage(
option_name='transform',
message=f"Invalid configurable value: '{sections}' for sections for NormalizeSeparators transformer."
f" Sections to be transformed should be provided in comma separated list with valid section"
f" names:\n{sorted(default)}")
parsed_sections.add(split)
parsed_sections.add(part)
return parsed_sections

def visit_File(self, node): # noqa
Expand Down
4 changes: 2 additions & 2 deletions robotidy/transformers/OrderSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ def get_order(order, default, name_map):
return default
if not order:
return []
splitted = order.lower().split(',')
parts = order.lower().split(',')
try:
return [name_map[split] for split in splitted]
return [name_map[part] for part in parts]
except KeyError:
raise click.BadOptionUsage(
option_name='transform',
Expand Down
10 changes: 5 additions & 5 deletions robotidy/transformers/OrderSettingsSection.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,24 @@ def parse_group_order(order):
return default
if not order:
return []
splitted = order.lower().split(',')
if any(split not in default for split in splitted):
parts = order.lower().split(',')
if any(part not in default for part in parts):
raise click.BadOptionUsage(
option_name='transform',
message=f"Invalid configurable value: '{order}' for group_order for OrderSettingsSection transformer."
f" Custom order should be provided in comma separated list with valid group names:\n{default}"
)
return splitted
return parts

@staticmethod
def parse_order_in_group(order, default, mapping):
if order is None:
return default
if not order:
return []
splitted = order.lower().split(',')
parts = order.lower().split(',')
try:
return [mapping[split] for split in splitted]
return [mapping[part] for part in parts]
except KeyError:
raise click.BadOptionUsage(
option_name='transform',
Expand Down
12 changes: 6 additions & 6 deletions robotidy/transformers/ReplaceRunKeywordIf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ReplaceRunKeywordIf(ModelTransformer):
${var} Keyword2
END

Run Keywords inside Run Keyword If will be splitted into separate keywords::
Run Keywords inside Run Keyword If will be split into separate keywords::

Run Keyword If ${condition} Run Keywords Keyword ${arg} AND Keyword2

Expand Down Expand Up @@ -87,7 +87,7 @@ def create_branched(self, node):
Token(Token.EOL)
])
prev_if = None
for branch in reversed(list(self.split_args_on_delimeters(raw_args, ('ELSE', 'ELSE IF'), assign=assign))):
for branch in reversed(list(self.split_args_on_delimiters(raw_args, ('ELSE', 'ELSE IF'), assign=assign))):
if branch[0].value == 'ELSE':
header = ElseHeader([
separator,
Expand Down Expand Up @@ -128,7 +128,7 @@ def create_branched(self, node):
def create_keywords(self, arg_tokens, assign, indent):
if normalize_name(arg_tokens[0].value) == 'runkeywords':
return [self.args_to_keyword(keyword[1:], assign, indent)
for keyword in self.split_args_on_delimeters(arg_tokens, ('AND',))]
for keyword in self.split_args_on_delimiters(arg_tokens, ('AND',))]
return self.args_to_keyword(arg_tokens, assign, indent)

def args_to_keyword(self, arg_tokens, assign, indent):
Expand All @@ -140,13 +140,13 @@ def args_to_keyword(self, arg_tokens, assign, indent):
return KeywordCall.from_tokens(separated_tokens)

@staticmethod
def split_args_on_delimeters(args, delimeters, assign=None):
split_points = [index for index, arg in enumerate(args) if arg.value in delimeters]
def split_args_on_delimiters(args, delimiters, assign=None):
split_points = [index for index, arg in enumerate(args) if arg.value in delimiters]
prev_index = 0
for split_point in split_points:
yield args[prev_index:split_point]
prev_index = split_point
yield args[prev_index:len(args)]
if assign and 'ELSE' in delimeters and not any(arg.value == 'ELSE' for arg in args):
if assign and 'ELSE' in delimiters and not any(arg.value == 'ELSE' for arg in args):
values = [Token(Token.ARGUMENT, '${None}')] * len(assign)
yield [Token(Token.ELSE), Token(Token.ARGUMENT, 'Set Variable'), *values]
2 changes: 1 addition & 1 deletion robotidy/transformers/SmartSortKeywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class SmartSortKeywords(ModelTransformer):
"""
Sort keywords in *** Keywords *** section.

By default sorting is case insensitve, but keywords with leading underscore go to the bottom. Other underscores are
By default sorting is case insensitive, but keywords with leading underscore go to the bottom. Other underscores are
treated as spaces.
Empty lines (or lack of them) between keywords are preserved.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ Return first and comment last
[Return] stuff
# I want to be here

# what will happend with me?
# what will happen with me?
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ Return first and comment last
[Return] stuff
# I want to be here

# what will happend with me?
# what will happen with me?
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ Return first and comment last
[Return] stuff
# I want to be here

# what will happend with me?
# what will happen with me?
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ Return first and comment last
[Return] stuff
# I want to be here

# what will happend with me?
# what will happen with me?
2 changes: 1 addition & 1 deletion tests/atest/transformers/OrderSettings/source/test.robot
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ Return first and comment last
Keyword
# I want to be here

# what will happend with me?
# what will happen with me?
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Different keyword calls
... a # comment

# comment
This is a keyword these arguments wont fit with that
This is a keyword these arguments won't fit with that

# comment
This is a keyword these arguments wont fit with or
This is a keyword these arguments won't fit with or
... without that

# Edge case here →→→→→→→→→→→→→→→→ HERE
Expand Down Expand Up @@ -86,10 +86,10 @@ For loop
... a # comment

# comment
This is a keyword these arguments wont fit with that
This is a keyword these arguments won't fit with that

# comment
This is a keyword these arguments wont fit with or
This is a keyword these arguments won't fit with or
... without that

# Edge case here →→→→→→→→→→→→→→→→ HERE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Different keyword calls
This is a keyword
... these
... arguments
... wont
... won't
... fit
... with
... that
Expand All @@ -40,7 +40,7 @@ Different keyword calls
This is a keyword
... these
... arguments
... wont
... won't
... fit
... with
... or
Expand Down Expand Up @@ -154,7 +154,7 @@ For loop
This is a keyword
... these
... arguments
... wont
... won't
... fit
... with
... that
Expand All @@ -163,7 +163,7 @@ For loop
This is a keyword
... these
... arguments
... wont
... won't
... fit
... with
... or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Different keyword calls

This is a keyword this last argument is not really a # comment

This is a keyword these arguments wont fit with that # comment
This is a keyword these arguments won't fit with that # comment

This is a keyword these arguments wont fit with or without that # comment
This is a keyword these arguments won't fit with or without that # comment

This is a keyword these args have an interesting
... # Edge case here →→→→→→→→→→→→→→→→ HERE
Expand Down Expand Up @@ -72,9 +72,9 @@ For loop

This is a keyword this last argument is not really a # comment

This is a keyword these arguments wont fit with that # comment
This is a keyword these arguments won't fit with that # comment

This is a keyword these arguments wont fit with or without that # comment
This is a keyword these arguments won't fit with or without that # comment

This is a keyword these args have an interesting
... # Edge case here →→→→→→→→→→→→→→→→ HERE
Expand Down
2 changes: 1 addition & 1 deletion tests/utest/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def test_skip_node_start_end_line_setting(self, node_start, node_end, start_line
def test_list_transformers(self, flag):
result = run_tidy([flag])
assert 'To see detailed docs run --desc <transformer_name> or --desc all. Transformers with (disabled) tag \n' \
'are executed only when selected explictly with --transform. Available transformers:\n'\
'are executed only when selected explicitly with --transform. Available transformers:\n'\
in result.output
assert 'ReplaceRunKeywordIf\n' in result.output
assert 'SmartSortKeywords (disabled)\n' in result.output # this transformer is disabled by default
Expand Down