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

[Fix #197] Disable Performance/ArraySemiInfiniteRangeSlice cop #199

Merged
merged 1 commit into from Nov 25, 2020

Conversation

tejasbubane
Copy link
Contributor

@tejasbubane tejasbubane commented Nov 23, 2020

This cop is unsafe for string slices because string does not have #take and #drop methods. Although we could change the cop to skip literal strings, it still remains unsafe for variables which we cannot determine statically if they are arrays or strings.

Closes #197, #198


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@marcandre
Copy link
Contributor

It's not just unsafe, it is unsound, see #198

@tejasbubane tejasbubane changed the title [Fix #197] Mark Performance/ArraySemiInfiniteRangeSlice cop as unsafe [Fix #197] Disable Performance/ArraySemiInfiniteRangeSlice cop Nov 23, 2020
@tejasbubane
Copy link
Contributor Author

@marcandre Disabled. Also marked as unsafe in case some users enable it in their project configs but run into the string slices.

Copy link
Contributor

@marcandre marcandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

config/default.yml Outdated Show resolved Hide resolved
config/default.yml Outdated Show resolved Hide resolved
@tejasbubane
Copy link
Contributor Author

@koic Changes done.

CHANGELOG.md Outdated Show resolved Hide resolved
This cop was created due to a mistake in microbenchmark
Refer rubocop#175 (comment)

Closes rubocop#197, rubocop#198
@koic
Copy link
Member

koic commented Nov 25, 2020

Thanks!

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 this pull request may close these issues.

Performance/ArraySemiInfiniteRangeSlice breaks code on Strings
3 participants