rule to replace substring is unsafe. should be deprecated
Brought to you by:
chrismair
Reported by @evgeny_goldin on twitter:
UnnecessarySubstring: s.substring( j ) != s[ j .. -1 ], substring gets empty String if j = s.size(), s[ j .. -1 ] fails (#groovy)
I followed this rule and switched to [ j .. -1 ] which introduced a number of bugs in those edge cases. Back to safer substring()
@tim_yates says:
"apart from negative numbers return all the string, and numbers greater than its length return ''
I'm not 100% what the problem is. Maybe the rule is just a bad idea to begin with.