Commit ee2bcc4e9f5d5d59212302bd6e72c98c040b1d88
1 parent
086f0dc6
Exists in
master
and in
1 other branch
Rubocop: prefer if/unless as modifier when body trivial
Showing
6 changed files
with
6 additions
and
29 deletions
Show diff stats
.rubocop_todo.yml
... | ... | @@ -93,17 +93,6 @@ Style/FileName: |
93 | 93 | Style/GuardClause: |
94 | 94 | Enabled: false |
95 | 95 | |
96 | -# Offense count: 6 | |
97 | -# Cop supports --auto-correct. | |
98 | -# Configuration parameters: MaxLineLength. | |
99 | -Style/IfUnlessModifier: | |
100 | - Exclude: | |
101 | - - 'app/controllers/api/v1/stats_controller.rb' | |
102 | - - 'app/controllers/application_controller.rb' | |
103 | - - 'app/controllers/problems_controller.rb' | |
104 | - - 'app/models/notice.rb' | |
105 | - - 'app/models/user.rb' | |
106 | - | |
107 | 96 | # Offense count: 873 |
108 | 97 | # Cop supports --auto-correct. |
109 | 98 | # Configuration parameters: EnforcedStyle, SupportedStyles. | ... | ... |
app/controllers/api/v1/stats_controller.rb
... | ... | @@ -25,9 +25,7 @@ class Api::V1::StatsController < ApplicationController |
25 | 25 | |
26 | 26 | protected def require_api_key_or_authenticate_user! |
27 | 27 | if params[:api_key].present? |
28 | - if (@app = App.where(api_key: params[:api_key]).first) | |
29 | - return true | |
30 | - end | |
28 | + return true if (@app = App.where(api_key: params[:api_key]).first) | |
31 | 29 | end |
32 | 30 | |
33 | 31 | authenticate_user! | ... | ... |
app/controllers/application_controller.rb
... | ... | @@ -41,8 +41,6 @@ protected |
41 | 41 | user_token = params[User.token_authentication_key].presence |
42 | 42 | user = user_token && User.find_by(authentication_token: user_token) |
43 | 43 | |
44 | - if user | |
45 | - sign_in user, store: false | |
46 | - end | |
44 | + sign_in user, store: false if user | |
47 | 45 | end |
48 | 46 | end | ... | ... |
app/controllers/problems_controller.rb
... | ... | @@ -58,9 +58,7 @@ class ProblemsController < ApplicationController |
58 | 58 | issue = Issue.new(problem: problem, user: current_user) |
59 | 59 | issue.body = render_to_string(*issue.render_body_args) |
60 | 60 | |
61 | - unless issue.save | |
62 | - flash[:error] = issue.errors.full_messages.join(', ') | |
63 | - end | |
61 | + flash[:error] = issue.errors.full_messages.join(', ') unless issue.save | |
64 | 62 | |
65 | 63 | redirect_to app_problem_path(app, problem) |
66 | 64 | end | ... | ... |
app/models/notice.rb
... | ... | @@ -107,15 +107,11 @@ class Notice |
107 | 107 | # TODO: Move on decorator maybe |
108 | 108 | # |
109 | 109 | def project_root |
110 | - if server_environment | |
111 | - server_environment['project-root'] || '' | |
112 | - end | |
110 | + server_environment['project-root'] || '' if server_environment | |
113 | 111 | end |
114 | 112 | |
115 | 113 | def app_version |
116 | - if server_environment | |
117 | - server_environment['app-version'] || '' | |
118 | - end | |
114 | + server_environment['app-version'] || '' if server_environment | |
119 | 115 | end |
120 | 116 | |
121 | 117 | # filter memory addresses out of object strings | ... | ... |
app/models/user.rb