Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
fa95d9e4
Commit
fa95d9e4
authored
Aug 08, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dz-newlines-styleguide' into 'master'
Add newlines styleguide for Ruby code See merge request !5636
parents
1eccfde7
13cabe71
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
104 additions
and
0 deletions
+104
-0
CONTRIBUTING.md
CONTRIBUTING.md
+2
-0
doc/development/newlines_styleguide.md
doc/development/newlines_styleguide.md
+102
-0
No files found.
CONTRIBUTING.md
View file @
fa95d9e4
...
@@ -465,6 +465,7 @@ merge request:
...
@@ -465,6 +465,7 @@ merge request:
-
multi-line method chaining style
**Option B**
: dot
`.`
on previous line
-
multi-line method chaining style
**Option B**
: dot
`.`
on previous line
-
string literal quoting style
**Option A**
: single quoted by default
-
string literal quoting style
**Option A**
: single quoted by default
1.
[
Rails
](
https://github.com/bbatsov/rails-style-guide
)
1.
[
Rails
](
https://github.com/bbatsov/rails-style-guide
)
1.
[
Newlines styleguide
][
newlines-styleguide
]
1.
[
Testing
](
doc/development/testing.md
)
1.
[
Testing
](
doc/development/testing.md
)
1.
[
JavaScript (ES6)
](
https://github.com/airbnb/javascript
)
1.
[
JavaScript (ES6)
](
https://github.com/airbnb/javascript
)
1.
[
JavaScript (ES5)
](
https://github.com/airbnb/javascript/tree/master/es5
)
1.
[
JavaScript (ES5)
](
https://github.com/airbnb/javascript/tree/master/es5
)
...
@@ -537,6 +538,7 @@ available at [http://contributor-covenant.org/version/1/1/0/](http://contributor
...
@@ -537,6 +538,7 @@ available at [http://contributor-covenant.org/version/1/1/0/](http://contributor
[
rss-naming
]:
https://github.com/bbatsov/ruby-style-guide/blob/master/README.md#naming
[
rss-naming
]:
https://github.com/bbatsov/ruby-style-guide/blob/master/README.md#naming
[
doc-styleguide
]:
doc/development/doc_styleguide.md
"Documentation styleguide"
[
doc-styleguide
]:
doc/development/doc_styleguide.md
"Documentation styleguide"
[
scss-styleguide
]:
doc/development/scss_styleguide.md
"SCSS styleguide"
[
scss-styleguide
]:
doc/development/scss_styleguide.md
"SCSS styleguide"
[
newlines-styleguide
]:
doc/development/newlines_styleguide.md
"Newlines styleguide"
[
gitlab-design
]:
https://gitlab.com/gitlab-org/gitlab-design
[
gitlab-design
]:
https://gitlab.com/gitlab-org/gitlab-design
[
free Antetype viewer (Mac OSX only)
]:
https://itunes.apple.com/us/app/antetype-viewer/id824152298?mt=12
[
free Antetype viewer (Mac OSX only)
]:
https://itunes.apple.com/us/app/antetype-viewer/id824152298?mt=12
[
`gitlab8.atype` file
]:
https://gitlab.com/gitlab-org/gitlab-design/tree/master/current/
[
`gitlab8.atype` file
]:
https://gitlab.com/gitlab-org/gitlab-design/tree/master/current/
...
...
doc/development/newlines_styleguide.md
0 → 100644
View file @
fa95d9e4
# Newlines styleguide
This style guide recommends best practices for newlines in Ruby code.
## Rule: separate code with newlines only when it makes sense from logic perspectice
```
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
```
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment