diff --git a/.bummr-build.sh b/.bummr-build.sh new file mode 100755 index 000000000..19f8f7b14 --- /dev/null +++ b/.bummr-build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +bundle exec rspec --fail-fast diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 000000000..8ad868d4c --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,35 @@ +engines: + brakeman: + enabled: true + bundler-audit: + enabled: true + csslint: + enabled: true + duplication: + enabled: true + config: + languages: + - ruby + # mass_threshold: 30 + - javascript + exclude_paths: + - 'spec/**/*' + - 'vendor/**/*' + eslint: + enabled: true + exclude_paths: + - 'vendor/**/*' + fixme: + enabled: true + exclude_paths: + - 'vendor/**/*' + rubocop: + enabled: true + scss-lint: + enabled: true + +ratings: + paths: + - app/** + - lib/** + - '**.rb' diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 000000000..62da8fd39 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,31 @@ +{ + 'extends': 'airbnb', + 'parser': 'babel-eslint', + 'env': { + 'browser': true, + 'commonjs': true, + 'es6': true, + 'mocha': true + }, + 'globals': { + '$': true, + '__DEV__': true, + 'assert': true, + 'chai': true, + 'sinon': true, + 'expect': true, + 'fixture': true + }, + 'rules': { + 'func-names': 0, + 'space-before-function-paren': 0, + 'prefer-arrow-callback': 0 + }, + 'parserOptions': { + 'ecmaVersion': 6, + 'sourceType': 'module', + 'ecmaFeatures': { + 'jsx': true + } + } +} diff --git a/.ruby-version b/.ruby-version index 585940699..2bf1c1ccf 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.2.3 +2.3.1 diff --git a/.travis.yml b/.travis.yml index a71ee4dfa..af6028dd0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ cache: bundler sudo: false script: bundle exec rspec rvm: -- 2.2.3 +- 2.3.1 deploy: provider: heroku app: ohana-staging diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1fc607066..f96da8203 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -64,9 +64,6 @@ pass. style checkers. If your specs fail and/or style offenses are reported, return to **step 7**. -9. _(If applicable)_ **Clean up JavaScript code:** Run `rake jshint` to check -JavaScript code quality. - 10. **Commit changes:** Add, commit, and push your changes. 11. **Pull request:** [Submit a pull request][pr] to send your changes to this diff --git a/Gemfile b/Gemfile index ccae8c8c3..96128bae8 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -ruby '2.2.3' +ruby '2.3.1' gem 'railties', '~> 4.2' gem 'actionmailer' @@ -38,7 +38,7 @@ gem 'newrelic_rpm', '>= 3.8.0.218' gem 'rack-rewrite', '~> 1.5.0' # For Google translation API. -gem 'google-api-client', '~> 0.8.1' +gem 'google-api-client', '~> 0.8.6' # App config and ENV variables for heroku. gem 'figaro' @@ -62,9 +62,6 @@ group :development do # For mocking emails for sending. gem 'letter_opener' - # For linting JS with `rake jshint`. - gem 'jshint' - # For code documentation, run `yard --help` for list of commands. gem 'yard' @@ -77,6 +74,9 @@ group :development do gem 'derailed' gem 'rack-mini-profiler' gem 'flamegraph' + gem 'stackprof' + + gem 'bummr' end group :test do @@ -84,8 +84,8 @@ group :test do gem 'capybara', '~> 2.4' gem 'poltergeist' gem 'vcr' - gem 'webmock', '~> 1.20' - gem 'email_spec', '~> 1.6.0' + gem 'webmock', '~> 2.1' + gem 'email_spec' gem 'haml_lint' # Ruby static code analyzer, based on the community Ruby style guide. diff --git a/Gemfile.lock b/Gemfile.lock index ff2ecf372..314de3577 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -40,7 +40,7 @@ GEM thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.3.8) - ast (2.2.0) + ast (2.3.0) autoparse (0.3.3) addressable (>= 2.3.1) extlib (>= 0.9.15) @@ -53,7 +53,10 @@ GEM binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) builder (3.2.2) - capybara (2.6.2) + bummr (0.1.2) + colorize + thor + capybara (2.7.1) addressable mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -63,6 +66,7 @@ GEM chunky_png (1.3.5) cliver (0.3.2) coderay (1.1.1) + colorize (0.7.7) compass (1.0.3) chunky_png (~> 1.2) compass-core (~> 1.0.2) @@ -101,25 +105,22 @@ GEM thor (~> 0.19) diff-lcs (1.2.5) docile (1.1.5) - email_spec (1.6.0) + email_spec (2.1.0) + htmlentities (~> 4.3.3) launchy (~> 2.1) - mail (~> 2.2) + mail (~> 2.6.3) erubis (2.7.0) execjs (2.6.0) extlib (0.9.16) faraday (0.9.2) multipart-post (>= 1.2, < 3) - faraday-http-cache (1.2.2) + faraday-http-cache (1.3.0) faraday (~> 0.8) - fast_stack (0.1.0) - rake - rake-compiler ffi (1.9.10) figaro (1.1.1) thor (~> 0.14) - flamegraph (0.1.0) - fast_stack - font-awesome-rails (4.5.0.1) + flamegraph (0.9.5) + font-awesome-rails (4.6.3.0) railties (>= 3.2, < 5.1) get_process_mem (0.2.0) globalid (0.3.6) @@ -151,9 +152,9 @@ GEM haml (>= 4.0.6, < 5.0) html2haml (>= 1.0.1) railties (>= 4.0.1) - haml_lint (0.16.1) + haml_lint (0.17.1) haml (~> 4.0) - rake (~> 10.0) + rake (>= 10, < 12) rubocop (>= 0.36.0) sysexits (~> 1.1) hashdiff (0.3.0) @@ -165,38 +166,36 @@ GEM haml (~> 4.0.0) nokogiri (~> 1.6.0) ruby_parser (~> 3.5) + htmlentities (4.3.4) i18n (0.7.0) - jshint (1.4.0) - execjs (>= 1.4.0) - multi_json (~> 1.0) - therubyracer (~> 0.12.1) json (1.8.3) jwt (1.5.4) - kaminari (0.16.3) + kaminari (0.17.0) actionpack (>= 3.0.0) activesupport (>= 3.0.0) launchy (2.4.3) addressable (~> 2.3) letter_opener (1.4.1) launchy (~> 2.2) - libv8 (3.16.14.13) listen (3.0.6) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9.7) little-plugger (1.1.4) - logging (2.0.0) + logging (2.1.0) little-plugger (~> 1.1) multi_json (~> 1.10) loofah (2.0.3) nokogiri (>= 1.5.9) - mail (2.6.3) - mime-types (>= 1.16, < 3) + mail (2.6.4) + mime-types (>= 1.16, < 4) memoist (0.14.0) memory_profiler (0.9.6) - mime-types (2.99.1) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) mini_portile2 (2.0.0) - minitest (5.8.4) - multi_json (1.11.2) + minitest (5.9.0) + multi_json (1.12.1) multipart-post (2.0.0) newrelic_rpm (3.14.0.305) nokogiri (1.6.7.2) @@ -204,7 +203,7 @@ GEM ohanakapa (1.1.2) sawyer (~> 0.5.3) os (0.9.6) - parser (2.3.0.6) + parser (2.3.1.2) ast (~> 2.2) poltergeist (1.9.0) capybara (~> 2.1) @@ -212,13 +211,13 @@ GEM multi_json (~> 1.0) websocket-driver (>= 0.2.0) powerpack (0.1.1) - puma (3.1.0) + puma (3.4.0) quiet_assets (1.1.0) railties (>= 3.1, < 5.0) rack (1.6.4) rack-cache (1.6.1) rack (>= 0.4) - rack-mini-profiler (0.9.9.2) + rack-mini-profiler (0.10.1) rack (>= 1.2.0) rack-rewrite (1.5.1) rack-test (0.6.3) @@ -243,8 +242,6 @@ GEM thor (>= 0.18.1, < 2.0) rainbow (2.1.0) rake (10.5.0) - rake-compiler (0.9.6) - rake rb-fsevent (0.9.7) rb-inotify (0.9.7) ffi (>= 0.5.0) @@ -252,7 +249,6 @@ GEM connection_pool (~> 2.1) redis (~> 3.0) redis (3.2.2) - ref (2.0.0) requirejs-rails (0.9.5) railties (>= 3.1.1) retriable (1.4.1) @@ -273,13 +269,13 @@ GEM rspec-mocks (~> 3.4.0) rspec-support (~> 3.4.0) rspec-support (3.4.1) - rubocop (0.38.0) - parser (>= 2.3.0.6, < 3.0) + rubocop (0.40.0) + parser (>= 2.3.1.0, < 3.0) powerpack (~> 0.1) rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.7.5) + ruby-progressbar (1.8.1) ruby_parser (3.8.1) sexp_processor (~> 4.1) safe_yaml (1.0.4) @@ -304,7 +300,7 @@ GEM json (~> 1.8) simplecov-html (~> 0.10.0) simplecov-html (0.10.0) - spring (1.6.4) + spring (1.7.1) spring-commands-rspec (1.0.4) spring (>= 0.9.1) spring-watcher-listen (2.0.0) @@ -319,24 +315,21 @@ GEM actionpack (>= 3.0) activesupport (>= 3.0) sprockets (>= 2.8, < 4.0) + stackprof (0.2.9) sysexits (1.2.0) term-ansicolor (1.3.2) tins (~> 1.0) - therubyracer (0.12.2) - libv8 (~> 3.16.14.0) - ref thor (0.19.1) thread_safe (0.3.5) tilt (1.4.1) tins (1.6.0) tzinfo (1.2.2) thread_safe (~> 0.1) - uglifier (2.7.2) - execjs (>= 0.3.0) - json (>= 1.8.0) - unicode-display_width (1.0.2) - vcr (3.0.1) - webmock (1.24.2) + uglifier (3.0.0) + execjs (>= 0.3.0, < 3) + unicode-display_width (1.0.5) + vcr (3.0.3) + webmock (2.1.0) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff @@ -354,19 +347,19 @@ DEPENDENCIES actionmailer better_errors binding_of_caller (~> 0.7.2) + bummr capybara (~> 2.4) compass-rails coveralls derailed - email_spec (~> 1.6.0) + email_spec faraday-http-cache (~> 1.0) figaro flamegraph font-awesome-rails - google-api-client (~> 0.8.1) + google-api-client (~> 0.8.6) haml-rails haml_lint - jshint kaminari letter_opener newrelic_rpm (>= 3.8.0.218) @@ -387,10 +380,14 @@ DEPENDENCIES spring-commands-rspec spring-watcher-listen sprockets (~> 2.12) + stackprof uglifier vcr - webmock (~> 1.20) + webmock (~> 2.1) yard +RUBY VERSION + ruby 2.3.1p112 + BUNDLED WITH - 1.10.6 + 1.12.4 diff --git a/README.md b/README.md index 7ce491019..fed387f8e 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ You can see a running version of the application at ## Stack Overview -* Ruby version 2.2.3 -* Rails version 4.2.5 +* Ruby version 2.3.1 +* Rails version 4.2.6 * Template Engines: ERB and HAML * Testing Frameworks: RSpec, Capybara, Poltergeist diff --git a/app/assets/javascripts/app/FeedbackForm.js b/app/assets/javascripts/app/FeedbackForm.js index 53ed74cc2..42695a367 100644 --- a/app/assets/javascripts/app/FeedbackForm.js +++ b/app/assets/javascripts/app/FeedbackForm.js @@ -28,7 +28,6 @@ function (alerts, util, eventObserver, $) { var _emailInput; // @param selector [String] The HTML DOM selector for the feedback form. - // jshint validthis: true function init(selector) { var form = document.querySelector(selector); _sendBtn = form.querySelector('.button-feedback-send'); diff --git a/app/assets/javascripts/util/EventObserver.js b/app/assets/javascripts/util/EventObserver.js index 8e0146e3c..2f22f8eb0 100644 --- a/app/assets/javascripts/util/EventObserver.js +++ b/app/assets/javascripts/util/EventObserver.js @@ -22,7 +22,6 @@ function () { // @param evt [String] The event name to listen for. // @param callback [Function] The function called when the event has fired. function addEventListener(evt, callback) { - // jshint validthis: true if (_events.hasOwnProperty(evt)) _events[evt].push(callback); else @@ -36,7 +35,6 @@ function () { // @param evt [String] The event name to remove. // @param callback [Function] The function attached to the event. function removeEventListener(evt, callback) { - // jshint validthis: true if (!_events.hasOwnProperty(evt)) return; @@ -51,7 +49,6 @@ function () { // @param evt [String] The type of event to broadcast. // @param options [Object] The event object to pass to the event handler. function dispatchEvent(evt, options) { - // jshint validthis: true if (!_events.hasOwnProperty(evt)) return; diff --git a/app/assets/javascripts/util/geolocation/geolocate-action.js b/app/assets/javascripts/util/geolocation/geolocate-action.js index 109802825..7843d2dc0 100644 --- a/app/assets/javascripts/util/geolocation/geolocate-action.js +++ b/app/assets/javascripts/util/geolocation/geolocate-action.js @@ -52,7 +52,7 @@ function (geo, alerts, googleMaps) { _reverseGeocodeLocation(latitude, longitude); }); }, - error: function(error) { // jshint ignore:line + error: function(error) { //console.log("Geolocation failed due to: " + error.message); alerts.show(LOCATION_NOT_FOUND_ERROR_TEXT, alerts.type.ERROR); _locateTargetReady(); diff --git a/app/assets/javascripts/util/map/MapSizeControl.js b/app/assets/javascripts/util/map/MapSizeControl.js index 7678bdeb1..a511f64ee 100644 --- a/app/assets/javascripts/util/map/MapSizeControl.js +++ b/app/assets/javascripts/util/map/MapSizeControl.js @@ -27,8 +27,8 @@ function (eventObserver) { var _atMaxSize = false; // 'Constants' for map button text content. - var LARGER_MAP_TEXT = " Smaller map"; // jshint ignore:line - var SMALLER_MAP_TEXT = " Larger map"; // jshint ignore:line + var LARGER_MAP_TEXT = " Smaller map"; + var SMALLER_MAP_TEXT = " Larger map"; function _init() { _buttonElm.innerHTML = SMALLER_MAP_TEXT; diff --git a/app/assets/javascripts/util/map/google/map-renderer.js b/app/assets/javascripts/util/map/google/map-renderer.js index 4d9033c58..34d7ae96c 100644 --- a/app/assets/javascripts/util/map/google/map-renderer.js +++ b/app/assets/javascripts/util/map/google/map-renderer.js @@ -114,12 +114,12 @@ function (markers, markerDataLoader, plugins, MapDOM, infoBoxManager) { if (orgName !== markerData.name) agency = '

' + orgName + '

'; - var content = "
" + // jshint ignore:line + var content = "
" + '

' + mainName + '

' + agency + '

' + markerData.street_address + ', ' + - markerData.city + '

' + "

' + "

View more details…

"; // jshint ignore:line + "'>View more details…

"; _registerMarkerEvents(marker, content, spiderfier); @@ -228,7 +228,7 @@ function (markers, markerDataLoader, plugins, MapDOM, infoBoxManager) { // Change marker icon appearances when the markers spiderfy. spiderfier.addListener('spiderfy', function(spiderfied, - unspiderfied) { // jshint ignore:line + unspiderfied) { infoBoxManager.turnOn(infoBoxManager.STATE.HAS_SPIDERFIED); var index = spiderfied.length - 1; while (index >= 0) { @@ -239,7 +239,7 @@ function (markers, markerDataLoader, plugins, MapDOM, infoBoxManager) { // Change marker icon appearances when the markers unspiderfy. spiderfier.addListener('unspiderfy', function(spiderfied, - unspiderfied) { // jshint ignore:line + unspiderfied) { var index = spiderfied.length - 1; while (index >= 0) { _setIcon(spiderfied[index--], true); diff --git a/app/assets/javascripts/util/translation/google-translate.js b/app/assets/javascripts/util/translation/google-translate.js index 0acb73215..d8af89302 100644 --- a/app/assets/javascripts/util/translation/google-translate.js +++ b/app/assets/javascripts/util/translation/google-translate.js @@ -64,7 +64,7 @@ function (util, cookie, DropDownLayout) { layout: _getGoogleLayout(), autoDisplay: false }; - new google.translate.TranslateElement( gadgetOptions, // jshint ignore:line + new google.translate.TranslateElement( gadgetOptions, GOOGLE_TRANSLATE_ELEMENT_ID ); // Activate hooks to manipulate Google Website Translator Gadget through diff --git a/app/controllers/concerns/cacheable.rb b/app/controllers/concerns/cacheable.rb index 1f4d0b87c..bbd4da59b 100644 --- a/app/controllers/concerns/cacheable.rb +++ b/app/controllers/concerns/cacheable.rb @@ -2,6 +2,7 @@ module Cacheable def cache_page(field) return unless ENV['ENABLE_CACHING'] == 'true' fresh_when( - etag: ENV['LATEST_COMMIT_HASH'], last_modified: field, public: true) + etag: ENV['LATEST_COMMIT_HASH'], last_modified: field, public: true + ) end end diff --git a/app/helpers/language_links_helper.rb b/app/helpers/language_links_helper.rb index 7e5939e72..ee0394761 100644 --- a/app/helpers/language_links_helper.rb +++ b/app/helpers/language_links_helper.rb @@ -5,7 +5,8 @@ def language_link_tag(language_plus_code) link_to_unless( @current_lang == code, - language, "?translate=#{code}", lang: code, class: no_translate_class) do |language_text| + language, "?translate=#{code}", lang: code, class: no_translate_class + ) do |language_text| content_tag(:a, language_text, lang: code, class: translate_active_class) end end diff --git a/app/helpers/schedules_helper.rb b/app/helpers/schedules_helper.rb index 46e488949..6c8db6ab7 100644 --- a/app/helpers/schedules_helper.rb +++ b/app/helpers/schedules_helper.rb @@ -63,7 +63,8 @@ def holiday_schedule_content_for(schedule) content_tag :section do "#{date_range_for(schedule.start_date, schedule.end_date)}: "\ "#{holiday_hours( - schedule.closed, schedule.opens_at, schedule.closes_at)}".html_safe + schedule.closed, schedule.opens_at, schedule.closes_at + )}".html_safe end end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 97b29e900..426a2f419 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -18,4 +18,5 @@ routes/locations/show.js vendor.js ie8.js - ie9.js) + ie9.js +) diff --git a/config/jshint.yml b/config/jshint.yml deleted file mode 100644 index e9eaaff4f..000000000 --- a/config/jshint.yml +++ /dev/null @@ -1,35 +0,0 @@ -files: ['**/*.js'] # No need to put app/assets/ or vendor/assets here -exclude_paths: ['vendor/assets/javascripts'] -options: - bitwise: false - camelcase: false - curly: false - eqeqeq: true - es3: true - forin: true - immed: true - indent: 2 - latedef: true - newcap: true - noarg: true - noempty: true - nonew: true - plusplus: false - quotmark: true - undef: true - unused: true - strict: true - maxparams: 5 - maxdepth: 5 - maxstatements: 25 - maxcomplexity: 10 - maxlen: 80 - browser: true - devel: true - globals: - jQuery: true - '$': true - define: true - require: true - requirejs: true - google: true diff --git a/script/test b/script/test index fcb4c6a5f..b4baa3273 100755 --- a/script/test +++ b/script/test @@ -6,7 +6,5 @@ echo 'Running rspec test suite...' spring rspec echo '\nRunning haml-lint Haml linter...' haml-lint app/views/ -echo '\nRunning jshint JavaScript linter...' -bin/rake jshint echo '\nRunning rubocop Ruby linter...' rubocop -R diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 4e90d5e6e..5687ac03b 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -8,7 +8,8 @@ Capybara.register_driver :poltergeist do |app| Capybara::Poltergeist::Driver.new( - app, js_errors: false, phantomjs_options: ['--ignore-ssl-errors=yes']) + app, js_errors: false, phantomjs_options: ['--ignore-ssl-errors=yes'] + ) end Capybara.add_selector(:rel) do