diff --git a/.erb-lint.yml b/.erb-lint.yml index 5e68e12e6..bcb502b62 100644 --- a/.erb-lint.yml +++ b/.erb-lint.yml @@ -1,4 +1,8 @@ linters: + ErbSafety: + # TODO: [@rhymes] re-enable this and fix the violations, + # see https://github.com/Shopify/erb-lint#ErbSafety + enabled: false SelfClosingTag: enabled: false ParserErrors: diff --git a/Gemfile b/Gemfile index 10a0861e4..17ed003f7 100644 --- a/Gemfile +++ b/Gemfile @@ -74,7 +74,7 @@ gem "pusher-push-notifications", "~> 2.0" # Pusher Push Notifications Ruby serve gem "rack-attack", "~> 6.5.0" # Used to throttle requests to prevent brute force attacks gem "rack-cors", "~> 1.1" # Middleware that will make Rack-based apps CORS compatible gem "rack-timeout", "~> 0.6" # Rack middleware which aborts requests that have been running for longer than a specified timeout -gem "rails", "~> 6.0.3" # Ruby on Rails +gem "rails", "~> 6.1" # Ruby on Rails gem "rails-settings-cached", ">= 2.1.1" # Settings plugin for Rails that makes managing a table of global key, value pairs easy. gem "ransack", "~> 2.4" # Searching and sorting gem "recaptcha", "~> 5.7", require: "recaptcha/rails" # Helpers for the reCAPTCHA API @@ -124,10 +124,9 @@ group :development do gem "brakeman", "~> 5.0", require: false # Brakeman detects security vulnerabilities in Ruby on Rails applications via static analysis gem "bundler-audit", "~> 0.8" # bundler-audit provides patch-level verification for Bundled apps gem "derailed_benchmarks", "~> 2.0", require: false # A series of things you can use to benchmark a Rails or Ruby app - gem "erb_lint", github: "thepracticaldev/erb-lint", branch: "jess/remove-version-pinning", require: false # ERB Linter tool + gem "erb_lint", "~> 0.0.37", require: false # ERB Linter tool gem "guard", "~> 2.16", require: false # Guard is a command line tool to easily handle events on file system modifications gem "guard-livereload", "~> 2.5", require: false # Guard::LiveReload automatically reloads your browser when 'view' files are modified - gem "guard-rspec", "~> 4.7", require: false # Guard::RSpec automatically run your specs gem "listen", "~> 3.5", require: false # Helps 'listen' to file system modifications events (also used by other gems like guard) gem "memory_profiler", "~> 1.0", require: false # Memory profiling routines for Ruby 2.3+ gem "pry", "~> 0.13" # An IRB alternative and runtime developer console diff --git a/Gemfile.lock b/Gemfile.lock index 1097cb324..7f5f33c4d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -18,85 +18,75 @@ GIT responders warden (~> 1.2.3) -GIT - remote: https://github.com/thepracticaldev/erb-lint.git - revision: 05596ea189ee00fb2ad3ea10a41489e2dba345c4 - branch: jess/remove-version-pinning - specs: - erb_lint (0.0.35) - activesupport - better_html (~> 1.0.7) - html_tokenizer - parser (>= 2.7.1.4) - rainbow - rubocop - smart_properties - GEM remote: https://rubygems.org/ specs: - actioncable (6.0.3.5) - actionpack (= 6.0.3.5) + actioncable (6.1.3.1) + actionpack (= 6.1.3.1) + activesupport (= 6.1.3.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.0.3.5) - actionpack (= 6.0.3.5) - activejob (= 6.0.3.5) - activerecord (= 6.0.3.5) - activestorage (= 6.0.3.5) - activesupport (= 6.0.3.5) + actionmailbox (6.1.3.1) + actionpack (= 6.1.3.1) + activejob (= 6.1.3.1) + activerecord (= 6.1.3.1) + activestorage (= 6.1.3.1) + activesupport (= 6.1.3.1) mail (>= 2.7.1) - actionmailer (6.0.3.5) - actionpack (= 6.0.3.5) - actionview (= 6.0.3.5) - activejob (= 6.0.3.5) + actionmailer (6.1.3.1) + actionpack (= 6.1.3.1) + actionview (= 6.1.3.1) + activejob (= 6.1.3.1) + activesupport (= 6.1.3.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.0.3.5) - actionview (= 6.0.3.5) - activesupport (= 6.0.3.5) - rack (~> 2.0, >= 2.0.8) + actionpack (6.1.3.1) + actionview (= 6.1.3.1) + activesupport (= 6.1.3.1) + rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.0.3.5) - actionpack (= 6.0.3.5) - activerecord (= 6.0.3.5) - activestorage (= 6.0.3.5) - activesupport (= 6.0.3.5) + actiontext (6.1.3.1) + actionpack (= 6.1.3.1) + activerecord (= 6.1.3.1) + activestorage (= 6.1.3.1) + activesupport (= 6.1.3.1) nokogiri (>= 1.8.5) - actionview (6.0.3.5) - activesupport (= 6.0.3.5) + actionview (6.1.3.1) + activesupport (= 6.1.3.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) active_record_union (1.3.0) activerecord (>= 4.0) - activejob (6.0.3.5) - activesupport (= 6.0.3.5) + activejob (6.1.3.1) + activesupport (= 6.1.3.1) globalid (>= 0.3.6) - activemodel (6.0.3.5) - activesupport (= 6.0.3.5) - activerecord (6.0.3.5) - activemodel (= 6.0.3.5) - activesupport (= 6.0.3.5) - activestorage (6.0.3.5) - actionpack (= 6.0.3.5) - activejob (= 6.0.3.5) - activerecord (= 6.0.3.5) - marcel (~> 0.3.1) - activesupport (6.0.3.5) + activemodel (6.1.3.1) + activesupport (= 6.1.3.1) + activerecord (6.1.3.1) + activemodel (= 6.1.3.1) + activesupport (= 6.1.3.1) + activestorage (6.1.3.1) + actionpack (= 6.1.3.1) + activejob (= 6.1.3.1) + activerecord (= 6.1.3.1) + activesupport (= 6.1.3.1) + marcel (~> 1.0.0) + mini_mime (~> 1.0.2) + activesupport (6.1.3.1) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) acts-as-taggable-on (7.0.0) activerecord (>= 5.0, < 6.2) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) - ahoy_email (1.1.0) + ahoy_email (1.1.1) actionmailer (>= 5) addressable (>= 2.3.2) nokogiri @@ -126,7 +116,7 @@ GEM coderay (>= 1.0.0) erubi (>= 1.0.0) rack (>= 0.9.0) - better_html (1.0.15) + better_html (1.0.16) actionview (>= 4.0) activesupport (>= 4.0) ast (~> 2.0) @@ -145,7 +135,7 @@ GEM bootsnap (1.7.3) msgpack (~> 1.0) brakeman (5.0.0) - browser (5.2.0) + browser (5.3.1) brpoplpush-redis_script (0.1.2) concurrent-ruby (~> 1.0, >= 1.0.5) redis (>= 1.0, <= 5.0) @@ -166,12 +156,12 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - carrierwave (2.2.0) + carrierwave (2.2.1) activemodel (>= 5.0.0) activesupport (>= 5.0.0) addressable (~> 2.6) image_processing (~> 1.1) - mimemagic (>= 0.3.0) + marcel (~> 1.0.0) mini_mime (>= 0.1.3) ssrf_filter (~> 1.0) carrierwave-bombshelter (0.2.2) @@ -207,8 +197,8 @@ GEM dante (0.2.0) ddtrace (0.47.0) msgpack - dead_end (1.1.4) - debug_inspector (0.0.3) + dead_end (1.1.6) + debug_inspector (1.1.0) derailed_benchmarks (2.0.1) benchmark-ips (~> 2) dead_end @@ -229,8 +219,8 @@ GEM devise (>= 4.6) diff-lcs (1.4.4) distribution (0.8.0) - docile (1.3.4) - dogstatsd-ruby (4.8.3) + docile (1.3.5) + dogstatsd-ruby (4.9.0) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) doorkeeper (5.5.0) @@ -254,6 +244,14 @@ GEM activemodel emoji_regex (3.2.2) equalizer (0.0.11) + erb_lint (0.0.37) + activesupport + better_html (~> 1.0.7) + html_tokenizer + parser (>= 2.7.1.4) + rainbow + rubocop + smart_properties errbase (0.2.1) erubi (1.10.0) et-orbi (1.2.4) @@ -274,7 +272,7 @@ GEM multipart-post (>= 1.2, < 3) ruby2_keywords faraday-net_http (1.0.1) - fastimage (2.2.1) + fastimage (2.2.3) fastly (3.0.1) feedjira (3.1.2) loofah (>= 2.3.1) @@ -315,11 +313,11 @@ GEM nokogiri (>= 1.5.11, < 2.0.0) formatador (0.2.5) front_matter_parser (1.0.0) - fugit (1.4.1) + fugit (1.4.4) et-orbi (~> 1.1, >= 1.1.8) raabro (~> 1.4) gemoji (4.0.0.rc2) - geocoder (1.6.5) + geocoder (1.6.6) get_process_mem (0.2.7) ffi (~> 1.0) gibbon (3.4.0) @@ -342,10 +340,6 @@ GEM guard (~> 2.8) guard-compat (~> 1.0) multi_json (~> 1.8) - guard-rspec (4.7.3) - guard (~> 2.1) - guard-compat (~> 1.1) - rspec (>= 2.99.0, < 4.0) hashdiff (1.0.1) hashie (4.1.0) heapy (0.2.0) @@ -422,8 +416,9 @@ GEM rake launchy (2.5.0) addressable (~> 2.7) - libhoney (1.17.0) + libhoney (1.18.0) addressable (~> 2.0) + excon http (>= 2.0, < 5.0) liquid (5.0.1) listen (3.5.1) @@ -435,8 +430,7 @@ GEM lumberjack (1.2.8) mail (2.7.1) mini_mime (>= 0.1.1) - marcel (0.3.3) - mimemagic (~> 0.3.2) + marcel (1.0.0) memoizable (0.4.2) thread_safe (~> 0.3, >= 0.3.1) memory_profiler (1.0.0) @@ -444,11 +438,9 @@ GEM mime-types (3.3.1) mime-types-data (~> 3.2015) mime-types-data (3.2021.0225) - mimemagic (0.3.5) mini_histogram (0.3.1) mini_magick (4.11.0) - mini_mime (1.0.2) - mini_portile2 (2.5.0) + mini_mime (1.0.3) minitest (5.14.4) modis (3.3.0) activemodel (>= 4.2) @@ -470,9 +462,6 @@ GEM http-2 (~> 0.11) netrc (0.11.0) nio4r (2.5.7) - nokogiri (1.11.2) - mini_portile2 (~> 2.5.0) - racc (~> 1.4) nokogiri (1.11.2-x86_64-darwin) racc (~> 1.4) nokogiri (1.11.2-x86_64-linux) @@ -481,7 +470,7 @@ GEM nenv (~> 0.1) shellany (~> 0.0) oauth (0.5.5) - oauth2 (1.4.4) + oauth2 (1.4.7) faraday (>= 0.8, < 2.0) jwt (>= 1.0, < 3.0) multi_json (~> 1.3) @@ -563,20 +552,20 @@ GEM rack-test (1.1.0) rack (>= 1.0, < 3) rack-timeout (0.6.0) - rails (6.0.3.5) - actioncable (= 6.0.3.5) - actionmailbox (= 6.0.3.5) - actionmailer (= 6.0.3.5) - actionpack (= 6.0.3.5) - actiontext (= 6.0.3.5) - actionview (= 6.0.3.5) - activejob (= 6.0.3.5) - activemodel (= 6.0.3.5) - activerecord (= 6.0.3.5) - activestorage (= 6.0.3.5) - activesupport (= 6.0.3.5) - bundler (>= 1.3.0) - railties (= 6.0.3.5) + rails (6.1.3.1) + actioncable (= 6.1.3.1) + actionmailbox (= 6.1.3.1) + actionmailer (= 6.1.3.1) + actionpack (= 6.1.3.1) + actiontext (= 6.1.3.1) + actionview (= 6.1.3.1) + activejob (= 6.1.3.1) + activemodel (= 6.1.3.1) + activerecord (= 6.1.3.1) + activestorage (= 6.1.3.1) + activesupport (= 6.1.3.1) + bundler (>= 1.15.0) + railties (= 6.1.3.1) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) @@ -585,12 +574,12 @@ GEM loofah (~> 2.3) rails-settings-cached (2.5.2) rails (>= 5.0.0) - railties (6.0.3.5) - actionpack (= 6.0.3.5) - activesupport (= 6.0.3.5) + railties (6.1.3.1) + actionpack (= 6.1.3.1) + activesupport (= 6.1.3.1) method_source rake (>= 0.8.7) - thor (>= 0.20.3, < 2.0) + thor (~> 1.0) rainbow (3.0.0) rake (13.0.3) ransack (2.4.2) @@ -648,10 +637,6 @@ GEM webpush (~> 1.0) rpush-redis (1.1.0) modis (~> 3.0) - rspec (3.10.0) - rspec-core (~> 3.10.0) - rspec-expectations (~> 3.10.0) - rspec-mocks (~> 3.10.0) rspec-core (3.10.1) rspec-support (~> 3.10.0) rspec-expectations (3.10.1) @@ -696,8 +681,8 @@ GEM ruby-prof (1.4.3) ruby-progressbar (1.11.0) ruby-statistics (2.1.3) - ruby-vips (2.0.17) - ffi (~> 1.9) + ruby-vips (2.1.0) + ffi (~> 1.12) ruby2_keywords (0.0.4) rubyzip (2.3.0) s3_direct_upload (0.1.7) @@ -729,7 +714,7 @@ GEM selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) - semantic_range (2.3.1) + semantic_range (3.0.0) shellany (0.0.1) shoulda-matchers (4.5.1) activesupport (>= 4.2.0) @@ -797,8 +782,8 @@ GEM multipart-post (~> 2.0) naught (~> 1.0) simple_oauth (~> 0.3.0) - tzinfo (1.2.9) - thread_safe (~> 0.1) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) ulid (1.3.0) @@ -806,7 +791,7 @@ GEM unf_ext unf_ext (0.0.7.7) unicode-display_width (2.0.0) - uniform_notifier (1.14.1) + uniform_notifier (1.14.2) validate_url (1.0.13) activemodel (>= 3.0.0) public_suffix @@ -856,9 +841,7 @@ GEM zonebie (0.6.1) PLATFORMS - ruby x86_64-darwin-19 - x86_64-darwin-20 x86_64-linux DEPENDENCIES @@ -893,7 +876,7 @@ DEPENDENCIES elasticsearch (~> 7.12) email_validator (~> 2.2) emoji_regex (~> 3.2) - erb_lint! + erb_lint (~> 0.0.37) exifr (>= 1.3.6) factory_bot_rails (~> 6.1) faker (~> 2.17) @@ -909,7 +892,6 @@ DEPENDENCIES gibbon (~> 3.4) guard (~> 2.16) guard-livereload (~> 2.5) - guard-rspec (~> 4.7) honeybadger (~> 4.8) honeycomb-beeline (~> 2.4.0) html_truncator (~> 0.4) @@ -954,7 +936,7 @@ DEPENDENCIES rack-cors (~> 1.1) rack-host-redirect (~> 1.3) rack-timeout (~> 0.6) - rails (~> 6.0.3) + rails (~> 6.1) rails-settings-cached (>= 2.1.1) ransack (~> 2.4) recaptcha (~> 5.7) @@ -1018,4 +1000,4 @@ RUBY VERSION ruby 2.7.2p137 BUNDLED WITH - 2.2.14 + 2.2.15 diff --git a/app/models/article.rb b/app/models/article.rb index 2f1c271ec..135be27c5 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -400,6 +400,10 @@ class Article < ApplicationRecord def video_duration_in_minutes duration = ActiveSupport::Duration.build(video_duration_in_seconds.to_i).parts + + # add default hours and minutes for the substitutions below + duration = duration.reverse_merge(seconds: 0, minutes: 0, hours: 0) + minutes_and_seconds = format("%02d:%02d", duration) return minutes_and_seconds if duration[:hours] < 1 @@ -468,7 +472,7 @@ class Article < ApplicationRecord self.description = processed_description if description.blank? rescue StandardError => e - errors[:base] << ErrorMessages::Clean.call(e.message) + errors.add(:base, ErrorMessages::Clean.call(e.message)) end def set_tag_list(tags) diff --git a/app/services/analytics_service.rb b/app/services/analytics_service.rb index eeb68477e..da70c268d 100644 --- a/app/services/analytics_service.rb +++ b/app/services/analytics_service.rb @@ -1,4 +1,6 @@ class AnalyticsService + DEFAULT_REACTION_TOTALS = { total: 0, like: 0, readinglist: 0, unicorn: 0 }.freeze + def initialize(user_or_org, start_date: "", end_date: "", article_id: nil) @user_or_org = user_or_org @article_id = article_id @@ -107,9 +109,13 @@ class AnalyticsService Arel.sql("COUNT(*) FILTER (WHERE category = 'unicorn')"), ) - # this transforms the counts, eg. [1, 0, 1, 0] - # in a hash, eg. {total: 1, like: 0, readinglist: 1, unicorn: 0} - keys.zip(counts).to_h + if counts + # this transforms the counts, eg. [1, 0, 1, 0] + # in a hash, eg. {total: 1, like: 0, readinglist: 1, unicorn: 0} + keys.zip(counts).to_h + else + DEFAULT_REACTION_TOTALS + end end def calculate_page_views_totals diff --git a/bin/__tests__/generate-css-utility-classes-docs.test.js b/bin/__tests__/generate-css-utility-classes-docs.test.js old mode 100644 new mode 100755 diff --git a/bin/rails b/bin/rails index 073966023..21d3e02d8 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +load File.expand_path("spring", __dir__) APP_PATH = File.expand_path('../config/application', __dir__) -require_relative '../config/boot' -require 'rails/commands' +require_relative "../config/boot" +require "rails/commands" diff --git a/bin/rake b/bin/rake index 17240489f..7327f471e 100755 --- a/bin/rake +++ b/bin/rake @@ -1,4 +1,5 @@ #!/usr/bin/env ruby -require_relative '../config/boot' -require 'rake' +load File.expand_path("spring", __dir__) +require_relative "../config/boot" +require "rake" Rake.application.run diff --git a/bin/setup b/bin/setup index 35c7118cd..98ecea7bf 100755 --- a/bin/setup +++ b/bin/setup @@ -1,6 +1,5 @@ #!/usr/bin/env ruby require "fileutils" -include FileUtils # path to your application root. APP_ROOT = File.expand_path("..", __dir__) @@ -9,7 +8,7 @@ def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") end -chdir APP_ROOT do +FileUtils.chdir APP_ROOT do # This script is a way to set up or update your development environment automatically. # This script is idempotent, so that you can run it at anytime and get an expectable outcome. # Add necessary setup steps to this file. @@ -28,7 +27,7 @@ chdir APP_ROOT do puts "\n== Copying sample files ==" unless File.exist?("config/database.yml") - cp "config/database.yml.sample", "config/database.yml" + FileUtils.cp "config/database.yml.sample", "config/database.yml" end puts "\n== Preparing Test Elasticsearch ==" diff --git a/bin/spring b/bin/spring index b44ad1a7a..b4147e843 100755 --- a/bin/spring +++ b/bin/spring @@ -1,17 +1,14 @@ #!/usr/bin/env ruby - -# This file loads spring without using Bundler, in order to be fast. -# It gets overwritten when you run the `spring binstub` command. - -unless defined?(Spring) - require "rubygems" +if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"]) + gem "bundler" require "bundler" - lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) - spring = lockfile.specs.detect { |spec| spec.name == "spring" } - if spring + # Load Spring without loading other gems in the Gemfile, for speed. + Bundler.locked_gems&.specs&.find { |spec| spec.name == "spring" }&.tap do |spring| Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path gem "spring", spring.version require "spring/binstub" + rescue Gem::LoadError + # Ignore when Spring is not installed. end end diff --git a/bin/yarn b/bin/yarn index 460dd565b..9fab2c350 100755 --- a/bin/yarn +++ b/bin/yarn @@ -1,9 +1,15 @@ #!/usr/bin/env ruby APP_ROOT = File.expand_path('..', __dir__) Dir.chdir(APP_ROOT) do - begin - exec "yarnpkg", *ARGV - rescue Errno::ENOENT + yarn = ENV["PATH"].split(File::PATH_SEPARATOR). + select { |dir| File.expand_path(dir) != __dir__ }. + product(["yarn", "yarn.cmd", "yarn.ps1"]). + map { |dir, file| File.expand_path(file, dir) }. + find { |file| File.executable?(file) } + + if yarn + exec yarn, *ARGV + else $stderr.puts "Yarn executable was not detected in the system." $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" exit 1 diff --git a/config.ru b/config.ru index 846e1c70a..4a3c09a68 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,6 @@ # This file is used by Rack-based servers to start the application. -require ::File.expand_path("config/environment", __dir__) +require_relative "config/environment" + run Rails.application +Rails.application.load_server diff --git a/config/application.rb b/config/application.rb index f48c1c6fc..ebd249a57 100644 --- a/config/application.rb +++ b/config/application.rb @@ -8,6 +8,8 @@ require "active_record/railtie" # require "active_storage/engine" require "action_controller/railtie" require "action_mailer/railtie" +# require "action_mailbox/engine" +# require "action_text/engine" require "action_view/railtie" # require "action_cable/engine" require "sprockets/railtie" diff --git a/config/environments/development.rb b/config/environments/development.rb index fb0172e72..d11f0cdfc 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,10 +1,11 @@ +require "active_support/core_ext/integer/time" + # rubocop:disable Metrics/BlockLength Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development - # since you don't have to restart the web server when you make code changes. + # In the development environment your application's code is reloaded any time + # it changes. This slows down response time but is perfect for development config.cache_classes = false # Do not eager load code on boot. @@ -17,6 +18,7 @@ Rails.application.configure do # Run rails dev:cache to toggle caching. if Rails.root.join("tmp/caching-dev.txt").exist? config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true DEFAULT_EXPIRATION = 1.hour.to_i.freeze config.cache_store = :redis_cache_store, { url: ENV["REDIS_URL"], expires_in: DEFAULT_EXPIRATION } @@ -30,9 +32,6 @@ Rails.application.configure do config.cache_store = :null_store end - # Store uploaded files on the local file system (see config/storage.yml for options) - # config.active_storage.service = :local - # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false @@ -41,6 +40,12 @@ Rails.application.configure do # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load @@ -64,6 +69,12 @@ Rails.application.configure do # Suppress logger output for asset requests. config.assets.quiet = true + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true + # Adds additional error checking when serving assets at runtime. # Checks for improperly declared sprockets dependencies. # Raises helpful error messages. @@ -92,9 +103,6 @@ Rails.application.configure do config.action_mailer.preview_path = Rails.root.join("spec/mailers/previews") - # Raises error for missing translations - # config.action_view.raise_on_missing_translations = true - config.public_file_server.enabled = true # Use an evented file watcher to asynchronously detect changes in source code, @@ -104,6 +112,9 @@ Rails.application.configure do # Debug is the default log_level, but can be changed per environment. config.log_level = :debug + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true + if ENV["RAILS_LOG_TO_STDOUT"].present? logger = ActiveSupport::Logger.new($stdout) logger.formatter = config.log_formatter diff --git a/config/environments/production.rb b/config/environments/production.rb index f288ece56..9a26dbf5c 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,3 +1,5 @@ +require "active_support/core_ext/integer/time" + # rubocop:disable Metrics/BlockLength Rails.application.configure do # Allow the app to know when booted up in context where we haven't set ENV vars @@ -57,9 +59,6 @@ Rails.application.configure do # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX - # Store uploaded files on the local file system (see config/storage.yml for options) - # config.active_storage.service = :local - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. config.force_ssl = ENV["FORCE_SSL_IN_RAILS"] == "true" @@ -79,7 +78,7 @@ Rails.application.configure do # Use a real queuing backend for Active Job (and separate queues per environment) # config.active_job.queue_adapter = :resque - # config.active_job.queue_name_prefix = "practical_developer_#{Rails.env}" + # config.active_job.queue_name_prefix = "practical_developer_production" config.action_mailer.perform_caching = false @@ -94,6 +93,12 @@ Rails.application.configure do # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify + # Log disallowed deprecations. + config.active_support.disallowed_deprecation = :log + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + # Filter sensitive information from production logs config.filter_parameters += %i[ auth_data_dump content email encrypted @@ -138,6 +143,27 @@ Rails.application.configure do config.middleware.use Rack::HostRedirect, ENV["HEROKU_APP_URL"] => ENV["APP_DOMAIN"] end + + # Inserts middleware to perform automatic connection switching. + # The `database_selector` hash is used to pass options to the DatabaseSelector + # middleware. The `delay` is used to determine how long to wait after a write + # to send a subsequent read to the primary. + # + # The `database_resolver` class is used by the middleware to determine which + # database is appropriate to use based on the time delay. + # + # The `database_resolver_context` class is used by the middleware to set + # timestamps for the last write to the primary. The resolver uses the context + # class timestamps to determine how long to wait before reading from the + # replica. + # + # By default Rails will store a last write timestamp in the session. The + # DatabaseSelector middleware is designed as such you can define your own + # strategy for connection switching and pass that into the middleware through + # these configuration options. + # config.active_record.database_selector = { delay: 2.seconds } + # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver + # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session end # rubocop:enable Metrics/BlockLength diff --git a/config/environments/test.rb b/config/environments/test.rb index d48bf2369..d6e9f46a8 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,25 +1,23 @@ +require "active_support/core_ext/integer/time" + +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + # rubocop:disable Metrics/BlockLength Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. + config.cache_classes = true + # Include middleware to ensure timezone for browser requests for Capybara specs # matches the random zonebie timezone set at the beginning of our spec run config.middleware.use SetTimeZone - # The test environment is used exclusively to run your application's - # test suite. You never need to work with it otherwise. Remember that - # your test database is "scratch space" for the test suite and is wiped - # and recreated between test runs. Don't rely on the data there! - config.cache_classes = true - # See https://github.com/rails/rails/issues/40613#issuecomment-727283155 config.action_view.cache_template_loading = true - # NOTE: [Rails 6] this is the default store in testing, - # as we haven't enabled Rails 6.0 defaults in config/application.rb, - # we need to keep this explicit, for now - config.cache_store = :null_store - # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that # preloads Rails for running tests, you may have to set it to true. @@ -34,6 +32,7 @@ Rails.application.configure do # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false + config.cache_store = :null_store # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false @@ -41,9 +40,6 @@ Rails.application.configure do # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false - # Store uploaded files on the local file system in a temporary directory - # config.active_storage.service = :test - config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. @@ -60,14 +56,23 @@ Rails.application.configure do # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr - # Raises error for missing translations - # config.action_view.raise_on_missing_translations = true + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] config.active_job.queue_adapter = :test # Debug is the default log_level, but can be changed per environment. config.log_level = :debug + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names + # config.action_view.annotate_rendered_view_with_filenames = true + # enable Bullet in testing mode only if requested config.after_initialize do Bullet.enable = true diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index 59385cdf3..33699c309 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1,7 +1,8 @@ # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. -# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } +# Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) } -# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. -# Rails.backtrace_cleaner.remove_silencers! +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code +# by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'". +Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"] diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 2e8c5514a..580cbdb0a 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -5,29 +5,29 @@ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy Rails.application.config.content_security_policy do |policy| - # if Rails.env.production? # policy.default_src :self, :https # policy.font_src :self, :https, :data # policy.img_src :self, :https, :data # policy.object_src :none - # policy.script_src :self, :https, :unsafe_inline - # policy.style_src :self, :https, :unsafe_inline - # policy.connect_src :self, :https, :unsafe_inline, "*.pusher.com" - # end - # # Specify URI for violation reports - # # policy.report_uri "/csp-violation-report-endpoint" + # policy.script_src :self, :https + # policy.style_src :self, :https - # allow webpack-dev-server host as allowed origin for connect-src + # If you are using webpack-dev-server then specify webpack-dev-server host if Rails.env.development? webpack_host = "#{ApplicationConfig.app_domain_no_port}:3035" - policy.connect_src :self, :https, - "http://#{webpack_host}", "ws://#{webpack_host}" + policy.connect_src :self, :https, "http://#{webpack_host}", "ws://#{webpack_host}" end + + # # Specify URI for violation reports + # # policy.report_uri "/csp-violation-report-endpoint" end # If you are using UJS then enable automatic nonce generation # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } +# Set the nonce only to specific directives +# Rails.application.config.content_security_policy_nonce_directives = %w(script-src) + # Report CSP violations to a specified URI # For further information see the following documentation: # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb index 6b012e066..d41b7da16 100644 --- a/config/initializers/cors.rb +++ b/config/initializers/cors.rb @@ -1,5 +1,10 @@ # Be sure to restart your server when you modify this file. +# Avoid CORS issues when API is called from the frontend app. +# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests. + +# Read more: https://github.com/cyu/rack-cors + # Enable CORS for API v0 (logging is only activated when debug is enabled) Rails.application.config.middleware.insert_before( 0, diff --git a/config/initializers/feature_policy.rb b/config/initializers/feature_policy.rb new file mode 100644 index 000000000..a1c46695d --- /dev/null +++ b/config/initializers/feature_policy.rb @@ -0,0 +1,11 @@ +# Define an application-wide HTTP feature policy. For further +# information see https://developers.google.com/web/updates/2018/06/feature-policy +# +# Rails.application.config.feature_policy do |f| +# f.camera :none +# f.gyroscope :none +# f.microphone :none +# f.usb :none +# f.fullscreen :self +# f.payment :self, "https://secure.example.com" +# end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 4a994e1e7..fd60d0150 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,4 +1,6 @@ # Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. -Rails.application.config.filter_parameters += [:password] +Rails.application.config.filter_parameters += %i[ + password passw secret token _key crypt salt certificate otp ssn +] diff --git a/config/initializers/new_framework_defaults_5_2.rb b/config/initializers/new_framework_defaults_5_2.rb index fa86c9939..991545d1b 100644 --- a/config/initializers/new_framework_defaults_5_2.rb +++ b/config/initializers/new_framework_defaults_5_2.rb @@ -36,6 +36,7 @@ Rails.application.config.action_controller.default_protect_from_forgery = true # see and # # Use SHA-1 instead of MD5 to generate non-sensitive digests, such as the ETag header. +# NOTE: deprecated in Rails 6.1 in favor of config.active_support.hash_digest_class = ::Digest::SHA1 # Rails.application.config.active_support.use_sha1_digests = true # Make `form_with` generate id attributes for any generated HTML tags. diff --git a/config/initializers/new_framework_defaults_6_0.rb b/config/initializers/new_framework_defaults_6_0.rb index ea023423f..628f2b255 100644 --- a/config/initializers/new_framework_defaults_6_0.rb +++ b/config/initializers/new_framework_defaults_6_0.rb @@ -16,9 +16,11 @@ # It's best enabled when your entire app is migrated and stable on 6.0. # Rails.application.config.action_dispatch.use_cookies_with_metadata = true +# NOTE: deprecated in Rails 6.1, see # Change the return value of `ActionDispatch::Response#content_type` to Content-Type header without modification. # Rails.application.config.action_dispatch.return_only_media_type_on_content_type = false +# NOTE: deprecated in Rails 6.1, see # Return false instead of self when enqueuing is aborted from a callback. # Rails.application.config.active_job.return_false_on_aborted_enqueue = true diff --git a/config/initializers/new_framework_defaults_6_1.rb b/config/initializers/new_framework_defaults_6_1.rb new file mode 100644 index 000000000..9526b835a --- /dev/null +++ b/config/initializers/new_framework_defaults_6_1.rb @@ -0,0 +1,67 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 6.1 upgrade. +# +# Once upgraded flip defaults one by one to migrate to the new default. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# Support for inversing belongs_to -> has_many Active Record associations. +# Rails.application.config.active_record.has_many_inversing = true + +# Track Active Storage variants in the database. +# Rails.application.config.active_storage.track_variants = true + +# Apply random variation to the delay when retrying failed jobs. +# Rails.application.config.active_job.retry_jitter = 0.15 + +# Stop executing `after_enqueue`/`after_perform` callbacks if +# `before_enqueue`/`before_perform` respectively halts with `throw :abort`. +# Rails.application.config.active_job.skip_after_callbacks_if_terminated = true + +# Specify cookies SameSite protection level: either :none, :lax, or :strict. +# +# This change is not backwards compatible with earlier Rails versions. +# It's best enabled when your entire app is migrated and stable on 6.1. +# Rails.application.config.action_dispatch.cookies_same_site_protection = :lax + +# Generate CSRF tokens that are encoded in URL-safe Base64. +# +# This change is not backwards compatible with earlier Rails versions. +# It's best enabled when your entire app is migrated and stable on 6.1. +# Rails.application.config.action_controller.urlsafe_csrf_tokens = true + +# Specify whether `ActiveSupport::TimeZone.utc_to_local` returns a time with an +# UTC offset or a UTC time. +# ActiveSupport.utc_to_local_returns_utc_offset_times = true + +# Change the default HTTP status code to `308` when redirecting non-GET/HEAD +# requests to HTTPS in `ActionDispatch::SSL` middleware. +# Rails.application.config.action_dispatch.ssl_default_redirect_status = 308 + +# Use new connection handling API. For most applications this won't have any +# effect. For applications using multiple databases, this new API provides +# support for granular connection swapping. +# Rails.application.config.active_record.legacy_connection_handling = false + +# Make `form_with` generate non-remote forms by default. +# Rails.application.config.action_view.form_with_generates_remote_forms = false + +# Set the default queue name for the analysis job to the queue adapter default. +# Rails.application.config.active_storage.queues.analysis = nil + +# Set the default queue name for the purge job to the queue adapter default. +# Rails.application.config.active_storage.queues.purge = nil + +# Set the default queue name for the incineration job to the queue adapter default. +# Rails.application.config.action_mailbox.queues.incineration = nil + +# Set the default queue name for the routing job to the queue adapter default. +# Rails.application.config.action_mailbox.queues.routing = nil + +# Set the default queue name for the mail deliver job to the queue adapter default. +# Rails.application.config.action_mailer.deliver_later_queue_name = nil + +# Generate a `Link` header that gives a hint to modern browsers about +# preloading assets when using `javascript_include_tag` and `stylesheet_link_tag`. +# Rails.application.config.action_view.preload_links_header = true diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb new file mode 100644 index 000000000..00f64d71b --- /dev/null +++ b/config/initializers/permissions_policy.rb @@ -0,0 +1,11 @@ +# Define an application-wide HTTP permissions policy. For further +# information see https://developers.google.com/web/updates/2018/06/feature-policy +# +# Rails.application.config.permissions_policy do |f| +# f.camera :none +# f.gyroscope :none +# f.microphone :none +# f.usb :none +# f.fullscreen :self +# f.payment :self, "https://secure.example.com" +# end diff --git a/config/locales/en.yml b/config/locales/en.yml index c814e6ee3..0f62a9393 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -27,7 +27,7 @@ # 'true': 'foo' # # To learn more, please read the Rails Internationalization guide -# available at http://guides.rubyonrails.org/i18n.html. +# available at https://guides.rubyonrails.org/i18n.html. en: hello: "Hello world" diff --git a/config/puma.rb b/config/puma.rb index 4dbb059f3..3a4097940 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -19,7 +19,7 @@ environment ENV.fetch("RAILS_ENV") { "development" } pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } # Specifies the number of `workers` to boot in clustered mode. -# Workers are forked webserver processes. If using threads and workers together +# Workers are forked web server processes. If using threads and workers together # the concurrency of the application would be max `threads` * `workers`. # Workers do not work on JRuby or Windows (both of which do not support # processes). diff --git a/config/spring.rb b/config/spring.rb index 9fa7863f9..643868a10 100644 --- a/config/spring.rb +++ b/config/spring.rb @@ -1,6 +1,6 @@ -%w[ - .ruby-version - .rbenv-vars - tmp/restart.txt - tmp/caching-dev.txt -].each { |path| Spring.watch(path) } +Spring.watch( + ".ruby-version", + ".rbenv-vars", + "tmp/restart.txt", + "tmp/caching-dev.txt", +) diff --git a/package.json b/package.json index 85541ac31..5dc6097c6 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,10 @@ "app/views/**/*.jbuilder": [ "bundle exec rubocop --require rubocop-rspec --auto-correct" ], - "Gemfile": [ + "./Gemfile": [ + "bundle exec rubocop --require rubocop-rspec --auto-correct" + ], + "docs/Gemfile": [ "bundle exec rubocop --require rubocop-rspec --auto-correct" ], "*.rake": [ diff --git a/spec/requests/admin/podcasts_spec.rb b/spec/requests/admin/podcasts_spec.rb index 4581dcc21..e499ab821 100644 --- a/spec/requests/admin/podcasts_spec.rb +++ b/spec/requests/admin/podcasts_spec.rb @@ -54,9 +54,9 @@ RSpec.describe "/admin/podcasts", type: :request do soundcloud_url: "https://soundcloud.example.com", website_url: "https://example.com", twitter_username: "@ThePracticalDev", - pattern_image: fixture_file_upload("files/800x600.png", "image/png"), + pattern_image: fixture_file_upload("800x600.png", "image/png"), main_color_hex: "ffffff", - image: fixture_file_upload("files/podcast.png", "image/png"), + image: fixture_file_upload("podcast.png", "image/png"), slug: "postcast-test-url", reachable: true, published: true diff --git a/spec/requests/organizations_update_spec.rb b/spec/requests/organizations_update_spec.rb index ea99b1f6a..dcc12dfa6 100644 --- a/spec/requests/organizations_update_spec.rb +++ b/spec/requests/organizations_update_spec.rb @@ -33,7 +33,7 @@ RSpec.describe "OrganizationsUpdate", type: :request do it "updates nav_image" do put "/organizations/#{org_id}", params: { organization: { id: org_id, - nav_image: fixture_file_upload("files/podcast.png", + nav_image: fixture_file_upload("podcast.png", "image/png") } } expect(Organization.find(org_id).nav_image_url).to be_present end @@ -48,7 +48,7 @@ RSpec.describe "OrganizationsUpdate", type: :request do it "returns error if profile image file name is too long" do organization = user.organizations.first allow(Organization).to receive(:find_by).and_return(organization) - image = fixture_file_upload("files/800x600.png", "image/png") + image = fixture_file_upload("800x600.png", "image/png") allow(image).to receive(:original_filename).and_return("#{'a_very_long_filename' * 15}.png") put "/organizations/#{org_id}", params: { organization: { id: org_id, profile_image: image } } diff --git a/spec/requests/podcasts/podcast_create_spec.rb b/spec/requests/podcasts/podcast_create_spec.rb index 5a4f587cf..93188aac2 100644 --- a/spec/requests/podcasts/podcast_create_spec.rb +++ b/spec/requests/podcasts/podcast_create_spec.rb @@ -16,7 +16,7 @@ RSpec.describe "Podcast Create", type: :request do title: Faker::Hipster.words(number: 2).join(", "), description: Faker::Hipster.paragraph(sentence_count: 1), twitter_username: "hello-pod", - image: fixture_file_upload("files/podcast.png", "image/png"), + image: fixture_file_upload("podcast.png", "image/png"), slug: "hello-pod", main_color_hex: "ffffff", website_url: Faker::Internet.url, @@ -76,7 +76,7 @@ RSpec.describe "Podcast Create", type: :request do end it "returns error if image file name is too long" do - image = fixture_file_upload("files/podcast.png", "image/png") + image = fixture_file_upload("podcast.png", "image/png") allow(image).to receive(:original_filename).and_return("#{'a_very_long_filename' * 15}.png") valid_attributes[:image] = image post podcasts_path, params: { podcast: valid_attributes } @@ -91,7 +91,7 @@ RSpec.describe "Podcast Create", type: :request do end it "returns error if pattern_image file name is too long" do - image = fixture_file_upload("files/podcast.png", "image/png") + image = fixture_file_upload("podcast.png", "image/png") allow(image).to receive(:original_filename).and_return("#{'a_very_long_filename' * 15}.png") valid_attributes[:pattern_image] = image post podcasts_path, params: { podcast: valid_attributes } diff --git a/spec/requests/user/user_organization_spec.rb b/spec/requests/user/user_organization_spec.rb index ca20a10f9..d843c08de 100644 --- a/spec/requests/user/user_organization_spec.rb +++ b/spec/requests/user/user_organization_spec.rb @@ -70,7 +70,7 @@ RSpec.describe "UserOrganization", type: :request do it "returns error if profile image file name is too long" do sign_in user org_params = build(:organization).attributes - image = fixture_file_upload("files/800x600.png", "image/png") + image = fixture_file_upload("800x600.png", "image/png") allow(image).to receive(:original_filename).and_return("#{'a_very_long_filename' * 15}.png") org_params["profile_image"] = image allow(Organization).to receive(:new).and_return(organization) diff --git a/spec/services/profiles/update_spec.rb b/spec/services/profiles/update_spec.rb index cff51fea6..db02e0449 100644 --- a/spec/services/profiles/update_spec.rb +++ b/spec/services/profiles/update_spec.rb @@ -48,7 +48,7 @@ RSpec.describe Profiles::Update, type: :service do end it "returns an error if Profile image is too large" do - profile_image = fixture_file_upload("files/large_profile_img.jpg", "image/jpeg") + profile_image = fixture_file_upload("large_profile_img.jpg", "image/jpeg") service = described_class.call(user, profile: {}, user: { profile_image: profile_image }) expect(service.success?).to be false @@ -64,7 +64,7 @@ RSpec.describe Profiles::Update, type: :service do end it "returns an error if Profile image file name is too long" do - profile_image = fixture_file_upload("files/800x600.png", "image/png") + profile_image = fixture_file_upload("800x600.png", "image/png") allow(profile_image).to receive(:original_filename).and_return("#{'a_very_long_filename' * 15}.png") service = described_class.call(user, profile: {}, user: { profile_image: profile_image }) @@ -80,7 +80,7 @@ RSpec.describe Profiles::Update, type: :service do end it "enqueues resave articles job when changing profile_image" do - profile_image = fixture_file_upload("files/800x600.jpg") + profile_image = fixture_file_upload("800x600.jpg") sidekiq_assert_resave_article_worker(user) do described_class.call(user, user: { profile_image: profile_image }) diff --git a/spec/uploaders/article_image_uploader_spec.rb b/spec/uploaders/article_image_uploader_spec.rb index d9cb46d75..b98eca0d3 100644 --- a/spec/uploaders/article_image_uploader_spec.rb +++ b/spec/uploaders/article_image_uploader_spec.rb @@ -5,11 +5,11 @@ require "exifr/jpeg" describe ArticleImageUploader, type: :uploader do include CarrierWave::Test::Matchers - let(:image_jpg) { fixture_file_upload("files/800x600.jpg", "image/jpeg") } - let(:image_png) { fixture_file_upload("files/800x600.png", "image/png") } - let(:image_webp) { fixture_file_upload("files/800x600.webp", "image/webp") } - let(:image_with_gps) { fixture_file_upload("files/image_gps_data.jpg", "image/jpeg") } - let(:high_frame_count) { fixture_file_upload("files/high_frame_count.gif", "image/gif") } + let(:image_jpg) { fixture_file_upload("800x600.jpg", "image/jpeg") } + let(:image_png) { fixture_file_upload("800x600.png", "image/png") } + let(:image_webp) { fixture_file_upload("800x600.webp", "image/webp") } + let(:image_with_gps) { fixture_file_upload("image_gps_data.jpg", "image/jpeg") } + let(:high_frame_count) { fixture_file_upload("high_frame_count.gif", "image/gif") } # we need a new uploader before each test, and since the uploader is not a model # we can recreate it quickly in memory with `let!` diff --git a/spec/uploaders/badge_uploader_spec.rb b/spec/uploaders/badge_uploader_spec.rb index 4d8bfe141..57089dd28 100644 --- a/spec/uploaders/badge_uploader_spec.rb +++ b/spec/uploaders/badge_uploader_spec.rb @@ -5,10 +5,10 @@ require "exifr/jpeg" describe BadgeUploader, type: :uploader do include CarrierWave::Test::Matchers - let(:image_jpg) { fixture_file_upload("files/800x600.jpg", "image/jpeg") } - let(:image_png) { fixture_file_upload("files/800x600.png", "image/png") } - let(:image_webp) { fixture_file_upload("files/800x600.webp", "image/webp") } - let(:image_with_gps) { fixture_file_upload("files/image_gps_data.jpg", "image/jpeg") } + let(:image_jpg) { fixture_file_upload("800x600.jpg", "image/jpeg") } + let(:image_png) { fixture_file_upload("800x600.png", "image/png") } + let(:image_webp) { fixture_file_upload("800x600.webp", "image/webp") } + let(:image_with_gps) { fixture_file_upload("image_gps_data.jpg", "image/jpeg") } let(:badge) { create(:badge) } diff --git a/spec/uploaders/cover_image_uploader_spec.rb b/spec/uploaders/cover_image_uploader_spec.rb index e489be1e4..24086525c 100644 --- a/spec/uploaders/cover_image_uploader_spec.rb +++ b/spec/uploaders/cover_image_uploader_spec.rb @@ -5,10 +5,10 @@ require "exifr/jpeg" describe CoverImageUploader, type: :uploader do include CarrierWave::Test::Matchers - let(:image_jpg) { fixture_file_upload("files/800x600.jpg", "image/jpeg") } - let(:image_png) { fixture_file_upload("files/800x600.png", "image/png") } - let(:image_webp) { fixture_file_upload("files/800x600.webp", "image/webp") } - let(:image_with_gps) { fixture_file_upload("files/image_gps_data.jpg", "image/jpeg") } + let(:image_jpg) { fixture_file_upload("800x600.jpg", "image/jpeg") } + let(:image_png) { fixture_file_upload("800x600.png", "image/png") } + let(:image_webp) { fixture_file_upload("800x600.webp", "image/webp") } + let(:image_with_gps) { fixture_file_upload("image_gps_data.jpg", "image/jpeg") } let(:event) { create(:event) } diff --git a/spec/uploaders/profile_image_uploader_spec.rb b/spec/uploaders/profile_image_uploader_spec.rb index 7cc9375ba..ac38f5113 100644 --- a/spec/uploaders/profile_image_uploader_spec.rb +++ b/spec/uploaders/profile_image_uploader_spec.rb @@ -6,10 +6,10 @@ describe ProfileImageUploader, type: :uploader do include CarrierWave::Test::Matchers let(:mounted_as) { :profile_image } - let(:image_jpg) { fixture_file_upload("files/800x600.jpg", "image/jpeg") } - let(:image_png) { fixture_file_upload("files/800x600.png", "image/png") } - let(:image_webp) { fixture_file_upload("files/800x600.webp", "image/webp") } - let(:image_with_gps) { fixture_file_upload("files/image_gps_data.jpg", "image/jpeg") } + let(:image_jpg) { fixture_file_upload("800x600.jpg", "image/jpeg") } + let(:image_png) { fixture_file_upload("800x600.png", "image/png") } + let(:image_webp) { fixture_file_upload("800x600.webp", "image/webp") } + let(:image_with_gps) { fixture_file_upload("image_gps_data.jpg", "image/jpeg") } let(:user) { create(:user) } diff --git a/vendor/cache/actioncable-6.0.3.5.gem b/vendor/cache/actioncable-6.0.3.5.gem deleted file mode 100644 index 3be218f28..000000000 Binary files a/vendor/cache/actioncable-6.0.3.5.gem and /dev/null differ diff --git a/vendor/cache/actioncable-6.1.3.1.gem b/vendor/cache/actioncable-6.1.3.1.gem new file mode 100644 index 000000000..a932d1802 Binary files /dev/null and b/vendor/cache/actioncable-6.1.3.1.gem differ diff --git a/vendor/cache/actionmailbox-6.0.3.5.gem b/vendor/cache/actionmailbox-6.0.3.5.gem deleted file mode 100644 index 79e761e72..000000000 Binary files a/vendor/cache/actionmailbox-6.0.3.5.gem and /dev/null differ diff --git a/vendor/cache/actionmailbox-6.1.3.1.gem b/vendor/cache/actionmailbox-6.1.3.1.gem new file mode 100644 index 000000000..68f0933bd Binary files /dev/null and b/vendor/cache/actionmailbox-6.1.3.1.gem differ diff --git a/vendor/cache/actionmailer-6.0.3.5.gem b/vendor/cache/actionmailer-6.0.3.5.gem deleted file mode 100644 index 6a518e4a7..000000000 Binary files a/vendor/cache/actionmailer-6.0.3.5.gem and /dev/null differ diff --git a/vendor/cache/actionmailer-6.1.3.1.gem b/vendor/cache/actionmailer-6.1.3.1.gem new file mode 100644 index 000000000..cd2ace717 Binary files /dev/null and b/vendor/cache/actionmailer-6.1.3.1.gem differ diff --git a/vendor/cache/actionpack-6.0.3.5.gem b/vendor/cache/actionpack-6.0.3.5.gem deleted file mode 100644 index 1a2c16f31..000000000 Binary files a/vendor/cache/actionpack-6.0.3.5.gem and /dev/null differ diff --git a/vendor/cache/actionpack-6.1.3.1.gem b/vendor/cache/actionpack-6.1.3.1.gem new file mode 100644 index 000000000..d93eb5d38 Binary files /dev/null and b/vendor/cache/actionpack-6.1.3.1.gem differ diff --git a/vendor/cache/actiontext-6.0.3.5.gem b/vendor/cache/actiontext-6.0.3.5.gem deleted file mode 100644 index e45880f9f..000000000 Binary files a/vendor/cache/actiontext-6.0.3.5.gem and /dev/null differ diff --git a/vendor/cache/actiontext-6.1.3.1.gem b/vendor/cache/actiontext-6.1.3.1.gem new file mode 100644 index 000000000..47499de1c Binary files /dev/null and b/vendor/cache/actiontext-6.1.3.1.gem differ diff --git a/vendor/cache/actionview-6.0.3.5.gem b/vendor/cache/actionview-6.0.3.5.gem deleted file mode 100644 index 37d0c8788..000000000 Binary files a/vendor/cache/actionview-6.0.3.5.gem and /dev/null differ diff --git a/vendor/cache/actionview-6.1.3.1.gem b/vendor/cache/actionview-6.1.3.1.gem new file mode 100644 index 000000000..7e30b6abe Binary files /dev/null and b/vendor/cache/actionview-6.1.3.1.gem differ diff --git a/vendor/cache/activejob-6.0.3.5.gem b/vendor/cache/activejob-6.0.3.5.gem deleted file mode 100644 index f98289308..000000000 Binary files a/vendor/cache/activejob-6.0.3.5.gem and /dev/null differ diff --git a/vendor/cache/activejob-6.1.3.1.gem b/vendor/cache/activejob-6.1.3.1.gem new file mode 100644 index 000000000..a4f488218 Binary files /dev/null and b/vendor/cache/activejob-6.1.3.1.gem differ diff --git a/vendor/cache/activemodel-6.0.3.5.gem b/vendor/cache/activemodel-6.0.3.5.gem deleted file mode 100644 index b2a161037..000000000 Binary files a/vendor/cache/activemodel-6.0.3.5.gem and /dev/null differ diff --git a/vendor/cache/activemodel-6.1.3.1.gem b/vendor/cache/activemodel-6.1.3.1.gem new file mode 100644 index 000000000..c48d8ccff Binary files /dev/null and b/vendor/cache/activemodel-6.1.3.1.gem differ diff --git a/vendor/cache/activerecord-6.0.3.5.gem b/vendor/cache/activerecord-6.0.3.5.gem deleted file mode 100644 index 55ea24305..000000000 Binary files a/vendor/cache/activerecord-6.0.3.5.gem and /dev/null differ diff --git a/vendor/cache/activerecord-6.1.3.1.gem b/vendor/cache/activerecord-6.1.3.1.gem new file mode 100644 index 000000000..c2b4ebd49 Binary files /dev/null and b/vendor/cache/activerecord-6.1.3.1.gem differ diff --git a/vendor/cache/activestorage-6.0.3.5.gem b/vendor/cache/activestorage-6.0.3.5.gem deleted file mode 100644 index 7f57fd850..000000000 Binary files a/vendor/cache/activestorage-6.0.3.5.gem and /dev/null differ diff --git a/vendor/cache/activestorage-6.1.3.1.gem b/vendor/cache/activestorage-6.1.3.1.gem new file mode 100644 index 000000000..d6fc44e4d Binary files /dev/null and b/vendor/cache/activestorage-6.1.3.1.gem differ diff --git a/vendor/cache/activesupport-6.0.3.5.gem b/vendor/cache/activesupport-6.0.3.5.gem deleted file mode 100644 index 202a17d35..000000000 Binary files a/vendor/cache/activesupport-6.0.3.5.gem and /dev/null differ diff --git a/vendor/cache/activesupport-6.1.3.1.gem b/vendor/cache/activesupport-6.1.3.1.gem new file mode 100644 index 000000000..ba77d4d28 Binary files /dev/null and b/vendor/cache/activesupport-6.1.3.1.gem differ diff --git a/vendor/cache/acts_as_follower-06393d3693a1/acts_as_follower.gemspec b/vendor/cache/acts_as_follower-06393d3693a1/acts_as_follower.gemspec index 675c15b3e..58e044f2d 100644 --- a/vendor/cache/acts_as_follower-06393d3693a1/acts_as_follower.gemspec +++ b/vendor/cache/acts_as_follower-06393d3693a1/acts_as_follower.gemspec @@ -8,7 +8,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= s.require_paths = ["lib".freeze] s.authors = ["Tom Cocca".freeze] - s.date = "2021-01-02" + s.date = "2021-03-31" s.description = "acts_as_follower is a Rubygem to allow any model to follow any other model. This is accomplished through a double polymorphic relationship on the Follow model. There is also built in support for blocking/un-blocking follow records. Main uses would be for Users to follow other Users or for Users to follow Books, etc\u2026 (Basically, to develop the type of follow system that GitHub has)".freeze s.email = ["tom dot cocca at gmail dot com".freeze] s.files = [".gitignore".freeze, ".travis.yml".freeze, "Gemfile".freeze, "MIT-LICENSE".freeze, "README.rdoc".freeze, "Rakefile".freeze, "acts_as_follower.gemspec".freeze, "init.rb".freeze, "lib/acts_as_follower.rb".freeze, "lib/acts_as_follower/follow_scopes.rb".freeze, "lib/acts_as_follower/followable.rb".freeze, "lib/acts_as_follower/follower.rb".freeze, "lib/acts_as_follower/follower_lib.rb".freeze, "lib/acts_as_follower/railtie.rb".freeze, "lib/acts_as_follower/version.rb".freeze, "lib/generators/USAGE".freeze, "lib/generators/acts_as_follower_generator.rb".freeze, "lib/generators/templates/migration.rb".freeze, "lib/generators/templates/model.rb".freeze, "test/README".freeze, "test/acts_as_followable_test.rb".freeze, "test/acts_as_follower_test.rb".freeze, "test/dummy30/Gemfile".freeze, "test/dummy30/Rakefile".freeze, "test/dummy30/app/models/application_record.rb".freeze, "test/dummy30/app/models/band.rb".freeze, "test/dummy30/app/models/band/punk.rb".freeze, "test/dummy30/app/models/band/punk/pop_punk.rb".freeze, "test/dummy30/app/models/custom_record.rb".freeze, "test/dummy30/app/models/some.rb".freeze, "test/dummy30/app/models/user.rb".freeze, "test/dummy30/config.ru".freeze, "test/dummy30/config/application.rb".freeze, "test/dummy30/config/boot.rb".freeze, "test/dummy30/config/database.yml".freeze, "test/dummy30/config/environment.rb".freeze, "test/dummy30/config/environments/development.rb".freeze, "test/dummy30/config/environments/test.rb".freeze, "test/dummy30/config/initializers/backtrace_silencers.rb".freeze, "test/dummy30/config/initializers/inflections.rb".freeze, "test/dummy30/config/initializers/secret_token.rb".freeze, "test/dummy30/config/initializers/session_store.rb".freeze, "test/dummy30/config/locales/en.yml".freeze, "test/dummy30/config/routes.rb".freeze, "test/factories/bands.rb".freeze, "test/factories/somes.rb".freeze, "test/factories/users.rb".freeze, "test/follow_test.rb".freeze, "test/schema.rb".freeze, "test/test_helper.rb".freeze] diff --git a/vendor/cache/ahoy_email-1.1.0.gem b/vendor/cache/ahoy_email-1.1.0.gem deleted file mode 100644 index d0a499592..000000000 Binary files a/vendor/cache/ahoy_email-1.1.0.gem and /dev/null differ diff --git a/vendor/cache/ahoy_email-1.1.1.gem b/vendor/cache/ahoy_email-1.1.1.gem new file mode 100644 index 000000000..06bfc06c2 Binary files /dev/null and b/vendor/cache/ahoy_email-1.1.1.gem differ diff --git a/vendor/cache/better_html-1.0.15.gem b/vendor/cache/better_html-1.0.15.gem deleted file mode 100644 index 92dc0f2db..000000000 Binary files a/vendor/cache/better_html-1.0.15.gem and /dev/null differ diff --git a/vendor/cache/better_html-1.0.16.gem b/vendor/cache/better_html-1.0.16.gem new file mode 100644 index 000000000..bda1caa53 Binary files /dev/null and b/vendor/cache/better_html-1.0.16.gem differ diff --git a/vendor/cache/browser-5.2.0.gem b/vendor/cache/browser-5.2.0.gem deleted file mode 100644 index 100c7874d..000000000 Binary files a/vendor/cache/browser-5.2.0.gem and /dev/null differ diff --git a/vendor/cache/browser-5.3.1.gem b/vendor/cache/browser-5.3.1.gem new file mode 100644 index 000000000..1b0154dd5 Binary files /dev/null and b/vendor/cache/browser-5.3.1.gem differ diff --git a/vendor/cache/carrierwave-2.2.0.gem b/vendor/cache/carrierwave-2.2.0.gem deleted file mode 100644 index 1d000086f..000000000 Binary files a/vendor/cache/carrierwave-2.2.0.gem and /dev/null differ diff --git a/vendor/cache/carrierwave-2.2.1.gem b/vendor/cache/carrierwave-2.2.1.gem new file mode 100644 index 000000000..016a686d4 Binary files /dev/null and b/vendor/cache/carrierwave-2.2.1.gem differ diff --git a/vendor/cache/dead_end-1.1.4.gem b/vendor/cache/dead_end-1.1.4.gem deleted file mode 100644 index 05943131b..000000000 Binary files a/vendor/cache/dead_end-1.1.4.gem and /dev/null differ diff --git a/vendor/cache/dead_end-1.1.6.gem b/vendor/cache/dead_end-1.1.6.gem new file mode 100644 index 000000000..aa2ab113e Binary files /dev/null and b/vendor/cache/dead_end-1.1.6.gem differ diff --git a/vendor/cache/debug_inspector-0.0.3.gem b/vendor/cache/debug_inspector-0.0.3.gem deleted file mode 100644 index ea61fce65..000000000 Binary files a/vendor/cache/debug_inspector-0.0.3.gem and /dev/null differ diff --git a/vendor/cache/debug_inspector-1.1.0.gem b/vendor/cache/debug_inspector-1.1.0.gem new file mode 100644 index 000000000..c16993e82 Binary files /dev/null and b/vendor/cache/debug_inspector-1.1.0.gem differ diff --git a/vendor/cache/devise-0cd72a56f984/devise.gemspec b/vendor/cache/devise-0cd72a56f984/devise.gemspec index d072e03d5..b21afef14 100644 --- a/vendor/cache/devise-0cd72a56f984/devise.gemspec +++ b/vendor/cache/devise-0cd72a56f984/devise.gemspec @@ -8,7 +8,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= s.require_paths = ["lib".freeze] s.authors = ["Jos\u00E9 Valim".freeze, "Carlos Ant\u00F4nio".freeze] - s.date = "2021-02-18" + s.date = "2021-03-31" s.description = "Flexible authentication solution for Rails with Warden".freeze s.email = "heartcombo@googlegroups.com".freeze s.files = ["CHANGELOG.md".freeze, "MIT-LICENSE".freeze, "README.md".freeze, "app/controllers/devise".freeze, "app/controllers/devise/confirmations_controller.rb".freeze, "app/controllers/devise/omniauth_callbacks_controller.rb".freeze, "app/controllers/devise/passwords_controller.rb".freeze, "app/controllers/devise/registrations_controller.rb".freeze, "app/controllers/devise/sessions_controller.rb".freeze, "app/controllers/devise/unlocks_controller.rb".freeze, "app/controllers/devise_controller.rb".freeze, "app/helpers/devise_helper.rb".freeze, "app/mailers/devise".freeze, "app/mailers/devise/mailer.rb".freeze, "app/views/devise/confirmations/new.html.erb".freeze, "app/views/devise/mailer/confirmation_instructions.html.erb".freeze, "app/views/devise/mailer/email_changed.html.erb".freeze, "app/views/devise/mailer/password_change.html.erb".freeze, "app/views/devise/mailer/reset_password_instructions.html.erb".freeze, "app/views/devise/mailer/unlock_instructions.html.erb".freeze, "app/views/devise/passwords/edit.html.erb".freeze, "app/views/devise/passwords/new.html.erb".freeze, "app/views/devise/registrations/edit.html.erb".freeze, "app/views/devise/registrations/new.html.erb".freeze, "app/views/devise/sessions/new.html.erb".freeze, "app/views/devise/shared/_error_messages.html.erb".freeze, "app/views/devise/shared/_links.html.erb".freeze, "app/views/devise/unlocks/new.html.erb".freeze, "config/locales/en.yml".freeze, "lib/devise".freeze, "lib/devise.rb".freeze, "lib/devise/controllers".freeze, "lib/devise/controllers/helpers.rb".freeze, "lib/devise/controllers/rememberable.rb".freeze, "lib/devise/controllers/scoped_views.rb".freeze, "lib/devise/controllers/sign_in_out.rb".freeze, "lib/devise/controllers/store_location.rb".freeze, "lib/devise/controllers/url_helpers.rb".freeze, "lib/devise/delegator.rb".freeze, "lib/devise/encryptor.rb".freeze, "lib/devise/failure_app.rb".freeze, "lib/devise/hooks".freeze, "lib/devise/hooks/activatable.rb".freeze, "lib/devise/hooks/csrf_cleaner.rb".freeze, "lib/devise/hooks/forgetable.rb".freeze, "lib/devise/hooks/lockable.rb".freeze, "lib/devise/hooks/proxy.rb".freeze, "lib/devise/hooks/rememberable.rb".freeze, "lib/devise/hooks/timeoutable.rb".freeze, "lib/devise/hooks/trackable.rb".freeze, "lib/devise/mailers".freeze, "lib/devise/mailers/helpers.rb".freeze, "lib/devise/mapping.rb".freeze, "lib/devise/models".freeze, "lib/devise/models.rb".freeze, "lib/devise/models/authenticatable.rb".freeze, "lib/devise/models/confirmable.rb".freeze, "lib/devise/models/database_authenticatable.rb".freeze, "lib/devise/models/lockable.rb".freeze, "lib/devise/models/omniauthable.rb".freeze, "lib/devise/models/recoverable.rb".freeze, "lib/devise/models/registerable.rb".freeze, "lib/devise/models/rememberable.rb".freeze, "lib/devise/models/timeoutable.rb".freeze, "lib/devise/models/trackable.rb".freeze, "lib/devise/models/validatable.rb".freeze, "lib/devise/modules.rb".freeze, "lib/devise/omniauth".freeze, "lib/devise/omniauth.rb".freeze, "lib/devise/omniauth/config.rb".freeze, "lib/devise/omniauth/url_helpers.rb".freeze, "lib/devise/orm".freeze, "lib/devise/orm/active_record.rb".freeze, "lib/devise/orm/mongoid.rb".freeze, "lib/devise/parameter_filter.rb".freeze, "lib/devise/parameter_sanitizer.rb".freeze, "lib/devise/rails".freeze, "lib/devise/rails.rb".freeze, "lib/devise/rails/deprecated_constant_accessor.rb".freeze, "lib/devise/rails/routes.rb".freeze, "lib/devise/rails/warden_compat.rb".freeze, "lib/devise/secret_key_finder.rb".freeze, "lib/devise/strategies".freeze, "lib/devise/strategies/authenticatable.rb".freeze, "lib/devise/strategies/base.rb".freeze, "lib/devise/strategies/database_authenticatable.rb".freeze, "lib/devise/strategies/rememberable.rb".freeze, "lib/devise/test".freeze, "lib/devise/test/controller_helpers.rb".freeze, "lib/devise/test/integration_helpers.rb".freeze, "lib/devise/test_helpers.rb".freeze, "lib/devise/time_inflector.rb".freeze, "lib/devise/token_generator.rb".freeze, "lib/devise/version.rb".freeze, "lib/generators/active_record".freeze, "lib/generators/active_record/devise_generator.rb".freeze, "lib/generators/active_record/templates".freeze, "lib/generators/active_record/templates/migration.rb".freeze, "lib/generators/active_record/templates/migration_existing.rb".freeze, "lib/generators/devise".freeze, "lib/generators/devise/controllers_generator.rb".freeze, "lib/generators/devise/devise_generator.rb".freeze, "lib/generators/devise/install_generator.rb".freeze, "lib/generators/devise/orm_helpers.rb".freeze, "lib/generators/devise/views_generator.rb".freeze, "lib/generators/mongoid".freeze, "lib/generators/mongoid/devise_generator.rb".freeze, "lib/generators/templates".freeze, "lib/generators/templates/README".freeze, "lib/generators/templates/controllers".freeze, "lib/generators/templates/controllers/README".freeze, "lib/generators/templates/controllers/confirmations_controller.rb".freeze, "lib/generators/templates/controllers/omniauth_callbacks_controller.rb".freeze, "lib/generators/templates/controllers/passwords_controller.rb".freeze, "lib/generators/templates/controllers/registrations_controller.rb".freeze, "lib/generators/templates/controllers/sessions_controller.rb".freeze, "lib/generators/templates/controllers/unlocks_controller.rb".freeze, "lib/generators/templates/devise.rb".freeze, "lib/generators/templates/markerb".freeze, "lib/generators/templates/markerb/confirmation_instructions.markerb".freeze, "lib/generators/templates/markerb/email_changed.markerb".freeze, "lib/generators/templates/markerb/password_change.markerb".freeze, "lib/generators/templates/markerb/reset_password_instructions.markerb".freeze, "lib/generators/templates/markerb/unlock_instructions.markerb".freeze, "lib/generators/templates/simple_form_for".freeze, "lib/generators/templates/simple_form_for/confirmations".freeze, "lib/generators/templates/simple_form_for/confirmations/new.html.erb".freeze, "lib/generators/templates/simple_form_for/passwords".freeze, "lib/generators/templates/simple_form_for/passwords/edit.html.erb".freeze, "lib/generators/templates/simple_form_for/passwords/new.html.erb".freeze, "lib/generators/templates/simple_form_for/registrations".freeze, "lib/generators/templates/simple_form_for/registrations/edit.html.erb".freeze, "lib/generators/templates/simple_form_for/registrations/new.html.erb".freeze, "lib/generators/templates/simple_form_for/sessions".freeze, "lib/generators/templates/simple_form_for/sessions/new.html.erb".freeze, "lib/generators/templates/simple_form_for/unlocks".freeze, "lib/generators/templates/simple_form_for/unlocks/new.html.erb".freeze] diff --git a/vendor/cache/docile-1.3.4.gem b/vendor/cache/docile-1.3.4.gem deleted file mode 100644 index 57b96c014..000000000 Binary files a/vendor/cache/docile-1.3.4.gem and /dev/null differ diff --git a/vendor/cache/docile-1.3.5.gem b/vendor/cache/docile-1.3.5.gem new file mode 100644 index 000000000..89fe679ea Binary files /dev/null and b/vendor/cache/docile-1.3.5.gem differ diff --git a/vendor/cache/dogstatsd-ruby-4.8.3.gem b/vendor/cache/dogstatsd-ruby-4.8.3.gem deleted file mode 100644 index 3126d0953..000000000 Binary files a/vendor/cache/dogstatsd-ruby-4.8.3.gem and /dev/null differ diff --git a/vendor/cache/dogstatsd-ruby-4.9.0.gem b/vendor/cache/dogstatsd-ruby-4.9.0.gem new file mode 100644 index 000000000..90aac9d16 Binary files /dev/null and b/vendor/cache/dogstatsd-ruby-4.9.0.gem differ diff --git a/vendor/cache/erb-lint-05596ea189ee/.bundlecache b/vendor/cache/erb-lint-05596ea189ee/.bundlecache deleted file mode 100644 index e69de29bb..000000000 diff --git a/vendor/cache/erb-lint-05596ea189ee/.gitignore b/vendor/cache/erb-lint-05596ea189ee/.gitignore deleted file mode 100644 index 37a035835..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -# Gem files -*.gem - -# DS_Store -.DS_Store - -# Bundle configs -.bundle - -.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml - -gemfiles/Gemfile*.lock diff --git a/vendor/cache/erb-lint-05596ea189ee/.rspec b/vendor/cache/erb-lint-05596ea189ee/.rspec deleted file mode 100644 index 16f9cdb01..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/.rspec +++ /dev/null @@ -1,2 +0,0 @@ ---color ---format documentation diff --git a/vendor/cache/erb-lint-05596ea189ee/.rubocop.yml b/vendor/cache/erb-lint-05596ea189ee/.rubocop.yml deleted file mode 100644 index a01e86650..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/.rubocop.yml +++ /dev/null @@ -1,9 +0,0 @@ -inherit_gem: - rubocop-shopify: rubocop.yml - -AllCops: - TargetRubyVersion: 2.5 - Exclude: - - 'vendor/**/*' - - 'gemfiles/vendor/**/*' - DisplayCopNames: true diff --git a/vendor/cache/erb-lint-05596ea189ee/.travis.yml b/vendor/cache/erb-lint-05596ea189ee/.travis.yml deleted file mode 100644 index daa4f9aa3..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: ruby -cache: bundler -rvm: - - 2.5 - - 2.6 - - 2.7 -gemfile: -- gemfiles/Gemfile.rubocop-old -- gemfiles/Gemfile.rubocop-next -script: - - bundle exec rspec spec - - bundle exec rubocop diff --git a/vendor/cache/erb-lint-05596ea189ee/Gemfile b/vendor/cache/erb-lint-05596ea189ee/Gemfile deleted file mode 100644 index feca8c52b..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/Gemfile +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'activesupport', '~> 5.1' -gem 'rake' - -group 'test' do - gem 'fakefs' -end - -gemspec diff --git a/vendor/cache/erb-lint-05596ea189ee/Gemfile.lock b/vendor/cache/erb-lint-05596ea189ee/Gemfile.lock deleted file mode 100644 index 8344e3c3f..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/Gemfile.lock +++ /dev/null @@ -1,105 +0,0 @@ -PATH - remote: . - specs: - erb_lint (0.0.35) - activesupport - better_html (~> 1.0.7) - html_tokenizer - parser (>= 2.7.1.4) - rainbow - rubocop - smart_properties - -GEM - remote: https://rubygems.org/ - specs: - actionview (5.2.4.1) - activesupport (= 5.2.4.1) - builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activesupport (5.2.4.1) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - ast (2.4.1) - better_html (1.0.15) - actionview (>= 4.0) - activesupport (>= 4.0) - ast (~> 2.0) - erubi (~> 1.4) - html_tokenizer (~> 0.0.6) - parser (>= 2.4) - smart_properties - builder (3.2.4) - concurrent-ruby (1.1.5) - crass (1.0.6) - diff-lcs (1.3) - erubi (1.10.0) - fakefs (1.0.0) - html_tokenizer (0.0.7) - i18n (1.8.1) - concurrent-ruby (~> 1.0) - jaro_winkler (1.5.4) - loofah (2.7.0) - crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mini_portile2 (2.4.0) - minitest (5.13.0) - nokogiri (1.10.10) - mini_portile2 (~> 2.4.0) - parallel (1.19.1) - parser (2.7.1.4) - ast (~> 2.4.1) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) - nokogiri (>= 1.6) - rails-html-sanitizer (1.3.0) - loofah (~> 2.3) - rainbow (3.0.0) - rake (13.0.1) - rspec (3.9.0) - rspec-core (~> 3.9.0) - rspec-expectations (~> 3.9.0) - rspec-mocks (~> 3.9.0) - rspec-core (3.9.1) - rspec-support (~> 3.9.1) - rspec-expectations (3.9.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-mocks (3.9.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-support (3.9.2) - rubocop (0.79.0) - jaro_winkler (~> 1.5.1) - parallel (~> 1.10) - parser (>= 2.7.0.1) - rainbow (>= 2.2.2, < 4.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.7) - rubocop-shopify (1.0.0) - rubocop (>= 0.78.0) - ruby-progressbar (1.10.1) - smart_properties (1.15.0) - thread_safe (0.3.6) - tzinfo (1.2.6) - thread_safe (~> 0.1) - unicode-display_width (1.6.0) - -PLATFORMS - ruby - -DEPENDENCIES - activesupport (~> 5.1) - erb_lint! - fakefs - rake - rspec - rubocop - rubocop-shopify - -BUNDLED WITH - 1.17.3 diff --git a/vendor/cache/erb-lint-05596ea189ee/LICENSE.txt b/vendor/cache/erb-lint-05596ea189ee/LICENSE.txt deleted file mode 100644 index eb64fec72..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/LICENSE.txt +++ /dev/null @@ -1,8 +0,0 @@ -Copyright (c) 2016 Justin Chan - - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/cache/erb-lint-05596ea189ee/README.md b/vendor/cache/erb-lint-05596ea189ee/README.md deleted file mode 100644 index d8396fbc1..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/README.md +++ /dev/null @@ -1,522 +0,0 @@ -# ERB Lint [![Build Status](https://travis-ci.org/Shopify/erb-lint.svg?branch=master)](https://travis-ci.org/Shopify/erb-lint) - -`erb-lint` is a tool to help lint your ERB or HTML files using the included linters or by writing your own. - -## Requirements - -* Ruby 2.3.0+ - - This is due to use of the safe navigation operator (`&.`) - - This is also due to the use of the tilde-heredoc `<<~` syntax in some tests. - -## Installation - -```bash -gem install erb_lint -``` - -...or add the following to your `Gemfile` and run `bundle install`: - -```ruby -gem 'erb_lint', require: false -``` - -## Configuration - -Create a `.erb-lint.yml` file in your project, with the following structure: - -```yaml ---- -EnableDefaultLinters: true -linters: - ErbSafety: - enabled: true - better_html_config: .better-html.yml - Rubocop: - enabled: true - rubocop_config: - inherit_from: - - .rubocop.yml -``` - -See below for linter-specific configuration options. - -## Usage - -This gem provides a command-line interface which can be run like so: - -1. Run `erblint [options]` if the gem is installed standalone. -2. Run `bundle exec erblint [options]` if the gem is installed as a Gemfile dependency for your app. - -For example, `erblint --lint-all --enable-all-linters` will run all available -linters on all ERB files in the current directory or its descendants (`**/*.html{+*,}.erb`). - -If you want to change the glob that is used, you can configure it by adding it to your config file as follows: - -```yaml ---- -glob: "**/*.{html,text,js}{+*,}.erb" -linters: - ErbSafety: - enabled: true - better_html_config: .better-html.yml - Rubocop: - enabled: true - rubocop_config: - inherit_from: - - .rubocop.yml -``` - -## Enable or disable default linters -`EnableDefaultLinters`: enables or disables default linters. [Default linters](#Linters) are enabled by default. - -## Linters - -| Available Linters | Default | Description | -| ------------------------------------------------ |:--------:|-------------| -| [AllowedScriptType](#AllowedScriptType) | Yes | prevents the addition of ` - -Allowed ✅ - -``` - -Example configuration: - -```yaml ---- -linters: - ErbSafety: - enabled: true - better_html_config: .better-html.yml -``` - -Linter-Specific Option | Description ------------------------|--------------------------------------------------------- -`better_html_config` | Name of the configuration file to use for `better-html`. Optional. Valid options and their defaults are described [in better-html's readme](https://github.com/Shopify/better-html#configuration). - -### Rubocop - -Runs RuboCop on all ruby statements found in ERB templates. The RuboCop configuration that `erb-lint` uses can inherit from -the configuration that the rest of your application uses. `erb-lint` can be configured independently however, as it will often -be necessary to disable specific RuboCop rules that do not apply to ERB files. - -**Note**: Each ruby statement (between ERB tags `<% ... %>`) is parsed and analyzed independently of each other. Any rule that requires a broader context can trigger false positives (e.g. `Lint/UselessAssignment` will complaint for an assignment even if used in a subsequent ERB tag). - -Example configuration: - -```yaml ---- -linters: - Rubocop: - enabled: true - rubocop_config: - inherit_from: - - .rubocop.yml - Layout/InitialIndentation: - Enabled: false - Layout/TrailingEmptyLines: - Enabled: false - Layout/TrailingWhitespace: - Enabled: false - Naming/FileName: - Enabled: false - Style/FrozenStringLiteralComment: - Enabled: false - Metrics/LineLength: - Enabled: false - Lint/UselessAssignment: - Enabled: false - Rails/OutputSafety: - Enabled: false -``` - -The cops disabled in the example configuration above provide a good starting point. - -Linter-Specific Option | Description ------------------------|--------------------------------------------------------- -`rubocop_config` | A valid rubocop configuration hash. Mandatory when this cop is enabled. See [rubocop's manual entry on Configuration](http://rubocop.readthedocs.io/en/latest/configuration/) -`only` | Only run cops listed in this array instead of all cops. - -### RightTrim - -Trimming at the right of an ERB tag can be done with either `=%>` or `-%>`, this linter enforces one of these two styles. - -Example configuration: - -```yaml ---- -linters: - RightTrim: - enabled: true - enforced_style: '-' -``` - -Linter-Specific Option | Description ------------------------|--------------------------------------------------------- -`enforced_style` | Which style to enforce, can be either `-` or `=`. Optional. Defaults to `-`. - -### SpaceAroundErbTag - -Enforce a single space after `<%` and before `%>` in the ERB source. -This linter ignores opening ERB tags (`<%`) that are followed by a newline, -and closing ERB tags (`%>`) that are preceded by a newline. - - -```erb -Bad ❌ -<%foo%> -<%=foo-%> - -Good ✅ -<% foo %> - -<% - foo -%> -``` - -Example configuration: - -```yaml ---- -linters: - SpaceAroundErbTag: - enabled: true -``` - -### NoJavascriptTagHelper - -This linter prevents the usage of -Rails' [`javascript_tag`](https://apidock.com/rails/ActionView/Helpers/JavaScriptHelper/javascript_tag) -helper in ERB templates. - -The html parser used in this gem knows not to look for html tags within certain other tags -like `script`, `style`, and others. The html parser does this to avoid confusing javascript -expressions like `if (11)` for a malformed html tag. Using the `javascript_tag` in -a ERB template prevents the parser from recognizing the change of parsing context and may -fail or produce erroneous output as a result. - -```erb -Bad ❌ -<%= javascript_tag(content, defer: true) %> -Good ✅ - - -Bad ❌ -<%= javascript_tag do %> - alert(1) -<% end %> -Good ✅ - -``` - -The autocorrection rule adds `//` markers to the existing script, as this is the default -behavior for `javascript_tag`. This can be disabled by changing the `correction_style` linter option -from `cdata` to `plain`. - -Example configuration: - -```yaml ---- -linters: - NoJavascriptTagHelper: - enabled: true - correction_style: 'plain' -``` - -Linter-Specific Option | Description ------------------------|--------------------------------------------------------- -`correction_style` | When configured with `cdata`, adds CDATA markers. When configured with `plain`, don't add makers. Defaults to `cdata`. - -### SelfClosingTag - -This linter enforces self closing tag styles for void elements. - -The void elements are `area`, `base`, `br`, `col`, `embed`, `hr`, `img`, `input`, `keygen`, `link`, `menuitem`, `meta`, `param`, `source`, `track`, and `wbr`. - -If `enforced_style` is set to `always` (XHTML style): - -```erb -Bad ❌ - -Good ✅ -Some Image -``` - -If `enforced_style` is set to `never` (HTML5 style): -```erb -Bad ❌ -
-Good ✅ - -``` - -Example configuration: - -```yaml ---- -linters: - SelfClosingTag: - enabled: true - enforced_style: 'always' -``` - -Linter-Specific Option | Description ------------------------|--------------------------------------------------------- -`enforced_style` | If we should `always` or `never` expect self closing tags for void elements. Defaults to `never`. - -### AllowedScriptType - -This linter prevent the addition of ` -Good ✅ - -``` - -By default, this linter allows the `type` attribute to be omitted, as the behavior in browsers is to -consider `" - end_content = "\n//]]>\n" + end_content if @config.correction_style == :cdata - corrector.replace(end_node.loc, end_content) - elsif script_content - script_content = "\n//\n" if @config.correction_style == :cdata - corrector.replace(begin_node.loc, - "#{script_content}") - end - rescue Utils::RubyToERB::Error, Utils::BlockMap::ParseError - nil - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/parser_errors.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/parser_errors.rb deleted file mode 100644 index 78de498ca..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/parser_errors.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -module ERBLint - module Linters - class ParserErrors < Linter - include LinterRegistry - - def run(processed_source) - processed_source.parser.parser_errors.each do |error| - add_offense( - error.loc, - "#{error.message} (at #{error.loc.source})" - ) - end - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/right_trim.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/right_trim.rb deleted file mode 100644 index 63a89da52..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/right_trim.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -module ERBLint - module Linters - # In ERB, right trim can be either =%> or -%> - # this linter will force one or the other. - class RightTrim < Linter - include LinterRegistry - - class ConfigSchema < LinterConfig - property :enforced_style, accepts: ['-', '='], default: '-' - end - self.config_schema = ConfigSchema - - def run(processed_source) - processed_source.ast.descendants(:erb).each do |erb_node| - _, _, _, trim_node = *erb_node - next if trim_node.nil? || trim_node.loc.source == @config.enforced_style - - add_offense( - trim_node.loc, - "Prefer #{@config.enforced_style}%> instead of #{trim_node.loc.source}%> for trimming on the right." - ) - end - end - - def autocorrect(_processed_source, offense) - lambda do |corrector| - corrector.replace(offense.source_range, @config.enforced_style) - end - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/rubocop.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/rubocop.rb deleted file mode 100644 index 25e0de081..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/rubocop.rb +++ /dev/null @@ -1,198 +0,0 @@ -# frozen_string_literal: true - -require 'better_html' -require 'tempfile' -require 'erb_lint/utils/offset_corrector' - -module ERBLint - module Linters - # Run selected rubocop cops on Ruby code - class Rubocop < Linter - include LinterRegistry - - class ConfigSchema < LinterConfig - property :only, accepts: array_of?(String) - property :rubocop_config, accepts: Hash, default: -> { {} } - end - - self.config_schema = ConfigSchema - - SUFFIX_EXPR = /[[:blank:]]*\Z/ - # copied from Rails: action_view/template/handlers/erb/erubi.rb - BLOCK_EXPR = /\s*((\s+|\))do|\{)(\s*\|[^|]*\|)?\s*\Z/ - - def initialize(file_loader, config) - super - @only_cops = @config.only - custom_config = config_from_hash(@config.rubocop_config) - @rubocop_config = ::RuboCop::ConfigLoader.merge_with_default(custom_config, '') - end - - def run(processed_source) - descendant_nodes(processed_source).each do |erb_node| - inspect_content(processed_source, erb_node) - end - end - - if ::RuboCop::Version::STRING.to_f >= 0.87 - def autocorrect(_processed_source, offense) - return unless offense.context - rubocop_correction = offense.context[:rubocop_correction] - return unless rubocop_correction - - lambda do |corrector| - corrector.import!(rubocop_correction, offset: offense.context[:offset]) - end - end - else - def autocorrect(processed_source, offense) - return unless offense.context - - lambda do |corrector| - passthrough = Utils::OffsetCorrector.new( - processed_source, - corrector, - offense.context[:offset], - offense.context[:bound_range], - ) - offense.context[:rubocop_correction].call(passthrough) - end - end - end - - private - - def descendant_nodes(processed_source) - processed_source.ast.descendants(:erb) - end - - def inspect_content(processed_source, erb_node) - indicator, _, code_node, = *erb_node - return if indicator&.children&.first == '#' - - original_source = code_node.loc.source - trimmed_source = original_source.sub(BLOCK_EXPR, '').sub(SUFFIX_EXPR, '') - alignment_column = code_node.loc.column - offset = code_node.loc.begin_pos - alignment_column - aligned_source = "#{' ' * alignment_column}#{trimmed_source}" - - source = rubocop_processed_source(aligned_source, processed_source.filename) - return unless source.valid_syntax? - - activate_team(processed_source, source, offset, code_node, build_team) - end - - if ::RuboCop::Version::STRING.to_f >= 0.87 - def activate_team(processed_source, source, offset, code_node, team) - report = team.investigate(source) - report.offenses.each do |rubocop_offense| - next if rubocop_offense.disabled? - - correction = rubocop_offense.corrector if rubocop_offense.corrected? - - offense_range = processed_source - .to_source_range(rubocop_offense.location) - .offset(offset) - - add_offense(rubocop_offense, offense_range, correction, offset, code_node.loc.range) - end - end - else - def activate_team(processed_source, source, offset, code_node, team) - team.inspect_file(source) - team.cops.each do |cop| - correction_offset = 0 - cop.offenses.reject(&:disabled?).each do |rubocop_offense| - if rubocop_offense.corrected? - correction = cop.corrections[correction_offset] - correction_offset += 1 - end - - offense_range = processed_source - .to_source_range(rubocop_offense.location) - .offset(offset) - - add_offense(rubocop_offense, offense_range, correction, offset, code_node.loc.range) - end - end - end - end - - def tempfile_from(filename, content) - Tempfile.create(File.basename(filename), Dir.pwd) do |tempfile| - tempfile.write(content) - tempfile.rewind - - yield(tempfile) - end - end - - def rubocop_processed_source(content, filename) - ::RuboCop::ProcessedSource.new( - content, - @rubocop_config.target_ruby_version, - filename - ) - end - - def cop_classes - if @only_cops.present? - selected_cops = ::RuboCop::Cop::Cop.all.select { |cop| cop.match?(@only_cops) } - ::RuboCop::Cop::Registry.new(selected_cops) - else - ::RuboCop::Cop::Registry.new(::RuboCop::Cop::Cop.all) - end - end - - def build_team - ::RuboCop::Cop::Team.new( - cop_classes, - @rubocop_config, - extra_details: true, - display_cop_names: true, - auto_correct: true, - stdin: "", - ) - end - - def config_from_hash(hash) - inherit_from = hash&.delete('inherit_from') - resolve_inheritance(hash, inherit_from) - - tempfile_from('.erblint-rubocop', hash.to_yaml) do |tempfile| - ::RuboCop::ConfigLoader.load_file(tempfile.path) - end - end - - def resolve_inheritance(hash, inherit_from) - base_configs(inherit_from) - .reverse_each do |base_config| - base_config.each do |k, v| - hash[k] = hash.key?(k) ? ::RuboCop::ConfigLoader.merge(v, hash[k]) : v if v.is_a?(Hash) - end - end - end - - def base_configs(inherit_from) - regex = URI::DEFAULT_PARSER.make_regexp(%w(http https)) - configs = Array(inherit_from).compact.map do |base_name| - if base_name =~ /\A#{regex}\z/ - ::RuboCop::ConfigLoader.load_file(::RuboCop::RemoteConfig.new(base_name, Dir.pwd)) - else - config_from_hash(@file_loader.yaml(base_name)) - end - end - - configs.compact - end - - def add_offense(rubocop_offense, offense_range, correction, offset, bound_range) - context = if rubocop_offense.corrected? - { rubocop_correction: correction, offset: offset, bound_range: bound_range } - end - - super(offense_range, rubocop_offense.message.strip, context) - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/rubocop_text.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/rubocop_text.rb deleted file mode 100644 index 768134bf5..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/rubocop_text.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -require_relative 'rubocop' - -module ERBLint - module Linters - class RubocopText < Rubocop - include LinterRegistry - - class ConfigSchema < LinterConfig - property :only, accepts: array_of?(String) - property :rubocop_config, accepts: Hash - end - - self.config_schema = ConfigSchema - - private - - def descendant_nodes(parser) - erb_nodes = [] - - parser.ast.descendants(:text).each do |text_node| - text_node.descendants(:erb).each do |erb_node| - erb_nodes << erb_node - end - end - erb_nodes - end - - def cop_classes - selected_cops = ::RuboCop::Cop::Cop.all.select { |cop| cop.match?(@only_cops) } - - ::RuboCop::Cop::Registry.new(selected_cops) - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/self_closing_tag.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/self_closing_tag.rb deleted file mode 100644 index 8f0648083..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/self_closing_tag.rb +++ /dev/null @@ -1,58 +0,0 @@ -# frozen_string_literal: true - -module ERBLint - module Linters - # Warns when a tag is not self-closed properly. - class SelfClosingTag < Linter - include LinterRegistry - - class ConfigSchema < LinterConfig - property :enforced_style, converts: :to_sym, accepts: [:always, :never], default: :never - end - self.config_schema = ConfigSchema - - SELF_CLOSING_TAGS = %w( - area base br col command embed hr input keygen - link menuitem meta param source track wbr img - ) - - def run(processed_source) - processed_source.ast.descendants(:tag).each do |tag_node| - tag = BetterHtml::Tree::Tag.from_node(tag_node) - next unless SELF_CLOSING_TAGS.include?(tag.name) - - if tag.closing? - start_solidus = tag_node.children.first - add_offense( - start_solidus.loc, - "Tag `#{tag.name}` is a void element, it must not start with ``.", - '/' - ) - end - - next unless @config.enforced_style == :never && tag.self_closing? - end_solidus = tag_node.children.last - add_offense( - end_solidus.loc, - "Tag `#{tag.name}` is a void element, it must end with `>` and not `/>`.", - '' - ) - end - end - - def autocorrect(_processed_source, offense) - lambda do |corrector| - corrector.replace(offense.source_range, offense.context) - end - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/space_around_erb_tag.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/space_around_erb_tag.rb deleted file mode 100644 index 7e4fe55f8..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/space_around_erb_tag.rb +++ /dev/null @@ -1,66 +0,0 @@ -# frozen_string_literal: true - -module ERBLint - module Linters - # Enforce a single space after `<%` and before `%>` in the erb source. - # This linter ignores opening erb tags (`<%`) that are followed by a newline, - # and closing erb tags (`%>`) that are preceeded by a newline. - class SpaceAroundErbTag < Linter - include LinterRegistry - - START_SPACES = /\A([[:space:]]*)/m - END_SPACES = /([[:space:]]*)\z/m - - def run(processed_source) - processed_source.ast.descendants(:erb).each do |erb_node| - indicator_node, ltrim, code_node, rtrim = *erb_node - indicator = indicator_node&.loc&.source - next if indicator == '#' || indicator == '%' - code = code_node.children.first - - start_spaces = code.match(START_SPACES)&.captures&.first || "" - if start_spaces.size != 1 && !start_spaces.include?("\n") - add_offense( - code_node.loc.resize(start_spaces.size), - "Use 1 space after `<%#{indicator}#{ltrim&.loc&.source}` "\ - "instead of #{start_spaces.size} space#{'s' if start_spaces.size > 1}.", - ' ' - ) - elsif start_spaces.count("\n") > 1 - lines = start_spaces.split("\n", -1) - add_offense( - code_node.loc.resize(start_spaces.size), - "Use 1 newline after `<%#{indicator&.loc&.source}#{ltrim&.loc&.source}` "\ - "instead of #{start_spaces.count("\n")}.", - "#{lines.first}\n#{lines.last}" - ) - end - - end_spaces = code.match(END_SPACES)&.captures&.first || "" - if end_spaces.size != 1 && !end_spaces.include?("\n") - add_offense( - code_node.loc.end.adjust(begin_pos: -end_spaces.size), - "Use 1 space before `#{rtrim&.loc&.source}%>` "\ - "instead of #{end_spaces.size} space#{'s' if start_spaces.size > 1}.", - ' ' - ) - elsif end_spaces.count("\n") > 1 - lines = end_spaces.split("\n", -1) - add_offense( - code_node.loc.end.adjust(begin_pos: -end_spaces.size), - "Use 1 newline before `#{rtrim&.loc&.source}%>` "\ - "instead of #{end_spaces.count("\n")}.", - "#{lines.first}\n#{lines.last}" - ) - end - end - end - - def autocorrect(_processed_source, offense) - lambda do |corrector| - corrector.replace(offense.source_range, offense.context) - end - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/space_in_html_tag.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/space_in_html_tag.rb deleted file mode 100644 index 6147f8afa..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/space_in_html_tag.rb +++ /dev/null @@ -1,111 +0,0 @@ -# frozen_string_literal: true - -module ERBLint - module Linters - # Detects extra or missing whitespace in html tags. - class SpaceInHtmlTag < Linter - include LinterRegistry - - def run(processed_source) - processed_source.ast.descendants(:tag).each do |tag_node| - start_solidus, name, attributes, end_solidus = *tag_node - - next_loc = name&.loc&.begin_pos || attributes&.loc&.begin_pos || - end_solidus&.loc&.begin_pos || (tag_node.loc.end_pos - 1) - if start_solidus - no_space(processed_source, (tag_node.loc.begin_pos + 1)...start_solidus.loc.begin_pos) - no_space(processed_source, start_solidus.loc.end_pos...next_loc) - else - no_space(processed_source, (tag_node.loc.begin_pos + 1)...next_loc) - end - - if attributes - single_space_or_newline(processed_source, name.loc.end_pos...attributes.loc.begin_pos) if name - process_attributes(processed_source, attributes) - end - - previous_loc = attributes&.loc&.end_pos || name&.loc&.end_pos || - start_solidus&.loc&.end_pos || (tag_node.loc.begin_pos + 1) - if end_solidus - single_space(processed_source, previous_loc...end_solidus.loc.begin_pos) - no_space(processed_source, end_solidus.loc.end_pos...(tag_node.loc.end_pos - 1)) - else - no_space(processed_source, previous_loc...(tag_node.loc.end_pos - 1)) - end - end - end - - def autocorrect(_processed_source, offense) - lambda do |corrector| - corrector.replace(offense.source_range, offense.context) - end - end - - private - - def no_space(processed_source, range) - chars = processed_source.file_content[range] - return if chars.empty? - - add_offense( - processed_source.to_source_range(range), - "Extra space detected where there should be no space.", - '' - ) - end - - def single_space_or_newline(processed_source, range) - single_space(processed_source, range, accept_newline: true) - end - - def single_space(processed_source, range, accept_newline: false) - chars = processed_source.file_content[range] - return if chars == ' ' - - newlines = chars.include?("\n") - expected = newlines && accept_newline ? "\n#{chars.split("\n", -1).last}" : ' ' - non_space = chars.match(/([^[[:space:]]])/m) - - if non_space && !non_space.captures.empty? - add_offense( - processed_source.to_source_range(range), - "Non-whitespace character(s) detected: "\ - "#{non_space.captures.map(&:inspect).join(', ')}.", - expected - ) - elsif newlines && accept_newline - if expected != chars - add_offense( - processed_source.to_source_range(range), - "#{chars.empty? ? 'No' : 'Extra'} space detected where there should be "\ - "a single space or a single line break.", - expected - ) - end - else - add_offense( - processed_source.to_source_range(range), - "#{chars.empty? ? 'No' : 'Extra'} space detected where there should be a single space.", - expected - ) - end - end - - def process_attributes(processed_source, attributes) - attributes.children.each_with_index do |attribute, index| - name, equal, value = *attribute - no_space(processed_source, name.loc.end_pos...equal.loc.begin_pos) if name && equal - no_space(processed_source, equal.loc.end_pos...value.loc.begin_pos) if equal && value - - next if index >= attributes.children.size - 1 - next_attribute = attributes.children[index + 1] - - single_space_or_newline( - processed_source, - attribute.loc.end_pos...next_attribute.loc.begin_pos - ) - end - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/space_indentation.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/space_indentation.rb deleted file mode 100644 index 9b17bb701..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/space_indentation.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -module ERBLint - module Linters - # Detects indentation with tabs and autocorrect them to spaces - class SpaceIndentation < Linter - include LinterRegistry - - class ConfigSchema < LinterConfig - property :tab_width, converts: :to_i, accepts: Integer, default: 2 - end - self.config_schema = ConfigSchema - - START_SPACES = /\A([[:blank:]]*)/ - - def run(processed_source) - lines = processed_source.file_content.split("\n", -1) - document_pos = 0 - lines.each do |line| - spaces = line.match(START_SPACES)&.captures&.first - - if spaces.include?("\t") - add_offense( - processed_source.to_source_range(document_pos...(document_pos + spaces.length)), - "Indent with spaces instead of tabs.", - spaces.gsub("\t", ' ' * @config.tab_width) - ) - end - - document_pos += line.length + 1 - end - end - - def autocorrect(_processed_source, offense) - lambda do |corrector| - corrector.replace(offense.source_range, offense.context) - end - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/trailing_whitespace.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/trailing_whitespace.rb deleted file mode 100644 index 36655fe10..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/linters/trailing_whitespace.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -module ERBLint - module Linters - # Detects trailing whitespace at the end of a line - class TrailingWhitespace < Linter - include LinterRegistry - - TRAILING_WHITESPACE = /([[:space:]]*)\Z/ - - def run(processed_source) - lines = processed_source.file_content.split("\n", -1) - document_pos = 0 - lines.each do |line| - document_pos += line.length + 1 - whitespace = line.match(TRAILING_WHITESPACE)&.captures&.first - next unless whitespace && !whitespace.empty? - - add_offense( - processed_source.to_source_range((document_pos - whitespace.length - 1)...(document_pos - 1)), - "Extra whitespace detected at end of line." - ) - end - end - - def autocorrect(_processed_source, offense) - lambda do |corrector| - corrector.replace(offense.source_range, '') - end - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/offense.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/offense.rb deleted file mode 100644 index fa3341e3a..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/offense.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -module ERBLint - # Defines common functionality available to all linters. - class Offense - attr_reader :linter, :source_range, :message, :context - - def initialize(linter, source_range, message, context = nil) - unless source_range.is_a?(Parser::Source::Range) - raise ArgumentError, "expected Parser::Source::Range for arg 2" - end - @linter = linter - @source_range = source_range - @message = message - @context = context - end - - def inspect - "#<#{self.class.name} linter=#{linter.class.name} "\ - "source_range=#{source_range.begin_pos}...#{source_range.end_pos} "\ - "message=#{message}>" - end - - def ==(other) - other.class <= ERBLint::Offense && - other.linter == linter && - other.source_range == source_range && - other.message == message - end - - def line_range - Range.new(source_range.line, source_range.last_line) - end - - def line_number - line_range.begin - end - - def column - source_range.column - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/processed_source.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/processed_source.rb deleted file mode 100644 index 8f9cf48b5..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/processed_source.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -module ERBLint - class ProcessedSource - attr_reader :filename, :file_content, :parser - - def initialize(filename, file_content) - @filename = filename - @file_content = file_content - @parser = BetterHtml::Parser.new(source_buffer, template_language: :html) - end - - def ast - @parser.ast - end - - def source_buffer - @source_buffer ||= begin - buffer = Parser::Source::Buffer.new(filename) - buffer.source = file_content - buffer - end - end - - def to_source_range(range) - range = (range.begin_pos...range.end_pos) if range.is_a?(::Parser::Source::Range) - BetterHtml::Tokenizer::Location.new( - source_buffer, - range.begin, - range.exclude_end? ? range.end : range.end + 1 - ) - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/reporter.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/reporter.rb deleted file mode 100644 index ff5e484d0..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/reporter.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true -require 'active_support/core_ext/class' - -module ERBLint - class Reporter - def self.create_reporter(format, *args) - reporter_klass = "#{ERBLint::Reporters}::#{format.to_s.camelize}Reporter".constantize - reporter_klass.new(*args) - end - - def self.available_format?(format) - available_formats.include?(format.to_s) - end - - def self.available_formats - descendants - .map(&:to_s) - .map(&:demodulize) - .map(&:underscore) - .map { |klass_name| klass_name.sub("_reporter", "") } - .sort - end - - def initialize(stats, autocorrect) - @stats = stats - @autocorrect = autocorrect - end - - def preview; end - - def show; end - - private - - attr_reader :stats, :autocorrect - delegate :processed_files, to: :stats - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/reporters/compact_reporter.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/reporters/compact_reporter.rb deleted file mode 100644 index 434100b50..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/reporters/compact_reporter.rb +++ /dev/null @@ -1,60 +0,0 @@ -# frozen_string_literal: true - -module ERBLint - module Reporters - class CompactReporter < Reporter - def preview - puts "Linting #{stats.files} files with "\ - "#{stats.linters} #{'autocorrectable ' if autocorrect}linters..." - end - - def show - processed_files.each do |filename, offenses| - offenses.each do |offense| - puts format_offense(filename, offense) - end - end - - footer - summary - end - - private - - def format_offense(filename, offense) - [ - "#{filename}:", - "#{offense.line_number}:", - "#{offense.column}: ", - offense.message.to_s, - ].join - end - - def footer; end - - def summary - if stats.corrected > 0 - report_corrected_offenses - elsif stats.found > 0 - warn(Rainbow("#{stats.found} error(s) were found in ERB files").red) - else - puts Rainbow("No errors were found in ERB files").green - end - end - - def report_corrected_offenses - corrected_found_diff = stats.found - stats.corrected - - if corrected_found_diff > 0 - message = Rainbow( - "#{stats.corrected} error(s) corrected and #{corrected_found_diff} error(s) remaining in ERB files" - ).red - - warn(message) - else - puts Rainbow("#{stats.corrected} error(s) corrected in ERB files").green - end - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/reporters/multiline_reporter.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/reporters/multiline_reporter.rb deleted file mode 100644 index 3e8d014d9..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/reporters/multiline_reporter.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true -require_relative "compact_reporter" - -module ERBLint - module Reporters - class MultilineReporter < CompactReporter - private - - def format_offense(filename, offense) - <<~EOF - - #{offense.message}#{Rainbow(' (not autocorrected)').red if autocorrect} - In file: #{filename}:#{offense.line_number} - EOF - end - - def footer - puts - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/runner.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/runner.rb deleted file mode 100644 index d39038925..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/runner.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -module ERBLint - # Runs all enabled linters against an html.erb file. - class Runner - attr_reader :offenses - - def initialize(file_loader, config) - @file_loader = file_loader - @config = config || RunnerConfig.default - raise ArgumentError, 'expect `config` to be a RunnerConfig instance' unless @config.is_a?(RunnerConfig) - - linter_classes = LinterRegistry.linters.select { |klass| @config.for_linter(klass).enabled? } - @linters = linter_classes.map do |linter_class| - linter_class.new(@file_loader, @config.for_linter(linter_class)) - end - @offenses = [] - end - - def run(processed_source) - @linters - .reject { |linter| linter.excludes_file?(processed_source.filename) } - .each do |linter| - linter.run(processed_source) - @offenses.concat(linter.offenses) - end - end - - def clear_offenses - @offenses = [] - @linters.each(&:clear_offenses) - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/runner_config.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/runner_config.rb deleted file mode 100644 index b07181e47..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/runner_config.rb +++ /dev/null @@ -1,91 +0,0 @@ -# frozen_string_literal: true - -require 'erb_lint/runner_config_resolver' - -module ERBLint - class RunnerConfig - class Error < StandardError; end - - def initialize(config = nil, file_loader = nil) - @config = (config || {}).dup.deep_stringify_keys - - resolver.resolve_inheritance_from_gems(@config, @config.delete('inherit_gem')) - resolver.resolve_inheritance(@config, file_loader) if file_loader - @config.delete("inherit_from") - end - - def to_hash - @config.dup - end - - def for_linter(klass) - klass_name = if klass.is_a?(String) - klass.to_s - elsif klass.is_a?(Class) && klass <= ERBLint::Linter - klass.simple_name - else - raise ArgumentError, 'expected String or linter class' - end - linter_klass = LinterRegistry.find_by_name(klass_name) - raise Error, "#{klass_name}: linter not found (is it loaded?)" unless linter_klass - linter_klass.config_schema.new(config_hash_for_linter(klass_name)) - end - - def global_exclude - @config['exclude'] || [] - end - - def merge(other_config) - self.class.new(@config.deep_merge(other_config.to_hash)) - end - - def merge!(other_config) - @config.deep_merge!(other_config.to_hash) - self - end - - class << self - def default(default_enabled: nil) - default_enabled = default_enabled.nil? ? true : default_enabled - new( - linters: { - AllowedScriptType: { enabled: default_enabled }, - ClosingErbTagIndent: { enabled: default_enabled }, - ExtraNewline: { enabled: default_enabled }, - FinalNewline: { enabled: default_enabled }, - NoJavascriptTagHelper: { enabled: default_enabled }, - ParserErrors: { enabled: default_enabled }, - RightTrim: { enabled: default_enabled }, - SelfClosingTag: { enabled: default_enabled }, - SpaceAroundErbTag: { enabled: default_enabled }, - SpaceIndentation: { enabled: default_enabled }, - SpaceInHtmlTag: { enabled: default_enabled }, - TrailingWhitespace: { enabled: default_enabled }, - }, - ) - end - - def default_for(config) - default_linters_enabled = config.to_hash.dig("EnableDefaultLinters") - default(default_enabled: default_linters_enabled).merge(config) - end - end - - private - - def linters_config - @config['linters'] || {} - end - - def config_hash_for_linter(klass_name) - config_hash = linters_config[klass_name] || {} - config_hash['exclude'] ||= [] - config_hash['exclude'].concat(global_exclude) if config_hash['exclude'].is_a?(Array) - config_hash - end - - def resolver - @resolver ||= ERBLint::RunnerConfigResolver.new - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/runner_config_resolver.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/runner_config_resolver.rb deleted file mode 100644 index f7f12b8f7..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/runner_config_resolver.rb +++ /dev/null @@ -1,66 +0,0 @@ -# frozen_string_literal: true - -# Copyright (c) 2012-18 Bozhidar Batsov -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -module ERBLint - class RunnerConfigResolver - def resolve_inheritance(hash, file_loader) - inherited_files = Array(hash['inherit_from']) - base_configs(file_loader, inherited_files).reverse_each do |base_config| - base_config.each do |k, v| - next unless v.is_a?(Hash) - v = v.deep_merge(hash[k]) if hash.key?(k) - hash[k] = v - end - end - end - - def resolve_inheritance_from_gems(hash, gems) - (gems || {}).each_pair do |gem_name, config_path| - raise(ArgumentError, "can't inherit configuration from the erb-lint gem") if gem_name == 'erb-lint' - - hash['inherit_from'] = Array(hash['inherit_from']) - Array(config_path).reverse_each do |path| - # Put gem configuration first so local configuration overrides it. - hash['inherit_from'].unshift(gem_config_path(gem_name, path)) - end - end - end - - private - - def gem_config_path(gem_name, relative_config_path) - spec = Gem::Specification.find_by_name(gem_name) - File.join(spec.gem_dir, relative_config_path) - rescue Gem::LoadError => e - raise Gem::LoadError, "Unable to find gem #{gem_name}; is the gem installed? #{e}" - end - - def base_configs(file_loader, inherit_from) - configs = Array(inherit_from).compact.map do |f| - inherited_file = File.expand_path(f, file_loader.base_path) - file_loader.yaml(inherited_file) - end - configs.compact - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/stats.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/stats.rb deleted file mode 100644 index 3b4952c7a..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/stats.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true -module ERBLint - class Stats - attr_accessor :found, - :corrected, - :exceptions, - :linters, - :files, - :processed_files - - def initialize( - found: 0, - corrected: 0, - exceptions: 0, - linters: 0, - files: 0, - processed_files: {} - ) - @found = found - @corrected = corrected - @exceptions = exceptions - @linters = linters - @files = files - @processed_files = processed_files - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/utils/block_map.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/utils/block_map.rb deleted file mode 100644 index 556d6972c..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/utils/block_map.rb +++ /dev/null @@ -1,227 +0,0 @@ -# frozen_string_literal: true - -require 'better_html/ast/node' -require 'better_html/test_helper/ruby_node' - -module ERBLint - module Utils - class BlockMap - attr_reader :connections - - class ParseError < StandardError; end - - def initialize(processed_source) - @processed_source = processed_source - @entries = [] - @connections = [] - @ruby_code = "" - build_map - end - - def find_connected_nodes(other) - connection = @connections.find { |conn| conn.include?(other) } - connection&.nodes - end - - private - - def erb_nodes - erb_ast.descendants(:erb).sort { |a, b| a.loc.begin_pos <=> b.loc.begin_pos } - end - - class Entry - attr_reader :node, :erb_range, :ruby_range - - def initialize(node, ruby_range) - @node = node - @erb_range = node.loc.range - @ruby_range = ruby_range - end - - def contains_ruby_range?(range) - range.begin >= @ruby_range.begin && range.end <= @ruby_range.end - end - end - - class ConnectedErbNodes - attr_reader :type, :nodes - - def initialize(type, nodes) - @type = type - @nodes = ordered(nodes) - end - - def concat(other) - @nodes = ordered(@nodes.concat(other.nodes)) - end - - def include?(other) - @nodes.map(&:loc).include?(other.loc) - end - - def inspect - "\#<#{self.class.name} type=#{type.inspect} nodes=#{nodes.inspect}>" - end - - def &(other) - nodes.select { |node| other.include?(node) } - end - - private - - def ordered(nodes) - nodes - .uniq(&:loc) - .sort { |a, b| a.loc.begin_pos <=> b.loc.begin_pos } - end - end - - def build_map - erb_nodes.each do |erb_node| - indicator_node, _, code_node, _ = *erb_node - length = code_node.loc.size - start = current_pos - if indicator_node.nil? - append("#{code_node.loc.source}\n") - elsif block?(code_node.loc.source) - append("src= #{code_node.loc.source}\n") - start += 5 - else - append("src=(#{code_node.loc.source});\n") - start += 5 - end - ruby_range = Range.new(start, start + length) - @entries << Entry.new(erb_node, ruby_range) - end - - ruby_node = BetterHtml::TestHelper::RubyNode.parse(@ruby_code) - raise ParseError unless ruby_node - - ruby_node.descendants(:block, :if, :for).each do |node| - @connections << ConnectedErbNodes.new( - node.type, - extract_map_locations(node) - .map { |loc| find_entry(loc) } - .compact.map(&:node) - ) - end - - ruby_node.descendants(:kwbegin).each do |node| - @connections << ConnectedErbNodes.new( - :begin, - (extract_map_locations(node) + rescue_locations(node)) - .map { |loc| find_entry(loc) } - .compact.map(&:node) - ) - end - - ruby_node.descendants(:case).each do |node| - @connections << ConnectedErbNodes.new( - node.type, - (extract_map_locations(node) + when_locations(node)) - .map { |loc| find_entry(loc) } - .compact.map(&:node) - ) - end - - group_overlapping_connections - end - - def block?(source) - # taken from: action_view/template/handlers/erb/erubi.rb - /\s*((\s+|\))do|\{)(\s*\|[^|]*\|)?\s*\Z/.match?(source) - end - - def when_locations(node) - node.child_nodes - .select { |child| child.type?(:when) } - .map { |child| extract_map_locations(child) } - .flatten - end - - def rescue_locations(node) - node.child_nodes - .select { |child| child.type?(:rescue) } - .map(&:child_nodes) - .flatten - .select { |child| child.type?(:resbody) } - .map { |child| extract_map_locations(child) } - .flatten - end - - def extract_map_locations(node) - ( - case node.loc - when Parser::Source::Map::Collection - [node.loc.begin, node.loc.end] - when Parser::Source::Map::Condition - [node.loc.keyword, node.loc.begin, node.loc.else, node.loc.end] - when Parser::Source::Map::Constant - [node.loc.double_colon, node.loc.name, node.loc.operator] - when Parser::Source::Map::Definition - [node.loc.keyword, node.loc.operator, node.loc.name, node.loc.end] - when Parser::Source::Map::For - [node.loc.keyword, node.loc.in, node.loc.begin, node.loc.end] - when Parser::Source::Map::Heredoc - [node.loc.heredoc_body, node.loc.heredoc_end] - when Parser::Source::Map::Keyword - [node.loc.keyword, node.loc.begin, node.loc.end] - when Parser::Source::Map::ObjcKwarg - [node.loc.keyword, node.loc.operator, node.loc.argument] - when Parser::Source::Map::RescueBody - [node.loc.keyword, node.loc.assoc, node.loc.begin] - when Parser::Source::Map::Send - [node.loc.dot, node.loc.selector, node.loc.operator, node.loc.begin, node.loc.end] - when Parser::Source::Map::Ternary - [node.loc.question, node.loc.colon] - when Parser::Source::Map::Variable - [node.loc.name, node.loc.operator] - end + [node.loc.expression] - ).compact - end - - def current_pos - @ruby_code.size - end - - def append(code) - @ruby_code += code - end - - def parser - @processed_source.parser - end - - def find_entry(range) - return unless range - @entries.find do |entry| - entry.contains_ruby_range?(Range.new(range.begin_pos, range.end_pos)) - end - end - - def group_overlapping_connections - loop do - first, second = find_overlapping_pair - break unless first && second - - @connections.delete(second) - first.concat(second) - end - end - - def find_overlapping_pair - @connections.each do |first| - @connections.each do |second| - next if first == second - return [first, second] if (first & second).any? - end - end - nil - end - - def erb_ast - parser.ast - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/utils/offset_corrector.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/utils/offset_corrector.rb deleted file mode 100644 index c4913c239..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/utils/offset_corrector.rb +++ /dev/null @@ -1,72 +0,0 @@ -# frozen_string_literal: true - -module ERBLint - module Utils - class OffsetCorrector - def initialize(processed_source, corrector, offset, bound_range) - @processed_source = processed_source - @corrector = corrector - @offset = offset - @bound_range = bound_range - end - - def remove(range) - @corrector.remove(range_with_offset(range)) - end - - def insert_before(range, content) - @corrector.insert_before(range_with_offset(range), content) - end - - def insert_after(range, content) - @corrector.insert_after(range_with_offset(range), content) - end - - def replace(range, content) - @corrector.replace(range_with_offset(range), content) - end - - def remove_preceding(range, size) - @corrector.remove_preceding(range_with_offset(range), size) - end - - def remove_leading(range, size) - @corrector.remove_leading(range_with_offset(range), size) - end - - def remove_trailing(range, size) - @corrector.remove_trailing(range_with_offset(range), size) - end - - def range_with_offset(node_or_range) - range = to_range(node_or_range) - - @processed_source.to_source_range( - bound(@offset + range.begin_pos)..bound(@offset + (range.end_pos - 1)) - ) - end - - def bound(pos) - [ - [pos, @bound_range.min].max, - @bound_range.max, - ].min - end - - private - - def to_range(node_or_range) - case node_or_range - when ::RuboCop::AST::Node, ::Parser::Source::Comment - node_or_range.loc.expression - when ::Parser::Source::Range - node_or_range - else - raise TypeError, - 'Expected a Parser::Source::Range, Comment or ' \ - "Rubocop::AST::Node, got #{node_or_range.class}" - end - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/utils/ruby_to_erb.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/utils/ruby_to_erb.rb deleted file mode 100644 index 91291ac12..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/utils/ruby_to_erb.rb +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -module ERBLint - module Utils - class RubyToERB - class Error < StandardError; end - - class << self - def html_options_to_tag_attributes(hash_node) - hash_node.children.map do |pair_node| - key_node, value_node = *pair_node - key = ruby_to_erb(key_node, '=') { |s| s.tr('_', '-') } - value = ruby_to_erb(value_node, '=') { |s| escape_quote(s) } - [key, "\"#{value}\""].join('=') - end.join(' ') - end - - def ruby_to_erb(node, indicator = nil, &block) - return node if node.nil? || node.is_a?(String) - case node.type - when :str, :sym - s = node.children.first.to_s - s = yield s if block_given? - s - when :true, :false - node.type.to_s - when :nil - "" - when :dstr - node.children.map do |child| - case child.type - when :str - ruby_to_erb(child, indicator, &block) - when :begin - ruby_to_erb(child.children.first, indicator, &block) - else - raise Error, "unexpected #{child.type} in :dstr node" - end - end.join - else - "<%#{indicator} #{node.loc.expression.source} %>" - end - end - - def escape_quote(str) - str.gsub('"', '"') - end - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/version.rb b/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/version.rb deleted file mode 100644 index 2a077a5f0..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/lib/erb_lint/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -module ERBLint - VERSION = '0.0.35' -end diff --git a/vendor/cache/erb-lint-05596ea189ee/shipit.rubygems.yml b/vendor/cache/erb-lint-05596ea189ee/shipit.rubygems.yml deleted file mode 100644 index 60ac8acc8..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/shipit.rubygems.yml +++ /dev/null @@ -1 +0,0 @@ -# use defaults diff --git a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/block_map_spec.rb b/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/block_map_spec.rb deleted file mode 100644 index 14c0b17c6..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/block_map_spec.rb +++ /dev/null @@ -1,194 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe ERBLint::Utils::BlockMap do - include ::AST::Sexp - - describe 'map' do - let(:processed_source) { ERBLint::ProcessedSource.new('file.rb', file) } - let(:block_map) { described_class.new(processed_source) } - subject { block_map.connections } - - context 'with block' do - let(:file) { <<~ERB } - <%= javascript_tag do %> - foo - <% end %> - ERB - - it do - expect(subject.size).to(eq(1)) - expect(subject[0].type).to(eq(:block)) - expect(subject[0].nodes.map(&:loc).map(&:source)).to(eq(["<%= javascript_tag do %>", "<% end %>"])) - end - end - - context 'with block in single erb tag' do - let(:file) { <<~ERB } - <%= javascript_tag do foo; end %> - ERB - - it do - expect(subject.size).to(eq(1)) - expect(subject[0].type).to(eq(:block)) - expect(subject[0].nodes.map(&:loc).map(&:source)).to(eq(["<%= javascript_tag do foo; end %>"])) - end - end - - context 'with if' do - let(:file) { <<~ERB } - <% if foo %> - foo - <% end %> - ERB - - it do - expect(subject.size).to(eq(1)) - expect(subject[0].type).to(eq(:if)) - expect(subject[0].nodes.map(&:loc).map(&:source)).to(eq(["<% if foo %>", "<% end %>"])) - end - end - - context 'with if..else' do - let(:file) { <<~ERB } - <% if foo %> - a - <% else %> - b - <% end %> - ERB - - it do - expect(subject.size).to(eq(1)) - expect(subject[0].type).to(eq(:if)) - expect(subject[0].nodes.map(&:loc).map(&:source)).to(eq(["<% if foo %>", "<% else %>", "<% end %>"])) - end - end - - context 'with if..elsif..end' do - let(:file) { <<~ERB } - <% if foo %> - a - <% elsif bar %> - b - <% elsif baz %> - c - <% elsif qux %> - d - <% end %> - ERB - - it do - expect(subject.size).to(eq(1)) - expect(subject[0].type).to(eq(:if)) - expect(subject[0].nodes.map(&:loc).map(&:source)).to(eq([ - "<% if foo %>", - "<% elsif bar %>", - "<% elsif baz %>", - "<% elsif qux %>", - "<% end %>", - ])) - end - end - - context 'with block and if' do - let(:file) { <<~ERB } - <% foo do %> - <% if bar %> - baz - <% end %> - <% end %> - ERB - - it do - expect(subject.size).to(eq(2)) - expect(subject[0].type).to(eq(:block)) - expect(subject[0].nodes.map(&:loc).map(&:source)).to(eq(["<% foo do %>", "<% end %>"])) - expect(subject[0].nodes.map(&:loc).map(&:range)).to(eq([0...12, 48...57])) - expect(subject[1].type).to(eq(:if)) - expect(subject[1].nodes.map(&:loc).map(&:source)).to(eq(["<% if bar %>", "<% end %>"])) - expect(subject[1].nodes.map(&:loc).map(&:range)).to(eq([15...27, 38...47])) - end - end - - context 'with block and if overlapping' do - let(:file) { <<~ERB } - <% foo do - if bar %> - baz - <% end %> - <% end %> - ERB - - it do - expect(subject.size).to(eq(1)) - expect(subject[0].type).to(eq(:block)) - expect(subject[0].nodes.map(&:loc).map(&:source)).to(eq(["<% foo do\n if bar %>", "<% end %>", "<% end %>"])) - expect(subject[0].nodes.map(&:loc).map(&:range)).to(eq([0...21, 32...41, 42...51])) - end - end - - context 'with begin..end' do - let(:file) { <<~ERB } - <% begin %> - foo - <% end %> - ERB - - it do - expect(subject.size).to(eq(1)) - expect(subject[0].type).to(eq(:begin)) - expect(subject[0].nodes.map(&:loc).map(&:source)).to(eq(["<% begin %>", "<% end %>"])) - end - end - - context 'with begin..rescue..end' do - let(:file) { <<~ERB } - <% begin %> - <%= bla rescue nil %> - <% rescue Error1 => e %> - bar - <% rescue Error2 => e %> - bar - <% end %> - ERB - - it do - expect(subject.size).to(eq(1)) - expect(subject[0].type).to(eq(:begin)) - expect(subject[0].nodes.map(&:loc).map(&:source)).to(eq([ - "<% begin %>", - "<% rescue Error1 => e %>", - "<% rescue Error2 => e %>", - "<% end %>", - ])) - end - end - - context 'with case' do - let(:file) { <<~ERB } - <% case foo %> - <% when :bar %> - bar - <% when :baz %> - <%= bla rescue nil %> - <% else %> - baz - <% end %> - ERB - - it do - expect(subject.size).to(eq(1)) - expect(subject[0].type).to(eq(:case)) - expect(subject[0].nodes.map(&:loc).map(&:source)).to(eq([ - "<% case foo %>", - "<% when :bar %>", - "<% when :baz %>", - "<% else %>", - "<% end %>", - ])) - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/cli_spec.rb b/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/cli_spec.rb deleted file mode 100644 index 52a98c0ac..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/cli_spec.rb +++ /dev/null @@ -1,354 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' -require 'erb_lint/cli' -require 'pp' -require 'fakefs' -require 'fakefs/spec_helpers' - -describe ERBLint::CLI do - include FakeFS::SpecHelpers - - let(:args) { [] } - let(:cli) { described_class.new } - - around do |example| - FakeFS do - example.run - end - end - - before do - allow(ERBLint::LinterRegistry).to(receive(:linters) - .and_return([ERBLint::Linters::LinterWithErrors, - ERBLint::Linters::LinterWithoutErrors, - ERBLint::Linters::FinalNewline])) - end - - module ERBLint - module Linters - class LinterWithErrors < Linter - def run(processed_source) - add_offense( - processed_source.to_source_range(1..1), - 'fake message from a fake linter' - ) - end - end - - class LinterWithoutErrors < Linter - def run(_processed_source) - end - end - end - end - - describe '#run' do - subject { cli.run(args) } - - context 'with no arguments' do - it 'shows usage' do - expect { subject }.to(output(/erblint \[options\] \[file1, file2, ...\]/).to_stderr) - end - - it 'shows all known linters in stderr' do - expect { subject }.to(output( - /Known linters are: linter_with_errors, linter_without_errors, final_newline/ - ).to_stderr) - end - - it 'fails' do - expect(subject).to(be(false)) - end - end - - context 'with --version' do - let(:args) { ['--version'] } - it { expect { subject }.to(output("#{ERBLint::VERSION}\n").to_stdout) } - end - - context 'with --help' do - let(:args) { ['--help'] } - - it 'shows usage' do - expect { subject }.to(output(/erblint \[options\] \[file1, file2, ...\]/).to_stdout) - end - - it 'shows format instructions' do - expect { subject }.to( - output(/Report offenses in the given format: \(compact, multiline\) \(default: multiline\)/).to_stdout - ) - end - - it 'is successful' do - expect(subject).to(be(true)) - end - end - - context 'with --config' do - context 'when file does not exist' do - let(:args) { ['--config', '.somefile.yml'] } - - it { expect { subject }.to(output(/.somefile.yml: does not exist/).to_stderr) } - it 'is not successful' do - expect(subject).to(be(false)) - end - end - - context 'when file does exist' do - before { FakeFS::FileSystem.clone(File.join(__dir__, '../fixtures'), '/') } - - let(:args) { ['--config', 'config.yml', '--lint-all'] } - - it { expect { subject }.to_not(output("config.yml: does not exist").to_stderr) } - it 'is successful' do - expect(subject).to(be(true)) - end - end - end - - context 'with file as argument' do - context 'when file does not exist' do - let(:linted_file) { '/path/to/myfile.html.erb' } - let(:args) { [linted_file] } - - it { expect { subject }.to(output(/#{Regexp.escape(linted_file)}: does not exist/).to_stderr) } - it { expect(subject).to(be(false)) } - end - - context 'when file exists' do - let(:linted_file) { 'app/views/template.html.erb' } - let(:args) { ['--enable-linter', 'linter_with_errors,final_newline', linted_file] } - let(:file_content) { "this is a fine file" } - - before do - FileUtils.mkdir_p(File.dirname(linted_file)) - File.write(linted_file, file_content) - end - - context 'without --config' do - context 'when default config does not exist' do - it { expect { subject }.to(output(/\.erb-lint\.yml not found: using default config/).to_stderr) } - end - end - - it 'shows how many files and linters are used' do - expect { subject }.to(output(/Linting 1 files with 2 linters/).to_stdout) - end - - context 'when errors are found' do - it 'shows all error messages and line numbers' do - expect { subject }.to(output(Regexp.new(Regexp.escape(<<~EOF))).to_stdout) - - fake message from a fake linter - In file: /app/views/template.html.erb:1 - - Missing a trailing newline at the end of the file. - In file: /app/views/template.html.erb:1 - - EOF - end - - it 'prints that errors were found to stderr' do - expect { subject }.to(output(/2 error\(s\) were found in ERB files/).to_stderr) - end - - it 'is not successful' do - expect(subject).to(be(false)) - end - end - - context 'when no errors are found' do - let(:args) { ['--enable-linter', 'linter_without_errors', linted_file] } - - it 'shows that no errors were found to stdout' do - expect { subject }.to(output(/No errors were found in ERB files/).to_stdout) - end - - it 'is successful' do - expect(subject).to(be(true)) - end - end - end - end - - context 'with --lint-all as argument' do - let(:args) { ['--lint-all', '--enable-linter', 'linter_with_errors,final_newline'] } - context 'when a file exists' do - let(:linted_file) { 'app/views/template.html.erb' } - let(:file_content) { "this is a fine file" } - - before do - FileUtils.mkdir_p(File.dirname(linted_file)) - File.write(linted_file, file_content) - end - - context "with the default glob" do - it 'shows how many files and linters are used' do - allow(cli).to(receive(:glob).and_return(cli.class::DEFAULT_LINT_ALL_GLOB)) - expect { subject }.to(output(/Linting 1 files with 2 linters/).to_stdout) - end - end - - context "with a custom glob that does not match any files" do - it 'shows no files or linters' do - allow(cli).to(receive(:glob).and_return("no/file/glob")) - expect { subject }.to(output(/no files found/).to_stderr) - end - end - end - end - - context 'with dir as argument' do - context 'when dir does not exist' do - let(:linted_dir) { '/path/to' } - let(:args) { [linted_dir] } - - it { expect { subject }.to(output(/#{Regexp.escape(linted_dir)}: does not exist/).to_stderr) } - it { expect(subject).to(be(false)) } - end - - context 'when dir exists' do - let(:linted_dir) { 'app' } - - context 'with no descendant files that match default glob' do - let(:args) { ['--enable-linter', 'linter_with_errors,final_newline', linted_dir] } - - before do - FileUtils.mkdir_p(linted_dir) - end - - it 'fails' do - expect(subject).to(be(false)) - end - - it 'shows no files were found to stderr' do - expect { subject }.to(output(/no files found/).to_stderr) - end - end - - context 'with descendant files that match default glob' do - let(:linted_file) { 'app/views/template.html.erb' } - let(:args) { ['--enable-linter', 'linter_with_errors,final_newline', linted_dir] } - let(:file_content) { "this is a fine file" } - - before do - FileUtils.mkdir_p(File.dirname(linted_file)) - File.write(linted_file, file_content) - end - - context 'without --config' do - context 'when default config does not exist' do - it { expect { subject }.to(output(/\.erb-lint\.yml not found: using default config/).to_stderr) } - end - end - - it 'shows how many files and linters are used' do - expect { subject }.to(output(/Linting 1 files with 2 linters/).to_stdout) - end - - context 'when errors are found' do - it 'shows all error messages and line numbers' do - expect { subject }.to(output(Regexp.new(Regexp.escape(<<~EOF))).to_stdout) - - fake message from a fake linter - In file: /app/views/template.html.erb:1 - - Missing a trailing newline at the end of the file. - In file: /app/views/template.html.erb:1 - - EOF - end - - it 'prints that errors were found to stdout' do - expect { subject }.to(output(/2 error\(s\) were found in ERB files/).to_stderr) - end - - it 'is not successful' do - expect(subject).to(be(false)) - end - end - - context 'with --format compact' do - let(:args) do - [ - '--enable-linter', 'linter_with_errors,final_newline', - '--format', 'compact', - linted_dir - ] - end - - it 'shows all error messages and line numbers' do - expect { subject }.to(output(Regexp.new(Regexp.escape(<<~EOF))).to_stdout) - /app/views/template.html.erb:1:1: fake message from a fake linter - /app/views/template.html.erb:1:19: Missing a trailing newline at the end of the file. - EOF - end - - it 'is not successful' do - expect(subject).to(be(false)) - end - end - - context 'with invalid --format option' do - let(:args) do - [ - '--enable-linter', 'linter_with_errors,final_newline', - '--format', 'nonexistentformat', - linted_dir - ] - end - - it 'shows all error messages and line numbers' do - expect { subject }.to(output(Regexp.new(Regexp.escape(<<~EOF.strip))).to_stderr) - nonexistentformat: is not a valid format. Available formats: - - compact - - multiline - EOF - end - - it 'is not successful' do - expect(subject).to(be(false)) - end - end - - context 'when no errors are found' do - let(:args) { ['--enable-linter', 'linter_without_errors', linted_dir] } - - it 'shows that no errors were found to stdout' do - expect { subject }.to(output(/No errors were found in ERB files/).to_stdout) - end - - it 'is successful' do - expect(subject).to(be(true)) - end - end - end - end - end - - context 'with unknown argument' do - let(:args) { ['--foo'] } - - it { expect { subject }.to(output(/invalid option: --foo/).to_stderr) } - - it 'is not successful' do - expect(subject).to(be(false)) - end - end - - context 'with invalid --enable-linters argument' do - let(:args) { ['--enable-linter', 'foo'] } - - it do - expect { subject }.to(output( - /foo: not a valid linter name \(linter_with_errors, linter_without_errors, final_newline\)/ - ).to_stderr) - end - - it 'is not successful' do - expect(subject).to(be(false)) - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/fixtures/cops/auto_correct_cop.rb b/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/fixtures/cops/auto_correct_cop.rb deleted file mode 100644 index eeb982534..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/fixtures/cops/auto_correct_cop.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -module RuboCop - module Cop - module ErbLint - class AutoCorrectCop < Cop - MSG = 'An arbitrary rule has been violated.' - METHODS_TO_WATCH = %i(auto_correct_me dont_auto_correct_me) - - def on_send(node) - return unless METHODS_TO_WATCH.include?(node.method_name) - - add_offense(node, location: :selector) - end - alias_method :on_csend, :on_send - - def autocorrect(node) - return if node.method_name == :dont_auto_correct_me - - lambda do |corrector| - corrector.replace(node.loc.selector, 'safe_method') - end - end - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/fixtures/linters/custom_linter.rb b/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/fixtures/linters/custom_linter.rb deleted file mode 100644 index 0abdb4318..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/fixtures/linters/custom_linter.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -module ERBLint - module Linters - class CustomLinter < Linter - include LinterRegistry - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linter_config_spec.rb b/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linter_config_spec.rb deleted file mode 100644 index 57a791680..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linter_config_spec.rb +++ /dev/null @@ -1,114 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe ERBLint::LinterConfig do - context 'with custom config' do - let(:linter_config) { described_class.new(config_hash) } - - describe '#to_hash' do - subject { linter_config.to_hash } - - context 'with empty hash' do - let(:config_hash) { {} } - - it 'returns default config' do - expect(subject).to(eq("enabled" => false, "exclude" => [])) - end - end - - context 'with custom data' do - let(:config_hash) { { foo: true } } - - it { expect { subject }.to(raise_error(described_class::Error, "Given key is not allowed: foo")) } - end - end - - describe '#[]' do - subject { linter_config[key] } - - class CustomConfig < described_class - property :foo - end - let(:linter_config) { CustomConfig.new(config_hash) } - - context 'with empty hash' do - let(:config_hash) { {} } - let(:key) { 'foo' } - - it { expect(subject).to(eq(nil)) } - end - - context 'with custom data' do - let(:config_hash) { { foo: 'custom value' } } - let(:key) { 'foo' } - - it { expect(subject).to(eq('custom value')) } - end - - context 'with string data and symbol key' do - let(:config_hash) { { 'foo' => 'custom value' } } - let(:key) { :foo } - - it { expect(subject).to(eq('custom value')) } - end - - context 'with unknown key' do - let(:config_hash) { {} } - let(:key) { 'bogus' } - - it { expect { subject }.to(raise_error(described_class::Error, "No such property: bogus")) } - end - end - - describe '#enabled?' do - subject { linter_config.enabled? } - - context 'when enabled is true' do - let(:config_hash) { { enabled: true } } - it { expect(subject).to(eq(true)) } - end - - context 'when enabled is false' do - let(:config_hash) { { enabled: false } } - it { expect(subject).to(eq(false)) } - end - - context 'when enabled key is missing' do - let(:config_hash) { {} } - it { expect(subject).to(eq(false)) } - end - - context 'when enabled key is not true or false' do - let(:config_hash) { { enabled: 42 } } - it do - expect { subject }.to(\ - raise_error( - described_class::Error, - "ERBLint::LinterConfig does not accept 42 as value for the property enabled. Only accepts: [true, false]" - ) - ) - end - end - - context 'when enabled key is nil' do - let(:config_hash) { { enabled: nil } } - it { expect(subject).to(eq(nil)) } - end - end - - describe '#excludes_file?' do - context 'when glob matches' do - let(:config_hash) { { exclude: ['vendor/**/*'] } } - subject { linter_config.excludes_file?('vendor/gem/foo.rb') } - it { expect(subject).to(eq(true)) } - end - - context 'when glob does not match' do - let(:config_hash) { { exclude: ['vendor/**/*'] } } - subject { linter_config.excludes_file?('app/foo.rb') } - it { expect(subject).to(eq(false)) } - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linter_registry_spec.rb b/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linter_registry_spec.rb deleted file mode 100644 index bd3e400fd..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linter_registry_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe ERBLint::LinterRegistry do - let(:custom_directory) { File.expand_path('../fixtures/linters', __FILE__) } - - context 'when including the LinterRegistry module' do - after do - described_class.clear - end - - it 'adds the linter to the set of registered linters' do - expect do - class FakeLinter < ERBLint::Linter - include ERBLint::LinterRegistry - end - end.to(change { described_class.linters.count }.by(1)) - end - - it 'adds custom linters to the set of registered linters' do - stub_const('ERBLint::LinterRegistry::CUSTOM_LINTERS_DIR', custom_directory) - - expect(described_class.linters).to(include(ERBLint::Linters::CustomLinter)) - end - end - - describe '.load_custom_linters' do - it 'adds the custom linter to the set of registered linters' do - expect(described_class).to(receive(:require) - .with(File.join(custom_directory, 'custom_linter.rb')).once) - described_class.load_custom_linters(custom_directory) - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linter_spec.rb b/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linter_spec.rb deleted file mode 100644 index 8a9156c28..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linter_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe ERBLint::Linter do - context 'when inheriting from the Linter class' do - let(:linter_config) { ERBLint::LinterConfig.new } - let(:file_loader) { ERBLint::FileLoader.new('.') } - let(:linter) { ERBLint::Linters::Fake.new(file_loader, linter_config) } - let(:processed_source) { ERBLint::ProcessedSource.new('file.rb', file) } - subject { linter } - - module ERBLint - module Linters - class Fake < ERBLint::Linter - attr_accessor :offenses - end - end - end - - describe '.simple_name' do - it 'returns the name of the class with the ERBLint::Linter prefix removed' do - expect(subject.class.simple_name).to(eq('Fake')) - end - end - - describe '.clear_offenses' do - it 'clears all offenses from the offenses ivar' do - linter.offenses = %w(someoffense) - linter.clear_offenses - expect(linter.offenses).to(eq([])) - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linters/allowed_script_type_spec.rb b/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linters/allowed_script_type_spec.rb deleted file mode 100644 index dcdf842fc..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linters/allowed_script_type_spec.rb +++ /dev/null @@ -1,154 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe ERBLint::Linters::AllowedScriptType do - let(:linter_config) { described_class.config_schema.new } - - let(:file_loader) { ERBLint::FileLoader.new('.') } - let(:linter) { described_class.new(file_loader, linter_config) } - let(:processed_source) { ERBLint::ProcessedSource.new('file.rb', file) } - let(:offenses) { linter.offenses } - let(:corrector) { ERBLint::Corrector.new(processed_source, offenses) } - let(:corrected_content) { corrector.corrected_content } - before { linter.run(processed_source) } - - describe 'offenses' do - subject { offenses } - - context 'when type is correct' do - let(:file) { ' - FILE - - it 'reports 1 offense' do - expect(subject.size).to(eq(1)) - end - - it 'reports an offense with message containing suggestion 1' do - expect(subject.first.message).to(include(suggestion_1)) - end - - it 'reports an offense with position range that is adjusted in the nested context' do - expect(subject.first.source_range.begin_pos).to(eq(28)) - expect(subject.first.source_range.end_pos).to(eq(45)) - expect(subject.first.source_range.source).to(eq("
")) - end - end - - context 'when the file contains both classes from set 1' do - context 'when both classes are on the same tag' do - let(:file) { <<~FILE } -
- Content -
- FILE - - it 'reports 2 offenses' do - expect(subject.size).to(eq(2)) - end - - it 'reports offenses with messages containing suggestion 1' do - expect(subject[0].message).to(include(suggestion_1)) - expect(subject[1].message).to(include(suggestion_1)) - end - end - - context 'when both classes are on different tags' do - let(:file) { <<~FILE } -
- -
- FILE - - it 'reports 2 offenses' do - expect(subject.size).to(eq(2)) - end - - it 'reports offenses with messages containing suggestion 1' do - expect(subject[0].message).to(include(suggestion_1)) - expect(subject[1].message).to(include(suggestion_1)) - end - end - end - - context 'when the file contains a class matching both expressions from set 2' do - let(:file) { <<~FILE } -
- Content -
- FILE - - it 'reports 2 offenses' do - expect(subject.size).to(eq(2)) - end - - it 'reports offenses with messages containing suggestion 2' do - expect(subject[0].message).to(include(suggestion_2)) - expect(subject[1].message).to(include(suggestion_2)) - end - end - - context 'when an addendum is present' do - let(:linter_config) do - described_class.config_schema.new( - rule_set: rule_set, - addendum: addendum, - ) - end - let(:addendum) { 'Addendum badoo ba!' } - - context 'when the file is empty' do - let(:file) { '' } - - it 'does not report any offenses' do - expect(subject).to(eq([])) - end - end - - context 'when the file contains a class from a deprecated set' do - let(:file) { <<~FILE } -
- Content -
- FILE - - it 'reports 1 offense' do - expect(subject.size).to(eq(1)) - end - - it 'reports an offense with its message ending with the addendum' do - expect(subject.first.message).to(end_with(addendum)) - end - end - end - - context 'when an addendum is absent' do - let(:linter_config) do - described_class.config_schema.new( - rule_set: rule_set - ) - end - - context 'when the file is empty' do - let(:file) { '' } - - it 'does not report any offenses' do - expect(subject).to(eq([])) - end - end - - context 'when the file contains a class from a deprecated set' do - let(:file) { <<~FILE } -
- Content -
- FILE - - it 'reports 1 offense' do - expect(subject.size).to(eq(1)) - end - - it 'reports an offense with its message ending with the suggestion' do - expect(subject.first.message).to(end_with(suggestion_1)) - end - end - end - - context 'when invalid attributes have really long names' do - let(:file) { <<~FILE } -
- FILE - - it 'does not report any offenses' do - expect(subject).to(eq([])) - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linters/erb_safety_spec.rb b/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linters/erb_safety_spec.rb deleted file mode 100644 index 227e95d2a..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linters/erb_safety_spec.rb +++ /dev/null @@ -1,188 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe ERBLint::Linters::ErbSafety do - let(:linter_config) { described_class.config_schema.new } - let(:better_html_config) do - { - javascript_safe_methods: %w(to_json), - } - end - let(:file_loader) { MockFileLoader.new(better_html_config) } - let(:linter) { described_class.new(file_loader, linter_config) } - let(:processed_source) { ERBLint::ProcessedSource.new('file.rb', file) } - subject { linter.offenses } - before { linter.run(processed_source) } - - class MockFileLoader - def initialize(config) - @config = config - end - - def yaml(_filename) - @config - end - end - - context 'interpolate a variable in js attribute' do - let(:file) { <<~FILE } - - FILE - - it { expect(subject).to(eq([unsafe_interpolate(23..25)])) } - end - - context 'interpolate a variable in js attribute calling safe method' do - let(:file) { <<~FILE } - - FILE - - it { expect(subject).to(eq([])) } - end - - context 'interpolate a variable in js attribute calling safe method inside string interpolation' do - let(:file) { <<~FILE } - )"> - FILE - - it { expect(subject).to(eq([])) } - end - - context 'html_safe in any attribute is unsafe' do - let(:file) { <<~FILE } -
- FILE - - it { expect(subject).to(eq([unsafe_html_safe(16..28)])) } - end - - context 'html_safe in any attribute is unsafe despite having to_json' do - let(:file) { <<~FILE } - - FILE - - it { expect(subject).to(eq([unsafe_html_safe(16..36), unsafe_interpolate(16..36)])) } - end - - context '<== in any attribute is unsafe' do - let(:file) { <<~FILE } -
- FILE - - it { expect(subject).to(eq([unsafe_erb_interpolate(12..22)])) } - end - - context '<== in any attribute is unsafe despite having to_json' do - let(:file) { <<~FILE } -
- FILE - - it { expect(subject).to(eq([unsafe_erb_interpolate(12..30)])) } - end - - context 'raw in any attribute is unsafe' do - let(:file) { <<~FILE } -
- FILE - - it { expect(subject).to(eq([unsafe_raw(16..22)])) } - end - - context 'raw in any attribute is unsafe despite having to_json' do - let(:file) { <<~FILE } -
- FILE - - it { expect(subject).to(eq([unsafe_raw(16..30)])) } - end - - context 'unsafe erb in - FILE - - it { expect(subject).to(eq([unsafe_javascript_tag_interpolate(18..30)])) } - end - - context 'safe erb in - FILE - - it { expect(subject).to(eq([])) } - end - - context 'safe erb in - FILE - - it { expect(subject).to(eq([])) } - end - - context 'statements not allowed in - FILE - - it { expect(subject).to(eq([erb_statements_not_allowed(8..20)])) } - end - - context 'changing better-html config file works' do - let(:linter_config) do - described_class.config_schema.new( - 'better_html_config' => '.better-html.yml' - ) - end - let(:file) { <<~FILE } - - FILE - - context 'with default config' do - let(:better_html_config) { {} } - it { expect(subject).to(eq([unsafe_javascript_tag_interpolate(8..20)])) } - end - - context 'with non-default config' do - let(:better_html_config) { { javascript_safe_methods: %w(foobar) } } - it { expect(subject).to(eq([])) } - end - - context 'with string keys in config' do - let(:better_html_config) { { 'javascript_safe_methods' => %w(foobar) } } - it { expect(subject).to(eq([])) } - end - end - - private - - def unsafe_interpolate(range) - build_offense(range, - "erb interpolation in javascript attribute must be wrapped in safe helper such as '(...).to_json'") - end - - def unsafe_html_safe(range) - build_offense(range, "erb interpolation with '<%= (...).html_safe %>' in this context is never safe") - end - - def unsafe_erb_interpolate(range) - build_offense(range, "erb interpolation with '<%==' inside html attribute is never safe") - end - - def unsafe_raw(range) - build_offense(range, "erb interpolation with '<%= raw(...) %>' in this context is never safe") - end - - def unsafe_javascript_tag_interpolate(range) - build_offense(range, "erb interpolation in javascript tag must call '(...).to_json'") - end - - def erb_statements_not_allowed(range) - build_offense(range, "erb statement not allowed here; did you mean '<%=' ?") - end - - def build_offense(range, message) - ERBLint::Offense.new(linter, processed_source.to_source_range(range), message) - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linters/extra_newline_spec.rb b/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linters/extra_newline_spec.rb deleted file mode 100644 index 2af09cd17..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linters/extra_newline_spec.rb +++ /dev/null @@ -1,153 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe ERBLint::Linters::ExtraNewline do - let(:linter_config) { described_class.config_schema.new } - - let(:file_loader) { ERBLint::FileLoader.new('.') } - let(:linter) { described_class.new(file_loader, linter_config) } - let(:processed_source) { ERBLint::ProcessedSource.new('file.rb', file) } - let(:offenses) { linter.offenses } - let(:corrector) { ERBLint::Corrector.new(processed_source, offenses) } - let(:corrected_content) { corrector.corrected_content } - before { linter.run(processed_source) } - - describe 'offenses' do - subject { offenses } - - context 'when no new line is present' do - let(:file) { "this is a line" } - it { expect(subject).to(eq([])) } - end - - context 'when no blank lines are present' do - let(:file) { <<~FILE } - line 1 - line 2 - line 3 - FILE - it { expect(subject).to(eq([])) } - end - - context 'when a single blank line is present' do - let(:file) { <<~FILE } - line 1 - - line 3 - FILE - it { expect(subject).to(eq([])) } - end - - context 'when two blank lines follow each other' do - let(:file) { <<~FILE } - line 1 - - - line 3 - FILE - it do - expect(subject).to(eq([ - build_offense(8..8, "Extra blank line detected."), - ])) - end - end - - context 'when more than two newlines follow each other' do - let(:file) { <<~FILE } - line 1 - - - - - line 3 - FILE - it do - expect(subject).to(eq([ - build_offense(8..10, "Extra blank line detected."), - ])) - end - end - end - - describe 'autocorrect' do - subject { corrected_content } - - context 'when no new line is present' do - let(:file) { "this is a line" } - it { expect(subject).to(eq(file)) } - end - - context 'when single blank line present at end of file' do - let(:file) { "this is a line\n\n" } - it { expect(subject).to(eq(file)) } - end - - context 'when multiple blank lines present at end of file' do - let(:file) { "this is a line\n\n\n\n" } - it { expect(subject).to(eq("this is a line\n\n")) } - end - - context 'when no blank lines are present' do - let(:file) { <<~FILE } - line 1 - line 2 - line 3 - FILE - it { expect(subject).to(eq(file)) } - end - - context 'when a single blank line is present' do - let(:file) { <<~FILE } - line 1 - - line 3 - FILE - it { expect(subject).to(eq(file)) } - end - - context 'when two blank lines follow each other' do - let(:file) { <<~FILE } - line 1 - - - line 3 - FILE - it do - expect(subject).to(eq(<<~FILE)) - line 1 - - line 3 - FILE - end - end - - context 'when more than two newlines follow each other' do - let(:file) { <<~FILE } - line 1 - - - - - line 3 - FILE - it do - expect(subject).to(eq(<<~FILE)) - line 1 - - line 3 - FILE - end - end - end - - private - - def build_offense(range, message) - ERBLint::Offense.new( - linter, - processed_source.to_source_range(range), - message - ) - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linters/final_newline_spec.rb b/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linters/final_newline_spec.rb deleted file mode 100644 index db06b5ff3..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linters/final_newline_spec.rb +++ /dev/null @@ -1,175 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe ERBLint::Linters::FinalNewline do - let(:linter_config) { described_class.config_schema.new(present: present) } - - let(:file_loader) { ERBLint::FileLoader.new('.') } - let(:linter) { described_class.new(file_loader, linter_config) } - let(:processed_source) { ERBLint::ProcessedSource.new('file.rb', file) } - let(:offenses) { linter.offenses } - let(:corrector) { ERBLint::Corrector.new(processed_source, offenses) } - let(:corrected_content) { corrector.corrected_content } - subject { offenses } - before { linter.run(processed_source) } - - context 'when trailing newline is preferred' do - let(:present) { true } - - context 'when the file is empty' do - let(:file) { '' } - - it 'does not report any offenses' do - expect(subject).to(eq([])) - end - end - - context 'when the file ends with a newline' do - let(:file) { "
\nContent\n
\n" } - - it 'does not report any errors' do - expect(subject).to(eq([])) - end - end - - context 'when the file ends with multiple newlines' do - let(:file) { "
\nContent\n
\n\n\n" } - - it 'reports 1 offense' do - expect(subject.size).to(eq(1)) - end - - it 'the offense range is set to an empty range after the last character of the file' do - expect(subject.first.source_range.begin_pos).to(eq(28)) - expect(subject.first.source_range.end_pos).to(eq(30)) - expect(subject.first.source_range.source).to(eq("\n\n")) - expect(subject.first.message).to(eq(\ - "Remove multiple trailing newline at the end of the file." - )) - end - - it 'autocorrects' do - expect(corrected_content).to(eq("
\nContent\n
\n")) - end - end - - context 'when the file does not end with a newline' do - let(:file) { "
\nContent\n
" } - - it 'reports 1 offense' do - expect(subject.size).to(eq(1)) - end - - it 'reports an offense on the last line' do - expect(subject.first.line_range).to(eq(3..3)) - end - - it 'the offense range is set to an empty range after the last character of the file' do - expect(subject.first.source_range.begin_pos).to(eq(27)) - expect(subject.first.source_range.end_pos).to(eq(27)) - expect(subject.first.source_range.source).to(eq("")) - end - - it 'autocorrects' do - expect(corrected_content).to(eq("
\nContent\n
\n")) - end - end - end - - context 'when no trailing newline is preferred' do - let(:present) { false } - - context 'when the file is empty' do - let(:file) { '' } - - it 'does not report any offenses' do - expect(subject).to(eq([])) - end - end - - context 'when the file ends with a newline' do - let(:file) { "
\nContent\n
\n" } - - it 'reports 1 offense' do - expect(subject.size).to(eq(1)) - end - - it 'reports meaningful message' do - expect(subject.first.message).to(eq('Remove 1 trailing newline at the end of the file.')) - end - - it 'reports an offense on the last line' do - expect(subject.first.line_range).to(eq(3..4)) - end - - it 'the offense range is set to the newline character' do - expect(subject.first.source_range.begin_pos).to(eq(27)) - expect(subject.first.source_range.end_pos).to(eq(28)) - expect(subject.first.source_range.source).to(eq("\n")) - end - - it 'autocorrects' do - expect(corrected_content).to(eq("
\nContent\n
")) - end - end - - context 'when the file ends with multiple newlines' do - let(:file) { "foo\n\n\n\n" } - - it 'the offense range includes all newline characters' do - expect(subject.first.source_range.begin_pos).to(eq(3)) - expect(subject.first.source_range.end_pos).to(eq(7)) - expect(subject.first.source_range.source).to(eq("\n\n\n\n")) - end - - it 'reports meaningful message' do - expect(subject.first.message).to(eq('Remove 4 trailing newline at the end of the file.')) - end - - it 'autocorrects' do - expect(corrected_content).to(eq("foo")) - end - end - - context 'when the file does not end with a newline' do - let(:file) { "
\nContent\n
" } - - it 'does not report any offenses' do - expect(subject).to(eq([])) - end - end - end - - context 'when trailing newline preference is not stated' do - let(:linter_config) { described_class.config_schema.new } - - context 'when the file is empty' do - let(:file) { '' } - - it 'does not report any offenses' do - expect(subject).to(eq([])) - end - end - - context 'when the file ends with a newline' do - let(:file) { "
\nContent\n
\n" } - - it 'does not report any offenses' do - expect(subject).to(eq([])) - end - end - - context 'when the file does not end with a newline' do - let(:file) { "
\nContent\n
" } - - it 'reports 1 offense' do - expect(subject.size).to(eq(1)) - end - - it 'reports an offense on the last line' do - expect(subject.first.line_range).to(eq(3..3)) - end - end - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linters/hard_coded_string_spec.rb b/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linters/hard_coded_string_spec.rb deleted file mode 100644 index 7ee711a81..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linters/hard_coded_string_spec.rb +++ /dev/null @@ -1,295 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe ERBLint::Linters::HardCodedString do - let(:linter_options) { { i18n_load_path: 'test/load/path' } } - let(:linter_config) do - described_class.config_schema.new(linter_options) - end - let(:file_loader) { ERBLint::FileLoader.new('.') } - let(:linter) { described_class.new(file_loader, linter_config) } - let(:processed_source) { ERBLint::ProcessedSource.new('file.rb', file) } - subject { linter.offenses } - before { linter.run(processed_source) } - - context 'when file contains hard coded string' do - let(:file) { <<~FILE } - Hello - FILE - - it { expect(subject).to(eq([untranslated_string_error(7..11, 'String not translated: Hello')])) } - end - - context 'when file contains nested hard coded string' do - let(:file) { <<~FILE } - -
- Example -
-
- FILE - - it { expect(subject).to(eq([untranslated_string_error(61..67, 'String not translated: Example')])) } - end - - context 'when file contains a mix of hard coded string and erb' do - let(:file) { <<~FILE } - <%= foo %> Example - FILE - - it { expect(subject).to(eq([untranslated_string_error(17..23, 'String not translated: Example')])) } - end - - context 'when file contains hard coded string nested inside erb' do - let(:file) { <<~FILE } - - <% foo do %> - Example - <% end %> - - FILE - - it { expect(subject).to(eq([untranslated_string_error(33..39, 'String not translated: Example')])) } - end - - context 'when file contains multiple hard coded string' do - let(:file) { <<~FILE } - Example - Foo - Test - FILE - - it 'find all offenses' do - expect(subject).to(eq([ - untranslated_string_error(7..13, 'String not translated: Example'), - untranslated_string_error(30..32, 'String not translated: Foo'), - untranslated_string_error(49..52, 'String not translated: Test'), - ])) - end - end - - context 'when file does not contain any hard coded string' do - let(:file) { <<~FILE } - -
- <%= t(:hello) %> -
-
- FILE - - it { expect(subject).to(eq([])) } - end - - context 'when file contains blacklisted extraction' do - let(:file) { <<~FILE } -   - FILE - - it { expect(subject).to(eq([])) } - end - - context 'when file contains irrelevant hard coded string' do - let(:file) { <<~FILE } - - <% discounted_by %>% - - - - FILE - - it 'does not add offense' do - expect(subject).to(eq([])) - end - end - - context 'when file contains hard coded string inside javascript' do - let(:file) { <<~FILE } - - FILE - - it { expect(subject).to(eq([])) } - end - - context 'when file contains hard coded string inside style' do - let(:file) { <<~FILE } - - FILE - - it { expect(subject).to(eq([])) } - end - - %w(xmp iframe noembed noframes listing).each do |tag| - context "when file contains hard coded string inside #{tag}" do - let(:file) { <<~FILE } - <#{tag}> - hardcoded string - - FILE - - it { expect(subject).to(eq([])) } - end - end - - context 'when file contains hard coded string following a javascript block' do - let(:file) { <<~FILE } - - Example - FILE - - it { expect(subject).to(eq([untranslated_string_error(158..164, "String not translated: Example")])) } - end - - context 'when file contains multiple chunks of hardcoded strings' do - let(:file) { <<~FILE } -
- Foo <%= bar %> Foo2 <% bar %> Foo3 -
- FILE - - it do - expected = [ - untranslated_string_error(8..10, "String not translated: Foo"), - untranslated_string_error(23..26, "String not translated: Foo2"), - untranslated_string_error(38..41, "String not translated: Foo3"), - ] - - expect(subject).to(eq(expected)) - end - end - - context 'when file contains multiple hardcoded strings that spans on multiple lines' do - let(:file) { <<~FILE } -
- Foo - John - Albert - Smith - <%= test %> -
- FILE - - it 'creates a new offense for each' do - expected = [ - untranslated_string_error(8..10, "String not translated: Foo"), - untranslated_string_error(14..17, "String not translated: John"), - untranslated_string_error(21..26, "String not translated: Albert"), - untranslated_string_error(30..34, "String not translated: Smith"), - ] - - expect(subject).to(eq(expected)) - end - end - - context 'with corrector and load_path' do - let(:corrector_file) do - Tempfile.new(['my_class', '.rb']).tap do |f| - f.write(<<~EOM) - class I18nCorrector - attr_reader :node - - def initialize(node, filename, i18n_load_path, range) - end - - def autocorrect(tag_start:, tag_end:) - ->(corrector) do - node - end - end - end - EOM - f.rewind - end - end - - let(:translation_file) do - Tempfile.new(['en', '.yml']).tap do |f| - f.write(<<~EOM) - --- - EOM - f.rewind - end - end - - after(:each) do - corrector_file.unlink - corrector_file.close - translation_file.unlink - translation_file.close - end - - let(:linter_options) do - { corrector: { path: corrector_file.path, name: 'I18nCorrector', i18n_load_path: translation_file.path } } - end - - let(:file) { <<~FILE } - Hello - FILE - - it 'require the corrector' do - offense = untranslated_string_error(7..11, 'String not translated: Hello') - linter.autocorrect(processed_source, offense) - - expect(defined?(I18nCorrector)).to(eq('constant')) - end - - context 'without i18n load path' do - let(:linter_options) do - { corrector: { path: corrector_file.path, name: 'I18nCorrector' } } - end - - it 'rescues the MissingI18nLoadPath error when no load path options is passed' do - offense = untranslated_string_error(7..11, 'String not translated: Hello') - - expect(linter.autocorrect(processed_source, offense)).to(eq(nil)) - end - end - - context 'without corrector' do - let(:linter_options) { {} } - - it 'rescue the MissingCorrector error when no corrector option is passed' do - offense = untranslated_string_error(7..11, 'String not translated: Hello') - - expect(linter.autocorrect(processed_source, offense)).to(eq(nil)) - end - end - - context 'can not constanize the class' do - let(:linter_options) do - { corrector: { path: corrector_file.path, i18n_load_path: translation_file.path, name: 'UnknownClass' } } - end - - it 'does not continue the auto correction when the class passed is not whitelisted' do - offense = untranslated_string_error(7..11, 'String not translated: Hello') - - error = ERBLint::Linters::HardCodedString::ForbiddenCorrector - expect { linter.autocorrect(processed_source, offense) }.to(raise_error(error)) - end - end - end - - private - - def untranslated_string_error(range, string) - ERBLint::Offense.new( - linter, - processed_source.to_source_range(range), - string - ) - end -end diff --git a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linters/no_javascript_tag_helper_spec.rb b/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linters/no_javascript_tag_helper_spec.rb deleted file mode 100644 index 7df792257..000000000 --- a/vendor/cache/erb-lint-05596ea189ee/spec/erb_lint/linters/no_javascript_tag_helper_spec.rb +++ /dev/null @@ -1,197 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe ERBLint::Linters::NoJavascriptTagHelper do - let(:linter_config) { described_class.config_schema.new } - let(:file_loader) { ERBLint::FileLoader.new('.') } - let(:linter) { described_class.new(file_loader, linter_config) } - let(:processed_source) { ERBLint::ProcessedSource.new('file.rb', file) } - let(:offenses) { linter.offenses } - let(:corrector) { ERBLint::Corrector.new(processed_source, offenses) } - let(:corrected_content) { corrector.corrected_content } - before { linter.run(processed_source) } - - describe 'offenses' do - subject { offenses } - - context 'usage of javascript_tag helper' do - let(:file) { <<~FILE } -
- <%= javascript_tag do %> - FILE - - it { expect(subject).to(eq([build_offense(7..30)])) } - end - - context 'regression with <%%= syntax does not raise an exception' do - let(:file) { <<~FILE } - <%%= ma_tile do |tile| %> - <%%= tile.image 'styleguide/toronto-stunning-sunset' %> - <%% end %> - <% end %> - FILE - - it { expect(subject).to(eq([])) } - end - - context 'no method calls in erb tag' do - let(:file) { <<~FILE } - <%= true %> - FILE - - it { expect(subject).to(eq([])) } - end - end - - describe 'autocorrect' do - subject { corrected_content } - - context 'with string argument' do - let(:file) { <<~HTML } - <%= javascript_tag("var myData = 1;") %> - HTML - - it { expect(subject).to(eq(<<~HTML)) } - - HTML - end - - context 'with plain correction style' do - let(:linter_config) { described_class.config_schema.new(correction_style: 'plain') } - let(:file) { <<~HTML } - <%= javascript_tag("var myData = 1;") %> - HTML - - it { expect(subject).to(eq(<<~HTML)) } - - HTML - end - - context 'with string argument and options' do - let(:file) { <<~HTML } - <%= javascript_tag('var myData = 1;', defer: true) %> - HTML - - it { expect(subject).to(eq(<<~HTML)) } - - HTML - end - - context 'with string argument and options and interpolations' do - let(:file) { <<~HTML } - <%= javascript_tag("var myData = \#{myData.to_json};", custom_attribute: "foo-\#{my_attribute}") %> - HTML - - it { expect(subject).to(eq(<<~HTML)) } - - HTML - end - - context 'with method argument' do - let(:file) { <<~HTML } - <%= javascript_tag(data) %> - HTML - - it { expect(subject).to(eq(<<~HTML)) } - - HTML - end - - context 'without options and block' do - let(:file) { <<~HTML } - <%= javascript_tag do %> - foo - <% end %> - HTML - - it { expect(subject).to(eq(<<~HTML)) } - - HTML - end - - context 'without options and block when correction style is plain' do - let(:linter_config) { described_class.config_schema.new(correction_style: 'plain') } - let(:file) { <<~HTML } - <%= javascript_tag do %> - foo - <% end %> - HTML - - it { expect(subject).to(eq(<<~HTML)) } - - HTML - end - - context 'with html options and block' do - let(:file) { <<~HTML } - <%= javascript_tag(defer: true, async: true) do %> - foo - <% end %> - HTML - - it { expect(subject).to(eq(<<~HTML)) } - - HTML - end - - context 'with old hash syntax options and block' do - let(:file) { <<~HTML } - <%= javascript_tag('defer' => true, :async => 'true') do %> - foo - <% end %> - HTML - - it { expect(subject).to(eq(<<~HTML)) } - - HTML - end - end - - private - - def build_offense(range) - ERBLint::Offense.new( - linter, - processed_source.to_source_range(range), - "Avoid using 'javascript_tag do' as it confuses tests "\ - "that validate html, use inline