Merge pull request #1490 from divyanshumehta/issue_1488
Added Rubocop Cop:Rails/Delegate
This commit is contained in:
commit
374903def1
4 changed files with 6 additions and 10 deletions
|
|
@ -188,6 +188,10 @@ Rails:
|
||||||
Rails/Validation:
|
Rails/Validation:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
# Looks for delegations, that could have been created automatically with delegate method
|
||||||
|
Rails/Delegate:
|
||||||
|
Enabled: true
|
||||||
|
|
||||||
#################### Performance ###############################
|
#################### Performance ###############################
|
||||||
|
|
||||||
# Identifies places where gsub can be replaced by tr or delete.
|
# Identifies places where gsub can be replaced by tr or delete.
|
||||||
|
|
|
||||||
|
|
@ -124,12 +124,6 @@ Rails/Blank:
|
||||||
Rails/Date:
|
Rails/Date:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Rails/Delegate:
|
|
||||||
Exclude:
|
|
||||||
- 'app/serializers/speaker_serializer.rb'
|
|
||||||
|
|
||||||
# Offense count: 3
|
# Offense count: 3
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
# Configuration parameters: Whitelist.
|
# Configuration parameters: Whitelist.
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ We are using [rubocop](https://github.com/bbatsov/rubocop) as a style checker. I
|
||||||
vagrant exec bundle exec rubocop
|
vagrant exec bundle exec rubocop
|
||||||
```
|
```
|
||||||
|
|
||||||
You can read through current enabled rules in `.rubocop.yml` file. Explanations of the defined [rules](http://rubydoc.info/github/bbatsov/rubocop/master/frames) can be found in modules [Cop::Lint](http://rubydoc.info/github/bbatsov/rubocop/master/Rubocop/Cop/Lint) and [Cop::Style](http://rubydoc.info/github/bbatsov/rubocop/master/Rubocop/Cop/Style).
|
You can read through current enabled rules in `.rubocop.yml` file. Explanations of the defined [rules](http://rubydoc.info/github/bbatsov/rubocop/master/frames) can be found in modules [Cop::Lint](http://rubydoc.info/github/bbatsov/rubocop/master/Rubocop/Cop/Lint) and [Cop::Style](http://rubydoc.info/github/bbatsov/rubocop/master/Rubocop/Cop/Style) and [Cop:Rails](https://rubocop.readthedocs.io/en/latest/cops_rails/).
|
||||||
Additionally you can read through the [ruby style-guide](https://github.com/bbatsov/ruby-style-guide) to better understand core principles.
|
Additionally you can read through the [ruby style-guide](https://github.com/bbatsov/ruby-style-guide) to better understand core principles.
|
||||||
|
|
||||||
### Test Suite
|
### Test Suite
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,5 @@ class SpeakerSerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
attributes :name, :affiliation, :biography
|
attributes :name, :affiliation, :biography
|
||||||
|
|
||||||
def name
|
delegate :name, to: :object
|
||||||
object.name
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue