Skip to content

Commit

Permalink
rubocop: fix offences of the Style/HashSyntax cop
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrylo committed Oct 12, 2018
1 parent 4f121a6 commit f33d827
Show file tree
Hide file tree
Showing 64 changed files with 390 additions and 397 deletions.
7 changes: 0 additions & 7 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1130,13 +1130,6 @@ Style/GlobalVars:
Style/GuardClause:
Enabled: false

# Offense count: 459
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
Style/HashSyntax:
Enabled: false

# Offense count: 2
Style/IdenticalConditionalBranches:
Exclude:
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ gem 'rake', '~> 10.0'
group :development do
gem 'gist'
gem 'yard'
gem 'rb-inotify', :require => false
gem 'rb-fsevent', :require => false
gem 'rb-inotify', require: false
gem 'rb-fsevent', require: false

# Rubocop supports only >=2.2.0
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0')
gem 'rubocop', '= 0.59.2', :require => false
gem 'rubocop', '= 0.59.2', require: false
end
end

Expand Down
20 changes: 10 additions & 10 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CLEAN.include('**/*#*', '**/*#*.*', '**/*_flymake*.*', '**/*_flymake', '**/*.rbc

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
task default: :spec

desc "Run pry (you can pass arguments using _ in place of -)"
task :pry do
Expand All @@ -29,7 +29,7 @@ desc "Profile pry's startup time"
task :profile do
require 'profile'
require 'pry'
Pry.start(TOPLEVEL_BINDING, :input => StringIO.new('exit'))
Pry.start(TOPLEVEL_BINDING, input: StringIO.new('exit'))
end

def modify_base_gemspec
Expand Down Expand Up @@ -77,23 +77,23 @@ end
end

desc "build all platform gems at once"
task :gems => [:clean, :rmgems, 'ruby:gem', 'jruby:gem']
task gems: [:clean, :rmgems, 'ruby:gem', 'jruby:gem']

desc "remove all platform gems"
task :rmgems => ['ruby:clobber_package']
task :rm_gems => :rmgems
task :rm_pkgs => :rmgems
task rmgems: ['ruby:clobber_package']
task rm_gems: :rmgems
task rm_pkgs: :rmgems

desc "reinstall gem"
task :reinstall => :gems do
task reinstall: :gems do
sh "gem uninstall pry" rescue nil
sh "gem install #{File.dirname(__FILE__)}/pkg/pry-#{Pry::VERSION}.gem"
end

task :install => :reinstall
task install: :reinstall

desc "build and push latest gems"
task :pushgems => :gems do
task pushgems: :gems do
chdir("#{File.dirname(__FILE__)}/pkg") do
Dir["*.gem"].each do |gemfile|
sh "gem push #{gemfile}"
Expand All @@ -108,7 +108,7 @@ namespace :docker do
end

desc "test pry on multiple ruby versions"
task :test => :build do
task test: :build do
system "docker run -i -t -v /tmp/prytmp:/tmp/prytmp pry/pry ./multi_test_inside_docker.sh"
end
end
12 changes: 6 additions & 6 deletions lib/pry/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def parse_options(args=ARGV)
begin
opts = Pry::Slop.parse!(
args,
:help => true,
:multiple_switches => false,
:strict => true,
help: true,
multiple_switches: false,
strict: true,
&options
)
rescue Pry::Slop::InvalidOptionError
Expand Down Expand Up @@ -113,7 +113,7 @@ def start(opts)
end

# Start the session (running any code passed with -e, if there is any)
Pry.start(context, :input => StringIO.new(Pry.config.exec_string))
Pry.start(context, input: StringIO.new(Pry.config.exec_string))
end

end
Expand Down Expand Up @@ -198,7 +198,7 @@ def start(opts)
Pry.config.requires << file
end

on :I=, "Add a path to the $LOAD_PATH", :as => Array, :delimiter => ":" do |load_path|
on :I=, "Add a path to the $LOAD_PATH", as: Array, delimiter: ":" do |load_path|
load_path.map! do |path|
/\A\.\// =~ path ? path : File.expand_path(path)
end
Expand All @@ -220,6 +220,6 @@ def start(opts)

on(:c, :context=,
"Start the session in the specified context. Equivalent to `context.pry` in a session.",
:default => "Pry.toplevel_binding"
default: "Pry.toplevel_binding"
)
end
2 changes: 1 addition & 1 deletion lib/pry/code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def comment_describing(line_number)
# @param [Integer] line_number (1-based)
# @return [String] the code.
def expression_at(line_number, consume = 0)
self.class.expression_at(raw, line_number, :consume => consume)
self.class.expression_at(raw, line_number, consume: consume)
end

# Get the (approximate) Module.nesting at the give line number.
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/code_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def lookup(str, _pry_, options={})

def initialize(str, _pry_, options={})
options = {
:super => 0,
super: 0,
}.merge!(options)

@str = str
Expand Down
16 changes: 8 additions & 8 deletions lib/pry/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ def source_line

def default_options(match)
{
:requires_gem => [],
:keep_retval => false,
:argument_required => false,
:interpolate => true,
:shellwords => true,
:listing => (String === match ? match : match.inspect),
:use_prefix => true,
:takes_block => false
requires_gem: [],
keep_retval: false,
argument_required: false,
interpolate: true,
shellwords: true,
listing: (String === match ? match : match.inspect),
use_prefix: true,
takes_block: false
}
end
end
Expand Down
10 changes: 5 additions & 5 deletions lib/pry/command_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ def alias_command(match, action, options = {})
original_options = cmd.options.dup

options = original_options.merge!({
:desc => "Alias for `#{action}`",
:listing => match
desc: "Alias for `#{action}`",
listing: match
}).merge!(options)

# ensure default description is used if desc is nil
Expand Down Expand Up @@ -249,8 +249,8 @@ def rename_command(new_match, search, options={})
cmd = find_command_by_match_or_listing(search)

options = {
:listing => new_match,
:description => cmd.description
listing: new_match,
description: cmd.description
}.merge!(options)

@commands[new_match] = cmd.dup
Expand Down Expand Up @@ -396,7 +396,7 @@ def valid_command?(val)
# @return [CommandSet::Result]
def process_line(val, context={})
if command = find_command(val)
context = context.merge(:command_set => self)
context = context.merge(command_set: self)
retval = command.new(context).process_line(val)
Result.new(true, retval)
else
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/commands/amend_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Command::AmendLine < Pry::ClassCommand
match(/amend-line(?: (-?\d+)(?:\.\.(-?\d+))?)?/)
group 'Editing'
description 'Amend a line of input in multi-line mode.'
command_options :interpolate => false, :listing => 'amend-line'
command_options interpolate: false, listing: 'amend-line'

banner <<-'BANNER'
Amend a line of input in multi-line mode. `amend-line N`, where the N represents
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/commands/bang.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Command::Bang < Pry::ClassCommand
match(/^\s*!\s*$/)
group 'Editing'
description 'Clear the input buffer.'
command_options :use_prefix => false
command_options use_prefix: false

banner <<-'BANNER'
Clear the input buffer. Useful if the parsing process goes wrong and you get
Expand Down
10 changes: 5 additions & 5 deletions lib/pry/commands/cat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ class Command::Cat < Pry::ClassCommand
BANNER

def options(opt)
opt.on :ex, "Show the context of the last exception", :optional_argument => true, :as => Integer
opt.on :i, :in, "Show one or more entries from Pry's expression history", :optional_argument => true, :as => Range, :default => -5..-1
opt.on :s, :start, "Starting line (defaults to the first line)", :optional_argument => true, :as => Integer
opt.on :e, :end, "Ending line (defaults to the last line)", :optional_argument => true, :as => Integer
opt.on :ex, "Show the context of the last exception", optional_argument: true, as: Integer
opt.on :i, :in, "Show one or more entries from Pry's expression history", optional_argument: true, as: Range, default: -5..-1
opt.on :s, :start, "Starting line (defaults to the first line)", optional_argument: true, as: Integer
opt.on :e, :end, "Ending line (defaults to the last line)", optional_argument: true, as: Integer
opt.on :l, :'line-numbers', "Show line numbers"
opt.on :t, :type, "The file type for syntax highlighting (e.g., 'ruby' or 'python')", :argument => true, :as => Symbol
opt.on :t, :type, "The file type for syntax highlighting (e.g., 'ruby' or 'python')", argument: true, as: Symbol
end

def process
Expand Down
10 changes: 5 additions & 5 deletions lib/pry/commands/code_collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ def self.inject_options(opt)
@output_result_ranges = []

opt.on :l, :lines, "Restrict to a subset of lines. Takes a line number or range",
:optional_argument => true, :as => Range, :default => 1..-1
optional_argument: true, as: Range, default: 1..-1
opt.on :o, :out, "Select lines from Pry's output result history. Takes an index or range",
:optional_argument => true, :as => Range, :default => -5..-1 do |r|
optional_argument: true, as: Range, default: -5..-1 do |r|
output_result_ranges << (r || (-5..-1))
end
opt.on :i, :in, "Select lines from Pry's input expression history. Takes an index or range",
:optional_argument => true, :as => Range, :default => -5..-1 do |r|
optional_argument: true, as: Range, default: -5..-1 do |r|
input_expression_ranges << (r || (-5..-1))
end
opt.on :s, :super, "Select the 'super' method. Can be repeated to traverse the ancestors",
:as => :count
as: :count
opt.on :d, :doc, "Select lines from the code object's documentation"
end

Expand Down Expand Up @@ -74,7 +74,7 @@ def content
#
# @return [Pry::WrappedModule, Pry::Method, Pry::Command]
def code_object
Pry::CodeObject.lookup(obj_name, _pry_, :super => opts[:super])
Pry::CodeObject.lookup(obj_name, _pry_, super: opts[:super])
end

# Given a string and a range, return the `range` lines of that
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/commands/easter_eggs.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Pry
Pry::Commands.instance_eval do
command "nyan-cat", "", :requires_gem => ["nyancat"] do
command "nyan-cat", "", requires_gem: ["nyancat"] do
run ".nyancat"
end

Expand Down
6 changes: 3 additions & 3 deletions lib/pry/commands/edit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class Command::Edit < Pry::ClassCommand

def options(opt)
opt.on :e, :ex, "Open the file that raised the most recent exception (_ex_.file)",
:optional_argument => true, :as => Integer
optional_argument: true, as: Integer
opt.on :i, :in, "Open a temporary file containing the Nth input expression. N may be a range",
:optional_argument => true, :as => Range, :default => -1..-1
optional_argument: true, as: Range, default: -1..-1
opt.on :t, :temp, "Open an empty temporary file"
opt.on :l, :line, "Jump to this line in the opened file",
:argument => true, :as => Integer
argument: true, as: Integer
opt.on :n, :"no-reload", "Don't automatically reload the edited file"
opt.on :c, :current, "Open the current __FILE__ and at __LINE__ (as returned by `whereami`)"
opt.on :r, :reload, "Reload the edited code immediately (default for ruby files)"
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/commands/exit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Command::Exit < Pry::ClassCommand
match 'exit'
group 'Navigating Pry'
description 'Pop the previous binding.'
command_options :keep_retval => true
command_options keep_retval: true

banner <<-'BANNER'
Usage: exit [OPTIONS] [--help]
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/commands/find_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Command::FindMethod < Pry::ClassCommand
match 'find-method'
group 'Context'
description 'Recursively search for a method within a Class/Module or the current namespace.'
command_options :shellwords => false
command_options shellwords: false

banner <<-'BANNER'
Usage: find-method [-n|-c] METHOD [NAMESPACE]
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/commands/gem_cd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Command::GemCd < Pry::ClassCommand
match 'gem-cd'
group 'Gems'
description "Change working directory to specified gem's directory."
command_options :argument_required => true
command_options argument_required: true

banner <<-'BANNER'
Usage: gem-cd GEM_NAME
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/commands/gem_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Command::GemInstall < Pry::ClassCommand
match 'gem-install'
group 'Gems'
description 'Install a gem and refresh the gem cache.'
command_options :argument_required => true
command_options argument_required: true

banner <<-'BANNER'
Usage: gem-install GEM_NAME
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/commands/gem_open.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Command::GemOpen < Pry::ClassCommand
match 'gem-open'
group 'Gems'
description 'Opens the working directory of the gem in your editor.'
command_options :argument_required => true
command_options argument_required: true

banner <<-'BANNER'
Usage: gem-open GEM_NAME
Expand Down
8 changes: 4 additions & 4 deletions lib/pry/commands/gist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Command::Gist < Pry::ClassCommand
match 'gist'
group 'Misc'
description 'Upload code, docs, history to https://gist.github.com/.'
command_options :requires_gem => "gist"
command_options requires_gem: "gist"

banner <<-'BANNER'
Usage: gist [OPTIONS] [--help]
Expand All @@ -22,8 +22,8 @@ def setup
def options(opt)
CodeCollector.inject_options(opt)
opt.on :login, "Authenticate the gist gem with GitHub"
opt.on :p, :public, "Create a public gist (default: false)", :default => false
opt.on :clip, "Copy the selected content to clipboard instead, do NOT gist it", :default => false
opt.on :p, :public, "Create a public gist (default: false)", default: false
opt.on :clip, "Copy the selected content to clipboard instead, do NOT gist it", default: false
end

def process
Expand Down Expand Up @@ -81,7 +81,7 @@ def comment_expression_result_for_gist(result)
end

def gist_content(content, filename)
response = ::Gist.gist(content, :filename => filename || "pry_gist.rb", :public => !!opts[:p])
response = ::Gist.gist(content, filename: filename || "pry_gist.rb", public: !!opts[:p])
if response
url = response['html_url']
message = "Gist created at URL #{url}"
Expand Down
14 changes: 7 additions & 7 deletions lib/pry/commands/hist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class Command::Hist < Pry::ClassCommand

def options(opt)
opt.on :a, :all, "Display all history"
opt.on :H, :head, "Display the first N items", :optional_argument => true, :as => Integer
opt.on :T, :tail, "Display the last N items", :optional_argument => true, :as => Integer
opt.on :s, :show, "Show the given range of lines", :optional_argument => true, :as => Range
opt.on :G, :grep, "Show lines matching the given pattern", :argument => true, :as => String
opt.on :H, :head, "Display the first N items", optional_argument: true, as: Integer
opt.on :T, :tail, "Display the last N items", optional_argument: true, as: Integer
opt.on :s, :show, "Show the given range of lines", optional_argument: true, as: Range
opt.on :G, :grep, "Show lines matching the given pattern", argument: true, as: String
opt.on :c, :clear , "Clear the current session's history"
opt.on :r, :replay, "Replay a line or range of lines", :argument => true, :as => Range
opt.on :save, "Save history to a file", :argument => true, :as => Range
opt.on :r, :replay, "Replay a line or range of lines", argument: true, as: Range
opt.on :save, "Save history to a file", argument: true, as: Range
opt.on :e, :'exclude-pry', "Exclude Pry commands from the history"
opt.on :n, :'no-numbers', "Omit line numbers"
end
Expand Down Expand Up @@ -120,7 +120,7 @@ def process_replay
check_for_juxtaposed_replay(replay_sequence)

replay_sequence.lines.each do |line|
_pry_.eval line, :generated => true
_pry_.eval line, generated: true
end
end

Expand Down
Loading

0 comments on commit f33d827

Please sign in to comment.