In auto-correct mode, RuboCop will try to automatically fix offenses:
$ rubocop -a
For some offenses, it is not possible to implement automatic correction.
Some automatic corrections that are possible have not been implemented yet.
$ rubocop --safe-auto-correct
In RuboCop 0.60, we began to annotate cops as Safe
or not safe. Eventually,
the safety of each cop will be determined.
- Safe (true/false) - indicates whether the cop can yield false positives (by design) or not.
- SafeAutoCorrect (true/false) - indicates whether the auto-correct the cop does is safe (equivalent) by design. #5978 (comment)
If a cop is annotated as "not safe", it will be omitted.
array = []
array << 'Foo' <<
'Bar' <<
'Baz'
puts array.join('-')
Style/LineEndConcatenation
will correct the above to:
array = []
array << 'Foo' \
'Bar' \
'Baz'
puts array.join('-')
Therefore, in this (unusual) scenario, Style/LineEndConcatenation
is unsafe.
(This is a contrived example. Real code would use %w
for an array of string
literals.)