Skip to content

Commit

Permalink
Bump rubocop to ruby 2.3, fix all warnings raised in the new version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Clark committed Aug 22, 2016
1 parent 5fccacf commit 7873f29
Show file tree
Hide file tree
Showing 49 changed files with 52 additions and 5 deletions.
1 change: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ AllCops:
- 'log/**/*'
- 'test/**/*'
- 'vendor/**/*'
TargetRubyVersion: 2.2
Rails:
Enabled: true

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
source 'https://rubygems.org'

ruby '2.3.1'
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env rake
# frozen_string_literal: true
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

Expand Down
1 change: 1 addition & 0 deletions app/controllers/achievements_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class AchievementsController < ApplicationController
def index
@achievements = @game.achievements.order(:text)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception

Expand Down
1 change: 1 addition & 0 deletions app/controllers/challenges_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class ChallengesController < ApplicationController
before_action :enforce_access
before_action :find_challenge, except: :index
Expand Down
1 change: 1 addition & 0 deletions app/controllers/games_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class GamesController < ApplicationController
helper :all

Expand Down
1 change: 1 addition & 0 deletions app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class MessagesController < ApplicationController
def index
@messages = @game.messages.order(:updated_at).reverse_order.page(params[:page]).per(10)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class SessionsController < Devise::SessionsController
skip_before_action :verify_authenticity_token, only: [:new, :create], if: :json_request?
respond_to :json
Expand Down
1 change: 1 addition & 0 deletions app/controllers/timeline_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class TimelineController < ApplicationController
def index
# Grab a set of flags submitted and group them by minutes
Expand Down
1 change: 1 addition & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class UsersController < ApplicationController
before_action :enforce_access, only: [:download]

Expand Down
1 change: 1 addition & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true
module ApplicationHelper
end
1 change: 1 addition & 0 deletions app/helpers/categories_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true
module CategoriesHelper
end
1 change: 1 addition & 0 deletions app/helpers/challenges_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module ChallengesHelper
def embed(youtube_url)
youtube_id = youtube_url.split('v=').last
Expand Down
1 change: 1 addition & 0 deletions app/helpers/games_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true
module GamesHelper
end
1 change: 1 addition & 0 deletions app/helpers/messages_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true
module MessagesHelper
end
1 change: 1 addition & 0 deletions app/helpers/sessions_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module SessionsHelper
def deny_access
store_location
Expand Down
1 change: 1 addition & 0 deletions app/helpers/timeline_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true
module TimelineHelper
end
1 change: 1 addition & 0 deletions app/models/achievement.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Achievement < FeedItem
validates :text, presence: true, uniqueness: true

Expand Down
1 change: 1 addition & 0 deletions app/models/admin.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true
class Admin < User
end
1 change: 1 addition & 0 deletions app/models/category.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Category < ActiveRecord::Base
belongs_to :game

Expand Down
3 changes: 2 additions & 1 deletion app/models/challenge.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Challenge < ActiveRecord::Base
after_create :add_states_to_challenges

Expand Down Expand Up @@ -32,7 +33,7 @@ def open?(division)
end

def solved?
(SolvedChallenge.where('challenge_id = :challenge', challenge: self).count > 0)
SolvedChallenge.where('challenge_id = :challenge', challenge: self).count.positive?
end

# Returns whether or not challenge is available to be opened.
Expand Down
1 change: 1 addition & 0 deletions app/models/challenge_state.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class ChallengeState < ActiveRecord::Base
before_validation :default_values
belongs_to :challenge
Expand Down
1 change: 1 addition & 0 deletions app/models/division.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Division < ActiveRecord::Base
after_create :add_states_to_challenges

Expand Down
1 change: 1 addition & 0 deletions app/models/feed_item.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class FeedItem < ActiveRecord::Base
belongs_to :player, foreign_key: :user_id
belongs_to :challenge
Expand Down
1 change: 1 addition & 0 deletions app/models/flag.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Flag < ActiveRecord::Base
belongs_to :challenge, inverse_of: :flags

Expand Down
1 change: 1 addition & 0 deletions app/models/game.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Game < ActiveRecord::Base
# players
has_many :players, through: :divisions
Expand Down
1 change: 1 addition & 0 deletions app/models/message.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Message < ActiveRecord::Base
belongs_to :game
validates :text, :game_id, :title, presence: true
Expand Down
1 change: 1 addition & 0 deletions app/models/player.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Player < User
belongs_to :division

Expand Down
5 changes: 3 additions & 2 deletions app/models/score_adjustment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class ScoreAdjustment < FeedItem
include ActionView::Helpers::TextHelper

Expand All @@ -10,7 +11,7 @@ def description
color = ''
verb = ''
points = point_value
if points < 0
if points.negative?
color = 'red'
verb = 'decreased'
else
Expand All @@ -22,7 +23,7 @@ def description
# rubocop:enable MethodLength

def icon
point_value < 0 ? 'chevron-down' : 'chevron-up'
point_value.negative? ? 'chevron-down' : 'chevron-up'
end

def point_value_is_not_zero
Expand Down
3 changes: 2 additions & 1 deletion app/models/solved_challenge.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class SolvedChallenge < FeedItem
validates :challenge_id, :flag, :division_id, :player, presence: true
validate :user_has_not_solved_challenge, :challenge_is_open, :game_is_open
Expand All @@ -24,7 +25,7 @@ def game_is_open
end

def user_has_not_solved_challenge
if player.solved_challenges.where('challenge_id = ?', challenge.id).count > 0
if player.solved_challenges.where('challenge_id = ?', challenge.id).count.positive?
errors.add(:base, I18n.t('challenge.already_solved'))
end
end
Expand Down
1 change: 1 addition & 0 deletions app/models/submitted_flag.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class SubmittedFlag < ActiveRecord::Base
belongs_to :player, foreign_key: :user_id
belongs_to :challenge
Expand Down
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
Expand Down
1 change: 1 addition & 0 deletions app/views/games/show.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
json.array!(@game.players) do |json, player|
json.name player.name
json.tags player.tags
Expand Down
1 change: 1 addition & 0 deletions bin/bundle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')
1 change: 1 addition & 0 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
1 change: 1 addition & 0 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require_relative '../config/boot'
require 'rake'
Rake.application.run
1 change: 1 addition & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'pathname'

# path to your application root.
Expand Down
1 change: 1 addition & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
Expand Down
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require File.expand_path('../boot', __FILE__)

require 'rails/all'
Expand Down
1 change: 1 addition & 0 deletions config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rubygems'

# Set up gems listed in the Gemfile.
Expand Down
1 change: 1 addition & 0 deletions config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Load the rails application
require File.expand_path('../application', __FILE__)

Expand Down
1 change: 1 addition & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
Scoreboard::Application.configure do
# Settings specified here will take precedence over those in config/application.rb

Expand Down
1 change: 1 addition & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
Scoreboard::Application.configure do
# Settings specified here will take precedence over those in config/application.rb

Expand Down
1 change: 1 addition & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
Scoreboard::Application.configure do
# Settings specified here will take precedence over those in config/application.rb

Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
Scoreboard::Application.routes.draw do
# admin
mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/cucumber.rake
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/scoreboard.rake
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
namespace :scoreboard do
namespace :user do
desc 'Add a user to the Game'
Expand Down
1 change: 1 addition & 0 deletions script/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
# This command will automatically be run when you run "rails" with Rails 3
gems installed from the root of your application.

Expand Down

0 comments on commit 7873f29

Please sign in to comment.