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

Inconsistent LineLength behavior with URL-like strings #9558

Closed
mvz opened this issue Mar 5, 2021 · 0 comments
Closed

Inconsistent LineLength behavior with URL-like strings #9558

mvz opened this issue Mar 5, 2021 · 0 comments

Comments

@mvz
Copy link
Contributor

@mvz mvz commented Mar 5, 2021

When using double-quoted strings, a long URL-like string unexpectedly triggers a LineLength offense when it is used as argument to a method call using parentheses. This does not happen for single-quoted strings.

Expected behavior

None of the following lines should trigger a LineLength offense:

  foo = "http://www.example.com/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/'"
  bar("http://www.example.com/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/'")
  bar('http://www.example.com/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/')
  bar "http://www.example.com/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/'"

Actual behavior

An LineLength offense is output for the line

  bar("http://www.example.com/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/'")

Steps to reproduce the problem

  1. Create a file foo.rb containing
# frozen_string_literal: true

def long
  foo = "http://www.example.com/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/'"
  bar("http://www.example.com/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/'")
  bar('http://www.example.com/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/')
  bar "http://www.example.com/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/foo/bar/baz/'"
  foo
end
  1. Create a file .rubocop.yml containing
AllCops:
  NewCops: enable
  1. Run rubocop

RuboCop version

$ rubocop -V
1.11.0 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 3.0.0 x86_64-linux)
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Mar 8, 2021
…wrapped in single quotes vs double quotes.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Mar 8, 2021
…wrapped in single quotes vs double quotes.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Mar 8, 2021
…wrapped in single quotes vs double quotes.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Mar 8, 2021
…wrapped in single quotes vs double quotes.
bbatsov added a commit that referenced this issue Mar 10, 2021
… in single quotes vs double quotes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

1 participant