Skip to content

Commit

Permalink
Use rubocop to enforce a few styling rules
Browse files Browse the repository at this point in the history
  • Loading branch information
st0012 committed Jan 31, 2024
1 parent f052097 commit d1ade29
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 4 deletions.
32 changes: 32 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
AllCops:
TargetRubyVersion: 3.0
DisabledByDefault: true
SuggestExtensions: false

Layout/TrailingWhitespace:
Enabled: true

Layout/TrailingEmptyLines:
Enabled: true

Layout/IndentationConsistency:
Enabled: true

Layout/CaseIndentation:
Enabled: true
EnforcedStyle: end

Layout/CommentIndentation:
Enabled: true

Layout/IndentationStyle:
Enabled: true

Layout/SpaceAroundKeyword:
Enabled: true

Layout/SpaceBeforeComma:
Enabled: true

Layout/SpaceAfterComma:
Enabled: true
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ gem "rake"
gem "test-unit"
gem "test-unit-ruby-core"

gem "rubocop"

gem "debug", github: "ruby/debug", platforms: [:mri, :mswin]

if RUBY_VERSION >= "3.0.0" && !is_truffleruby
Expand Down
2 changes: 1 addition & 1 deletion lib/irb/inspector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Inspector
# Determines the inspector to use where +inspector+ is one of the keys passed
# during inspector definition.
def self.keys_with_inspector(inspector)
INSPECTORS.select{|k,v| v == inspector}.collect{|k, v| k}
INSPECTORS.select{|k, v| v == inspector}.collect{|k, v| k}
end

# Example
Expand Down
2 changes: 1 addition & 1 deletion lib/irb/locale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def load(file)
end
end

def find(file , paths = $:)
def find(file, paths = $:)
dir = File.dirname(file)
dir = "" if dir == "."
base = File.basename(file)
Expand Down
1 change: 0 additions & 1 deletion test/irb/test_input_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,3 @@ def has_rdoc_content?
end
end
end

2 changes: 1 addition & 1 deletion test/irb/test_workspace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_toplevel_binding_local_variables
irb_path = "#{top_srcdir}/#{dir}/irb"
File.exist?(irb_path)
end or omit 'irb command not found'
assert_in_out_err(bundle_exec + ['-W0', "-C#{top_srcdir}", '-e', <<~RUBY , '--', '-f', '--'], 'binding.local_variables', /\[:_\]/, [], bug17623)
assert_in_out_err(bundle_exec + ['-W0', "-C#{top_srcdir}", '-e', <<~RUBY, '--', '-f', '--'], 'binding.local_variables', /\[:_\]/, [], bug17623)
version = 'xyz' # typical rubygems loading file
load('#{irb_path}')
RUBY
Expand Down

0 comments on commit d1ade29

Please sign in to comment.