Skip to content

Lint permissions.set_readonly(false) #9702

Closed
@Alexendoo

Description

@Alexendoo

What it does

The lint would catch any usage of Permissions::set_readonly called with false

.set_readonly(false) on unix platforms sets the file to be world writable - rust-lang/rust#101644

Lint Name

permissions_set_readonly_false

Category

suspicious

Advantage

The behaviour is surprising, so a lint to inform people that it's probably not doing what they expect would be useful

Drawbacks

If someone knows about that behaviour and is using it intentionally it would be a false positive, however in that case the #[allow] would be a good indicator to others that it is intentional

It's possible that the behaviour will be changed or deprecated upstream before the lint is written

Example

let f = File::create("foo.txt")?;
let metadata = f.metadata()?;
let mut permissions = metadata.permissions();

permissions.set_readonly(false);

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions