Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn on use of Windows DOS devices in paths #8511

Open
ChrisDenton opened this issue Mar 7, 2022 · 0 comments
Open

Warn on use of Windows DOS devices in paths #8511

ChrisDenton opened this issue Mar 7, 2022 · 0 comments
Labels
A-lint Area: New lints

Comments

@ChrisDenton
Copy link

ChrisDenton commented Mar 7, 2022

What it does

If the user uses a bare dos device name such as aux, windows will convert it to \\.\aux (the aux device). This may be surprising. Clippy could warn the user and suggest they explicitly use \\.\aux if that was intended. Using .\aux could also suppress this lint.

The DOS device names are (case insensitive):

  • AUX
  • CON
  • CONIN$
  • CONOUT$
  • COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, COM², COM³, COM¹
  • LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9, LPT², LPT³, LPT¹
  • NUL
  • PRN

Lint Name

bare_dos_device_name

Category

suspicious

Advantage

Avoids unexpected and surprising path transformations.

Drawbacks

This is platform specific behaviour.

Example

File::open("aux");

Could be written as:

File::open(r"\\.\aux");

Or

File::open("./aux");
@ChrisDenton ChrisDenton added the A-lint Area: New lints label Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant