diff --git a/Gemfile.lock b/Gemfile.lock index 70d8e537..31fd9db9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -290,17 +290,17 @@ GEM actionpack (>= 5.0) railties (>= 5.0) rexml (3.2.4) - rubocop (0.88.0) + rubocop (0.89.1) parallel (~> 1.10) parser (>= 2.7.1.1) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.7) rexml - rubocop-ast (>= 0.1.0, < 1.0) + rubocop-ast (>= 0.3.0, < 1.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 2.0) - rubocop-ast (0.2.0) - parser (>= 2.7.0.1) + rubocop-ast (0.3.0) + parser (>= 2.7.1.4) rubocop-rails (2.7.1) activesupport (>= 4.2.0) rack (>= 1.1) diff --git a/app/controllers/user_requests_controller.rb b/app/controllers/user_requests_controller.rb index ee3a44ec..daf1d61d 100644 --- a/app/controllers/user_requests_controller.rb +++ b/app/controllers/user_requests_controller.rb @@ -48,12 +48,14 @@ def destroy # accept the users request. # Reducing the Cyclomatic Complexity on this severely reduces the readability of this function # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/PerceivedComplexity def captain_of_team_requested @user_request = current_user&.team&.user_requests&.find(params[:id]) @team = @user_request&.team raise ActiveRecord::RecordNotFound unless @user_request&.team&.team_captain&.eql?(current_user) end # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity # Only allow team captain and the user requesting to delete a user request. def check_if_able_to_reject diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 498d92ee..c8080132 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -28,6 +28,6 @@ def active_navbar?(page) end def amount_of_errors(alerts) - pluralize(alerts.length, I18n.t('challenges.error_singular')) + ':' + "#{pluralize(alerts.length, I18n.t('challenges.error_singular'))}:" end end diff --git a/app/helpers/teams_helper.rb b/app/helpers/teams_helper.rb index 6c9bd705..ed767905 100644 --- a/app/helpers/teams_helper.rb +++ b/app/helpers/teams_helper.rb @@ -4,7 +4,7 @@ module TeamsHelper def display_name(team) return team.team_name if team.eligible? - "#{team.team_name} (" + I18n.t('challenges.team_ineligible_for_prizes') + ')' + "#{team.team_name} (#{I18n.t('challenges.team_ineligible_for_prizes')})" end def solved_challenge_table_point_value(solved_challenge, team) @@ -22,6 +22,6 @@ def eligible?(user_request) end def header_with_points(team) - "#{display_name(team)} - " + pluralize(team.score, I18n.t('challenges.point_value_singular')) + "#{display_name(team)} - #{pluralize(team.score, I18n.t('challenges.point_value_singular'))}" end end diff --git a/app/models/team.rb b/app/models/team.rb index e006fb7f..e7fed599 100644 --- a/app/models/team.rb +++ b/app/models/team.rb @@ -89,14 +89,14 @@ def find_rank (1 + (division.ordered_teams.index self)) end - # rubocop:disable Metrics/AbcSize # Takes a query and the column it is filtering and returns results. def self.search_by(query, column_to_filter) # condition query, parse into individual keywords terms = query.to_s.downcase.split(/\s+/) # replace "*" with "%" for wildcard searches, # prepend and append '%', remove duplicate '%'s - terms = terms.map { |e| ('%' + e.tr('*', '%') + '%').gsub(/%+/, '%') } + # string concatenation here works much better than interpolation + terms = terms.map { |e| ('%' + e.tr('*', '%') + '%').gsub(/%+/, '%') } # rubocop:disable Style/StringConcatenation # configure number of OR conditions for provision # of interpolation arguments. Adjust this if you # change the number of OR conditions. @@ -109,7 +109,6 @@ def self.search_by(query, column_to_filter) *terms.map { |e| [e] * num_or_conditions }.flatten ) end - # rubocop:enable Metrics/AbcSize def cleanup destroy if users.empty? diff --git a/config/environments/production.rb b/config/environments/production.rb index a3697c7f..6b519149 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -83,7 +83,7 @@ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') if ENV['RAILS_LOG_TO_STDOUT'].present? - logger = ActiveSupport::Logger.new(STDOUT) + logger = ActiveSupport::Logger.new($stdout) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) end