Open ashmaroli opened 4 years ago
Performance/ChainArrayAllocation
already handles this for arrays:
https://docs.rubocop.org/rubocop-performance/cops_performance.html#performancechainarrayallocation
Awesome! Thanks for the info @eugeneius Keeping this open to extend handling to String duplication.
Is your feature request related to a problem? Please describe.
Given that strings are an essential data type in a program, apps occasionally initialize a lot of String objects by chaining non-mutating methods.
For example:
Will duplicate the
string
argument 3 times before returning the result.Describe the solution you'd like
While the issue is applicable to more core classes, handling Strings first would be a good start.