Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freeze string literals by default #929

Merged
merged 4 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ Style/StringLiterals:
Style/SymbolArray:
EnforcedStyle: brackets

# Code is currently broken with frozen string literal comments applied.
# TODO: Enable and fix build
Style/FrozenStringLiteralComment:
Enabled: false

# Be relatively lenient with line length
Layout/LineLength:
Max: 94
Expand Down
2 changes: 2 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

SimpleCov.configure do
# Activate branch coverage
enable_coverage :branch
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"

# Use dependencies from gemspec
Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

$LOAD_PATH << File.expand_path(__dir__)

require "aruba/platform"
Expand Down
2 changes: 2 additions & 0 deletions aruba.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative "lib/aruba/version"

Gem::Specification.new do |spec|
Expand Down
1 change: 1 addition & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path("../lib", __dir__)

Expand Down
1 change: 1 addition & 0 deletions exe/aruba
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

$LOAD_PATH << File.expand_path("../lib", __dir__)

Expand Down
2 changes: 2 additions & 0 deletions features/step_definitions/hooks.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "cucumber/platform"

Before "@requires-python" do
Expand Down
2 changes: 2 additions & 0 deletions features/support/aruba.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "aruba/cucumber"

Aruba.configure do |config|
Expand Down
2 changes: 2 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path("../../lib", __dir__)

# Has to be the first file required so that all other files show coverage information
Expand Down
2 changes: 2 additions & 0 deletions features/support/jruby.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

if RUBY_PLATFORM == "java"
Before do
@aruba_timeout_seconds = 15
Expand Down
2 changes: 2 additions & 0 deletions features/support/simplecov_setup.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @note this file is loaded in env.rb to setup simplecov using RUBYOPTs for
# child processes and @in-process
unless RUBY_PLATFORM.include?("java")
Expand Down
2 changes: 2 additions & 0 deletions features/support/timing.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# From https://itshouldbeuseful.wordpress.com/2010/11/10/find-your-slowest-running-cucumber-features/

scenario_times = {}
Expand Down
2 changes: 2 additions & 0 deletions fixtures/cli-app/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"

# Use dependencies from gemspec
Expand Down
2 changes: 2 additions & 0 deletions fixtures/cli-app/Rakefile
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
1 change: 1 addition & 0 deletions fixtures/cli-app/bin/aruba-test-cli
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

$LOAD_PATH << File.expand_path("../lib", __dir__)
require "cli/app"
Expand Down
2 changes: 2 additions & 0 deletions fixtures/cli-app/cli-app.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "cli/app/version"
Expand Down
2 changes: 2 additions & 0 deletions fixtures/cli-app/features/support/aruba.rb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# frozen_string_literal: true

require "aruba/cucumber"
2 changes: 2 additions & 0 deletions fixtures/cli-app/features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# frozen_string_literal: true

require_relative "aruba"
2 changes: 2 additions & 0 deletions fixtures/cli-app/lib/cli/app.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "cli/app/version"

Dir.glob(File.expand_path("**/*.rb", __dir__)).each { |f| require_relative f }
Expand Down
2 changes: 2 additions & 0 deletions fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SimpleCov
module Formatter
class HTMLFormatter
Expand Down
4 changes: 3 additions & 1 deletion fixtures/cli-app/lib/cli/app/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

module Cli
module App
VERSION = "0.1.0".freeze
VERSION = "0.1.0"
end
end
1 change: 1 addition & 0 deletions fixtures/cli-app/script/console
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
require "cli/app"
Expand Down
2 changes: 2 additions & 0 deletions fixtures/cli-app/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path("../lib", __dir__)

require "cli/app"
Expand Down
2 changes: 2 additions & 0 deletions fixtures/cli-app/spec/support/aruba.rb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# frozen_string_literal: true

require "aruba/rspec"
2 changes: 2 additions & 0 deletions fixtures/empty-app/Rakefile
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
2 changes: 2 additions & 0 deletions fixtures/empty-app/cli-app.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "cli/app/version"
Expand Down
2 changes: 2 additions & 0 deletions fixtures/empty-app/lib/cli/app.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "cli/app/version"

module Cli
Expand Down
4 changes: 3 additions & 1 deletion fixtures/empty-app/lib/cli/app/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

module Cli
module App
VERSION = "0.1.0".freeze
VERSION = "0.1.0"
end
end
2 changes: 2 additions & 0 deletions fixtures/getting-started-app/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"

gem "aruba", path: File.expand_path("../../..", __dir__)
Expand Down
2 changes: 2 additions & 0 deletions fixtures/getting-started-app/features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# frozen_string_literal: true

require "aruba/cucumber"
2 changes: 2 additions & 0 deletions gemfiles/cucumber_8.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source "https://rubygems.org"
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/cucumber_9.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source "https://rubygems.org"
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba.rb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# frozen_string_literal: true

require "aruba/api"
2 changes: 2 additions & 0 deletions lib/aruba/api.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "rspec/expectations"
require "shellwords"

Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/api/bundler.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "aruba/api/environment"
require "bundler"

Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/api/commands.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "pathname"

require "aruba/platform"
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/api/core.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "rspec/expectations"
require "aruba/runtime"
require "aruba/errors"
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/api/environment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "aruba/platform"

# Aruba
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/api/filesystem.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "pathname"

require "aruba/platform"
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/api/text.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Aruba
module Aruba
# Api
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/aruba_logger.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "logger"

# Aruba
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/aruba_path.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "pathname"

# Aruba
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/basic_configuration.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "contracts"
require "aruba/basic_configuration/option"
require "aruba/in_config_wrapper"
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/basic_configuration/option.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Aruba
module Aruba
# Basic Configuration
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/cli.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "thor"
require "aruba/console"
require "aruba/initializer"
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/colorizer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Aruba
module Aruba
# Simple colorizer class. Only supports the color cyan
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "delegate"
require "aruba/processes/spawn_process"
require "aruba/processes/in_process"
Expand Down
6 changes: 4 additions & 2 deletions lib/aruba/command_monitor.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "aruba/errors"

# Aruba
Expand Down Expand Up @@ -96,7 +98,7 @@ def clear
def all_stdout
registered_commands.each(&:stop)

registered_commands.each_with_object("") { |e, a| a << e.stdout }
registered_commands.map(&:stdout).join
end

# Get stderr of all commands
Expand All @@ -106,7 +108,7 @@ def all_stdout
def all_stderr
registered_commands.each(&:stop)

registered_commands.each_with_object("") { |e, a| a << e.stderr }
registered_commands.map(&:stderr).join
end

# Get stderr and stdout of all commands
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/config/jruby.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "rbconfig"

# ideas taken from: http://blog.headius.com/2010/03/jruby-startup-time-tips.html
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/config_wrapper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Aruba
# This wraps the current runtime configuration of aruba.
# If an option is changed, it notifies the event queue.
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "contracts"

require "aruba/version"
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/console.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "irb"

require "aruba/api"
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/console/help.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "aruba/api"

# Aruba
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/contracts/absolute_path.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "aruba/platform"

# Aruba
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/contracts/enum.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "contracts"

# Aruba
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/contracts/is_power_of_two.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "aruba/aruba_path"

# Aruba
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/contracts/relative_path.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "aruba/platform"

# Aruba
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/cucumber.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "aruba/version"

require "aruba/api"
Expand Down
6 changes: 4 additions & 2 deletions lib/aruba/cucumber/command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "aruba/generators/script_file"

When(/^I run `([^`]*)`$/) do |cmd|
Expand Down Expand Up @@ -88,7 +90,7 @@
When "I wait for output/stdout to contain:" do |expected|
Timeout.timeout(aruba.config.exit_timeout) do
loop do
output = last_command_started.public_send :stdout, wait_for_io: 0
output = last_command_started.stdout wait_for_io: 0

output = sanitize_text(output)
expected = sanitize_text(expected)
Expand All @@ -103,7 +105,7 @@
When "I wait for output/stdout to contain {string}" do |expected|
Timeout.timeout(aruba.config.exit_timeout) do
loop do
output = last_command_started.public_send :stdout, wait_for_io: 0
output = last_command_started.stdout wait_for_io: 0

output = sanitize_text(output)
expected = sanitize_text(expected)
Expand Down
2 changes: 2 additions & 0 deletions lib/aruba/cucumber/environment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

Given(/^a mocked home directory$/) do
set_environment_variable "HOME", expand_path(".")
end
Expand Down
Loading