Skip to content

Commit

Permalink
Merge branch 'master' into flag-submission-box-disappears-mitre-cyber…
Browse files Browse the repository at this point in the history
  • Loading branch information
camdenmoors authored Aug 11, 2020
2 parents 190625b + 5a06b6b commit f0d0fa7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/user_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions app/helpers/teams_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
5 changes: 2 additions & 3 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f0d0fa7

Please sign in to comment.