From 432e02fbf22873bcf99654ed99d192e35e789bb1 Mon Sep 17 00:00:00 2001 From: Laust Rud Jacobsen Date: Sun, 11 Oct 2015 12:46:49 +0200 Subject: [PATCH] Rubocop: manually fixing linter warnings: assignment in condition --- app/controllers/api/v1/stats_controller.rb | 4 ++-- app/controllers/apps_controller.rb | 6 +++--- app/controllers/users/omniauth_callbacks_controller.rb | 2 +- app/models/app.rb | 4 ++-- app/models/notice.rb | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/api/v1/stats_controller.rb b/app/controllers/api/v1/stats_controller.rb index 67f7a92..ec2b755 100644 --- a/app/controllers/api/v1/stats_controller.rb +++ b/app/controllers/api/v1/stats_controller.rb @@ -6,7 +6,7 @@ class Api::V1::StatsController < ApplicationController before_action :require_api_key_or_authenticate_user! def app - if problem = @app.problems.order_by(:last_notice_at.desc).first + if (problem = @app.problems.order_by(:last_notice_at.desc).first) @last_error_time = problem.last_notice_at end @@ -28,7 +28,7 @@ class Api::V1::StatsController < ApplicationController def require_api_key_or_authenticate_user! if params[:api_key].present? - if @app = App.where(:api_key => params[:api_key]).first + if (@app = App.where(:api_key => params[:api_key]).first) return true end end diff --git a/app/controllers/apps_controller.rb b/app/controllers/apps_controller.rb index 1acc3f5..d4f7e50 100644 --- a/app/controllers/apps_controller.rb +++ b/app/controllers/apps_controller.rb @@ -94,7 +94,7 @@ class AppsController < ApplicationController def initialize_subclassed_notification_service # set the app's notification service - if params[:app][:notification_service_attributes] && notification_type = params[:app][:notification_service_attributes][:type] + if params[:app][:notification_service_attributes] && (notification_type = params[:app][:notification_service_attributes][:type]) available_notification_classes = [NotificationService] + NotificationService.subclasses notification_class = available_notification_classes.detect{|c| c.name == notification_type} if !notification_class.nil? @@ -112,7 +112,7 @@ class AppsController < ApplicationController # email_at_notices is edited as a string, and stored as an array. def parse_email_at_notices_or_set_default - if params[:app] && val = params[:app][:email_at_notices] + if params[:app] && (val = params[:app][:email_at_notices]) # Sanitize negative values, split on comma, # strip, parse as integer, remove all '0's. # If empty, set as default and show an error message. @@ -127,7 +127,7 @@ class AppsController < ApplicationController end def parse_notice_at_notices_or_set_default - if params[:app][:notification_service_attributes] && val = params[:app][:notification_service_attributes][:notify_at_notices] + if params[:app][:notification_service_attributes] && (val = params[:app][:notification_service_attributes][:notify_at_notices]) # Sanitize negative values, split on comma, # strip, parse as integer, remove all '0's. # If empty, set as default and show an error message. diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index c4505ad..f3941d8 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -5,7 +5,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController github_user = User.where(:github_login => github_login).first github_site_title = Errbit::Config.github_site_title - if github_user.nil? && github_org_id = Errbit::Config.github_org_id + if github_user.nil? && (github_org_id = Errbit::Config.github_org_id) # See if they are a member of the organization that we have access for # If they are, automatically create an account client = Octokit::Client.new(access_token: github_token) diff --git a/app/models/app.rb b/app/models/app.rb index 186f796..367ff5b 100644 --- a/app/models/app.rb +++ b/app/models/app.rb @@ -153,14 +153,14 @@ class App # Copy app attributes from another app. def copy_attributes_from(app_id) - if copy_app = App.where(:_id => app_id).first + if (copy_app = App.where(:_id => app_id).first) # Copy fields (copy_app.fields.keys - %w(_id name created_at updated_at)).each do |k| self.send("#{k}=", copy_app.send(k)) end # Clone the embedded objects that can be changed via apps/edit (ignore errs & deploys, etc.) %w(watchers issue_tracker notification_service).each do |relation| - if obj = copy_app.send(relation) + if (obj = copy_app.send(relation)) self.send("#{relation}=", obj.is_a?(Array) ? obj.map(&:clone) : obj.clone) end end diff --git a/app/models/notice.rb b/app/models/notice.rb index 5fa5b0a..49c4b57 100644 --- a/app/models/notice.rb +++ b/app/models/notice.rb @@ -82,7 +82,7 @@ class Notice def to_curl return "N/A" if url.blank? headers = %w(Accept Accept-Encoding Accept-Language Cookie Referer User-Agent).each_with_object([]) do |name, h| - if value = env_vars["HTTP_#{name.underscore.upcase}"] + if (value = env_vars["HTTP_#{name.underscore.upcase}"]) h << "-H '#{name}: #{value}'" end end -- libgit2 0.21.2