From 8086597b1eec17fa3dfc11fcb394d74aa5513e4d Mon Sep 17 00:00:00 2001 From: Laust Rud Jacobsen Date: Wed, 4 Nov 2015 21:03:17 +0100 Subject: [PATCH] Rubocop: unfold single-line methods for readability --- .rubocop_todo.yml | 11 ----------- app/models/notification_service.rb | 26 ++++++++++++++++++++------ spec/decorators/issue_tracker_decorator_spec.rb | 13 ++++++++++--- spec/decorators/issue_tracker_type_decorator_spec.rb | 9 +++++++-- spec/errbit_plugin/mock_issue_tracker.rb | 8 ++++++-- spec/views/problems/show.html.haml_spec.rb | 28 ++++++++++++++++++++++------ 6 files changed, 65 insertions(+), 30 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e5b66dc..b22e20d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -282,17 +282,6 @@ Style/SingleLineBlockParams: - 'app/models/notice_fingerprinter.rb' - 'lib/hoptoad/v2.rb' -# Offense count: 19 -# Cop supports --auto-correct. -# Configuration parameters: AllowIfMethodIsEmpty. -Style/SingleLineMethods: - Exclude: - - 'app/models/notification_service.rb' - - 'spec/decorators/issue_tracker_decorator_spec.rb' - - 'spec/decorators/issue_tracker_type_decorator_spec.rb' - - 'spec/errbit_plugin/mock_issue_tracker.rb' - - 'spec/views/problems/show.html.haml_spec.rb' - # Offense count: 11 # Cop supports --auto-correct. Style/SingleSpaceBeforeFirstArg: diff --git a/app/models/notification_service.rb b/app/models/notification_service.rb index 93b92f0..1ef6cb2 100644 --- a/app/models/notification_service.rb +++ b/app/models/notification_service.rb @@ -32,22 +32,36 @@ class NotificationService end # Subclasses are responsible for overwriting this method. - def check_params; true; end + def check_params + true + end def notification_description(problem) "[#{problem.environment}][#{problem.where}] #{problem.message.to_s.truncate(100)}" end # Allows us to set the issue tracker class from a single form. - def type; _type; end - def type=(t); self._type = t; end + def type + _type + end + + def type=(t) + self._type = t + end - def url; nil; end + def url + nil + end # Retrieve tracker label from either class or instance. Label = '' - def self.label; self::Label; end - def label; self.class.label; end + def self.label + self::Label + end + + def label + self.class.label + end def configured? api_token.present? diff --git a/spec/decorators/issue_tracker_decorator_spec.rb b/spec/decorators/issue_tracker_decorator_spec.rb index 22a2e05..764c8f8 100644 --- a/spec/decorators/issue_tracker_decorator_spec.rb +++ b/spec/decorators/issue_tracker_decorator_spec.rb @@ -1,8 +1,13 @@ describe IssueTrackerDecorator do let(:fake_tracker) do klass = Class.new(ErrbitPlugin::IssueTracker) { - def self.label; 'fake'; end - def self.note; 'a note'; end + def self.label + 'fake' + end + + def self.note + 'a note' + end def self.fields { @@ -11,7 +16,9 @@ describe IssueTrackerDecorator do } end - def configured?; true; end + def configured? + true + end } klass.new 'nothing special' end diff --git a/spec/decorators/issue_tracker_type_decorator_spec.rb b/spec/decorators/issue_tracker_type_decorator_spec.rb index 0410567..f45e604 100644 --- a/spec/decorators/issue_tracker_type_decorator_spec.rb +++ b/spec/decorators/issue_tracker_type_decorator_spec.rb @@ -1,8 +1,13 @@ describe IssueTrackerDecorator do let(:fake_tracker_class) do klass = Class.new(ErrbitPlugin::IssueTracker) do - def self.label; 'fake'; end - def self.note; 'a note'; end + def self.label + 'fake' + end + + def self.note + 'a note' + end def self.fields { diff --git a/spec/errbit_plugin/mock_issue_tracker.rb b/spec/errbit_plugin/mock_issue_tracker.rb index f3ae0ed..8b7bb1e 100644 --- a/spec/errbit_plugin/mock_issue_tracker.rb +++ b/spec/errbit_plugin/mock_issue_tracker.rb @@ -38,8 +38,12 @@ module ErrbitPlugin "http://example.com/mock-errbit" end - def url; ''; end + def url + '' + end - def comments_allowed?; false; end + def comments_allowed? + false + end end end diff --git a/spec/views/problems/show.html.haml_spec.rb b/spec/views/problems/show.html.haml_spec.rb index 292bd84..a0ac64f 100644 --- a/spec/views/problems/show.html.haml_spec.rb +++ b/spec/views/problems/show.html.haml_spec.rb @@ -3,16 +3,32 @@ describe "problems/show.html.haml", type: 'view' do let(:comment) { Fabricate(:comment) } let(:pivotal_tracker) { Class.new(ErrbitPlugin::MockIssueTracker) do - def self.label; 'pivotal'; end - def self.icons; {}; end - def configured?; true; end + def self.label + 'pivotal' + end + + def self.icons + {} + end + + def configured? + true + end end } let(:github_tracker) { Class.new(ErrbitPlugin::MockIssueTracker) do - def self.label; 'github'; end - def self.icons; {}; end - def configured?; true; end + def self.label + 'github' + end + + def self.icons + {} + end + + def configured? + true + end end } let(:trackers) { -- libgit2 0.21.2