Skip to content

Commit

Permalink
Update multiline strings based on latest RuboCop
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredcwhite committed Jun 27, 2022
1 parent 5c7a7f0 commit 953fbee
Show file tree
Hide file tree
Showing 27 changed files with 78 additions and 70 deletions.
8 changes: 8 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This configuration file was automatically generated by Gitpod.
# Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file)
# and commit this file to your remote git repository to share the goodness with others.

tasks:
- init: bundle install


10 changes: 5 additions & 5 deletions bridgetown-core/features/step_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#

Given(%r!^I have a blank site in "(.*)"$!) do |path|
FileUtils.mkdir_p(path) unless File.exist?(path)
FileUtils.mkdir_p(path)
end

#
Expand All @@ -47,7 +47,7 @@
#{text}
DATA
else
FileUtils.mkdir_p("src") unless File.exist?("src")
FileUtils.mkdir_p("src")
File.write(File.join("src", file), <<~DATA)
---
#{key || "layout"}: #{value || "none"}
Expand All @@ -64,7 +64,7 @@
if Paths.root_files.include?(file.split("/").first)
File.write(file, text)
else
FileUtils.mkdir_p("src") unless File.exist?("src")
FileUtils.mkdir_p("src")
File.write(File.join("src", file), text)
end
end
Expand All @@ -85,15 +85,15 @@
if Paths.root_files.include?(file.split("/").first)
File.write(file, text)
else
FileUtils.mkdir_p("src") unless File.exist?("src")
FileUtils.mkdir_p("src")
File.write(File.join("src", file), text)
end
end

#

Given(%r!^I have an? "(.*)" page(?: configured with (.*) "(.*)")? with content:$!) do |file, key, value, text|
FileUtils.mkdir_p("src") unless File.exist?("src")
FileUtils.mkdir_p("src")
File.write(File.join("src", file), <<~DATA)
---
#{key || "layout"}: #{value || "none"}
Expand Down
4 changes: 2 additions & 2 deletions bridgetown-core/lib/bridgetown-core/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ def determine_sort_order(sort_key, apples, olives)
end

def order_with_warning(sort_key, resource, order)
Bridgetown.logger.warn "Sort warning:", "'#{sort_key}' not defined in" \
" #{resource.relative_path}"
Bridgetown.logger.warn "Sort warning:", "'#{sort_key}' not defined in " \
"#{resource.relative_path}"
order
end

Expand Down
6 changes: 3 additions & 3 deletions bridgetown-core/lib/bridgetown-core/commands/apply.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def apply_in_pwd
automation_command = args.empty? ? "bridgetown.automation.rb" : args[0]

if args.empty? && !File.exist?("bridgetown.automation.rb")
raise ArgumentError, "You must specify a path or a URL," \
" or add bridgetown.automation.rb to the" \
" current folder."
raise ArgumentError, "You must specify a path or a URL, " \
"or add bridgetown.automation.rb to the " \
"current folder."
end

Bridgetown.with_unbundled_env do
Expand Down
12 changes: 6 additions & 6 deletions bridgetown-core/lib/bridgetown-core/commands/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def self.banner
desc: "Watch for changes and rebuild"

def self.print_startup_message
Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta}" \
" (codename \"#{Bridgetown::CODE_NAME.yellow}\")"
Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta} " \
"(codename \"#{Bridgetown::CODE_NAME.yellow}\")"
end

# Build your bridgetown site
Expand All @@ -45,8 +45,8 @@ def build
@site = Bridgetown::Site.new(config_options)

if config_options.fetch("skip_initial_build", false)
Bridgetown.logger.warn "Build Warning:", "Skipping the initial build." \
" This may result in an out-of-date site."
Bridgetown.logger.warn "Build Warning:", "Skipping the initial build. " \
"This may result in an out-of-date site."
else
build_site(config_options)
end
Expand Down Expand Up @@ -77,8 +77,8 @@ def build_site(config_options)
end
Bridgetown.logger.info "Generating…"
@site.process
Bridgetown.logger.info "Done! 🎉", "#{"Completed".bold.green} in less than" \
" #{(Time.now - t).ceil(2)} seconds."
Bridgetown.logger.info "Done! 🎉", "#{"Completed".bold.green} in less than " \
"#{(Time.now - t).ceil(2)} seconds."

return unless config_options[:using_puma]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def self.extended(klass)
desc: "Destination directory (defaults to output)"
klass.class_option :root_dir,
aliases: "-r",
desc: "The top-level root folder" \
" where config files are located"
desc: "The top-level root folder " \
"where config files are located"
klass.class_option :plugins_dir,
aliases: "-p",
type: :array,
Expand Down
10 changes: 5 additions & 5 deletions bridgetown-core/lib/bridgetown-core/commands/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def console
require "irb/ext/save-history"
require "amazing_print" unless options[:"bypass-ap"]

Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta}" \
" (codename \"#{Bridgetown::CODE_NAME.yellow}\")" \
" console…"
Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta} " \
"(codename \"#{Bridgetown::CODE_NAME.yellow}\") " \
"console…"
Bridgetown.logger.info "Environment:", Bridgetown.environment.cyan
site = Bridgetown::Site.new(configuration_with_overrides(options))

Expand All @@ -80,8 +80,8 @@ def console
IRB.conf[:MAIN_CONTEXT] = irb.context
Bridgetown.logger.info "Console:", "Your site is now available as #{"site".cyan}"
Bridgetown.logger.info "",
"You can also access #{"collections".cyan} or perform a" \
" #{"reload!".cyan}"
"You can also access #{"collections".cyan} or perform a " \
"#{"reload!".cyan}"

trap("SIGINT") do
irb.signal_handle
Expand Down
14 changes: 7 additions & 7 deletions bridgetown-core/lib/bridgetown-core/commands/doctor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def conflicting_urls(site)
next unless paths.size > 1

conflicting_urls = true
Bridgetown.logger.warn "Conflict:", "The URL '#{url}' is the destination" \
" for the following pages: #{paths.join(", ")}"
Bridgetown.logger.warn "Conflict:", "The URL '#{url}' is the destination " \
"for the following pages: #{paths.join(", ")}"
end
conflicting_urls
end
Expand All @@ -77,8 +77,8 @@ def urls_only_differ_by_case(site)
urls_only_differ_by_case = true
Bridgetown.logger.warn(
"Warning:",
"The following URLs only differ by case. On a case-insensitive file system one of the" \
" URLs will be overwritten by the other: #{real_urls.join(", ")}"
"The following URLs only differ by case. On a case-insensitive file system one of " \
"the URLs will be overwritten by the other: #{real_urls.join(", ")}"
)
end
urls_only_differ_by_case
Expand Down Expand Up @@ -121,7 +121,7 @@ def case_insensitive_urls(things, _destination)
def url_exists?(url)
return true unless url.nil? || url.empty?

Bridgetown.logger.warn "Warning:", "You didn't set an URL in the config file, "\
Bridgetown.logger.warn "Warning:", "You didn't set an URL in the config file, " \
"you may encounter problems with some plugins."
false
end
Expand All @@ -132,15 +132,15 @@ def url_valid?(url)
# Addressable::URI#parse only raises a TypeError
# https://git.io/vFfbx
rescue TypeError
Bridgetown.logger.warn "Warning:", "The site URL does not seem to be valid, "\
Bridgetown.logger.warn "Warning:", "The site URL does not seem to be valid, " \
"check the value of `url` in your config file."
false
end

def url_absolute(url)
return true if url.is_a?(String) && Addressable::URI.parse(url).absolute?

Bridgetown.logger.warn "Warning:", "Your site URL does not seem to be absolute, "\
Bridgetown.logger.warn "Warning:", "Your site URL does not seem to be absolute, " \
"check the value of `url` in your config file."
false
end
Expand Down
20 changes: 10 additions & 10 deletions bridgetown-core/lib/bridgetown-core/commands/new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def new_site
if preserve_source_location?(new_site_path, options)
say_status :conflict, "#{new_site_path} exists and is not empty.", :red
Bridgetown.logger.abort_with(
"Ensure #{new_site_path} is empty or else try again with `--force` to proceed and" \
" overwrite any files."
"Ensure #{new_site_path} is empty or else try again with `--force` to proceed and " \
"overwrite any files."
)
end

Expand Down Expand Up @@ -194,18 +194,18 @@ def after_install(path, cli_path, options = {})
logger = Bridgetown.logger
bt_start = "bin/bridgetown start"
logger.info ""
logger.info "Success!".green, "🎉 Your new Bridgetown site was" \
" generated in #{cli_path.cyan}."
logger.info "Success!".green, "🎉 Your new Bridgetown site was " \
"generated in #{cli_path.cyan}."
if options["skip-yarn"]
logger.info "You can now #{"cd".cyan} #{cli_path.cyan} to get started."
logger.info "You'll probably also want to #{"yarn install".cyan}" \
" to load in your frontend assets."
logger.info "You'll probably also want to #{"yarn install".cyan} " \
"to load in your frontend assets."
else
logger.info "You can now #{"cd".cyan} #{cli_path.cyan} and run #{bt_start.cyan}" \
" to get started."
logger.info "You can now #{"cd".cyan} #{cli_path.cyan} and run #{bt_start.cyan} " \
"to get started."
end
logger.info "Then check out our online documentation for" \
" next steps: #{DOCSURL.cyan}"
logger.info "Then check out our online documentation for " \
"next steps: #{DOCSURL.cyan}"

if @skipped_bundle
logger.info "Bundle install skipped.".yellow
Expand Down
4 changes: 2 additions & 2 deletions bridgetown-core/lib/bridgetown-core/commands/serve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ def boot_or_detach(server, opts)

Process.detach(pid)
Bridgetown.logger.info "Server detached with pid '#{pid}'.", \
"Run `pkill -f bridgetown' or `kill -9 #{pid}'" \
" to stop the server."
"Run `pkill -f bridgetown' or `kill -9 #{pid}' " \
"to stop the server."
else
t = Thread.new { server.start }
trap("INT") { server.shutdown }
Expand Down
2 changes: 1 addition & 1 deletion bridgetown-core/lib/bridgetown-core/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def render_in(view_context, &block)
end
rescue StandardError => e
Bridgetown.logger.error "Component error:",
"#{self.class} encountered an error while "\
"#{self.class} encountered an error while " \
"rendering `#{self.class.path_for_errors}'"
raise e
end
Expand Down
4 changes: 2 additions & 2 deletions bridgetown-core/lib/bridgetown-core/concerns/transformable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def transform_content(document)
output.html_safe
rescue StandardError => e
Bridgetown.logger.error "Conversion error:",
"#{converter.class} encountered an error while "\
"#{converter.class} encountered an error while " \
"converting `#{document.relative_path}'"
raise e
end
Expand Down Expand Up @@ -53,7 +53,7 @@ def transform_with_layout(layout, output, document)
layout_output
rescue StandardError => e
Bridgetown.logger.error "Conversion error:",
"#{converter.class} encountered an error while "\
"#{converter.class} encountered an error while " \
"converting `#{document.relative_path}'"
raise e
end
Expand Down
4 changes: 2 additions & 2 deletions bridgetown-core/lib/bridgetown-core/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ def read_config_files(files)
config = Utils.deep_merge_hashes(self, new_config)
end
rescue ArgumentError => e
Bridgetown.logger.warn "WARNING:", "Error reading configuration. Using defaults" \
" (and options)."
Bridgetown.logger.warn "WARNING:", "Error reading configuration. Using defaults " \
"(and options)."
warn e
end

Expand Down
4 changes: 2 additions & 2 deletions bridgetown-core/lib/bridgetown-core/model/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ def method_missing(method_name, *args)
return attributes[key]
end

Bridgetown.logger.warn "key `#{method_name}' not found in attributes for" \
" #{attributes[:id].presence || "new #{self.class}"}"
Bridgetown.logger.warn "key `#{method_name}' not found in attributes for " \
"#{attributes[:id].presence || "new #{self.class}"}"
nil
end

Expand Down
4 changes: 2 additions & 2 deletions bridgetown-core/lib/bridgetown-core/rack/boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def self.boot(roda_app = nil)
rescue Roda::RodaError => e
if e.message.include?("sessions plugin :secret option")
raise Bridgetown::Errors::InvalidConfigurationError,
"The Roda sessions plugin can't find a valid secret. Run `bin/bridgetown secret'" \
" and put the key in a ENV var you can use to configure the session in `roda_app.rb'"
"The Roda sessions plugin can't find a valid secret. Run `bin/bridgetown secret' " \
"and put the key in a ENV var you can use to configure the session in `roda_app.rb'"
end

raise e
Expand Down
2 changes: 1 addition & 1 deletion bridgetown-core/lib/bridgetown-core/static_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def write(dest)
self.class.mtimes[path] = mtime

FileUtils.mkdir_p(File.dirname(dest_path))
FileUtils.rm(dest_path) if File.exist?(dest_path)
FileUtils.rm_rf(dest_path)
Bridgetown.logger.debug "Saving file:", dest_path
copy_file(dest_path)

Expand Down
2 changes: 1 addition & 1 deletion bridgetown-core/lib/bridgetown-core/tags/highlight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def add_code_tag(code)
"class=\"language-#{@lang.to_s.tr("+", "-")}\"",
"data-lang=\"#{@lang}\"",
].join(" ")
"<figure class=\"highlight\"><pre><code #{code_attributes}>"\
"<figure class=\"highlight\"><pre><code #{code_attributes}>" \
"#{code.chomp}</code></pre></figure>"
end
end
Expand Down
2 changes: 1 addition & 1 deletion bridgetown-core/lib/bridgetown-core/tags/post_url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def render(context)
next unless @post.deprecated_equality document

Bridgetown::Deprecator.deprecation_message(
"A call to "\
"A call to " \
"'{% post_url #{@post.name} %}' did not match " \
"a post using the new matching method of checking name " \
"(path-date-slug) equality. Please make sure that you " \
Expand Down
2 changes: 1 addition & 1 deletion bridgetown-core/lib/bridgetown-core/url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def generate_url_from_drop(template)
winner = pool.find { |key| @placeholders.key?(key) }
if winner.nil?
raise NoMethodError,
"The URL template doesn't have #{pool.join(" or ")} keys. "\
"The URL template doesn't have #{pool.join(" or ")} keys. " \
"Check your permalink template!"
end

Expand Down
4 changes: 2 additions & 2 deletions bridgetown-core/lib/bridgetown-core/watcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ def reload_site(site, options, paths: []) # rubocop:todo Metrics/MethodLength

site.process
end
Bridgetown.logger.info "Done! 🎉", "#{"Completed".bold.green} in less than" \
" #{(Time.now - time).ceil(2)} seconds."
Bridgetown.logger.info "Done! 🎉", "#{"Completed".bold.green} in less than " \
"#{(Time.now - time).ceil(2)} seconds."
rescue StandardError => e
Bridgetown::Errors.print_build_error(e, trace: options[:trace])
end
Expand Down
2 changes: 1 addition & 1 deletion bridgetown-core/test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def mu_pp(obj)
end

def mocks_expect(*args)
RSpec::Mocks::ExampleMethods::ExpectHost.instance_method(:expect)\
RSpec::Mocks::ExampleMethods::ExpectHost.instance_method(:expect) \
.bind_call(self, *args)
end

Expand Down
2 changes: 1 addition & 1 deletion bridgetown-core/test/test_apply_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TestApplyCommand < BridgetownUnitTest
context "the apply command" do
setup do
@cmd = Bridgetown::Commands::Apply.new
File.delete("bridgetown.automation.rb") if File.exist?("bridgetown.automation.rb")
FileUtils.rm_rf("bridgetown.automation.rb")
@template = "" + <<-TEMPLATE
say_status :urltest, "Works!"
TEMPLATE
Expand Down
4 changes: 2 additions & 2 deletions bridgetown-core/test/test_doctor_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class TestDoctorCommand < BridgetownUnitTest
ret = Bridgetown::Commands::Doctor.new.send(:urls_only_differ_by_case, @site)
assert_equal true, ret
end
assert_includes output, "Warning: The following URLs only differ by case. "\
"On a case-insensitive file system one of the URLs will be overwritten by the "\
assert_includes output, "Warning: The following URLs only differ by case. " \
"On a case-insensitive file system one of the URLs will be overwritten by the " \
"other: #{dest_dir}/about/index.html, #{dest_dir}/About/index.html"
end
end
Expand Down
4 changes: 2 additions & 2 deletions bridgetown-core/test/test_generated_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def render_and_write
refute File.exist?(dest_dir("virtual-about", "index.html"))
end

should "be processed and written to destination when passed as "\
should "be processed and written to destination when passed as " \
"an entry in 'site.generated_pages' array" do
@page.content = "{{ site.title }}"
@page.data["permalink"] = "/virtual-about/"
Expand Down Expand Up @@ -305,7 +305,7 @@ def render_and_write

should "not be writable outside of destination" do
unexpected = File.expand_path("../../../baddie.html", dest_dir)
File.delete unexpected if File.exist?(unexpected)
FileUtils.rm_rf unexpected
page = setup_page("exploit.md")
do_render(page)
page.write(dest_dir)
Expand Down
Loading

0 comments on commit 953fbee

Please sign in to comment.