Skip to content

Commit

Permalink
multilineident: add tests and documentation
Browse files Browse the repository at this point in the history
for the new fix method

Signed-off-by: Konrad Weihmann <[email protected]>
  • Loading branch information
priv-kweihmann committed Jun 27, 2024
1 parent 06f98cb commit f12992d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ Rules marked with **[S]** can have multiple sub-IDs
* [oelint.vars.listappend](https://github.com/priv-kweihmann/oelint-adv/blob/master/docs/wiki/oelint.vars.listappend.md) - Proper append/prepend to lists **[F]**
* [oelint.vars.mispell.unknown](https://github.com/priv-kweihmann/oelint-adv/blob/master/docs/wiki/oelint.vars.mispell.unknown.md) - Variable is not known from CONSTANTS, typo is unlikely
* [oelint.vars.mispell](https://github.com/priv-kweihmann/oelint-adv/blob/master/docs/wiki/oelint.vars.mispell.md) - Possible typo detected
* [oelint.vars.multilineident](https://github.com/priv-kweihmann/oelint-adv/blob/master/docs/wiki/oelint.vars.multilineident.md) - On a multiline assignment, line indent is desirable
* [oelint.vars.multilineident](https://github.com/priv-kweihmann/oelint-adv/blob/master/docs/wiki/oelint.vars.multilineident.md) - On a multiline assignment, line indent is desirable **[F]**
* [oelint.vars.notneededspace](https://github.com/priv-kweihmann/oelint-adv/blob/master/docs/wiki/oelint.vars.notneededspace.md) - Space at the beginning of the var is not needed **[F]**
* [oelint.vars.notrailingslash](https://github.com/priv-kweihmann/oelint-adv/blob/master/docs/wiki/oelint.vars.notrailingslash.md) - Variable shall not end on a slash
* [oelint.vars.overrideappend](https://github.com/priv-kweihmann/oelint-adv/blob/master/docs/wiki/oelint.vars.overrideappend.md) - Check correct order of append/prepend on variables with override syntax
Expand Down
2 changes: 1 addition & 1 deletion oelint_adv/rule_base/rule_var_multilineindent.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def fix(self, _file: str, stash: Stash) -> List[str]:
found = True
_lines[index] = " " * _likeliest_indent + _lines[index].lstrip()
res.append(_file)
if found:
if found: # pragma: no cover
i.Raw = "\n".join(_lines)
i.RealRaw = "\n".join(_lines)
return res
51 changes: 51 additions & 0 deletions tests/test_class_oelint_vars_multilineident.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,57 @@ class TestClassOelintVarsMultilineIdent(TestBaseClass):
def test_bad(self, input_, id_, occurrence):
self.check_for_id(self._create_args(input_), id_, occurrence)

@pytest.mark.parametrize('id_', ['oelint.vars.multilineident'])
@pytest.mark.parametrize('input_',
[
{
'oelint_adv_test.bb':
'''
D = "a \\
e \\
"
''',
},
{
'oelint_adv_test.bb':
'''
D = " a \\
e \\
"
''',
},
{
'oelint_adv_test.bb':
'''
A = "a \\
b \\
c \\
"
''',
},
{
'oelint_adv_test.bb':
'''
A:append = "a \\
b \\
c \\
"
''',
},
{
'oelint_adv_test.bb':
'''
A += "a \\
b \\
c \\
"
''',
},
],
)
def test_fix(self, input_, id_):
self.fix_and_check(self._create_args_fix(input_), id_)

@pytest.mark.parametrize('id_', ['oelint.vars.multilineident'])
@pytest.mark.parametrize('occurrence', [2])
@pytest.mark.parametrize('input_',
Expand Down

0 comments on commit f12992d

Please sign in to comment.