starscope 1.5.4 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,10 @@
1
+ require 'pathname'
2
+
1
3
  module Starscope
2
4
  module Exportable
3
5
  CTAGS_DEFAULT_PATH = 'tags'.freeze
4
6
  CSCOPE_DEFAULT_PATH = 'cscope.out'.freeze
7
+ ASCII = Encoding.find('ASCII')
5
8
 
6
9
  class UnknownExportFormatError < StandardError; end
7
10
 
@@ -17,7 +20,7 @@ module Starscope
17
20
 
18
21
  @output.normal("Exporting to '#{path}' in format '#{format}'...")
19
22
  path_prefix = Pathname.getwd.relative_path_from(Pathname.new(path).dirname.expand_path)
20
- File.open(path, 'w') do |file|
23
+ File.open(path, 'wb') do |file|
21
24
  export_to(format, file, path_prefix)
22
25
  end
23
26
  @output.normal('Export complete.')
@@ -37,14 +40,14 @@ module Starscope
37
40
  private
38
41
 
39
42
  def export_ctags(file, path_prefix)
40
- file.puts <<END
41
- !_TAG_FILE_FORMAT 2 /extended format/
42
- !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
43
- !_TAG_PROGRAM_AUTHOR Evan Huus /eapache@gmail.com/
44
- !_TAG_PROGRAM_NAME Starscope //
45
- !_TAG_PROGRAM_URL https://github.com/eapache/starscope //
46
- !_TAG_PROGRAM_VERSION #{Starscope::VERSION} //
47
- END
43
+ file.puts <<~HEADER
44
+ !_TAG_FILE_FORMAT 2 /extended format/
45
+ !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
46
+ !_TAG_PROGRAM_AUTHOR Evan Huus /eapache@gmail.com/
47
+ !_TAG_PROGRAM_NAME Starscope //
48
+ !_TAG_PROGRAM_URL https://github.com/eapache/starscope //
49
+ !_TAG_PROGRAM_VERSION #{Starscope::VERSION} //
50
+ HEADER
48
51
  defs = (@tables[:defs] || {}).sort_by { |x| x[:name][-1].to_s }
49
52
  defs.each do |record|
50
53
  file.puts ctag_line(record, @meta[:files][record[:file]], path_prefix)
@@ -148,7 +151,7 @@ END
148
151
  file.print("0\n")
149
152
  file.print("#{files.length}\n")
150
153
  buf = ''
151
- files.each { |f| buf << f + "\n" }
154
+ files.each { |f| buf << "#{f}\n" }
152
155
  file.print("#{buf.length}\n#{buf}")
153
156
  end
154
157
 
@@ -157,6 +160,7 @@ END
157
160
  @tables.each do |tbl, records|
158
161
  records.each do |record|
159
162
  next unless record[:line_no]
163
+
160
164
  record[:tbl] = tbl
161
165
  db[record[:file]] ||= {}
162
166
  db[record[:file]][record[:line_no]] ||= []
@@ -175,16 +179,14 @@ END
175
179
  # use the column if we have it, otherwise fall back to scanning
176
180
  index = record[:col] || line.index(key)
177
181
 
178
- while index && !valid_index?(line, index, key)
179
- index = line.index(key, index + 1)
180
- end
182
+ index = line.index(key, index + 1) while index && !valid_index?(line, index, key)
181
183
 
182
184
  next if index.nil?
183
185
 
184
186
  # Strip trailing non-word characters, otherwise cscope barfs on
185
187
  # function names like `include?`
186
188
  if key =~ /^\W*$/
187
- next unless [:defs, :end].include?(record[:tbl])
189
+ next unless %i[defs end].include?(record[:tbl])
188
190
  else
189
191
  key.sub!(/\W+$/, '')
190
192
  end
@@ -207,25 +209,23 @@ END
207
209
 
208
210
  index = line.index(key, prev)
209
211
 
210
- while index && index + key.length < offset && !valid_index?(line, index, key)
211
- index = line.index(key, index + 1)
212
- end
212
+ index = line.index(key, index + 1) while index && index + key.length < offset && !valid_index?(line, index, key)
213
213
 
214
214
  next unless index && index + key.length < offset
215
215
 
216
216
  buf << cscope_plaintext(line, prev, index) << "\n"
217
- buf << "#{key}\n"
217
+ buf << "#{strip_unicode(key)}\n"
218
218
  prev = index + key.length
219
219
  end
220
220
 
221
221
  buf << cscope_plaintext(line, prev, offset) << "\n"
222
- buf << cscope_mark(record) << record[:key] << "\n"
222
+ buf << cscope_mark(record) << strip_unicode(record[:key]) << "\n"
223
223
 
224
224
  buf << CSCOPE_GLOBAL_HACK_START if record[:type] == :func && record[:tbl] == :end
225
225
  buf
226
226
  rescue ArgumentError
227
227
  # invalid utf-8 byte sequence in the line, oh well
228
- line
228
+ strip_unicode(line)
229
229
  end
230
230
 
231
231
  def valid_index?(line, index, key)
@@ -240,10 +240,10 @@ END
240
240
  ret.lstrip! if start == 0
241
241
  ret.rstrip! if stop == line.length
242
242
  ret.gsub!(/\s+/, ' ')
243
- ret.empty? ? ' ' : ret
243
+ ret.empty? ? ' ' : strip_unicode(ret)
244
244
  rescue ArgumentError
245
245
  # invalid utf-8 byte sequence in the line, oh well
246
- line
246
+ strip_unicode(line)
247
247
  end
248
248
 
249
249
  def cscope_mark(rec)
@@ -258,16 +258,16 @@ END
258
258
  when :file
259
259
  ret = '@'
260
260
  when :defs
261
- case rec[:type]
262
- when :func
263
- ret = '$'
264
- when :class, :module
265
- ret = 'c'
266
- when :type
267
- ret = 't'
268
- else
269
- ret = 'g'
270
- end
261
+ ret = case rec[:type]
262
+ when :func
263
+ '$'
264
+ when :class, :module
265
+ 'c'
266
+ when :type
267
+ 't'
268
+ else
269
+ 'g'
270
+ end
271
271
  when :calls
272
272
  ret = '`'
273
273
  when :requires
@@ -280,7 +280,11 @@ END
280
280
  return ''
281
281
  end
282
282
 
283
- "\t" + ret
283
+ "\t#{ret}"
284
+ end
285
+
286
+ def strip_unicode(str)
287
+ str.encode(ASCII, invalid: :replace, undef: :replace, replace: '')
284
288
  end
285
289
  end
286
290
  end
@@ -5,16 +5,15 @@ module Starscope
5
5
  @frags = frags
6
6
  end
7
7
 
8
- def extract(path, text)
9
- text = @frags.map { |f| f.delete(:frag).strip }.join("\n")
8
+ def extract(path, _text)
9
+ compiled_text = @frags.map { |f| f.delete(:frag).strip }.join("\n")
10
10
 
11
- extractor_metadata = @child.extract(path, text) do |tbl, name, args|
11
+ @child.extract(path, compiled_text) do |tbl, name, args|
12
12
  args.merge!(@frags[args[:line_no] - 1]) if args[:line_no]
13
13
  yield tbl, name, args
14
14
  end
15
15
 
16
16
  # TODO: translate metadata?
17
- extractor_metadata
18
17
  end
19
18
 
20
19
  def name
@@ -3,8 +3,8 @@ module Starscope
3
3
  module ERB
4
4
  VERSION = 1
5
5
 
6
- ERB_START = /<%(?:-|={1,4})?/
7
- ERB_END = /-?%>/
6
+ ERB_START = /<%(?:-|={1,4})?/.freeze
7
+ ERB_END = /[-=]?%>/.freeze
8
8
 
9
9
  def self.match_file(name)
10
10
  name.end_with?('.erb')
@@ -20,7 +20,7 @@ module Starscope
20
20
  term = line.index(ERB_END)
21
21
  if term
22
22
  yield Starscope::DB::FRAGMENT, :Ruby, frag: line[0...term], line_no: line_no
23
- line = line[term + 1..-1]
23
+ line = line[term + 1..]
24
24
  multiline = false
25
25
  else
26
26
  yield Starscope::DB::FRAGMENT, :Ruby, frag: line, line_no: line_no
@@ -3,13 +3,13 @@ module Starscope
3
3
  module Golang
4
4
  VERSION = 1
5
5
 
6
- FUNC_CALL = /([\w\.]*?\w)\(/
7
- END_OF_BLOCK = /^\s*\}\s*$/
8
- END_OF_GROUP = /^\s*\)\s*$/
9
- STRING_LITERAL = /".+?"/
10
- BUILTIN_FUNCS = %w(new make len close copy delete int int8 int16 int32 int64
11
- uint uint8 uint16 uint32 uint64 string byte).freeze
12
- CONTROL_KEYS = %w(if for switch case).freeze
6
+ FUNC_CALL = /([[[:word:]].]*?[[:word:]])\(/.freeze
7
+ END_OF_BLOCK = /^\s*\}\s*$/.freeze
8
+ END_OF_GROUP = /^\s*\)\s*$/.freeze
9
+ STRING_LITERAL = /".+?"/.freeze
10
+ BUILTIN_FUNCS = %w[new make len close copy delete int int8 int16 int32 int64
11
+ uint uint8 uint16 uint32 uint64 string byte].freeze
12
+ CONTROL_KEYS = %w[if for switch case].freeze
13
13
 
14
14
  def self.match_file(name)
15
15
  name.end_with?('.go')
@@ -36,6 +36,7 @@ module Starscope
36
36
  if stack[-1] == :comment
37
37
  match = %r{\*/(.*)}.match(line)
38
38
  next unless match
39
+
39
40
  line = match[1]
40
41
  stack.pop
41
42
  end
@@ -45,7 +46,7 @@ module Starscope
45
46
  pos = 0
46
47
  while (match = STRING_LITERAL.match(line, pos))
47
48
  eos = find_end_of_string(line, match.begin(0))
48
- line = line[0..match.begin(0)] + line[eos..-1]
49
+ line = line[0..match.begin(0)] + line[eos..]
49
50
  pos = match.begin(0) + 2
50
51
  end
51
52
  end
@@ -56,14 +57,14 @@ module Starscope
56
57
  case line
57
58
  when END_OF_BLOCK
58
59
  end_block(line_no, scope, stack, &block)
59
- when /(.+)\s+\w+/
60
+ when /(.+)\s+[[:word:]]+/
60
61
  parse_def(Regexp.last_match(1), line_no, scope, &block)
61
62
  end
62
63
  when :interface
63
64
  case line
64
65
  when END_OF_BLOCK
65
66
  end_block(line_no, scope, stack, &block)
66
- when /(\w+)\(.*\)\s+/
67
+ when /([[:word:]]+)\(.*\)\s+/
67
68
  yield :defs, scope + [Regexp.last_match(1)], line_no: line_no
68
69
  end
69
70
  when :def
@@ -105,45 +106,42 @@ module Starscope
105
106
  # handles new lines (when not in the middle of an existing definition)
106
107
  def self.parse_new_line(line, line_no, scope, stack, &block)
107
108
  case line
108
- when /^func\s+(\w+)\(/
109
+ when /^func\s+([[:word:]]+)\(/
109
110
  yield :defs, scope + [Regexp.last_match(1)], line_no: line_no, type: :func
110
111
  stack.push(:func)
111
- when /^func\s+\(\w+\s+\*?(\w+)\)\s*(\w+)\(/
112
+ when /^func\s+\([[:word:]]+\s+\*?([[:word:]]+)\)\s*([[:word:]]+)\(/
112
113
  yield :defs, scope + [Regexp.last_match(1), Regexp.last_match(2)], line_no: line_no, type: :func
113
114
  stack.push(:func)
114
- when /^package\s+(\w+)/
115
+ when /^package\s+([[:word:]]+)/
115
116
  scope.push(Regexp.last_match(1))
116
117
  yield :defs, scope, line_no: line_no, type: :package
117
- when /^type\s+(\w+)\s+struct\s*\{/
118
+ when /^type\s+([[:word:]]+)\s+struct\s*\{/
118
119
  scope.push(Regexp.last_match(1))
119
120
  stack.push(:struct)
120
121
  yield :defs, scope, line_no: line_no, type: :class
121
- when /^type\s+(\w+)\s+interface\s*\{/
122
+ when /^type\s+([[:word:]]+)\s+interface\s*\{/
122
123
  scope.push(Regexp.last_match(1))
123
124
  stack.push(:interface)
124
125
  yield :defs, scope, line_no: line_no, type: :class
125
- when /^type\s+(\w+)/
126
+ when /^type\s+([[:word:]]+)/
126
127
  yield :defs, scope + [Regexp.last_match(1)], line_no: line_no, type: :type
127
128
  when /^import\s+"(.+)"/
128
129
  name = Regexp.last_match(1).split('/')
129
130
  yield :imports, name, line_no: line_no
130
131
  when /^import\s+\(/
131
132
  stack.push(:import)
132
- when /^var\s+\(/
133
- stack.push(:def)
134
- when /^var\s+(\w+)\s/
135
- yield :defs, scope + [Regexp.last_match(1)], line_no: line_no
136
- parse_call(line, line_no, scope, &block)
137
- when /^const\s+\(/
133
+ when /^var\s+\(/, /^const\s+\(/
138
134
  stack.push(:def)
139
- when /^const\s+(\w+)\s/
135
+ when /^var\s+([[:word:]]+)\s/, /^const\s+([[:word:]]+)\s/
140
136
  yield :defs, scope + [Regexp.last_match(1)], line_no: line_no
141
137
  parse_call(line, line_no, scope, &block)
142
138
  when /^\s+(.*?) :?=[^=]/
143
- Regexp.last_match(1).split(' ').each do |var|
139
+ Regexp.last_match(1).split.each do |var|
144
140
  next if CONTROL_KEYS.include?(var)
141
+
145
142
  name = var.delete(',').split('.')
146
143
  next if name[0] == '_' # assigning to _ is a discard in golang
144
+
147
145
  if name.length == 1
148
146
  yield :assigns, scope + [name[0]], line_no: line_no
149
147
  else
@@ -158,9 +156,10 @@ module Starscope
158
156
 
159
157
  def self.parse_call(line, line_no, scope)
160
158
  line.scan(FUNC_CALL) do |match|
161
- name = match[0].split('.').select { |chunk| !chunk.empty? }
159
+ name = match[0].split('.').reject(&:empty?)
162
160
  if name.length == 1
163
161
  next if name[0] == 'func'
162
+
164
163
  if BUILTIN_FUNCS.include?(name[0])
165
164
  yield :calls, name[0], line_no: line_no
166
165
  else
@@ -96,7 +96,8 @@ module Starscope
96
96
  next
97
97
  end
98
98
 
99
- next if found[node.name] && found[node.name].include?(line)
99
+ next if found[node.name]&.include?(line)
100
+
100
101
  yield :defs, node.name, line_no: line
101
102
  found[node.name] ||= Set.new
102
103
  found[node.name].add(line)
@@ -113,7 +114,8 @@ module Starscope
113
114
  line = find_line(node.range.from, map, lines, name)
114
115
  next unless line
115
116
 
116
- next if found[name] && found[name].include?(line)
117
+ next if found[name]&.include?(line)
118
+
117
119
  yield :reads, name, line_no: line
118
120
  end
119
121
  end
@@ -16,9 +16,11 @@ module Starscope
16
16
 
17
17
  def self.match_file(name)
18
18
  return true if name.end_with?('.rb', '.rake')
19
+
19
20
  File.open(name) do |f|
20
21
  head = f.read(2)
21
22
  return false if head.nil? || !head.start_with?('#!')
23
+
22
24
  return f.readline.include?('ruby')
23
25
  end
24
26
  end
@@ -39,7 +41,7 @@ module Starscope
39
41
  extract_node(tree, scope, &block)
40
42
 
41
43
  new_scope = []
42
- if [:class, :module].include? tree.type
44
+ if %i[class module].include? tree.type
43
45
  new_scope = scoped_name(tree.children[0], scope)
44
46
  scope += new_scope
45
47
  end
@@ -90,7 +92,16 @@ module Starscope
90
92
 
91
93
  when :const
92
94
  name = scoped_name(node, scope)
93
- yield :reads, name, line_no: loc.line, col: loc.name.column
95
+ # handle `__ENCODING__` and other weird quasi-constants
96
+ column = case loc
97
+ when Parser::Source::Map::Constant
98
+ loc.name.column
99
+ when Parser::Source::Map
100
+ loc.column
101
+ when nil
102
+ return
103
+ end
104
+ yield :reads, name, line_no: loc.line, col: column
94
105
 
95
106
  when :lvar, :ivar, :cvar, :gvar
96
107
  yield :reads, scope + [node.children[0]], line_no: loc.line, col: loc.name.column
@@ -109,7 +120,7 @@ module Starscope
109
120
  def self.scoped_name(node, scope)
110
121
  if node.type == :block
111
122
  scoped_name(node.children[0], scope)
112
- elsif [:lvar, :ivar, :cvar, :gvar, :const, :send, :casgn].include? node.type
123
+ elsif %i[lvar ivar cvar gvar const send casgn].include? node.type
113
124
  if node.children[0].is_a? Symbol
114
125
  [node.children[0]]
115
126
  elsif node.children[0].is_a? AST::Node
@@ -1,6 +1,6 @@
1
1
  module Starscope
2
2
  class Matcher
3
- MATCH_TYPES = [:literal_match, :regexp_match].freeze
3
+ MATCH_TYPES = %i[literal_match regexp_match].freeze
4
4
 
5
5
  def initialize(query)
6
6
  @query = query
@@ -13,10 +13,9 @@ module Starscope
13
13
  end
14
14
 
15
15
  def match(input)
16
- case
17
- when input.end_with?(@query)
16
+ if input.end_with?(@query)
18
17
  :literal_match
19
- when @regexp && @regexp.match(input)
18
+ elsif @regexp&.match(input)
20
19
  :regexp_match
21
20
  end
22
21
  end
@@ -4,7 +4,7 @@ module Starscope
4
4
  class Output
5
5
  PBAR_FORMAT = '%t: %c/%C %E ||%b>%i||'.freeze
6
6
 
7
- def initialize(level, out = STDOUT)
7
+ def initialize(level, out = $stdout)
8
8
  @out = out
9
9
  @level = level
10
10
  @pbar = nil
@@ -12,27 +12,30 @@ module Starscope
12
12
 
13
13
  def new_pbar(title, num_items)
14
14
  return if @level == :quiet
15
+
15
16
  @pbar = ProgressBar.create(title: title, total: num_items,
16
17
  format: PBAR_FORMAT, length: 80,
17
18
  out: @out)
18
19
  end
19
20
 
20
21
  def inc_pbar
21
- @pbar.increment if @pbar
22
+ @pbar&.increment
22
23
  end
23
24
 
24
25
  def finish_pbar
25
- @pbar.finish if @pbar
26
+ @pbar&.finish
26
27
  @pbar = nil
27
28
  end
28
29
 
29
30
  def extra(msg)
30
31
  return unless @level == :verbose
32
+
31
33
  output(msg)
32
34
  end
33
35
 
34
36
  def normal(msg)
35
37
  return if @level == :quiet
38
+
36
39
  output(msg)
37
40
  end
38
41
 
@@ -26,6 +26,7 @@ module Starscope
26
26
 
27
27
  Starscope::Matcher::MATCH_TYPES.each do |type|
28
28
  next if results[type].nil? || results[type].empty?
29
+
29
30
  return results[type]
30
31
  end
31
32
 
@@ -1,3 +1,3 @@
1
1
  module Starscope
2
- VERSION = '1.5.4'.freeze
2
+ VERSION = '1.6.0'.freeze
3
3
  end
data/starscope.gemspec CHANGED
@@ -1,14 +1,14 @@
1
- require File.expand_path('../lib/starscope/version.rb', __FILE__)
1
+ require File.expand_path('lib/starscope/version.rb', __dir__)
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'starscope'
5
5
  gem.version = Starscope::VERSION
6
6
  gem.summary = 'Smart code search and indexing'
7
- gem.description = <<-EOF
7
+ gem.description = <<-DESC
8
8
  Starscope is a code indexer, search and navigation tool for Ruby, Golang, and JavaScript.
9
9
  Inspired by the extremely popular Ctags and Cscope utilities, Starscope can
10
10
  answer a lot of questions about a lot of code.
11
- EOF
11
+ DESC
12
12
  gem.authors = ['Evan Huus']
13
13
  gem.homepage = 'https://github.com/eapache/starscope'
14
14
  gem.email = 'eapache@gmail.com'
@@ -17,19 +17,22 @@ Gem::Specification.new do |gem|
17
17
  gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
18
18
  gem.test_files = `git ls-files -- test/*`.split("\n")
19
19
  gem.require_paths = ['lib']
20
- gem.required_ruby_version = '>= 1.9.3'
20
+ gem.required_ruby_version = '>= 2.6'
21
21
 
22
- gem.add_dependency 'oj', '~> 2.9'
23
- gem.add_dependency 'parser', '~> 2.3'
24
- gem.add_dependency 'ruby-progressbar', '~> 1.8'
25
- gem.add_dependency 'rkelly-remix', '~> 0.0.7'
26
22
  gem.add_dependency 'babel-transpiler', '~> 0.7'
23
+ gem.add_dependency 'oj', '~> 3.7'
24
+ gem.add_dependency 'parser', '~> 3.1'
25
+ gem.add_dependency 'rkelly-remix', '~> 0.0.7'
26
+ gem.add_dependency 'ruby-progressbar', '~> 1.9'
27
27
  gem.add_dependency 'sourcemap', '~> 0.1'
28
28
 
29
- gem.add_development_dependency 'bundler', '~> 1.7'
30
- gem.add_development_dependency 'rake', '~> 11.2'
31
- gem.add_development_dependency 'pry', '~> 0.10.1'
32
- gem.add_development_dependency 'minitest', '~> 5.8'
33
- gem.add_development_dependency 'mocha', '~> 1.1'
34
- gem.add_development_dependency 'rubocop', '~> 0.39.0'
29
+ gem.add_development_dependency 'bundler', '>= 1.7'
30
+ gem.add_development_dependency 'minitest', '~> 5.12'
31
+ gem.add_development_dependency 'mocha', '~> 1.3'
32
+ gem.add_development_dependency 'pry', '~> 0.11'
33
+ gem.add_development_dependency 'rake', '~> 13.0'
34
+ gem.add_development_dependency 'rubocop', '~> 1.25.0'
35
+ gem.add_development_dependency 'rubocop-minitest', '~> 0.17.1'
36
+ gem.add_development_dependency 'rubocop-rake', '~> 0.6.0'
37
+ gem.metadata['rubygems_mfa_required'] = 'true'
35
38
  end
@@ -10,7 +10,7 @@ var (
10
10
  }
11
11
  )
12
12
 
13
- var single_var = 3
13
+ var single_var_Äunicode = 3
14
14
 
15
15
  const single_const = 4
16
16
 
@@ -162,3 +162,5 @@ class Starscope::DB
162
162
  end
163
163
  end
164
164
  end
165
+
166
+ puts __ENCODING__
@@ -1,43 +1,43 @@
1
1
  require_relative '../test_helper'
2
2
 
3
- describe 'starscope executable script' do
4
- BASE = 'bundle exec bin/starscope --quiet'.freeze
5
- EXTRACT = "#{BASE} --no-read --no-write #{FIXTURES}".freeze
3
+ BASE = 'bundle exec bin/starscope --quiet'.freeze
4
+ EXTRACT = "#{BASE} --no-read --no-write #{FIXTURES}".freeze
6
5
 
6
+ describe 'starscope executable script' do
7
7
  it 'must not produce help wider than 80 characters' do
8
8
  `#{BASE} -h`.each_line do |line|
9
- line.length.must_be :<=, 80
9
+ _(line.length).must_be :<=, 80
10
10
  end
11
11
  end
12
12
 
13
13
  it 'must produce the right version' do
14
- `#{BASE} -v`.chomp.must_equal Starscope::VERSION
14
+ _(`#{BASE} -v`.chomp).must_equal Starscope::VERSION
15
15
  end
16
16
 
17
17
  it 'must produce a valid database summary' do
18
18
  lines = `#{EXTRACT} -s`.lines.to_a
19
- lines.length.must_equal 8
19
+ _(lines.length).must_equal 8
20
20
  end
21
21
 
22
22
  it 'must produce a valid database dump' do
23
23
  lines = `#{EXTRACT} -d requires`.lines.to_a
24
- lines[1].split.first.must_equal 'date'
25
- lines[2].split.first.must_equal 'foo-bar'
26
- lines[3].split.first.must_equal 'react-native'
27
- lines[4].split.first.must_equal 'zlib'
24
+ _(lines[1].split.first).must_equal 'date'
25
+ _(lines[2].split.first).must_equal 'foo-bar'
26
+ _(lines[3].split.first).must_equal 'react-native'
27
+ _(lines[4].split.first).must_equal 'zlib'
28
28
  end
29
29
 
30
30
  it 'must correctly query the database' do
31
31
  `#{EXTRACT} -q calls,add_file`.each_line do |line|
32
- line.split[0..2].must_equal %w(Starscope DB add_file)
32
+ _(line.split[0..2]).must_equal %w[Starscope DB add_file]
33
33
  end
34
34
 
35
35
  `#{EXTRACT} -q lang:ruby,calls,add_file`.each_line do |line|
36
- line.split[0..2].must_equal %w(Starscope DB add_file)
36
+ _(line.split[0..2]).must_equal %w[Starscope DB add_file]
37
37
  end
38
38
 
39
39
  `#{EXTRACT} -q lang:go,calls,add_file`.each_line do |line|
40
- line.must_equal "No results found.\n"
40
+ _(line).must_equal "No results found.\n"
41
41
  end
42
42
  end
43
43
 
@@ -45,7 +45,7 @@ describe 'starscope executable script' do
45
45
  file = Tempfile.new('starscope_test')
46
46
  begin
47
47
  `#{EXTRACT} -e cscope,#{file.path}`
48
- $?.exitstatus.must_equal 0
48
+ _($?.exitstatus).must_equal 0
49
49
  ensure
50
50
  file.close
51
51
  file.unlink
@@ -56,7 +56,7 @@ describe 'starscope executable script' do
56
56
  file = Tempfile.new('starscope_test')
57
57
  begin
58
58
  `#{EXTRACT} -e ctags,#{file.path}`
59
- $?.exitstatus.must_equal 0
59
+ _($?.exitstatus).must_equal 0
60
60
  ensure
61
61
  file.close
62
62
  file.unlink
data/test/test_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'minitest/autorun'
2
2
  require 'minitest/pride'
3
- require 'mocha/mini_test'
3
+ require 'mocha/minitest'
4
4
  require_relative '../lib/starscope'
5
5
 
6
6
  FIXTURES = 'test/fixtures'.freeze