diff --git a/.rubocop.yml b/.rubocop.yml index 6c8c79145..662a3e108 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,6 +7,7 @@ AllCops: Include: - '**/Rakefile' - '**/config.ru' + - '**/Gemfile' Exclude: - 'vendor/**/*' - 'spec/fixtures/**/*' @@ -16,6 +17,7 @@ AllCops: - 'db/seeds.rb' - 'client/node_modules/**/*' - 'bin/**/*' + - 'Procfile.*' - !ruby/regexp /old_and_unused\.rb$/ Metrics/LineLength: @@ -24,6 +26,9 @@ Metrics/LineLength: Metrics/MethodLength: Max: 25 +Metrics/BlockLength: + Max: 105 + Style/StringLiterals: EnforcedStyle: double_quotes diff --git a/.ruby-version b/.ruby-version index 2bf1c1ccf..005119baa 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.3.1 +2.4.1 diff --git a/.travis.yml b/.travis.yml index f0531fbc0..0dabfb608 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: - ruby rvm: - - 2.3.1 + - 2.4.1 sudo: false notifications: slack: shakacode:YvfXbuFMcFAHt6ZjABIs0KET diff --git a/Gemfile b/Gemfile index 8cb0b5107..a69182874 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,10 @@ source "https://rubygems.org" -ruby "2.3.1" +ruby "2.4.1" # # Bundle edge Rails instead: gem "rails", github: "rails/rails" -gem "rails" gem "listen" +gem "rails" # Note: We're using sqllite3 for development and testing # gem "sqlite3", group: [:development, :test] @@ -27,7 +27,7 @@ gem "coffee-rails" # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem "jbuilder" -gem 'redis' +gem "redis" # bundle exec rake doc:rails generates the API under doc/api. gem "sdoc", group: :doc @@ -65,38 +65,38 @@ group :development, :test do ################################################################################ # Manage application processes - gem "foreman" gem "factory_girl_rails" + gem "foreman" ################################################################################ # Linters and Security gem "rubocop", require: false gem "ruby-lint", require: false # Critical that require: false be set! https://github.com/brigade/scss-lint/issues/278 - gem "scss_lint", require: false gem "brakeman", require: false gem "bundler-audit", require: false + gem "scss_lint", require: false ################################################################################ # Favorite debugging gems gem "pry" + gem "pry-byebug" gem "pry-doc" gem "pry-rails" - gem "pry-stack_explorer" gem "pry-rescue" - gem "pry-byebug" + gem "pry-stack_explorer" ################################################################################ # Color console output gem "rainbow" end -group :test do - gem "coveralls", require: false +group :test do gem "capybara" gem "capybara-screenshot" gem "capybara-webkit" gem "chromedriver-helper" + gem "coveralls", require: false gem "database_cleaner" gem "generator_spec" gem "launchy" diff --git a/Gemfile.lock b/Gemfile.lock index 1e5ee7df1..71ae9755a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -44,18 +44,19 @@ GEM io-like (~> 0.3.0) arel (7.1.4) ast (2.3.0) - autoprefixer-rails (6.5.3) + autoprefixer-rails (6.7.7.1) execjs awesome_print (1.7.0) + bindex (0.5.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) - brakeman (3.4.1) + brakeman (3.6.1) builder (3.2.3) bundler-audit (0.5.0) bundler (~> 1.2) thor (~> 0.18) byebug (9.0.6) - capybara (2.7.1) + capybara (2.13.0) addressable mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -65,12 +66,12 @@ GEM capybara-screenshot (1.0.14) capybara (>= 1.0, < 3) launchy - capybara-webkit (1.11.1) - capybara (>= 2.3.0, < 2.8.0) + capybara-webkit (1.14.0) + capybara (>= 2.3.0, < 2.14.0) json - childprocess (0.5.9) + childprocess (0.6.3) ffi (~> 1.0, >= 1.0.11) - chromedriver-helper (1.0.0) + chromedriver-helper (1.1.0) archive-zip (~> 0.7.0) nokogiri (~> 1.6) cliver (0.3.2) @@ -81,28 +82,28 @@ GEM coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.10.0) + coffee-script-source (1.12.2) concurrent-ruby (1.0.5) connection_pool (2.2.1) - coveralls (0.8.15) + coveralls (0.8.20) json (>= 1.8, < 3) - simplecov (~> 0.12.0) + simplecov (~> 0.14.1) term-ansicolor (~> 1.3) - thor (~> 0.19.1) - tins (>= 1.6.0, < 2) + thor (~> 0.19.4) + tins (~> 1.6) database_cleaner (1.5.3) debug_inspector (0.0.2) - diff-lcs (1.2.5) + diff-lcs (1.3) docile (1.1.5) erubis (2.7.0) execjs (2.7.0) - factory_girl (4.7.0) + factory_girl (4.8.0) activesupport (>= 3.0.0) - factory_girl_rails (4.7.0) - factory_girl (~> 4.7.0) + factory_girl_rails (4.8.0) + factory_girl (~> 4.8.0) railties (>= 3.0.0) - ffi (1.9.14) - foreman (0.82.0) + ffi (1.9.18) + foreman (0.84.0) thor (~> 0.19.1) generator_spec (0.9.3) activesupport (>= 3.0.0) @@ -112,13 +113,13 @@ GEM i18n (0.8.1) interception (0.5) io-like (0.3.0) - jbuilder (2.6.0) - activesupport (>= 3.0.0, < 5.1) + jbuilder (2.6.3) + activesupport (>= 3.0.0, < 5.2) multi_json (~> 1.2) - json (1.8.3) + json (1.8.6) launchy (2.4.3) addressable (~> 2.3) - libv8 (5.3.332.38.1) + libv8 (5.3.332.38.5) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -132,17 +133,17 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) mini_portile2 (2.1.0) - mini_racer (0.1.7) + mini_racer (0.1.9) libv8 (~> 5.3) minitest (5.10.1) multi_json (1.12.1) nio4r (2.0.0) nokogiri (1.7.1) mini_portile2 (~> 2.1.0) - parser (2.3.2.0) + parser (2.4.0.0) ast (~> 2.2) pg (0.20.0) - poltergeist (1.11.0) + poltergeist (1.14.0) capybara (~> 2.1) cliver (~> 0.3.1) websocket-driver (>= 0.2.0) @@ -151,22 +152,22 @@ GEM coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - pry-byebug (3.4.1) + pry-byebug (3.4.2) byebug (~> 9.0) pry (~> 0.10) - pry-doc (0.9.0) + pry-doc (0.10.0) pry (~> 0.9) - yard (~> 0.8) - pry-rails (0.3.4) - pry (>= 0.9.10) - pry-rescue (1.4.4) + yard (~> 0.9) + pry-rails (0.3.6) + pry (>= 0.10.4) + pry-rescue (1.4.5) interception (>= 0.5) pry pry-stack_explorer (0.4.9.2) binding_of_caller (>= 0.7) pry (>= 0.9.11) public_suffix (2.0.5) - puma (3.6.2) + puma (3.8.2) rack (2.0.1) rack-test (0.6.3) rack (>= 1.0) @@ -194,9 +195,9 @@ GEM rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.2.1) - rake (11.3.0) + rake (12.0.0) rb-fsevent (0.9.8) - rb-inotify (0.9.7) + rb-inotify (0.9.8) ffi (>= 0.5.0) rdoc (4.3.0) react_on_rails (6.9.3) @@ -205,7 +206,7 @@ GEM execjs (~> 2.5) rails (>= 3.2) rainbow (~> 2.1) - redis (3.3.0) + redis (3.3.3) rspec-core (3.5.4) rspec-support (~> 3.5.0) rspec-expectations (3.5.0) @@ -222,11 +223,11 @@ GEM rspec-expectations (~> 3.5.0) rspec-mocks (~> 3.5.0) rspec-support (~> 3.5.0) - rspec-retry (0.5.2) + rspec-retry (0.5.3) rspec-core (> 3.3, < 3.6) rspec-support (3.5.0) - rubocop (0.45.0) - parser (>= 2.3.1.1, < 3.0) + rubocop (0.48.1) + parser (>= 2.3.3.1, < 3.0) powerpack (~> 0.1) rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.7) @@ -236,16 +237,16 @@ GEM slop (~> 3.4, >= 3.4.7) ruby-progressbar (1.8.1) ruby_dep (1.5.0) - rubyzip (1.2.0) - sass (3.4.22) + rubyzip (1.2.1) + sass (3.4.23) sass-rails (5.0.6) railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - scss_lint (0.50.3) - rake (>= 0.9, < 12) + scss_lint (0.52.0) + rake (>= 0.9, < 13) sass (~> 3.4.20) sdoc (0.4.2) json (~> 1.7, >= 1.7.7) @@ -254,13 +255,13 @@ GEM childprocess (~> 0.5) rubyzip (~> 1.0) websocket (~> 1.0) - simplecov (0.12.0) + simplecov (0.14.1) docile (~> 1.1.0) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.0) slop (3.6.0) - spring (2.0.0) + spring (2.0.1) activesupport (>= 4.2) spring-commands-rspec (1.0.4) spring (>= 0.9.1) @@ -271,29 +272,29 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - term-ansicolor (1.4.0) + term-ansicolor (1.5.0) tins (~> 1.0) thor (0.19.4) thread_safe (0.3.6) - tilt (2.0.5) - tins (1.12.0) + tilt (2.0.7) + tins (1.13.2) tzinfo (1.2.3) thread_safe (~> 0.1) - uglifier (3.0.3) + uglifier (3.1.13) execjs (>= 0.3.0, < 3) - unicode-display_width (1.1.1) - web-console (3.4.0) + unicode-display_width (1.1.3) + web-console (3.5.0) actionview (>= 5.0) activemodel (>= 5.0) - debug_inspector + bindex (>= 0.4.0) railties (>= 5.0) - websocket (1.2.3) + websocket (1.2.4) websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.2) xpath (2.0.0) nokogiri (~> 1.3) - yard (0.9.5) + yard (0.9.8) PLATFORMS ruby @@ -345,7 +346,7 @@ DEPENDENCIES web-console RUBY VERSION - ruby 2.3.1p112 + ruby 2.4.1p111 BUNDLED WITH 1.14.6 diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 440e2096c..66c877596 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -1,5 +1,5 @@ class CommentsController < ApplicationController - before_action :set_comment, only: [:show, :edit, :update, :destroy] + before_action :set_comment, only: %i[show edit update destroy] # GET /comments # GET /comments.json @@ -9,8 +9,7 @@ def index # GET /comments/1 # GET /comments/1.json - def show - end + def show; end # GET /comments/new def new @@ -18,8 +17,7 @@ def new end # GET /comments/1/edit - def edit - end + def edit; end # POST /comments # POST /comments.json diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 1ef8b0d37..3f3956c7a 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -32,8 +32,7 @@ def no_router render_html end - def simple - end + def simple; end private diff --git a/app/views/comments/show.json.jbuilder b/app/views/comments/show.json.jbuilder index 09b127a63..fa4b753a9 100644 --- a/app/views/comments/show.json.jbuilder +++ b/app/views/comments/show.json.jbuilder @@ -1 +1 @@ -json.partial! 'comment', comment: @comment +json.partial! "comment", comment: @comment diff --git a/config/initializers/react_on_rails.rb b/config/initializers/react_on_rails.rb index e7d3161c4..c1a84c09b 100644 --- a/config/initializers/react_on_rails.rb +++ b/config/initializers/react_on_rails.rb @@ -2,11 +2,11 @@ ReactOnRails.configure do |config| # Directory where your generated assets go. All generated assets must go to the same directory. # Configure this in your webpack config files. This relative to your Rails root directory. - config.generated_assets_dir = File.join(%w(app assets webpack)) + config.generated_assets_dir = File.join(%w[app assets webpack]) # Define the files for we need to check for webpack compilation when running tests - config.webpack_generated_files = %w( app-bundle.js vendor-bundle.js app-bundle.css - vendor-bundle.css server-bundle.js ) + config.webpack_generated_files = %w[ app-bundle.js vendor-bundle.js app-bundle.css + vendor-bundle.css server-bundle.js ] # This is the file used for server rendering of React when using `(prerender: true)` # If you are never using server rendering, you may set this to "". diff --git a/docs/codeship-ci.md b/docs/codeship-ci.md index df513bc78..47ebe2f97 100644 --- a/docs/codeship-ci.md +++ b/docs/codeship-ci.md @@ -10,7 +10,7 @@ Pick "I want to create my own custom commands" on the Project Settings, Test tab export PHANTOMJS_HOST="https://s3.amazonaws.com/codeship-packages" export PHANTOMJS_VERSION=2.1.1 \curl -sSL https://raw.githubusercontent.com/codeship/scripts/master/packages/phantomjs.sh | bash -s -rvm use 2.3.1 +rvm use 2.4.1 gem update --system gem install bundler bundle config build.nokogiri --use-system-libraries diff --git a/lib/tasks/brakeman.rake b/lib/tasks/brakeman.rake index f4833917d..f01e79202 100644 --- a/lib/tasks/brakeman.rake +++ b/lib/tasks/brakeman.rake @@ -1,17 +1,16 @@ namespace :brakeman do - desc "Run Brakeman" - task :run, :output_files do |t, args| - require 'brakeman' + task :run, :output_files do |_t, args| + require "brakeman" - files = args[:output_files].split(' ') if args[:output_files] - Brakeman.run :app_path => ".", :output_files => files, :print_report => true + files = args[:output_files].split(" ") if args[:output_files] + Brakeman.run app_path: ".", output_files: files, print_report: true end desc "Check your code with Brakeman" task :check do - require 'brakeman' - result = Brakeman.run app_path: '.', print_report: true + require "brakeman" + result = Brakeman.run app_path: ".", print_report: true exit Brakeman::Warnings_Found_Exit_Code unless result.filtered_warnings.empty? end end diff --git a/lib/tasks/ci.rake b/lib/tasks/ci.rake index 80565e373..468b7de4d 100644 --- a/lib/tasks/ci.rake +++ b/lib/tasks/ci.rake @@ -25,13 +25,13 @@ if Rails.env.development? || Rails.env.test? namespace :ci do desc "Run all audits and tests" # rspec_tests must be before lint and js_tests to build the locale files - task all: [:environment, :rspec_tests, :lint, :js_tests, :bundle_audit, :security_audit] do + task all: %i[environment rspec_tests lint js_tests bundle_audit security_audit] do begin puts "All CI tasks" puts Rainbow("PASSED").green puts "" - rescue Exception => e - puts "#{e}" + rescue StandardError => e + puts e.to_s puts Rainbow("FAILED").red puts "" raise(e) diff --git a/lib/tasks/linters.rake b/lib/tasks/linters.rake index b10f418e0..39211da96 100644 --- a/lib/tasks/linters.rake +++ b/lib/tasks/linters.rake @@ -1,4 +1,4 @@ -if %w(development test).include? Rails.env +if %w[development test].include? Rails.env namespace :lint do # require "rubocop/rake_task" # require "slim_lint/rake_task" @@ -10,9 +10,9 @@ if %w(development test).include? Rails.env desc "Run Rubocop lint as shell. Specify option fix to auto-correct (and don't have uncommitted files!)." task :rubocop, [:fix] => [] do |_t, args| def to_bool(str) - return true if str =~ (/^(true|t|yes|y|1)$/i) - return false if str.blank? || str =~ (/^(false|f|no|n|0)$/i) - fail ArgumentError, "invalid value for Boolean: \"#{str}\"" + return true if str =~ /^(true|t|yes|y|1)$/i + return false if str.blank? || str =~ /^(false|f|no|n|0)$/i + raise ArgumentError, "invalid value for Boolean: \"#{str}\"" end fix = (args.fix == "fix") || to_bool(args.fix) @@ -54,7 +54,7 @@ if %w(development test).include? Rails.env desc "See docs for task 'scss_lint'" task scss: :scss_lint - task lint: [:rubocop, :ruby, :js, :scss] do + task lint: %i[rubocop ruby js scss] do puts "Completed all linting" end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 136ecd8a9..4c37fde04 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -55,9 +55,9 @@ default_driver = :poltergeist_no_animations - supported_drivers = %i( poltergeist poltergeist_errors_ok + supported_drivers = %i[ poltergeist poltergeist_errors_ok poltergeist_no_animations webkit - selenium_chrome selenium_firefox selenium) + selenium_chrome selenium_firefox selenium] driver = ENV["DRIVER"].try(:to_sym) || default_driver Capybara.default_driver = driver diff --git a/spec/support/poltergeist.rb b/spec/support/poltergeist.rb index affa4a065..239d9bcce 100644 --- a/spec/support/poltergeist.rb +++ b/spec/support/poltergeist.rb @@ -3,7 +3,7 @@ # 2. restart_poltergeist RESTART_PHANTOMJS = ENV["RESTART_PHANTOMJS"] && - %w(TRUE YES).include?(ENV["RESTART_PHANTOMJS"].upcase) + %w[TRUE YES].include?(ENV["RESTART_PHANTOMJS"].upcase) puts "RESTART_PHANTOMJS = #{RESTART_PHANTOMJS}" CAPYBARA_TIMEOUT_RETRIES = 5