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

Style: align with RuboCop defaults for quotes #1853

Merged
merged 1 commit into from
Mar 3, 2023
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 0 additions & 11 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1785,17 +1785,6 @@ Style/StringConcatenation:
Style/StringHashKeys:
Enabled: false

# Disabling for now
Style/StringLiterals:
Enabled: false
# EnforcedStyle: double_quotes
# ConsistentQuotesInMultiline: false

# Disabling for now
Style/StringLiteralsInInterpolation:
Enabled: false
# EnforcedStyle: double_quotes

Style/StringMethods:
Enabled: false

Expand Down
2 changes: 1 addition & 1 deletion .simplecov
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ end
SimpleCov.start do
enable_coverage(:branch)
SimpleCov.root(File.join(File.dirname(__FILE__), '/lib'))
track_files("**/*.rb")
track_files('**/*.rb')
formatter(SimpleCov::Formatter::SimpleFormatter) if ENV['CI']
end
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# frozen_string_literal: true

source 'https://rubygems.org'
gemspec name: "newrelic_rpm"
gemspec name: 'newrelic_rpm'
14 changes: 7 additions & 7 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true
require './test/multiverse/lib/multiverse/bundler_patch'

test_folders = Dir.glob("test/new_relic/*").select { |f| File.directory?(f) }
test_folders += Dir.glob("test/new_relic/**/*").select { |f| File.directory?(f) }
test_folders = Dir.glob('test/new_relic/*').select { |f| File.directory?(f) }
test_folders += Dir.glob('test/new_relic/**/*').select { |f| File.directory?(f) }

rake_lib_path = Bundler.with_unbundled_env { `bundle exec gem which rake`.chomp.gsub("lib/rake.rb", "lib") }
rake_lib_path = Bundler.with_unbundled_env { `bundle exec gem which rake`.chomp.gsub('lib/rake.rb', 'lib') }
ruby_options = %(-w -I"#{rake_lib_path}" "#{rake_lib_path}/rake/rake_test_loader.rb")

guard_options = {
Expand All @@ -17,10 +17,10 @@ guard_options = {
guard :minitest, guard_options do
watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
watch(%r{^test/.+_test\.rb$})
watch(%r{^test/rum/.*}) { "test/new_relic/rack/browser_monitoring_test.rb" }
watch(%r{^test/rum/.*}) { 'test/new_relic/rack/browser_monitoring_test.rb' }
watch(%r{^test/fixtures/cross_agent_tests/distributed_tracing/(.+).json}) { |m| "test/new_relic/agent/distributed_tracing/#{m[1]}_cross_agent_test.rb" }
watch('test/test_helper.rb') { "test/new_relic" }
watch('test/agent_helper.rb') { "test/new_relic" }
watch('lib/new_relic/agent/configuration/default_source.rb') { "test/new_relic/agent/configuration/orphan_configuration_test.rb" }
watch('test/test_helper.rb') { 'test/new_relic' }
watch('test/agent_helper.rb') { 'test/new_relic' }
watch('lib/new_relic/agent/configuration/default_source.rb') { 'test/new_relic/agent/configuration/orphan_configuration_test.rb' }
watch(%r{^lib/new_relic/agent/transaction/(.+).rb}) { |m| "test/new_relic/agent/distributed_tracing/#{m[1]}_cross_agent_test.rb" }
end
16 changes: 8 additions & 8 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ task :default => :test
task :test => ['test:newrelic']

namespace :test do
desc "Run all tests"
desc 'Run all tests'
task :all => %w[newrelic multiverse all_compatible_envs]
agent_home = File.expand_path(File.dirname(__FILE__))

desc "Run agent performance tests"
desc 'Run agent performance tests'
task :performance, [:suite, :name] => [] do |t, args|
require File.expand_path(File.join(File.dirname(__FILE__), 'test', 'performance', 'lib', 'performance'))
options = {}
Expand All @@ -28,13 +28,13 @@ namespace :test do
Performance::Runner.new(options).run_and_report
end

desc "Run agent within existing mini environment(s): env[name1,name2,name3,etc.]"
desc 'Run agent within existing mini environment(s): env[name1,name2,name3,etc.]'
task :env do |t, args|
require File.expand_path(File.join(File.dirname(__FILE__), 'test', 'environments', 'lib', 'environments', 'runner'))
Environments::Runner.new(args.to_a).run_and_report
end

desc "Run all mini environment tests known to work with the current Ruby version"
desc 'Run all mini environment tests known to work with the current Ruby version'
task :all_compatible_envs do |t, args|
require File.expand_path(File.join(File.dirname(__FILE__), 'test', 'helpers', 'ruby_rails_mappings'))
rails_versions = rails_versions_for_ruby_version(RUBY_VERSION)
Expand Down Expand Up @@ -62,10 +62,10 @@ task :record_build, [:build_number, :stage] do |t, args|
build_string = args.build_number
build_string << ".#{args.stage}" unless args.stage.nil? || args.stage.empty?

gitsha = File.exist?(".git") ? `git rev-parse HEAD` : "Unknown"
gitsha = File.exist?('.git') ? `git rev-parse HEAD` : 'Unknown'
gitsha.chomp!

File.open("lib/new_relic/build.rb", "w") do |f|
File.open('lib/new_relic/build.rb', 'w') do |f|
f.write("# GITSHA: #{gitsha}\n")
f.write("module NewRelic; module VERSION; BUILD='#{build_string}'; end; end\n")
end
Expand Down Expand Up @@ -93,14 +93,14 @@ task :update_ca_bundle do |t|
bundle_last_update = `cd #{ca_bundle_path} && git show -s --format=%ci HEAD`
puts "Source CA bundle last updated #{bundle_last_update}"

bundle_path = "cert/cacert.pem"
bundle_path = 'cert/cacert.pem'
cert_paths = []
Dir.glob("#{ca_bundle_path}/*.pem").each { |p| cert_paths << p }
cert_paths.sort!

puts "Writing #{cert_paths.size} certs to bundle at #{bundle_path}..."

File.open(bundle_path, "w") do |f|
File.open(bundle_path, 'w') do |f|
cert_paths.each do |cert_path|
cert_name = File.basename(cert_path, '.pem')
puts "Adding #{cert_name}"
Expand Down
2 changes: 1 addition & 1 deletion Thorfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
# frozen_string_literal: true

Dir["./lib/tasks/**/*.thor"].sort.each { |f| load f }
Dir['./lib/tasks/**/*.thor'].sort.each { |f| load f }
38 changes: 19 additions & 19 deletions bin/nrdebug
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class LinuxProcessDataProvider < ProcessDataProvider
end

def procline
File.read(proc_path('cmdline')).tr("\000", " ")
File.read(proc_path('cmdline')).tr("\000", ' ')
end

def environment
Expand Down Expand Up @@ -189,7 +189,7 @@ class ProcessReport

def open
if @path
File.open(@path, "w") do |f|
File.open(@path, 'w') do |f|
yield(f)
end
else
Expand Down Expand Up @@ -217,15 +217,15 @@ class ProcessReport
section(f) do
c_backtraces, ruby_backtraces = @target.gather_backtraces
if /could not attach/i.match?(c_backtraces)
fail("Failed to attach to target process. Please try again with sudo.")
fail('Failed to attach to target process. Please try again with sudo.')
end

section(f, "C Backtraces") { c_backtraces }
section(f, "Ruby Backtrace(s)") { ruby_backtraces }
section(f, 'C Backtraces') { c_backtraces }
section(f, 'Ruby Backtrace(s)') { ruby_backtraces }
end

section(f, "Open files") { @target.open_files }
section(f, "Log") do
section(f, 'Open files') { @target.open_files }
section(f, 'Log') do
commands = Logger.messages.map { |(_, msg)| msg }
commands.join("\n")
end
Expand All @@ -235,14 +235,14 @@ class ProcessReport
private

def add_environment_sections(handle)
section(handle, "Time") { Time.now }
section(handle, "PID") { @target.pid }
section(handle, "Command") { @target.procline }
section(handle, "RSS") { @target.rss }
section(handle, "CPU") { @target.cpu }
section(handle, "Parent PID") { @target.ppid }
section(handle, "OS") { ShellWrapper.execute('uname -a') }
section(handle, "Environment") { @target.environment }
section(handle, 'Time') { Time.now }
section(handle, 'PID') { @target.pid }
section(handle, 'Command') { @target.procline }
section(handle, 'RSS') { @target.rss }
section(handle, 'CPU') { @target.cpu }
section(handle, 'Parent PID') { @target.ppid }
section(handle, 'OS') { ShellWrapper.execute('uname -a') }
section(handle, 'Environment') { @target.environment }
end
end

Expand Down Expand Up @@ -270,10 +270,10 @@ def prompt_for_confirmation(target_pid, target_cmd)
end

target_pid = ARGV[0]
fail("Please provide a PID for the target process", :usage => true) unless target_pid
fail('Please provide a PID for the target process', :usage => true) unless target_pid

gdb_path = `which gdb`
fail("Could not find gdb, please ensure it is installed and in your PATH") if gdb_path.empty?
fail('Could not find gdb, please ensure it is installed and in your PATH') if gdb_path.empty?

target = RubyProcess.new(target_pid)
if !target.attachable?
Expand All @@ -298,5 +298,5 @@ report.generate

puts "Generated '#{report_filename}'"
puts ''
puts "Please examine the output file for potentially sensitive information and"
puts "remove it before sharing this file with anyone."
puts 'Please examine the output file for potentially sensitive information and'
puts 'remove it before sharing this file with anyone.'
2 changes: 1 addition & 1 deletion infinite_tracing/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

source 'https://rubygems.org'

gemspec name: "newrelic-infinite_tracing"
gemspec name: 'newrelic-infinite_tracing'

group :development do
gem 'newrelic_rpm', path: '..'
Expand Down
4 changes: 2 additions & 2 deletions infinite_tracing/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ Rake::TestTask.new do |t|

t.libs << "#{ROOT}/test"
t.libs << "#{ROOT}/lib"
t.pattern = Array(file_pattern).join(",")
t.verbose = ENV["VERBOSE"]
t.pattern = Array(file_pattern).join(',')
t.verbose = ENV['VERBOSE']
end
4 changes: 2 additions & 2 deletions infinite_tracing/lib/infinite_tracing/agent_integrations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
module NewRelic::Agent
module InfiniteTracing
if Config.enabled? || Config.test_framework?
NewRelic::Agent.logger.debug("Integrating Infinite Tracer with Agent")
NewRelic::Agent.logger.debug('Integrating Infinite Tracer with Agent')

require_relative 'agent_integrations/agent'
require_relative 'agent_integrations/segment'
require_relative 'agent_integrations/datastore_segment'
require_relative 'agent_integrations/external_request_segment'

else
NewRelic::Agent.logger.debug("Skipped Integrating Infinite Tracer with Agent")
NewRelic::Agent.logger.debug('Skipped Integrating Infinite Tracer with Agent')
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# frozen_string_literal: true

module NewRelic::Agent
NewRelic::Agent.logger.debug("Installing Infinite Tracer in Agent")
NewRelic::Agent.logger.debug('Installing Infinite Tracer in Agent')

Agent.class_eval do
def new_infinite_tracer
# We must start streaming in a thread or we block/deadlock the
# entire start up process for the Agent.
InfiniteTracing::Client.new.tap do |client|
@infinite_tracer_thread = InfiniteTracing::Worker.new(:infinite_tracer) do
NewRelic::Agent.logger.debug("Opening Infinite Tracer Stream with gRPC server")
NewRelic::Agent.logger.debug('Opening Infinite Tracer Stream with gRPC server')
client.start_streaming
end
end
Expand All @@ -31,7 +31,7 @@ def handle_force_restart(error)

# Whenever we reconnect, close and restart
def close_infinite_tracer
NewRelic::Agent.logger.debug("Closing infinite tracer threads")
NewRelic::Agent.logger.debug('Closing infinite tracer threads')
return unless @infinite_tracer_thread

@infinite_tracer_thread.join
Expand Down
12 changes: 6 additions & 6 deletions infinite_tracing/lib/infinite_tracing/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def flush

# Turns camelcase base class name into upper snake case version of the name.
def formatted_class_name(class_name)
class_name = class_name.split(":")[-1]
class_name = class_name.split(':')[-1]
(class_name.gsub!(/(.)([A-Z])/, '\1_\2') || class_name).upcase
end

Expand All @@ -73,7 +73,7 @@ def record_error_metrics_and_log(error)
else
NewRelic::Agent.record_metric(GRPC_OTHER_ERROR_METRIC, 0.0)
end
NewRelic::Agent.logger.warn("gRPC response error received.", error)
NewRelic::Agent.logger.warn('gRPC response error received.', error)
end

def handle_error(error)
Expand All @@ -99,8 +99,8 @@ def suspended?
# server and re-establish the gRPC bi-directional stream. Useful for the server
# to initiate a load-balancing scheme.
def handle_close
NewRelic::Agent.logger.debug("The gRPC Trace Observer closed the stream with OK response. " \
"Restarting the stream.")
NewRelic::Agent.logger.debug('The gRPC Trace Observer closed the stream with OK response. ' \
'Restarting the stream.')
start_streaming
end

Expand All @@ -113,8 +113,8 @@ def suspend
@lock.synchronize do
@suspended = true
@buffer = new_streaming_buffer
NewRelic::Agent.logger.warn("The Trace Observer host signaled to suspend streaming span events. " \
"No more span events will be sent during this session.")
NewRelic::Agent.logger.warn('The Trace Observer host signaled to suspend streaming span events. ' \
'No more span events will be sent during this session.')
end
end

Expand Down
2 changes: 1 addition & 1 deletion infinite_tracing/lib/infinite_tracing/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Config
COMPRESSION_LEVEL_DISABLED = :none
COMPRESSION_LEVEL_DEFAULT = :high
COMPRESSION_LEVEL_LIST = %i[none low medium high].freeze
TRACE_OBSERVER_NOT_CONFIGURED_ERROR = "Trace Observer host not configured!"
TRACE_OBSERVER_NOT_CONFIGURED_ERROR = 'Trace Observer host not configured!'

# We only want to load the infinite tracing gem's files when
# a) we're inside test framework and running tests
Expand Down
8 changes: 4 additions & 4 deletions infinite_tracing/lib/infinite_tracing/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Connection
Connection.instance.notify_agent_started
rescue => error
NewRelic::Agent.logger.error( \
"Error during notify :server_source_configuration_added event",
'Error during notify :server_source_configuration_added event',
error
)
end
Expand Down Expand Up @@ -102,8 +102,8 @@ def metadata

@lock.synchronize do
@metadata = {
"license_key" => license_key,
"agent_run_token" => agent_id
'license_key' => license_key,
'agent_run_token' => agent_id
}
@metadata.merge!(request_headers_map)
merge_gzip_metadata
Expand Down Expand Up @@ -168,7 +168,7 @@ def with_reconnection_backoff(exponential_backoff = true, &block)
yield
rescue => exception
retry_connection_period = retry_connection_period(exponential_backoff)
::NewRelic::Agent.logger.error("Error establishing connection with infinite tracing service:", exception)
::NewRelic::Agent.logger.error('Error establishing connection with infinite tracing service:', exception)
::NewRelic::Agent.logger.info("Will re-attempt infinite tracing connection in #{retry_connection_period} seconds")
sleep(retry_connection_period)
note_connect_failure
Expand Down
4 changes: 2 additions & 2 deletions infinite_tracing/lib/infinite_tracing/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
module NewRelic::Agent
module InfiniteTracing
module Constants
SUPPORTABILITY_PREFIX = "Supportability/InfiniteTracing/Span"
SUPPORTABILITY_PREFIX = 'Supportability/InfiniteTracing/Span'

SPANS_SEEN_METRIC = "#{SUPPORTABILITY_PREFIX}/Seen"
SPANS_SENT_METRIC = "#{SUPPORTABILITY_PREFIX}/Sent"
QUEUE_DUMPED_METRIC = "#{SUPPORTABILITY_PREFIX}/AgentQueueDumped"
RESPONSE_ERROR_METRIC = "#{SUPPORTABILITY_PREFIX}/Response/Error"

GRPC_ERROR_NAME_METRIC = "#{SUPPORTABILITY_PREFIX}/gRPC/%s"
GRPC_OTHER_ERROR_METRIC = GRPC_ERROR_NAME_METRIC % "Other"
GRPC_OTHER_ERROR_METRIC = GRPC_ERROR_NAME_METRIC % 'Other'
end
end
end
Loading