Skip to content

[CI] Spaces and new lines should be style-checked for test files #27243

@jiasli

Description

@jiasli

Currently pylintrc ignores all tests folders:

ignore=tests,generated,vendored_sdks,privates

Some test files contain trailing-whitespace, trailing-newlines, or missing-final-newline.

For example, this line contains trailing-whitespace:

Even though code style in test files is not important, IDEs have options to automatically fix spaces and new lines. If another developer edits these test files, trailing-whitespace and trailing-newlines will be trimmed and missing-final-newline will be added, thus appearing in PR's diff. If the other developer doesn't want these changes to appear in the diff, they have to disable automatic fix to comply with the "bad" code style.

For example, in this python file . is used to denote spaces and - is used to denote new lines:

if True:
    print(True).
....
    print(False)
-
-

pylint will report:

> pylint D:\cli\testproj\testpylint.py
************* Module testpylint
testproj\testpylint.py:2:15: C0303: Trailing whitespace (trailing-whitespace)
testproj\testpylint.py:3:0: C0303: Trailing whitespace (trailing-whitespace)
testproj\testpylint.py:5:0: C0305: Trailing newlines (trailing-newlines)

Adding checks for trailing-whitespace, trailing-newlines and missing-final-newline will help unify code style.

Metadata

Metadata

Assignees

Labels

Azure CLI TeamThe command of the issue is owned by Azure CLI teamCICIOKR CandidateThis label is used to track how many GitHub issues we have resolved for OKR purpose.feature-request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions