cookstyle icon indicating copy to clipboard operation
cookstyle copied to clipboard

Improve documentation suggestion for ConditionalUsingTest

Open gravitystorm opened this issue 4 years ago • 0 comments

The documentation for ConditionalUsingTest currently reads as:

Use ::File.exist?('/foo/bar') instead of the slower 'test -f /foo/bar' which requires shelling out

However, it doesn't mention that the ruby code should be passed as a block. If you're like me and read the suggestion as-is, you might write:

...
not_if ::File.exist?('/foo/bar')
...

... which will then throw an error ArgumentError: Invalid only_if/not_if command, expected a string: true (TrueClass) if the file exists. Passing as a block:

...
not_if { ::File.exist?('/foo/bar') }
...

... is the intention of the cop.

gravitystorm avatar Mar 29 '21 10:03 gravitystorm