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,17 +93,6 @@ Style/FileName: | ||
93 | Style/GuardClause: | 93 | Style/GuardClause: |
94 | Enabled: false | 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 | # Offense count: 873 | 96 | # Offense count: 873 |
108 | # Cop supports --auto-correct. | 97 | # Cop supports --auto-correct. |
109 | # Configuration parameters: EnforcedStyle, SupportedStyles. | 98 | # Configuration parameters: EnforcedStyle, SupportedStyles. |
app/controllers/api/v1/stats_controller.rb
@@ -25,9 +25,7 @@ class Api::V1::StatsController < ApplicationController | @@ -25,9 +25,7 @@ class Api::V1::StatsController < ApplicationController | ||
25 | 25 | ||
26 | protected def require_api_key_or_authenticate_user! | 26 | protected def require_api_key_or_authenticate_user! |
27 | if params[:api_key].present? | 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 | end | 29 | end |
32 | 30 | ||
33 | authenticate_user! | 31 | authenticate_user! |
app/controllers/application_controller.rb
@@ -41,8 +41,6 @@ protected | @@ -41,8 +41,6 @@ protected | ||
41 | user_token = params[User.token_authentication_key].presence | 41 | user_token = params[User.token_authentication_key].presence |
42 | user = user_token && User.find_by(authentication_token: user_token) | 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 | end | 45 | end |
48 | end | 46 | end |
app/controllers/problems_controller.rb
@@ -58,9 +58,7 @@ class ProblemsController < ApplicationController | @@ -58,9 +58,7 @@ class ProblemsController < ApplicationController | ||
58 | issue = Issue.new(problem: problem, user: current_user) | 58 | issue = Issue.new(problem: problem, user: current_user) |
59 | issue.body = render_to_string(*issue.render_body_args) | 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 | redirect_to app_problem_path(app, problem) | 63 | redirect_to app_problem_path(app, problem) |
66 | end | 64 | end |
app/models/notice.rb
@@ -107,15 +107,11 @@ class Notice | @@ -107,15 +107,11 @@ class Notice | ||
107 | # TODO: Move on decorator maybe | 107 | # TODO: Move on decorator maybe |
108 | # | 108 | # |
109 | def project_root | 109 | def project_root |
110 | - if server_environment | ||
111 | - server_environment['project-root'] || '' | ||
112 | - end | 110 | + server_environment['project-root'] || '' if server_environment |
113 | end | 111 | end |
114 | 112 | ||
115 | def app_version | 113 | def app_version |
116 | - if server_environment | ||
117 | - server_environment['app-version'] || '' | ||
118 | - end | 114 | + server_environment['app-version'] || '' if server_environment |
119 | end | 115 | end |
120 | 116 | ||
121 | # filter memory addresses out of object strings | 117 | # filter memory addresses out of object strings |
app/models/user.rb
@@ -67,9 +67,7 @@ class User | @@ -67,9 +67,7 @@ class User | ||
67 | end | 67 | end |
68 | 68 | ||
69 | def github_login=(login) | 69 | def github_login=(login) |
70 | - if login.is_a?(String) && login.strip.empty? | ||
71 | - login = nil | ||
72 | - end | 70 | + login = nil if login.is_a?(String) && login.strip.empty? |
73 | self[:github_login] = login | 71 | self[:github_login] = login |
74 | end | 72 | end |
75 | 73 |