Skip to content

Commit c693b0e

Browse files
mamematzbot
authored andcommitted
[ruby/error_highlight] Improve English comments and messages
ruby/error_highlight@5f976265ef
1 parent 71e2318 commit c693b0e

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

lib/error_highlight/base.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
require_relative "version"
22

33
module ErrorHighlight
4-
# Identify the code fragment at that a given exception occurred.
4+
# Identify the code fragment where a given exception occurred.
55
#
66
# Options:
77
#
88
# point_type: :name | :args
9-
# :name (default) points the method/variable name that the exception occurred.
10-
# :args points the arguments of the method call that the exception occurred.
9+
# :name (default) points to the method/variable name where the exception occurred.
10+
# :args points to the arguments of the method call where the exception occurred.
1111
#
1212
# backtrace_location: Thread::Backtrace::Location
1313
# It locates the code fragment of the given backtrace_location.
@@ -113,7 +113,7 @@ def initialize(node, point_type: :name, name: nil)
113113
snippet = @node.script_lines[lineno - 1 .. last_lineno - 1].join("")
114114
snippet += "\n" unless snippet.end_with?("\n")
115115

116-
# It require some work to support Unicode (or multibyte) characters.
116+
# It requires some work to support Unicode (or multibyte) characters.
117117
# Tentatively, we stop highlighting if the code snippet has non-ascii characters.
118118
# See https://github.com/ruby/error_highlight/issues/4
119119
raise NonAscii unless snippet.ascii_only?
@@ -504,7 +504,6 @@ def spot_fcall_for_name
504504
def spot_fcall_for_args
505505
_mid, nd_args = @node.children
506506
if nd_args && nd_args.first_lineno == nd_args.last_lineno
507-
# binary operator
508507
fetch_line(nd_args.first_lineno)
509508
@beg_column = nd_args.first_column
510509
@end_column = nd_args.last_column

lib/error_highlight/core_ext.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module CoreExt
2424
_, _, snippet, highlight = ErrorHighlight.formatter.message_for(spot).lines
2525
out += "\n | #{ snippet } #{ highlight }"
2626
else
27-
out += "\n (cannot create a snippet of the method definition; use Ruby 3.5 or later)"
27+
out += "\n (cannot highlight method definition; try Ruby 3.5 or later)"
2828
end
2929
end
3030
ret << "\n" + out if out

lib/error_highlight/formatter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ def self.max_snippet_width=(width)
5656
end
5757

5858
def self.terminal_width
59-
# lazy load io/console, so it's not loaded when 'max_snippet_width' is set
59+
# lazy load io/console to avoid loading it when 'max_snippet_width' is manually set
6060
require "io/console"
6161
$stderr.winsize[1] if $stderr.tty?
6262
rescue LoadError, NoMethodError, SystemCallError
63-
# do not truncate when window size is not available
63+
# skip truncation when terminal window size is unavailable
6464
end
6565
end
6666

test/error_highlight/test_error_highlight.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ def test_wrong_number_of_arguments_for_method
14681468
MethodDefLocationSupported ?
14691469
"| def wrong_number_of_arguments_test(x, y)
14701470
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" :
1471-
"(cannot create a snippet of the method definition; use Ruby 3.5 or later)"
1471+
"(cannot highlight method definition; try Ruby 3.5 or later)"
14721472
}
14731473
END
14741474

@@ -1494,7 +1494,7 @@ def test_missing_keyword
14941494
MethodDefLocationSupported ?
14951495
"| def keyword_test(kw1:, kw2:, kw3:)
14961496
^^^^^^^^^^^^" :
1497-
"(cannot create a snippet of the method definition; use Ruby 3.5 or later)"
1497+
"(cannot highlight method definition; try Ruby 3.5 or later)"
14981498
}
14991499
END
15001500

@@ -1515,7 +1515,7 @@ def test_unknown_keyword
15151515
MethodDefLocationSupported ?
15161516
"| def keyword_test(kw1:, kw2:, kw3:)
15171517
^^^^^^^^^^^^" :
1518-
"(cannot create a snippet of the method definition; use Ruby 3.5 or later)"
1518+
"(cannot highlight method definition; try Ruby 3.5 or later)"
15191519
}
15201520
END
15211521

@@ -1545,7 +1545,7 @@ def test_wrong_number_of_arguments_for_method2
15451545
MethodDefLocationSupported ?
15461546
"| def wrong_number_of_arguments_test2(
15471547
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" :
1548-
"(cannot create a snippet of the method definition; use Ruby 3.5 or later)"
1548+
"(cannot highlight method definition; try Ruby 3.5 or later)"
15491549
}
15501550
END
15511551

@@ -1567,7 +1567,7 @@ def test_wrong_number_of_arguments_for_lambda_literal
15671567
MethodDefLocationSupported ?
15681568
"| v = -> {}
15691569
^^" :
1570-
"(cannot create a snippet of the method definition; use Ruby 3.5 or later)"
1570+
"(cannot highlight method definition; try Ruby 3.5 or later)"
15711571
}
15721572
END
15731573

@@ -1589,7 +1589,7 @@ def test_wrong_number_of_arguments_for_lambda_method
15891589
MethodDefLocationSupported ?
15901590
"| v = lambda { }
15911591
^" :
1592-
"(cannot create a snippet of the method definition; use Ruby 3.5 or later)"
1592+
"(cannot highlight method definition; try Ruby 3.5 or later)"
15931593
}
15941594
END
15951595

@@ -1615,7 +1615,7 @@ def test_wrong_number_of_arguments_for_define_method
16151615
MethodDefLocationSupported ?
16161616
"| define_method :define_method_test do |x, y|
16171617
^^" :
1618-
"(cannot create a snippet of the method definition; use Ruby 3.5 or later)"
1618+
"(cannot highlight method definition; try Ruby 3.5 or later)"
16191619
}
16201620
END
16211621

0 commit comments

Comments
 (0)