1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Merge pull request #2034 from pry/1824-frozen-string-literal

Fix offences of the Style/FrozenStringLiteralComment cop
This commit is contained in:
Kyrylo Silin 2019-05-08 00:19:05 +03:00 committed by GitHub
commit c123bce661
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
221 changed files with 522 additions and 72 deletions

View file

@ -71,3 +71,9 @@ Gemspec/RequiredRubyVersion:
Style/ModuleFunction:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: true
EnforcedStyle: always
Exclude:
- 'spec/fixtures/example_nesting.rb'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
source 'https://rubygems.org'
gemspec

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rake/clean'
require 'rubygems/package_task'

View file

@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
$0 = 'pry'
require 'pry'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'pry/version'
require 'pry/last_exception'
require 'pry/forwardable'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class BasicObject < BasicObject
[:Kernel, :File, :Dir, :LoadError, :ENV, :Pry].each do |constant|

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
# A super-class for Commands that are created with a single block.
#

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
# A super-class of Commands with structure.
#

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'stringio'
class Pry

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'method_source'
class Pry
@ -254,12 +256,12 @@ class Pry
# @return [String] a formatted representation (based on the configuration of
# the object).
def to_s
print_to_output("", false)
print_to_output(''.dup, false)
end
# @return [String] a (possibly highlighted) copy of the source code.
def highlighted
print_to_output("", true)
print_to_output(''.dup, true)
end
# Writes a formatted representation (based on the configuration of the

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'method_source'
class Pry

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Code
# Represents a range of lines in a code listing.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Code
# Represents a line of code (which may, in fact, contain multiple lines if

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
# This class is responsible for taking a string (identifying a
# command/class/method/etc) and returning the relevant type of object.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'pp'
require 'English'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'delegate'
require 'shellwords'
@ -352,7 +354,7 @@ class Pry
# @param [String] val The line of input
# @return [Array]
def tokenize(val)
val.replace(interpolate_string(val)) if command_options[:interpolate]
val = interpolate_string(val) if command_options[:interpolate]
self.class.command_regex =~ val

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class NoCommandError < StandardError
def initialize(match, owner)

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'ostruct'
class Pry

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class AmendLine < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Bang < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class BangPry < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Cat < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Cat

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Cat

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Cat

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Cat
@ -14,10 +16,10 @@ class Pry
raise CommandError, "No input expressions!" if numbered_input_items.empty?
if numbered_input_items.length > 1
content = ""
content = ''
numbered_input_items.each do |i, s|
content << "#{Helpers::Text.bold(i.to_s)}:\n"
content << decorate(Pry::Code(s).with_indentation(2)).to_s
content += "#{Helpers::Text.bold(i.to_s)}:\n"
content += decorate(Pry::Code(s).with_indentation(2)).to_s
end
content

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Cd < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class ChangeInspector < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class ChangePrompt < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class ClearScreen < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class CodeCollector
@ -142,7 +144,7 @@ class Pry
end
ranged_array = Array(array[range]) || []
ranged_array.compact.each { |v| all << yield(v) }
ranged_array.compact.each { |v| all += yield(v) }
end
all

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class DisablePry < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
Pry::Commands.instance_eval do
command(%r{!s/(.*?)/(.*?)}, "") do |source, dest|

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Edit < Pry::ClassCommand
@ -69,9 +71,7 @@ class Pry
initial_temp_file_content,
initial_temp_file_content.lines.count
)
silence_warnings do
eval_string.replace content
end
pry_instance.eval_string = content
Pry.history.push(content)
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Edit

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Edit

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Exit < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class ExitAll < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class ExitProgram < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class FindMethod < Pry::ClassCommand
@ -97,7 +99,7 @@ class Pry
# if `-c` was not given
def additional_info(header, method)
if opts.content?
": " << colorize_code(matched_method_lines(header, method))
': ' + colorize_code(matched_method_lines(header, method))
else
""
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class FixIndent < Pry::ClassCommand
@ -12,7 +14,7 @@ class Pry
def process
indented_str = Pry::Indent.indent(eval_string)
eval_string.replace indented_str
pry_instance.eval_string = indented_str
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Help < Pry::ClassCommand
@ -58,7 +60,7 @@ class Pry
# @param [Array<Pry::Command>] commands
# @return [String] The generated help string.
def help_text_for_commands(name, commands)
"#{bold(name.capitalize)}\n" << commands.map do |command|
"#{bold(name.capitalize)}\n" + commands.map do |command|
" #{command.options[:listing].to_s.ljust(18)} " \
"#{command.description.capitalize}"
end.join("\n")

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Hist < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class ImportSet < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class JumpTo < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class ListInspectors < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Ls < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Ls < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Ls < Pry::ClassCommand
@ -33,7 +35,7 @@ class Pry
end
def format_value(value)
Pry::ColorPrinter.pp(value, '')
Pry::ColorPrinter.pp(value, ''.dup)
end
def correct_opts?

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Ls < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Ls < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Ls < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Ls < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Ls < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Ls < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Ls < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Ls < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Ls < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Ls < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Ls < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Nesting < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Play < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class PryBacktrace < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Version < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
# N.B. using a regular expresion here so that "raise-up 'foo'" does the right thing.
class Command

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class ReloadCode < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Reset < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'stringio'
class Pry

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class SaveFile < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class ShellCommand < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class ShellMode < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class ShowDoc < Command::ShowInfo

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class ShowInfo < Pry::ClassCommand
@ -73,7 +75,7 @@ class Pry
end
def content_and_header_for_code_object(code_object)
header(code_object) << content_for(code_object)
header(code_object) + content_for(code_object)
end
def content_and_headers_for_all_module_candidates(mod)
@ -82,13 +84,13 @@ class Pry
mod.number_of_candidates.times do |v|
candidate = mod.candidate(v)
begin
result << "\nCandidate #{v + 1}/#{mod.number_of_candidates}: " \
result += "\nCandidate #{v + 1}/#{mod.number_of_candidates}: " \
"#{candidate.source_file}:#{candidate.source_line}\n"
content = content_for(candidate)
result << "Number of lines: #{content.lines.count}\n\n" << content
result += "Number of lines: #{content.lines.count}\n\n" + content
rescue Pry::RescuableException
result << "\nNo content found.\n"
result += "\nNo content found.\n"
next
end
end
@ -106,17 +108,17 @@ class Pry
content = content_for(code_object)
h = "\n#{bold('From:')} #{file_name}"
h << code_object_header(code_object, line_num)
h << "\n#{bold('Number of lines:')} " << "#{content.lines.count}\n\n"
h += code_object_header(code_object, line_num)
h += "\n#{bold('Number of lines:')} " + "#{content.lines.count}\n\n"
if @used_super
h << bold('** Warning:')
h << " Cannot find code for #{@original_code_object.nonblank_name}. " \
h += bold('** Warning:')
h += " Cannot find code for #{@original_code_object.nonblank_name}. " \
"Showing superclass #{code_object.nonblank_name} instead. **\n\n"
end
if content.lines.none?
h << bold('** Warning:')
h << " Cannot find code for '#{code_object.name}' (source_location is nil)"
h += bold('** Warning:')
h += " Cannot find code for '#{code_object.name}' (source_location is nil)"
end
h
@ -139,23 +141,23 @@ class Pry
def method_header(code_object, line_num)
h = ""
h << (code_object.c_method? ? ' (C Method):' : ":#{line_num}:")
h << method_sections(code_object)[:owner]
h << method_sections(code_object)[:visibility]
h << method_sections(code_object)[:signature]
h += (code_object.c_method? ? ' (C Method):' : ":#{line_num}:")
h += method_sections(code_object)[:owner]
h += method_sections(code_object)[:visibility]
h += method_sections(code_object)[:signature]
h
end
def module_header(code_object, line_num)
h = ""
h << ":#{line_num}\n"
h << bold(code_object.module? ? "Module" : "Class")
h << " #{bold('name:')} #{code_object.nonblank_name}"
h += ":#{line_num}\n"
h += bold(code_object.module? ? "Module" : "Class")
h += " #{bold('name:')} #{code_object.nonblank_name}"
if code_object.number_of_candidates > 1
h << bold("\nNumber of monkeypatches: ")
h << code_object.number_of_candidates.to_s
h << ". Use the `-a` option to display all available monkeypatches"
h += bold("\nNumber of monkeypatches: ")
h += code_object.number_of_candidates.to_s
h += ". Use the `-a` option to display all available monkeypatches"
end
h
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class ShowInput < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class ShowSource < Command::ShowInfo

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Stat < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class SwitchTo < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class ToggleColor < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class WatchExpression < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class WatchExpression
@ -12,7 +14,7 @@ class Pry
def eval!
@previous_value = value
@value = Pry::ColorPrinter.pp(target_eval(target, source), "")
@value = Pry::ColorPrinter.pp(target_eval(target, source), ''.dup)
end
def to_s

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'method_source'
class Pry
@ -105,7 +107,7 @@ class Pry
.with_marker(marker)
.highlighted
pry_instance.pager.page(
"\n#{bold('From:')} #{location}:\n\n" << pretty_code << "\n"
"\n#{bold('From:')} #{location}:\n\n" + pretty_code + "\n"
)
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Command
class Wtf < Pry::ClassCommand

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'ostruct'
class Pry

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Config
# Attributable provides the ability to create "attribute"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Config
# LazyValue is a Proc (block) wrapper. It is meant to be used as a

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Config
# MemoizedValue is a Proc (block) wrapper. It is meant to be used as a

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
class Config
# Value holds a value for the given attribute and decides how it should

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
# @api private
# @since ?.?.?

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
# @return [Array] Code of the method used when implementing Pry's
# __binding__, along with line indication to be used with instance_eval (and

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'shellwords'
class Pry

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
# @api private
# @since ?.?.?

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
# As a REPL, we often want to catch any unexpected exceptions that may have
# been raised; however we don't want to go overboard and prevent the user

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
module Forwardable
require 'forwardable'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "pry/helpers/base_helpers"
require "pry/helpers/options_helpers"
require "pry/helpers/command_helpers"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
module Helpers
module BaseHelpers

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'tempfile'
class Pry

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
module Helpers
# This class contains methods useful for extracting

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
module Helpers
module OptionsHelpers

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rbconfig'
class Pry

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Pry
module Helpers
def self.tablify_or_one_line(heading, things, config = Pry.config)

Some files were not shown because too many files have changed in this diff Show more