Commit 8086597b1eec17fa3dfc11fcb394d74aa5513e4d
1 parent
db32f4f6
Exists in
master
and in
1 other branch
Rubocop: unfold single-line methods for readability
To me these all now read trivially as they are quite simple. Thoughts, comments?
Showing
6 changed files
with
65 additions
and
30 deletions
Show diff stats
.rubocop_todo.yml
| @@ -282,17 +282,6 @@ Style/SingleLineBlockParams: | @@ -282,17 +282,6 @@ Style/SingleLineBlockParams: | ||
| 282 | - 'app/models/notice_fingerprinter.rb' | 282 | - 'app/models/notice_fingerprinter.rb' |
| 283 | - 'lib/hoptoad/v2.rb' | 283 | - 'lib/hoptoad/v2.rb' |
| 284 | 284 | ||
| 285 | -# Offense count: 19 | ||
| 286 | -# Cop supports --auto-correct. | ||
| 287 | -# Configuration parameters: AllowIfMethodIsEmpty. | ||
| 288 | -Style/SingleLineMethods: | ||
| 289 | - Exclude: | ||
| 290 | - - 'app/models/notification_service.rb' | ||
| 291 | - - 'spec/decorators/issue_tracker_decorator_spec.rb' | ||
| 292 | - - 'spec/decorators/issue_tracker_type_decorator_spec.rb' | ||
| 293 | - - 'spec/errbit_plugin/mock_issue_tracker.rb' | ||
| 294 | - - 'spec/views/problems/show.html.haml_spec.rb' | ||
| 295 | - | ||
| 296 | # Offense count: 11 | 285 | # Offense count: 11 |
| 297 | # Cop supports --auto-correct. | 286 | # Cop supports --auto-correct. |
| 298 | Style/SingleSpaceBeforeFirstArg: | 287 | Style/SingleSpaceBeforeFirstArg: |
app/models/notification_service.rb
| @@ -32,22 +32,36 @@ class NotificationService | @@ -32,22 +32,36 @@ class NotificationService | ||
| 32 | end | 32 | end |
| 33 | 33 | ||
| 34 | # Subclasses are responsible for overwriting this method. | 34 | # Subclasses are responsible for overwriting this method. |
| 35 | - def check_params; true; end | 35 | + def check_params |
| 36 | + true | ||
| 37 | + end | ||
| 36 | 38 | ||
| 37 | def notification_description(problem) | 39 | def notification_description(problem) |
| 38 | "[#{problem.environment}][#{problem.where}] #{problem.message.to_s.truncate(100)}" | 40 | "[#{problem.environment}][#{problem.where}] #{problem.message.to_s.truncate(100)}" |
| 39 | end | 41 | end |
| 40 | 42 | ||
| 41 | # Allows us to set the issue tracker class from a single form. | 43 | # Allows us to set the issue tracker class from a single form. |
| 42 | - def type; _type; end | ||
| 43 | - def type=(t); self._type = t; end | 44 | + def type |
| 45 | + _type | ||
| 46 | + end | ||
| 47 | + | ||
| 48 | + def type=(t) | ||
| 49 | + self._type = t | ||
| 50 | + end | ||
| 44 | 51 | ||
| 45 | - def url; nil; end | 52 | + def url |
| 53 | + nil | ||
| 54 | + end | ||
| 46 | 55 | ||
| 47 | # Retrieve tracker label from either class or instance. | 56 | # Retrieve tracker label from either class or instance. |
| 48 | Label = '' | 57 | Label = '' |
| 49 | - def self.label; self::Label; end | ||
| 50 | - def label; self.class.label; end | 58 | + def self.label |
| 59 | + self::Label | ||
| 60 | + end | ||
| 61 | + | ||
| 62 | + def label | ||
| 63 | + self.class.label | ||
| 64 | + end | ||
| 51 | 65 | ||
| 52 | def configured? | 66 | def configured? |
| 53 | api_token.present? | 67 | api_token.present? |
spec/decorators/issue_tracker_decorator_spec.rb
| 1 | describe IssueTrackerDecorator do | 1 | describe IssueTrackerDecorator do |
| 2 | let(:fake_tracker) do | 2 | let(:fake_tracker) do |
| 3 | klass = Class.new(ErrbitPlugin::IssueTracker) { | 3 | klass = Class.new(ErrbitPlugin::IssueTracker) { |
| 4 | - def self.label; 'fake'; end | ||
| 5 | - def self.note; 'a note'; end | 4 | + def self.label |
| 5 | + 'fake' | ||
| 6 | + end | ||
| 7 | + | ||
| 8 | + def self.note | ||
| 9 | + 'a note' | ||
| 10 | + end | ||
| 6 | 11 | ||
| 7 | def self.fields | 12 | def self.fields |
| 8 | { | 13 | { |
| @@ -11,7 +16,9 @@ describe IssueTrackerDecorator do | @@ -11,7 +16,9 @@ describe IssueTrackerDecorator do | ||
| 11 | } | 16 | } |
| 12 | end | 17 | end |
| 13 | 18 | ||
| 14 | - def configured?; true; end | 19 | + def configured? |
| 20 | + true | ||
| 21 | + end | ||
| 15 | } | 22 | } |
| 16 | klass.new 'nothing special' | 23 | klass.new 'nothing special' |
| 17 | end | 24 | end |
spec/decorators/issue_tracker_type_decorator_spec.rb
| 1 | describe IssueTrackerDecorator do | 1 | describe IssueTrackerDecorator do |
| 2 | let(:fake_tracker_class) do | 2 | let(:fake_tracker_class) do |
| 3 | klass = Class.new(ErrbitPlugin::IssueTracker) do | 3 | klass = Class.new(ErrbitPlugin::IssueTracker) do |
| 4 | - def self.label; 'fake'; end | ||
| 5 | - def self.note; 'a note'; end | 4 | + def self.label |
| 5 | + 'fake' | ||
| 6 | + end | ||
| 7 | + | ||
| 8 | + def self.note | ||
| 9 | + 'a note' | ||
| 10 | + end | ||
| 6 | 11 | ||
| 7 | def self.fields | 12 | def self.fields |
| 8 | { | 13 | { |
spec/errbit_plugin/mock_issue_tracker.rb
| @@ -38,8 +38,12 @@ module ErrbitPlugin | @@ -38,8 +38,12 @@ module ErrbitPlugin | ||
| 38 | "http://example.com/mock-errbit" | 38 | "http://example.com/mock-errbit" |
| 39 | end | 39 | end |
| 40 | 40 | ||
| 41 | - def url; ''; end | 41 | + def url |
| 42 | + '' | ||
| 43 | + end | ||
| 42 | 44 | ||
| 43 | - def comments_allowed?; false; end | 45 | + def comments_allowed? |
| 46 | + false | ||
| 47 | + end | ||
| 44 | end | 48 | end |
| 45 | end | 49 | end |
spec/views/problems/show.html.haml_spec.rb
| @@ -3,16 +3,32 @@ describe "problems/show.html.haml", type: 'view' do | @@ -3,16 +3,32 @@ describe "problems/show.html.haml", type: 'view' do | ||
| 3 | let(:comment) { Fabricate(:comment) } | 3 | let(:comment) { Fabricate(:comment) } |
| 4 | let(:pivotal_tracker) { | 4 | let(:pivotal_tracker) { |
| 5 | Class.new(ErrbitPlugin::MockIssueTracker) do | 5 | Class.new(ErrbitPlugin::MockIssueTracker) do |
| 6 | - def self.label; 'pivotal'; end | ||
| 7 | - def self.icons; {}; end | ||
| 8 | - def configured?; true; end | 6 | + def self.label |
| 7 | + 'pivotal' | ||
| 8 | + end | ||
| 9 | + | ||
| 10 | + def self.icons | ||
| 11 | + {} | ||
| 12 | + end | ||
| 13 | + | ||
| 14 | + def configured? | ||
| 15 | + true | ||
| 16 | + end | ||
| 9 | end | 17 | end |
| 10 | } | 18 | } |
| 11 | let(:github_tracker) { | 19 | let(:github_tracker) { |
| 12 | Class.new(ErrbitPlugin::MockIssueTracker) do | 20 | Class.new(ErrbitPlugin::MockIssueTracker) do |
| 13 | - def self.label; 'github'; end | ||
| 14 | - def self.icons; {}; end | ||
| 15 | - def configured?; true; end | 21 | + def self.label |
| 22 | + 'github' | ||
| 23 | + end | ||
| 24 | + | ||
| 25 | + def self.icons | ||
| 26 | + {} | ||
| 27 | + end | ||
| 28 | + | ||
| 29 | + def configured? | ||
| 30 | + true | ||
| 31 | + end | ||
| 16 | end | 32 | end |
| 17 | } | 33 | } |
| 18 | let(:trackers) { | 34 | let(:trackers) { |