Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance/Detect does not work with [0] or [-1] #163

Closed
iSarCasm opened this issue Sep 3, 2020 · 0 comments · Fixed by #167
Closed

Performance/Detect does not work with [0] or [-1] #163

iSarCasm opened this issue Sep 3, 2020 · 0 comments · Fixed by #167

Comments

@iSarCasm
Copy link

iSarCasm commented Sep 3, 2020

Is your feature request related to a problem? Please describe.

Since for arrays [0] is usually the same as .first and [-1] is same as .last I would expect the Performance/Detect to identify performance problems with index syntax as well.

Describe the solution you'd like

Add index syntax to Performance/Detect cop

@iSarCasm iSarCasm changed the title Performance/Detect does no work with [0] or [-1] Performance/Detect does not work with [0] or [-1] Sep 3, 2020
dvandersluis added a commit to dvandersluis/rubocop-performance that referenced this issue Sep 10, 2020
For example, `[1, 2, 3].detect{ ... }[0]` will now be caught and corrected by the cop.
dvandersluis added a commit to dvandersluis/rubocop-performance that referenced this issue Sep 11, 2020
For example, `[1, 2, 3].detect{ ... }[0]` will now be caught and corrected by the cop.
dvandersluis added a commit to dvandersluis/rubocop-performance that referenced this issue Sep 11, 2020
For example, `[1, 2, 3].detect{ ... }[0]` will now be caught and corrected by the cop.
dvandersluis added a commit to dvandersluis/rubocop-performance that referenced this issue Sep 11, 2020
For example, `[1, 2, 3].detect{ ... }[0]` will now be caught and corrected by the cop.
dvandersluis added a commit to dvandersluis/rubocop-performance that referenced this issue Sep 14, 2020
For example, `[1, 2, 3].detect{ ... }[0]` will now be caught and corrected by the cop.
@koic koic closed this as completed in #167 Sep 16, 2020
koic added a commit that referenced this issue Sep 16, 2020
[Fix #163] Detect array indexes for `Performance/Detect`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant