Fix others additional lints

This commit is contained in:
Artem Chernikov 2014-07-21 14:37:26 +02:00
parent 763f864dc9
commit 056fe5ec3f
18 changed files with 33 additions and 34 deletions

View file

@ -55,28 +55,25 @@ Lint/Loop:
Lint/ParenthesesAsGroupedExpression: Lint/ParenthesesAsGroupedExpression:
Enabled: true Enabled: true
# Offense count: 13 # Do not rescue Exceptions class itself
# Cop supports --auto-correct.
Lint/RescueException: Lint/RescueException:
Enabled: true Enabled: true
# Offense count: 1 # do not shadow local variables in blocks, choose other name
Lint/ShadowingOuterLocalVariable: Lint/ShadowingOuterLocalVariable:
Enabled: false Enabled: true
# Offense count: 5 # use _ or variable_name to explicitly mark variable as unused
# Cop supports --auto-correct.
Lint/UnusedBlockArgument: Lint/UnusedBlockArgument:
Enabled: false Enabled: true
# Offense count: 2 # use _ or _argument_name to explicitly mark argument as unused
# Cop supports --auto-correct.
Lint/UnusedMethodArgument: Lint/UnusedMethodArgument:
Enabled: false Enabled: true
# Offense count: 6 # avoid useless assignment
Lint/UselessAssignment: Lint/UselessAssignment:
Enabled: false Enabled: true
# Offense count: 1 # Offense count: 1
Lint/Void: Lint/Void:

View file

@ -9,7 +9,7 @@ class Admin::DietchoicesController < ApplicationController
begin begin
@conference.update_attributes!(params[:conference]) @conference.update_attributes!(params[:conference])
redirect_to(admin_conference_dietary_list_path(:conference_id => @conference.short_title), :notice => 'Dietary choices were successfully updated.') redirect_to(admin_conference_dietary_list_path(:conference_id => @conference.short_title), :notice => 'Dietary choices were successfully updated.')
rescue Exception => e rescue => e
redirect_to(admin_conference_dietary_list_path(:conference_id => @conference.short_title), :alert => "Dietary choices update failed: #{e.message}") redirect_to(admin_conference_dietary_list_path(:conference_id => @conference.short_title), :alert => "Dietary choices update failed: #{e.message}")
end end
end end

View file

@ -10,7 +10,7 @@ class Admin::EventtypesController < ApplicationController
redirect_to(admin_conference_eventtypes_path( redirect_to(admin_conference_eventtypes_path(
conference_id: @conference.short_title), conference_id: @conference.short_title),
notice: 'Event types were successfully updated.') notice: 'Event types were successfully updated.')
rescue Exception => e rescue => e
redirect_to(admin_conference_eventtypes_path( redirect_to(admin_conference_eventtypes_path(
conference_id: @conference.short_title), conference_id: @conference.short_title),
alert: "Event types update failed: #{e.message}") alert: "Event types update failed: #{e.message}")

View file

@ -44,7 +44,7 @@ module Admin
@registration.update_attributes!(params[:registration]) @registration.update_attributes!(params[:registration])
flash[:success] = "Successfully updated registration for #{@user.name} #{@user.email}" flash[:success] = "Successfully updated registration for #{@user.name} #{@user.email}"
redirect_to(admin_conference_registrations_path(@conference.short_title)) redirect_to(admin_conference_registrations_path(@conference.short_title))
rescue Exception => e rescue => e
Rails.logger.debug e.backtrace.join("\n") Rails.logger.debug e.backtrace.join("\n")
redirect_to(admin_conference_registrations_path(@conference.short_title), redirect_to(admin_conference_registrations_path(@conference.short_title),
alert: 'Failed to update registration:' + e.message) alert: 'Failed to update registration:' + e.message)
@ -104,7 +104,7 @@ module Admin
begin registration.destroy begin registration.destroy
redirect_to admin_conference_registrations_path redirect_to admin_conference_registrations_path
flash[:notice] = "Deleted registration for #{user.name} #{user.email}" flash[:notice] = "Deleted registration for #{user.name} #{user.email}"
rescue Exception => e rescue => e
Rails.logger.debug e.backtrace.join("\n") Rails.logger.debug e.backtrace.join("\n")
redirect_to(admin_conference_registrations_path(@conference.short_title), redirect_to(admin_conference_registrations_path(@conference.short_title),
alert: 'Failed to delete registration:' + e.message) alert: 'Failed to delete registration:' + e.message)

View file

@ -9,7 +9,7 @@ class Admin::SupporterLevelsController < ApplicationController
begin begin
@conference.update_attributes!(params[:conference]) @conference.update_attributes!(params[:conference])
redirect_to(admin_conference_supporter_levels_path(:conference_id => @conference.short_title), :notice => 'Supporter levels were successfully updated.') redirect_to(admin_conference_supporter_levels_path(:conference_id => @conference.short_title), :notice => 'Supporter levels were successfully updated.')
rescue Exception => e rescue => e
redirect_to(admin_conference_supporter_levels_path(:conference_id => @conference.short_title), :alert => "Supporter levels update failed: #{e.message}") redirect_to(admin_conference_supporter_levels_path(:conference_id => @conference.short_title), :alert => "Supporter levels update failed: #{e.message}")
end end
end end

View file

@ -18,7 +18,7 @@ class Admin::VolunteersController < ApplicationController
begin begin
@conference.update_attributes!(params[:conference]) @conference.update_attributes!(params[:conference])
redirect_to(admin_conference_volunteers_info_path(:conference_id => params[:conference_id]), :notice => "Volunteering options were successfully updated.") redirect_to(admin_conference_volunteers_info_path(:conference_id => params[:conference_id]), :notice => "Volunteering options were successfully updated.")
rescue Exception => e rescue => e
redirect_to(admin_conference_volunteers_info_path(:conference_id => params[:conference_id]), :alert => "Volunteering options update failed: #{e.message}") redirect_to(admin_conference_volunteers_info_path(:conference_id => params[:conference_id]), :alert => "Volunteering options update failed: #{e.message}")
end end
end end

View file

@ -68,7 +68,7 @@ class ConferenceRegistrationController < ApplicationController
else else
registration.update_attributes!(registration_params) registration.update_attributes!(registration_params)
end end
rescue Exception => e rescue => e
Rails.logger.debug e.backtrace.join('\n') Rails.logger.debug e.backtrace.join('\n')
redirect_to(register_conference_path(id: conference.short_title), redirect_to(register_conference_path(id: conference.short_title),
alert: 'Registration failed:' + e.message) alert: 'Registration failed:' + e.message)

View file

@ -53,7 +53,7 @@ class EventAttachmentsController < ApplicationController
if !organizer_or_admin? if !organizer_or_admin?
begin begin
event = current_user.events.find(params[:proposal_id]) event = current_user.events.find(params[:proposal_id])
rescue Exception => e rescue => e
# They certainly aren't allowed to attach a file to someone else's proposal # They certainly aren't allowed to attach a file to someone else's proposal
raise ActionController::RoutingError.new('Invalid proposal') raise ActionController::RoutingError.new('Invalid proposal')
end end

View file

@ -23,7 +23,7 @@ class ProposalController < ApplicationController
else else
@event = Event.find(params[:id]) @event = Event.find(params[:id])
end end
rescue Exception => e rescue => e
Rails.logger.debug("Proposal failure in verify_access: #{e.message}") Rails.logger.debug("Proposal failure in verify_access: #{e.message}")
redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), redirect_to(conference_proposal_index_path(conference_id: @conference.short_title),
alert: 'Invalid or uneditable proposal.') alert: 'Invalid or uneditable proposal.')
@ -91,7 +91,7 @@ class ProposalController < ApplicationController
event.update_attributes!(params[:event]) event.update_attributes!(params[:event])
redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), redirect_to(conference_proposal_index_path(conference_id: @conference.short_title),
notice: "'#{event.title}' was successfully updated.") notice: "'#{event.title}' was successfully updated.")
rescue Exception => e rescue => e
redirect_to edit_conference_proposal_path(@conference.short_title, @event), alert: e.message redirect_to edit_conference_proposal_path(@conference.short_title, @event), alert: e.message
end end
end end
@ -131,7 +131,7 @@ class ProposalController < ApplicationController
begin begin
@event.save! @event.save!
rescue Exception => e rescue => e
@url = conference_proposal_index_path(@conference.short_title) @url = conference_proposal_index_path(@conference.short_title)
@event_types = @conference.event_types @event_types = @conference.event_types
@user = current_user @user = current_user

View file

@ -26,7 +26,7 @@ module Users
sign_in user sign_in user
redirect_to root_path, notice: user.email + " signed in successfully with #{provider}" redirect_to root_path, notice: user.email + " signed in successfully with #{provider}"
rescue Exception => e rescue => e
redirect_back_or_to new_user_registration_path, alert: 'Failed' + e.message redirect_back_or_to new_user_registration_path, alert: 'Failed' + e.message
end end
end end

View file

@ -75,7 +75,7 @@ module ApplicationHelper
end end
def normalize_array_length(hashmap, length) def normalize_array_length(hashmap, length)
hashmap.each do |key, value| hashmap.each do |_, value|
if value.length < length if value.length < length
value.fill(value[-1], value.length...length) value.fill(value[-1], value.length...length)
end end

View file

@ -1,7 +1,7 @@
class Ability class Ability
include CanCan::Ability include CanCan::Ability
def initialize(user) def initialize(user) # rubocop:disable Lint/UnusedMethodArgument
# Define abilities for the passed in user here. For example: # Define abilities for the passed in user here. For example:
# #
# user ||= User.new # guest user (not logged in) # user ||= User.new # guest user (not logged in)

View file

@ -639,7 +639,7 @@ class Conference < ActiveRecord::Base
# ====Returns # ====Returns
# * +Fixnum+ -> Progress in Percent # * +Fixnum+ -> Progress in Percent
def calculate_setup_progress(result) def calculate_setup_progress(result)
(result.select { |k, v| v }.length / result.length.to_f * 100).round(0).to_s (result.select { |_k, v| v }.length / result.length.to_f * 100).round(0).to_s
end end
## ##

View file

@ -9,7 +9,7 @@ class Datatable
@view = view @view = view
end end
def as_json(options = {}) def as_json
{ {
sEcho: params[:sEcho].to_i, sEcho: params[:sEcho].to_i,
iTotalRecords: @klass.count, iTotalRecords: @klass.count,
@ -55,10 +55,10 @@ class Datatable
search_for = params[:sSearch].split(' ') search_for = params[:sSearch].split(' ')
terms = {} terms = {}
which_one = -1 which_one = -1
criteria = search_for.inject([]) do |criteria,atom| criteria = search_for.inject([]) do |mem, atom|
which_one += 1 which_one += 1
terms["search#{which_one}".to_sym] = "%#{atom}%" terms["search#{which_one}".to_sym] = "%#{atom}%"
criteria << "(#{search_cols.map{|col| "#{col} like :search#{which_one}"}.join(' or ')})" mem << "(#{search_cols.map{|col| "#{col} like :search#{which_one}"}.join(' or ')})"
end.join(' and ') end.join(' and ')
[criteria, terms] [criteria, terms]
end end

View file

@ -5,7 +5,7 @@ require File.expand_path('../application', __FILE__)
path = Rails.root.join("config", "config.yml") path = Rails.root.join("config", "config.yml")
begin begin
CONFIG = YAML.load_file(path)[Rails.env] CONFIG = YAML.load_file(path)[Rails.env]
rescue Exception rescue
puts "Error while parsing config file #{path}" puts "Error while parsing config file #{path}"
CONFIG = {} CONFIG = {}
end end

View file

@ -72,7 +72,7 @@ class AddEventsPerWeekToConference < ActiveRecord::Migration
hash.each do |week, values| hash.each do |week, values|
if previous if previous
values.each do |state, value| values.each do |state, _value|
hash[week][state] += previous[state] hash[week][state] += previous[state]
end end
end end

View file

@ -5,7 +5,8 @@ feature User do
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:admin_role) { create(:admin_role) }
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
shared_examples 'admin ability' do |user|
shared_examples 'admin ability' do
scenario 'deletes a user', feature: true, js: true do scenario 'deletes a user', feature: true, js: true do
sign_in(admin) sign_in(admin)
visit admin_users_path visit admin_users_path
@ -34,6 +35,7 @@ feature User do
sign_out sign_out
end end
end end
describe 'admin' do describe 'admin' do
it_behaves_like 'admin ability', :admin it_behaves_like 'admin ability', :admin
end end

View file

@ -8,7 +8,7 @@ feature Conference do
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let(:conference) { create(:conference) } let(:conference) { create(:conference) }
shared_examples 'volunteer' do |user| shared_examples 'volunteer' do
scenario 'adds and updates vdays', feature: true, js: true do scenario 'adds and updates vdays', feature: true, js: true do
sign_in(admin) sign_in(admin)
visit admin_conference_volunteers_info_path( visit admin_conference_volunteers_info_path(