diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /doc/development/newlines_styleguide.md | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'doc/development/newlines_styleguide.md')
-rw-r--r-- | doc/development/newlines_styleguide.md | 111 |
1 files changed, 7 insertions, 104 deletions
diff --git a/doc/development/newlines_styleguide.md b/doc/development/newlines_styleguide.md index 57962129b2f..014affa3e04 100644 --- a/doc/development/newlines_styleguide.md +++ b/doc/development/newlines_styleguide.md @@ -1,108 +1,11 @@ --- -stage: none -group: unassigned -info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments +redirect_to: 'backend/ruby_style_guide.md#newlines-style-guide' +remove_date: '2022-12-15' --- -# Newlines style guide +This document was moved to [another location](backend/ruby_style_guide.md#newlines-style-guide). -This style guide recommends best practices for newlines in Ruby code. - -## Rule: separate code with newlines only to group together related logic - -```ruby -# bad -def method - issue = Issue.new - - issue.save - - render json: issue -end -``` - -```ruby -# good -def method - issue = Issue.new - issue.save - - render json: issue -end -``` - -## Rule: separate code and block with newlines - -### Newline before block - -```ruby -# bad -def method - issue = Issue.new - if issue.save - render json: issue - end -end -``` - -```ruby -# good -def method - issue = Issue.new - - if issue.save - render json: issue - end -end -``` - -## Newline after block - -```ruby -# bad -def method - if issue.save - issue.send_email - end - render json: issue -end -``` - -```ruby -# good -def method - if issue.save - issue.send_email - end - - render json: issue -end -``` - -### Exception: no need for newline when code block starts or ends right inside another code block - -```ruby -# bad -def method - - if issue - - if issue.valid? - issue.save - end - - end - -end -``` - -```ruby -# good -def method - if issue - if issue.valid? - issue.save - end - end -end -``` +<!-- This redirect file can be deleted after 2022-12-15. --> +<!-- Redirects that point to other docs in the same project expire in three months. --> +<!-- Redirects that point to docs in a different project or site (for example, link is not relative and starts with `https:`) expire in one year. --> +<!-- Before deletion, see: https://docs.gitlab.com/ee/development/documentation/redirects.html --> |