From ba2d2e82962b282ff5515cf55526fb99b0e05e44 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Tue, 5 May 2015 16:36:05 +0200 Subject: [PATCH] Corrected with rubocop cop 'Lint/NonLocalExitFromIterator'. --- .rubocop.yml | 2 -- app/controllers/getting_started_controller.rb | 10 +++++----- app/controllers/import_otrs_controller.rb | 2 +- lib/auth.rb | 2 +- lib/sessions/backend/collections/base.rb | 9 ++++++++- lib/sso.rb | 2 +- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 3b8a84515..723628eab 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -250,8 +250,6 @@ Style/SpaceBeforeComment: Enabled: false Lint/UselessAssignment: Enabled: false -Lint/NonLocalExitFromIterator: - Enabled: false Rails/Date: Enabled: false Lint/UnreachableCode: diff --git a/app/controllers/getting_started_controller.rb b/app/controllers/getting_started_controller.rb index 6ad348a94..c34034240 100644 --- a/app/controllers/getting_started_controller.rb +++ b/app/controllers/getting_started_controller.rb @@ -239,21 +239,21 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password} result = email_probe_inbound( settings[:inbound] ) if result[:result] != 'ok' render json: result - return + return # rubocop:disable Lint/NonLocalExitFromIterator end # probe outbound result = email_probe_outbound( settings[:outbound], params[:email] ) if result[:result] != 'ok' render json: result - return + return # rubocop:disable Lint/NonLocalExitFromIterator end render json: { result: 'ok', setting: settings, } - return + return # rubocop:disable Lint/NonLocalExitFromIterator end } } @@ -632,7 +632,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password} message: e.to_s, subject: subject, } - return + return # rubocop:disable Lint/NonLocalExitFromIterator end if found && found == 'verify ok' @@ -693,7 +693,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password} render json: { result: 'ok', } - return + return # rubocop:disable Lint/NonLocalExitFromIterator end } diff --git a/app/controllers/import_otrs_controller.rb b/app/controllers/import_otrs_controller.rb index 970d477af..8529008b4 100644 --- a/app/controllers/import_otrs_controller.rb +++ b/app/controllers/import_otrs_controller.rb @@ -56,7 +56,7 @@ class ImportOtrsController < ApplicationController url: url, result: 'ok', } - return + return # rubocop:disable Lint/NonLocalExitFromIterator elsif response.body =~ /(otrs\sag|otrs.com|otrs.org)/i message_human = 'Host found, but no OTRS migrator is installed!' end diff --git a/lib/auth.rb b/lib/auth.rb index edcb8b019..da56ed171 100644 --- a/lib/auth.rb +++ b/lib/auth.rb @@ -41,7 +41,7 @@ returns # load backend backend = self.load_adapter( config_item[:adapter] ) - return if !backend + next if !backend user_auth = backend.check( username, password, config_item, user ) diff --git a/lib/sessions/backend/collections/base.rb b/lib/sessions/backend/collections/base.rb index 3647367dc..9743e26b5 100644 --- a/lib/sessions/backend/collections/base.rb +++ b/lib/sessions/backend/collections/base.rb @@ -32,9 +32,16 @@ class Sessions::Backend::Collections::Base return if !access end if self.class.is_not_role + + is_role = false self.class.is_not_role.each {|role| - return if @user.is_role(role) + + next if !@user.is_role(role) + + is_role = true + break } + return if is_role end # check timeout diff --git a/lib/sso.rb b/lib/sso.rb index 83cdb75c6..154795d40 100644 --- a/lib/sso.rb +++ b/lib/sso.rb @@ -52,7 +52,7 @@ returns # load backend backend = self.load_adapter( config_item[:adapter] ) - return if !backend + next if !backend user_auth = backend.check( params, config_item )