cookstyle
cookstyle copied to clipboard
Improve documentation suggestion for ConditionalUsingTest
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.