From e1aae93269356b7ef80c8dd27aa1eb66aeb06a0f Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 22 Aug 2015 00:40:32 +0200 Subject: [PATCH] Fixed rubocop checks. --- .gitignore | 2 -- app/models/organization/search.rb | 2 +- app/models/ticket/search.rb | 2 +- app/models/user/search.rb | 2 +- lib/calendar_subscriptions/tickets.rb | 4 ---- lib/sessions.rb | 2 -- lib/sessions/backend/collections/base.rb | 2 +- lib/time_calculation.rb | 8 ++++---- lib/user_agent.rb | 3 ++- script/websocket-server.rb | 1 - 10 files changed, 10 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index a76e9d47d..9f25704b1 100644 --- a/.gitignore +++ b/.gitignore @@ -25,8 +25,6 @@ # Ignore local database settings /config/database.yml -Gemfile.lock - # Ignore mac stuff .DS_Store diff --git a/app/models/organization/search.rb b/app/models/organization/search.rb index 1eb8448a1..ec008f731 100644 --- a/app/models/organization/search.rb +++ b/app/models/organization/search.rb @@ -68,7 +68,7 @@ returns # fallback do sql query # - stip out * we already search for *query* - - query.gsub! '*', '' + query.delete! '*', '' organizations = Organization.where( 'name LIKE ? OR note LIKE ?', "%#{query}%", "%#{query}%" ).order('name').limit(limit) diff --git a/app/models/ticket/search.rb b/app/models/ticket/search.rb index 4087738f3..955743154 100644 --- a/app/models/ticket/search.rb +++ b/app/models/ticket/search.rb @@ -146,7 +146,7 @@ returns # do query # - stip out * we already search for *query* - if query - query.gsub! '*', '' + query.delete! '*', '' tickets_all = Ticket.select('DISTINCT(tickets.id)') .where(access_condition) .where( '( `tickets`.`title` LIKE ? OR `tickets`.`number` LIKE ? OR `ticket_articles`.`body` LIKE ? OR `ticket_articles`.`from` LIKE ? OR `ticket_articles`.`to` LIKE ? OR `ticket_articles`.`subject` LIKE ?)', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%" ) diff --git a/app/models/user/search.rb b/app/models/user/search.rb index 54db73abe..59f2a6bc6 100644 --- a/app/models/user/search.rb +++ b/app/models/user/search.rb @@ -68,7 +68,7 @@ returns # fallback do sql query # - stip out * we already search for *query* - - query.gsub! '*', '' + query.delete! '*', '' if params[:role_ids] users = User.joins(:roles).where( 'roles.id' => params[:role_ids] ).where( '(users.firstname LIKE ? or users.lastname LIKE ? or users.email LIKE ?) AND users.id != 1', "%#{query}%", "%#{query}%", "%#{query}%", diff --git a/lib/calendar_subscriptions/tickets.rb b/lib/calendar_subscriptions/tickets.rb index fe0d70fb6..ec74342d8 100644 --- a/lib/calendar_subscriptions/tickets.rb +++ b/lib/calendar_subscriptions/tickets.rb @@ -120,10 +120,8 @@ class CalendarSubscriptions::Tickets translated_state = Translation.translate(user_locale, ticket.state.name) - # rubocop:disable Rails/TimeZone event_data[:dtstart] = Icalendar::Values::DateTime.new( pending_time ) event_data[:dtend] = Icalendar::Values::DateTime.new( pending_time ) - # rubocop:enable Rails/TimeZone event_data[:summary] = "#{translated_state} #{translated_ticket}: '#{ticket.title}'" event_data[:description] = "T##{ticket.number}" @@ -162,10 +160,8 @@ class CalendarSubscriptions::Tickets escalation_time = Time.zone.today end - # rubocop:disable Rails/TimeZone event_data[:dtstart] = Icalendar::Values::DateTime.new( escalation_time ) event_data[:dtend] = Icalendar::Values::DateTime.new( escalation_time ) - # rubocop:enable Rails/TimeZone event_data[:summary] = "#{translated_ticket_escalation}: '#{ticket.title}'" event_data[:description] = "T##{ticket.number}" diff --git a/lib/sessions.rb b/lib/sessions.rb index b0d38a3af..edc421a57 100644 --- a/lib/sessions.rb +++ b/lib/sessions.rb @@ -1,5 +1,3 @@ -# rubocop:disable Rails/TimeZone - require 'json' require 'session_helper' diff --git a/lib/sessions/backend/collections/base.rb b/lib/sessions/backend/collections/base.rb index 187ff0269..41dd5d2dc 100644 --- a/lib/sessions/backend/collections/base.rb +++ b/lib/sessions/backend/collections/base.rb @@ -1,7 +1,7 @@ class Sessions::Backend::Collections::Base class << self; attr_accessor :model, :roles, :not_roles end - def initialize( user, client = nil, client_id = nil, ttl ) + def initialize( user, client, client_id, ttl ) @user = user @client = client @client_id = client_id diff --git a/lib/time_calculation.rb b/lib/time_calculation.rb index 5c99190a2..e563a05e2 100644 --- a/lib/time_calculation.rb +++ b/lib/time_calculation.rb @@ -23,10 +23,10 @@ put working hours matrix and timezone in function, returns UTC working hours mat if timezone begin time_diff = Time.zone.parse(start_time.to_s).in_time_zone(timezone).utc_offset - rescue => e - Rails.logger.error "Can't fine tomezone #{timezone}" - Rails.logger.error e.inspect - Rails.logger.error e.backtrace + rescue => e + Rails.logger.error "Can't fine tomezone #{timezone}" + Rails.logger.error e.inspect + Rails.logger.error e.backtrace end end beginning_of_workday = Time.zone.parse("1977-10-27 #{config['beginning_of_workday']}") diff --git a/lib/user_agent.rb b/lib/user_agent.rb index ba091cca8..40095986e 100644 --- a/lib/user_agent.rb +++ b/lib/user_agent.rb @@ -402,7 +402,8 @@ returns end def success? - @success + return true if @success + false end end end diff --git a/script/websocket-server.rb b/script/websocket-server.rb index c2b3184b8..46d69399a 100755 --- a/script/websocket-server.rb +++ b/script/websocket-server.rb @@ -1,6 +1,5 @@ #!/usr/bin/env ruby # Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ -# rubocop:disable Rails/TimeZone $LOAD_PATH << './lib' require 'rubygems'