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

Empty lines around multi-line let and let! blocks #132

Open
ydakuka opened this issue Jul 8, 2023 · 2 comments
Open

Empty lines around multi-line let and let! blocks #132

ydakuka opened this issue Jul 8, 2023 · 2 comments

Comments

@ydakuka
Copy link
Contributor

ydakuka commented Jul 8, 2023

There is no information which style is preferred.

let :user do
  build(:user, profile: profile).tap do |user|
    user.save validate: false
  end
end
let :user do
  build(:user, profile: profile).tap do |user|
    user.save validate: false
  end
end
let :user do
  build(:user, profile: profile).tap do |user|
    user.save validate: false
  end
end

or

let :user do
  build(:user, profile: profile).tap do |user|
    user.save validate: false
  end
end

let :user do
  build(:user, profile: profile).tap do |user|
    user.save validate: false
  end
end

let :user do
  build(:user, profile: profile).tap do |user|
    user.save validate: false
  end
end
@ydakuka ydakuka changed the title Empty lines around multi-line let and let! Empty lines around multi-line let and let! blocks Jul 8, 2023
@pirj
Copy link
Member

pirj commented Oct 10, 2023

It would be quite hard to formalize, as the boundaries are blurry.

Would

let(:user) do
  create(:user, <a lot of attributes that forced the author to use the multi-line syntax because of the max line length limitation>)
end
let(:another_user) { create(:user) } # nothing fancy

Why separate the two?

And on the other hand,

let(:user) { create(:user) }

# the line above intentionally left blank as it separates unrelated setup
let(:multiplier) { 3 }
let(:divisor) { 5 }

@andyw8
Copy link
Contributor

andyw8 commented Oct 10, 2023

Would you want to have this applied to all multiline blocks? If so, see rubocop/ruby-style-guide#823

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

No branches or pull requests

3 participants