From be12db2cf1781664c192e238adef404733c4a590 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 22 Mar 2018 08:53:49 +0000 Subject: [PATCH 1/4] Bump rubocop from 0.52.1 to 0.54.0 Bumps [rubocop](https://github.com/bbatsov/rubocop) from 0.52.1 to 0.54.0. - [Release notes](https://github.com/bbatsov/rubocop/releases) - [Changelog](https://github.com/bbatsov/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/bbatsov/rubocop/compare/v0.52.1...v0.54.0) Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index 46d504f2..a39d7a67 100644 --- a/Gemfile +++ b/Gemfile @@ -18,7 +18,7 @@ group :development do gem "factory_bot", "~> 4.8.2" gem "rspec", "~> 3.7.0" - gem "rubocop", "~> 0.52.1" + gem "rubocop", "~> 0.54.0" gem "webmock", "~> 3.3.0" end diff --git a/Gemfile.lock b/Gemfile.lock index 0a5e2685..8e7adb8d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,7 +8,7 @@ GEM tzinfo (~> 1.1) addressable (2.5.2) public_suffix (>= 2.0.2, < 4.0) - ast (2.3.0) + ast (2.4.0) concurrent-ruby (1.0.5) crack (0.4.3) safe_yaml (~> 1.0.0) @@ -51,8 +51,8 @@ GEM opus-ruby (1.0.1) ffi parallel (1.12.1) - parser (2.4.0.2) - ast (~> 2.3) + parser (2.5.0.4) + ast (~> 2.4.0) powerpack (0.1.1) prius (2.0.0) public_suffix (3.0.1) @@ -79,9 +79,9 @@ GEM rspec-support (3.7.0) rspec_junit_formatter (0.3.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (0.52.1) + rubocop (0.54.0) parallel (~> 1.10) - parser (>= 2.4.0.2, < 3.0) + parser (>= 2.5) powerpack (~> 0.1) rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) @@ -125,7 +125,7 @@ DEPENDENCIES rake rspec (~> 3.7.0) rspec_junit_formatter (= 0.3.0) - rubocop (~> 0.52.1) + rubocop (~> 0.54.0) rufus-scheduler (~> 3.4.2) sentry-raven (~> 2.7.2) songkick-transport (~> 1.11.0) From 0f03b7a153ae00b21950ee91bfa9e2881d111aec Mon Sep 17 00:00:00 2001 From: Ivan Giuliani Date: Sat, 31 Mar 2018 20:10:52 +0100 Subject: [PATCH 2/4] Fun times parser 2.5.0.4 (whatever that is) has been pulled from rubygems in favour or 2.5.0.5. --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8e7adb8d..2f37fdd2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -51,7 +51,7 @@ GEM opus-ruby (1.0.1) ffi parallel (1.12.1) - parser (2.5.0.4) + parser (2.5.0.5) ast (~> 2.4.0) powerpack (0.1.1) prius (2.0.0) From 3b37f8aad9e31f9e5a05cce8d135be2d43c6bff2 Mon Sep 17 00:00:00 2001 From: Ivan Giuliani Date: Sat, 31 Mar 2018 20:21:21 +0100 Subject: [PATCH 3/4] Avoid using open() Rubocop doesn't like it, something something security. Though in this case it cannot be exploited so I could just ignore the warning, but better safe than sorry. --- app/tfl/data/update.rb | 15 +++++++-------- app/tfl/scraping/press_releases_feed.rb | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/tfl/data/update.rb b/app/tfl/data/update.rb index 9d2aa7f9..2d6a9047 100755 --- a/app/tfl/data/update.rb +++ b/app/tfl/data/update.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -require "open-uri" +require "net/http" require "json" # rubocop:disable Metrics/LineLength @@ -19,19 +19,18 @@ ].freeze # rubocop:enable Metrics/LineLength -DOWNLOADS.each do |download| - url, output, type = *download - +DOWNLOADS.each do |url, output, type| $stdout.puts "Downloading #{url} => #{output}" case type when :json - open(output, "w") do |file| - file << JSON.pretty_generate(JSON.parse(open(url).read)) << "\n" + File.open(output, "w") do |file| + content = Net::HTTP.get(URI(url)) + file << JSON.pretty_generate(JSON.parse(content)) << "\n" end when :xml - stream = open(url) - IO.copy_stream(stream, output) + content = Net::HTTP.get(URI(url)) + File.write(output, content) else raise ArgumentError, "Invalid type" end diff --git a/app/tfl/scraping/press_releases_feed.rb b/app/tfl/scraping/press_releases_feed.rb index fe19b479..2bd1559a 100644 --- a/app/tfl/scraping/press_releases_feed.rb +++ b/app/tfl/scraping/press_releases_feed.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "open-uri" +require "net/http" require "nokogiri" module Tfl @@ -31,7 +31,7 @@ def update!(raw_html: nil) private def download_content - open(PRESS_RELEASES_URL).read + Net::HTTP.get(URI(PRESS_RELEASES_URL)) end def parse_content(content) From 67a2c352cd9caeca8b714da2bed1c4b0764e98f6 Mon Sep 17 00:00:00 2001 From: Ivan Giuliani Date: Sat, 31 Mar 2018 20:25:01 +0100 Subject: [PATCH 4/4] One less level of indirection --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b18e444c..6c35a37f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path("../../app", __FILE__) +$LOAD_PATH.unshift File.expand_path("../app", __dir__) ENV["DISCORD_CLIENT_ID"] = "12345678901234567" ENV["DISCORD_TOKEN"] = "t0k3nt0k3nt0k3nt0k3nt0k3n.1234hrx0rz1234token"