Skip to content

New Cop: Detect '/dev/null' and suggest File::NULL instead #13490

Closed
@tagliala

Description

Is your feature request related to a problem? Please describe.

Apologies if this is a duplicate or if it is not the correct repository.

I've encountered a hardcoded '/dev/null' and am wondering if it would be useful to have a cop to detect this misuse.

I've also searched for occurrences on GitHub, and it appears to be quite common:

https://github.com/search?q=%22%27%2Fdev%2Fnull%27%22+language%3ARuby+path%3A.rb&type=code

Describe the solution you'd like

A cop that can detect '/dev/null' or "/dev/null" and suggest using File::NULL instead.

File::NULL has been introduced in Ruby 1.9.3

Describe alternatives you've considered

n/a

Additional context

The cop should detect for exactly '/dev/null' or "/dev/null", because most Rakefiles contain /dev/null as part of a command (like >> /dev/null) (and I guess they are platform-dependent

A CI failing on windows because of '/dev/null'

jamesmartin/inline_svg#174

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions