Skip to content

Commit

Permalink
Update rubocop and fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
swrobel committed Jun 18, 2017
1 parent 3148935 commit 7677f68
Show file tree
Hide file tree
Showing 59 changed files with 84 additions and 14 deletions.
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

ruby "~> #{`cat .ruby-version`.strip}"
Expand Down Expand Up @@ -30,8 +31,9 @@ group :development do
gem 'guard-shell', require: false
gem 'invoker', '1.5.1'
gem 'rack-toolbar'
gem 'rubocop', '~> 0.47.1'
gem 'rubocop', '~> 0.49.1'
gem 'spring'
gem 'spring-commands-rubocop', require: false
gem 'terminal-notifier-guard'
gem 'web-console', '~> 3.0'
end
Expand Down
9 changes: 7 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ GEM
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
parallel (1.11.2)
parser (2.4.0.0)
ast (~> 2.2)
pg (0.21.0)
Expand Down Expand Up @@ -177,7 +178,8 @@ GEM
rb-fsevent (0.9.8)
rb-inotify (0.9.9)
ffi (~> 1.0)
rubocop (0.47.1)
rubocop (0.49.1)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
Expand All @@ -199,6 +201,8 @@ GEM
slop (3.6.0)
spring (2.0.2)
activesupport (>= 4.2)
spring-commands-rubocop (0.2.0)
spring (>= 1.0, < 3.0)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand Down Expand Up @@ -250,9 +254,10 @@ DEPENDENCIES
rack-toolbar
rails (= 5.1.1)
rails_12factor
rubocop (~> 0.47.1)
rubocop (~> 0.49.1)
slim-rails
spring
spring-commands-rubocop
terminal-notifier-guard
web-console (~> 3.0)
webpacker
Expand Down
3 changes: 2 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 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 All @@ -12,5 +13,5 @@ if Rails.env.development? || Rails.env.test?
t.options = RUBOCOP_OPTS
end

task default: [:test, :rubocop]
task default: %i[test rubocop]
end
1 change: 1 addition & 0 deletions app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file. Action Cable runs in an EventMachine loop that does not support auto reloading.
module ApplicationCable
class Channel < ActionCable::Channel::Base
Expand Down
1 change: 1 addition & 0 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file. Action Cable runs in an EventMachine loop that does not support auto reloading.
module ApplicationCable
class Connection < ActionCable::Connection::Base
Expand Down
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/spots_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

class SpotsController < ApplicationController
before_action :set_spot, only: [:edit, :update, :destroy]
before_action :set_spot, only: %i[edit update destroy]

# GET /spots
# GET /spots.json
Expand Down
1 change: 1 addition & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module ApplicationHelper
def height_range(min, max)
return unless min && max
Expand Down
1 change: 1 addition & 0 deletions app/helpers/spots_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true

module SpotsHelper
end
1 change: 1 addition & 0 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true

class ApplicationJob < ActiveJob::Base
end
1 change: 1 addition & 0 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class ApplicationMailer < ActionMailer::Base
default from: '[email protected]'
layout 'mailer'
Expand Down
1 change: 1 addition & 0 deletions app/models/api_request.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true

class ApiRequest < ApplicationRecord
end
1 change: 1 addition & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
3 changes: 2 additions & 1 deletion app/models/forecast.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class Forecast < ApplicationRecord
extend ApiMethods
self.abstract_class = true
Expand Down Expand Up @@ -45,7 +46,7 @@ def forecasted_max(stamps)
private

def raise_not_implemented_error
raise NotImplementedError, "Subclass should override method '#{caller[0][/`.*'/][1..-2]}'"
raise NotImplementedError, "Subclass should override method '#{caller(0..0).first[/`.*'/][1..-2]}'"
end
end
end
1 change: 1 addition & 0 deletions app/models/msw.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class Msw < Forecast
def avg_height
(min_height + max_height) / 2
Expand Down
1 change: 1 addition & 0 deletions app/models/spitcast.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class Spitcast < Forecast
class << self
def site_url
Expand Down
3 changes: 2 additions & 1 deletion app/models/spot.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

class Spot < ApplicationRecord
extend FriendlyId
friendly_id :name, use: [:slugged, :finders]
friendly_id :name, use: %i[slugged finders]

has_many :surfline_nearshores
has_many :surfline_lolas
Expand Down
3 changes: 2 additions & 1 deletion app/models/surfline.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class Surfline < Forecast
self.abstract_class = true

Expand Down Expand Up @@ -78,7 +79,7 @@ def parse_response(_spot, request, responses)
spot_data = forecasts[spot_id]
# [1..-2] gets all elements except first & last
spot_data.keys[1..-2].each_with_index do |tstamp, index|
next unless spot_data[:swell_rating].blank?
next if spot_data[:swell_rating].present?
prev_tstamp = spot_data.keys[index] # index is already offset by 1
next_tstamp = spot_data.keys[index + 2]
prev_rating = spot_data[prev_tstamp][:swell_rating]
Expand Down
1 change: 1 addition & 0 deletions app/models/surfline_lola.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class SurflineLola < Surfline
class << self
def api_url(spot)
Expand Down
1 change: 1 addition & 0 deletions app/models/surfline_nearshore.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class SurflineNearshore < Surfline
class << self
def api_url(spot)
Expand Down
1 change: 1 addition & 0 deletions app/models/water_quality.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class WaterQuality < ApplicationRecord
extend ApiMethods

Expand Down
1 change: 1 addition & 0 deletions app/models/water_quality_department.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class WaterQualityDepartment < ApplicationRecord
has_many :water_qualities
end
1 change: 1 addition & 0 deletions app/views/spots/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

json.array!(@spots) do |spot|
json.extract! spot, :id, :name, :lat, :lon, :surfline_id, :msw_id, :spitcast_id, :wunder_id
json.url spot_url(spot, format: :json)
Expand Down
1 change: 1 addition & 0 deletions app/views/spots/show.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true

json.extract! @spot, :id, :name, :lat, :lon, :surfline_id, :msw_id, :spitcast_id, :wunder_id, :created_at, :updated_at
8 changes: 8 additions & 0 deletions bin/rubocop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
require 'bundler/setup'
load Gem.bin_path('rubocop', 'rubocop')
1 change: 1 addition & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 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
3 changes: 2 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require File.expand_path('../boot', __FILE__)

require 'rails/all'
Expand All @@ -15,7 +16,7 @@ class Application < Rails::Application

config.time_zone = 'Pacific Time (US & Canada)'

config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += %W[#{config.root}/lib]

config.force_ssl = true
end
Expand Down
1 change: 1 addition & 0 deletions config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

require 'bundler/setup' # Set up gems listed in the Gemfile.
1 change: 1 addition & 0 deletions config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 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,4 +1,5 @@
# frozen_string_literal: true

Rails.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,4 +1,5 @@
# frozen_string_literal: true

Rails.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,4 +1,5 @@
# frozen_string_literal: true

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Require `belongs_to` associations by default. This is a new Rails 5.0 default,
Expand Down
1 change: 1 addition & 0 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Expand Down
1 change: 1 addition & 0 deletions config/initializers/callback_terminator.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Do not halt callback chains when a callback returns false. This is a new Rails 5.0 default,
Expand Down
1 change: 1 addition & 0 deletions config/initializers/cookies_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# This is a new Rails 5.0 default, so introduced as a config to ensure apps made with earlier versions of Rails aren't affected when upgrading.
Expand Down
1 change: 1 addition & 0 deletions config/initializers/filter_parameter_logging.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Configure sensitive parameters which will be filtered from the log file.
Expand Down
5 changes: 3 additions & 2 deletions config/initializers/friendly_id.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# FriendlyId Global Configuration
#
# Use this to set up shared configuration options for your entire application.
Expand All @@ -17,8 +18,8 @@
# undesirable to allow as slugs. Edit this list as needed for your app.
config.use :reserved

config.reserved_words = %w(new edit index session login logout users admin
stylesheets assets javascripts images)
config.reserved_words = %w[new edit index session login logout users admin
stylesheets assets javascripts images]

# ## Friendly Finders
#
Expand Down
1 change: 1 addition & 0 deletions config/initializers/request_forgery_protection.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Enable origin-checking CSRF mitigation.
Expand Down
1 change: 1 addition & 0 deletions config/initializers/rubocop.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true

RUBOCOP_OPTS = ['--rails', '--display-cop-names', '--auto-correct'].freeze
1 change: 1 addition & 0 deletions config/initializers/session_store.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

Rails.application.config.session_store :cookie_store, key: '_meta-surf-forecast_session'
1 change: 1 addition & 0 deletions config/initializers/wrap_parameters.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# This file contains settings for ActionController::ParamsWrapper which
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
get '/(*path)' => redirect { |_params, req| "https://#{ENV['DOMAIN']}#{req.fullpath}" } if ENV['HOST'].present?
end

resources :spots, only: [:index, :show]
resources :spots, only: %i[index show]

root to: 'spots#index'
end
5 changes: 3 additions & 2 deletions config/spring.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true
%w(

%w[
.ruby-version
.rbenv-vars
tmp/restart.txt
tmp/caching-dev.txt
).each { |path| Spring.watch(path) }
].each { |path| Spring.watch(path) }
1 change: 1 addition & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

WaterQualityDepartment.find_or_create_by(code: 'LAPH') do |dept|
dept.name = 'Los Angeles County Department of Public Health'
dept.url = 'http://www.publichealth.lacounty.gov/phcommon/public/eh/water_quality/beach_grades.cfm'
Expand Down
1 change: 1 addition & 0 deletions lib/api_methods.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require 'open-uri'

module ApiMethods
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/cleanup.rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

namespace :cleanup do
desc 'Remove forecasts that are in the past'
task prune_past_forecasts: :environment do
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/msw.rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

namespace :msw do
desc 'Update forecast from MagicSeaweed'
task update: :environment do
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/spitcast.rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

namespace :spitcast do
desc 'Update forecast from Spitcast'
task update: :environment do
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/surfline.rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

namespace :surfline do
desc 'Update forecast from Surfline'
task update: :environment do
Expand Down
Loading

0 comments on commit 7677f68

Please sign in to comment.