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 | 282 | - 'app/models/notice_fingerprinter.rb' |
| 283 | 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 | 285 | # Offense count: 11 |
| 297 | 286 | # Cop supports --auto-correct. |
| 298 | 287 | Style/SingleSpaceBeforeFirstArg: | ... | ... |
app/models/notification_service.rb
| ... | ... | @@ -32,22 +32,36 @@ class NotificationService |
| 32 | 32 | end |
| 33 | 33 | |
| 34 | 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 | 39 | def notification_description(problem) |
| 38 | 40 | "[#{problem.environment}][#{problem.where}] #{problem.message.to_s.truncate(100)}" |
| 39 | 41 | end |
| 40 | 42 | |
| 41 | 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 | 56 | # Retrieve tracker label from either class or instance. |
| 48 | 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 | 66 | def configured? |
| 53 | 67 | api_token.present? | ... | ... |
spec/decorators/issue_tracker_decorator_spec.rb
| 1 | 1 | describe IssueTrackerDecorator do |
| 2 | 2 | let(:fake_tracker) do |
| 3 | 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 | 12 | def self.fields |
| 8 | 13 | { |
| ... | ... | @@ -11,7 +16,9 @@ describe IssueTrackerDecorator do |
| 11 | 16 | } |
| 12 | 17 | end |
| 13 | 18 | |
| 14 | - def configured?; true; end | |
| 19 | + def configured? | |
| 20 | + true | |
| 21 | + end | |
| 15 | 22 | } |
| 16 | 23 | klass.new 'nothing special' |
| 17 | 24 | end | ... | ... |
spec/decorators/issue_tracker_type_decorator_spec.rb
| 1 | 1 | describe IssueTrackerDecorator do |
| 2 | 2 | let(:fake_tracker_class) do |
| 3 | 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 | 12 | def self.fields |
| 8 | 13 | { | ... | ... |
spec/errbit_plugin/mock_issue_tracker.rb
spec/views/problems/show.html.haml_spec.rb
| ... | ... | @@ -3,16 +3,32 @@ describe "problems/show.html.haml", type: 'view' do |
| 3 | 3 | let(:comment) { Fabricate(:comment) } |
| 4 | 4 | let(:pivotal_tracker) { |
| 5 | 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 | 17 | end |
| 10 | 18 | } |
| 11 | 19 | let(:github_tracker) { |
| 12 | 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 | 32 | end |
| 17 | 33 | } |
| 18 | 34 | let(:trackers) { | ... | ... |