diff --git a/.rubocop.yml b/.rubocop.yml index 9410af03..c333e43a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -188,6 +188,10 @@ Rails: Rails/Validation: Enabled: true +# Looks for delegations, that could have been created automatically with delegate method +Rails/Delegate: + Enabled: true + #################### Performance ############################### # Identifies places where gsub can be replaced by tr or delete. diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 11fedc97..4356de97 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -124,12 +124,6 @@ Rails/Blank: Rails/Date: Enabled: false -# Offense count: 1 -# Cop supports --auto-correct. -Rails/Delegate: - Exclude: - - 'app/serializers/speaker_serializer.rb' - # Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: Whitelist. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ec8376ce..2ef507a8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -131,7 +131,7 @@ We are using [rubocop](https://github.com/bbatsov/rubocop) as a style checker. I 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. ### Test Suite diff --git a/app/serializers/speaker_serializer.rb b/app/serializers/speaker_serializer.rb index c017fb31..4a455a61 100644 --- a/app/serializers/speaker_serializer.rb +++ b/app/serializers/speaker_serializer.rb @@ -3,7 +3,5 @@ class SpeakerSerializer < ActiveModel::Serializer attributes :name, :affiliation, :biography - def name - object.name - end + delegate :name, to: :object end