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

View File

@@ -9,7 +9,7 @@ class Admin::DietchoicesController < ApplicationController
begin
@conference.update_attributes!(params[:conference])
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}")
end
end

View File

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

View File

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

View File

@@ -9,7 +9,7 @@ class Admin::SupporterLevelsController < ApplicationController
begin
@conference.update_attributes!(params[:conference])
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}")
end
end

View File

@@ -18,7 +18,7 @@ class Admin::VolunteersController < ApplicationController
begin
@conference.update_attributes!(params[:conference])
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}")
end
end

View File

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

View File

@@ -53,7 +53,7 @@ class EventAttachmentsController < ApplicationController
if !organizer_or_admin?
begin
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
raise ActionController::RoutingError.new('Invalid proposal')
end

View File

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

View File

@@ -26,7 +26,7 @@ module Users
sign_in user
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
end
end

View File

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

View File

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

View File

@@ -639,7 +639,7 @@ class Conference < ActiveRecord::Base
# ====Returns
# * +Fixnum+ -> Progress in Percent
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
##

View File

@@ -9,7 +9,7 @@ class Datatable
@view = view
end
def as_json(options = {})
def as_json
{
sEcho: params[:sEcho].to_i,
iTotalRecords: @klass.count,
@@ -55,10 +55,10 @@ class Datatable
search_for = params[:sSearch].split(' ')
terms = {}
which_one = -1
criteria = search_for.inject([]) do |criteria,atom|
criteria = search_for.inject([]) do |mem, atom|
which_one += 1
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 ')
[criteria, terms]
end

View File

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

View File

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

View File

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

View File

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