Cleanup Lint/AssignmentInCondition rubocop issues on code and remove it from ruboco_todo list
This commit is contained in:
@@ -6,14 +6,6 @@
|
|||||||
# Note that changes in the inspected code, or installation of new
|
# Note that changes in the inspected code, or installation of new
|
||||||
# versions of RuboCop, may require this file to be generated again.
|
# versions of RuboCop, may require this file to be generated again.
|
||||||
|
|
||||||
# Offense count: 3
|
|
||||||
# Configuration parameters: AllowSafeAssignment.
|
|
||||||
Lint/AssignmentInCondition:
|
|
||||||
Exclude:
|
|
||||||
- 'app/controllers/management/sessions_controller.rb'
|
|
||||||
- 'app/models/notification.rb'
|
|
||||||
- 'lib/capistrano/template.rb'
|
|
||||||
|
|
||||||
# Offense count: 2
|
# Offense count: 2
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
# Configuration parameters: AlignWith, SupportedStyles.
|
# Configuration parameters: AlignWith, SupportedStyles.
|
||||||
|
|||||||
@@ -37,8 +37,10 @@ class Legislation::AnnotationsController < ApplicationController
|
|||||||
range_start: annotation_params[:ranges].first[:start], range_start_offset: annotation_params[:ranges].first[:startOffset].to_i,
|
range_start: annotation_params[:ranges].first[:start], range_start_offset: annotation_params[:ranges].first[:startOffset].to_i,
|
||||||
range_end: annotation_params[:ranges].first[:end], range_end_offset: annotation_params[:ranges].first[:endOffset].to_i).first
|
range_end: annotation_params[:ranges].first[:end], range_end_offset: annotation_params[:ranges].first[:endOffset].to_i).first
|
||||||
|
|
||||||
if @annotation = existing_annotation
|
@annotation = existing_annotation
|
||||||
if comment = @annotation.comments.create(body: annotation_params[:text], user: current_user)
|
if @annotation.present?
|
||||||
|
comment = @annotation.comments.create(body: annotation_params[:text], user: current_user)
|
||||||
|
if comment.present?
|
||||||
render json: @annotation.to_json
|
render json: @annotation.to_json
|
||||||
else
|
else
|
||||||
render json: comment.errors.full_messages, status: :unprocessable_entity
|
render json: comment.errors.full_messages, status: :unprocessable_entity
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ class Legislation::ProcessesController < Legislation::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
if @process.allegations_phase.enabled? && @process.allegations_phase.started? && draft_version = @process.draft_versions.published.last
|
draft_version = @process.draft_versions.published.last
|
||||||
|
|
||||||
|
if @process.allegations_phase.enabled? && @process.allegations_phase.started? && draft_version.present?
|
||||||
redirect_to legislation_process_draft_version_path(@process, draft_version)
|
redirect_to legislation_process_draft_version_path(@process, draft_version)
|
||||||
elsif @process.debate_phase.enabled?
|
elsif @process.debate_phase.enabled?
|
||||||
redirect_to legislation_process_debate_path(@process)
|
redirect_to legislation_process_debate_path(@process)
|
||||||
@@ -33,7 +35,9 @@ class Legislation::ProcessesController < Legislation::BaseController
|
|||||||
@phase = :draft_publication
|
@phase = :draft_publication
|
||||||
|
|
||||||
if @process.draft_publication.started?
|
if @process.draft_publication.started?
|
||||||
if draft_version = @process.draft_versions.published.last
|
draft_version = @process.draft_versions.published.last
|
||||||
|
|
||||||
|
if draft_version.present?
|
||||||
redirect_to legislation_process_draft_version_path(@process, draft_version)
|
redirect_to legislation_process_draft_version_path(@process, draft_version)
|
||||||
else
|
else
|
||||||
render :phase_empty
|
render :phase_empty
|
||||||
@@ -48,7 +52,9 @@ class Legislation::ProcessesController < Legislation::BaseController
|
|||||||
@phase = :allegations_phase
|
@phase = :allegations_phase
|
||||||
|
|
||||||
if @process.allegations_phase.started?
|
if @process.allegations_phase.started?
|
||||||
if draft_version = @process.draft_versions.published.last
|
draft_version = @process.draft_versions.published.last
|
||||||
|
|
||||||
|
if draft_version.present?
|
||||||
redirect_to legislation_process_draft_version_path(@process, draft_version)
|
redirect_to legislation_process_draft_version_path(@process, draft_version)
|
||||||
else
|
else
|
||||||
render :phase_empty
|
render :phase_empty
|
||||||
@@ -63,7 +69,9 @@ class Legislation::ProcessesController < Legislation::BaseController
|
|||||||
@phase = :result_publication
|
@phase = :result_publication
|
||||||
|
|
||||||
if @process.result_publication.started?
|
if @process.result_publication.started?
|
||||||
if final_version = @process.final_draft_version
|
final_version = @process.final_draft_version
|
||||||
|
|
||||||
|
if final_version.present?
|
||||||
redirect_to legislation_process_draft_version_path(@process, final_version)
|
redirect_to legislation_process_draft_version_path(@process, final_version)
|
||||||
else
|
else
|
||||||
render :phase_empty
|
render :phase_empty
|
||||||
|
|||||||
@@ -37,9 +37,8 @@ class Management::SessionsController < ActionController::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def authenticated_manager?
|
def authenticated_manager?
|
||||||
if manager = ManagerAuthenticator.new(params).auth
|
manager = ManagerAuthenticator.new(params).auth
|
||||||
session[:manager] = manager
|
session[:manager] = manager if manager.present?
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ class PagesController < ApplicationController
|
|||||||
skip_authorization_check
|
skip_authorization_check
|
||||||
|
|
||||||
def show
|
def show
|
||||||
if @custom_page = SiteCustomization::Page.published.find_by(slug: params[:id])
|
@custom_page = SiteCustomization::Page.published.find_by(slug: params[:id])
|
||||||
|
|
||||||
|
if @custom_page.present?
|
||||||
render action: :custom_page
|
render action: :custom_page
|
||||||
else
|
else
|
||||||
render action: params[:id]
|
render action: params[:id]
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ class Notification < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.add(user_id, notifiable)
|
def self.add(user_id, notifiable)
|
||||||
if notification = Notification.find_by(user_id: user_id, notifiable: notifiable)
|
notification = Notification.find_by(user_id: user_id, notifiable: notifiable)
|
||||||
|
|
||||||
|
if notification.present?
|
||||||
Notification.increment_counter(:counter, notification.id)
|
Notification.increment_counter(:counter, notification.id)
|
||||||
else
|
else
|
||||||
Notification.create!(user_id: user_id, notifiable: notifiable)
|
Notification.create!(user_id: user_id, notifiable: notifiable)
|
||||||
@@ -50,4 +52,4 @@ class Notification < ActiveRecord::Base
|
|||||||
notifiable.is_a?(ProposalNotification) ? notifiable.proposal : notifiable
|
notifiable.is_a?(ProposalNotification) ? notifiable.proposal : notifiable
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,9 +21,8 @@ class SiteCustomization::Image < ActiveRecord::Base
|
|||||||
def self.image_path_for(filename)
|
def self.image_path_for(filename)
|
||||||
image_name = filename.split(".").first
|
image_name = filename.split(".").first
|
||||||
|
|
||||||
if i = find_by(name: image_name)
|
imageable = find_by(name: image_name)
|
||||||
i.image.exists? ? i.image.url : nil
|
imageable.present? && imageable.image.exists? ? imageable.image.url : nil
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def required_width
|
def required_width
|
||||||
|
|||||||
Reference in New Issue
Block a user