summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.rubocop_todo.yml9
-rw-r--r--lib/pry/command.rb30
-rw-r--r--lib/pry/commands/show_doc.rb4
-rw-r--r--lib/pry/commands/show_source.rb4
-rw-r--r--lib/pry/commands/stat.rb2
5 files changed, 17 insertions, 32 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 8e50a70a..4d4cc082 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -314,15 +314,6 @@ Style/PerlBackrefs:
- 'lib/pry/method.rb'
- 'lib/pry/rubygem.rb'
-# Offense count: 4
-# Cop supports --auto-correct.
-Style/UnneededCondition:
- Exclude:
- - 'lib/pry/command.rb'
- - 'lib/pry/commands/show_doc.rb'
- - 'lib/pry/commands/show_source.rb'
- - 'lib/pry/commands/stat.rb'
-
# Offense count: 5
# Cop supports --auto-correct.
Style/UnneededInterpolation:
diff --git a/lib/pry/command.rb b/lib/pry/command.rb
index 1078b317..462bc43f 100644
--- a/lib/pry/command.rb
+++ b/lib/pry/command.rb
@@ -211,22 +211,20 @@ class Pry
# manually overridden if necessary.
# Group should not be changed once it is initialized.
def group(name = nil)
- @group ||= if name
- name
- else
- case Pry::Method(block).source_file
- when %r{/pry/.*_commands/(.*).rb}
- Regexp.last_match(1).capitalize.tr('_', " ")
- when /(pry-\w+)-([\d\.]+([\w\.]+)?)/
- name = Regexp.last_match(1)
- version = Regexp.last_match(2)
- "#{name} (v#{version})"
- when /pryrc/
- "pryrc"
- else
- "(other)"
- end
- end
+ @group ||= begin
+ name || case Pry::Method(block).source_file
+ when %r{/pry/.*_commands/(.*).rb}
+ Regexp.last_match(1).capitalize.tr('_', " ")
+ when /(pry-\w+)-([\d\.]+([\w\.]+)?)/
+ name = Regexp.last_match(1)
+ version = Regexp.last_match(2)
+ "#{name} (v#{version})"
+ when /pryrc/
+ "pryrc"
+ else
+ "(other)"
+ end
+ end
end
end
diff --git a/lib/pry/commands/show_doc.rb b/lib/pry/commands/show_doc.rb
index 8fa97024..05251bb4 100644
--- a/lib/pry/commands/show_doc.rb
+++ b/lib/pry/commands/show_doc.rb
@@ -48,9 +48,7 @@ class Pry
# command '--help' shouldn't use markup highlighting
docs
else
- if docs.empty?
- raise CommandError, "No docs found for: #{obj_name ? obj_name : 'current context'}"
- end
+ raise CommandError, "No docs found for: #{obj_name || 'current context'}" if docs.empty?
process_comment_markup(docs)
end
diff --git a/lib/pry/commands/show_source.rb b/lib/pry/commands/show_source.rb
index 6317535a..56bfb9f1 100644
--- a/lib/pry/commands/show_source.rb
+++ b/lib/pry/commands/show_source.rb
@@ -69,9 +69,7 @@ class Pry
# command '--help' shouldn't use markup highlighting
docs
else
- if docs.empty?
- raise CommandError, "No docs found for: #{obj_name ? obj_name : 'current context'}"
- end
+ raise CommandError, "No docs found for: #{obj_name || 'current context'}" if docs.empty?
process_comment_markup(docs)
end
diff --git a/lib/pry/commands/stat.rb b/lib/pry/commands/stat.rb
index 7892cace..cfdfabd2 100644
--- a/lib/pry/commands/stat.rb
+++ b/lib/pry/commands/stat.rb
@@ -27,7 +27,7 @@ class Pry
--
Name: #{meth.name}
Alias#{'es' if aliases.length > 1}: #{aliases.any? ? aliases.join(', ') : 'None.'}
- Owner: #{meth.owner ? meth.owner : 'Unknown'}
+ Owner: #{meth.owner || 'Unknown'}
Visibility: #{meth.visibility}
Type: #{meth.is_a?(::Method) ? 'Bound' : 'Unbound'}
Arity: #{meth.arity}