rubocop-github 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/guides/rails-controller-render-shorthand.md +9 -0
- data/guides/rails-render-inline.md +27 -0
- data/guides/rails-render-literal.md +8 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52dfc4e189c20426f8c5cdadfd5c137c5a3bf450
|
4
|
+
data.tar.gz: d314b147c717c3e5cdb58a75c3cc037da0e225a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69e2346a9ac0e6c9f14c847034a13ef97b4666c822d384d983e3b14d6674c734491dab0d5da8d452be5ba7a93ddf493f4dfab676376e0670b09c91fd0e6980ad
|
7
|
+
data.tar.gz: e56c3191cf8e50de27fc51129e3f9d8526658eed23fac0c125d8f8b74968571d45891dad504d81b2b31f653141ed62419c29ef9ed24d6f97dec49a732e864f7b
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# GitHub/RailsRenderInline
|
2
|
+
|
3
|
+
tldr; Do not use `render inline:`.
|
4
|
+
|
5
|
+
## Rendering plain text
|
6
|
+
|
7
|
+
``` ruby
|
8
|
+
render inline: "Just plain text" # bad
|
9
|
+
```
|
10
|
+
|
11
|
+
The `inline:` option is often misused when plain text is being returned. Instead use `render plain: "Just plain text"`.
|
12
|
+
|
13
|
+
## Rendering a dynamic ERB string
|
14
|
+
|
15
|
+
String `#{}` interpolation is often misused with `render inline:` instead of using `<%= %>` interpolation. This will lead to a memory leak where an ERB method will be compiled and cached for each invocation of `render inline:`.
|
16
|
+
|
17
|
+
``` ruby
|
18
|
+
render inline: "Hello #{@name}" # bad
|
19
|
+
```
|
20
|
+
|
21
|
+
## Rendering static ERB strings
|
22
|
+
|
23
|
+
``` ruby
|
24
|
+
render inline: "Hello <%= @name %>" # bad
|
25
|
+
```
|
26
|
+
|
27
|
+
If you are passing a static ERB string to `render inline:`, this string is best moved to a `.erb` template under `app/views`. Template files are able to be precompiled at boot time.
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# GitHub/RailsRenderLiteral
|
2
|
+
|
3
|
+
tldr; `render` MUST be passed a string literal template path.
|
4
|
+
|
5
|
+
* When used in conjunction with `GitHub/RailsViewRenderPathsExist`, linters can ensure the target file exists on disk and would not crash rendering a missing template.
|
6
|
+
* Makes it easier for humans to trace callers of a template. Simply search for the full path of the target template to find **all** call sites.
|
7
|
+
* This same call site tracing enables automated unused template checking. If no callers are found, the template can be safely removed.
|
8
|
+
* Enables render precompilation and inlining optimizations. Target templates can be compiled and inlined on boot time rather than deferring to first render to lazily compile templates.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-github
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -77,6 +77,9 @@ files:
|
|
77
77
|
- STYLEGUIDE.md
|
78
78
|
- config/default.yml
|
79
79
|
- config/rails.yml
|
80
|
+
- guides/rails-controller-render-shorthand.md
|
81
|
+
- guides/rails-render-inline.md
|
82
|
+
- guides/rails-render-literal.md
|
80
83
|
- lib/rubocop/cop/github.rb
|
81
84
|
- lib/rubocop/cop/github/rails_application_record.rb
|
82
85
|
- lib/rubocop/cop/github/rails_controller_render_action_symbol.rb
|
@@ -108,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
111
|
version: '0'
|
109
112
|
requirements: []
|
110
113
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.5.
|
114
|
+
rubygems_version: 2.5.1
|
112
115
|
signing_key:
|
113
116
|
specification_version: 4
|
114
117
|
summary: RuboCop GitHub
|