inch 0.5.0.rc5 → 0.5.0.rc6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -6
- data/.rubocop_todo.yml +40 -34
- data/Gemfile +3 -3
- data/Rakefile +10 -6
- data/bin/inch +5 -5
- data/config/base.rb +4 -4
- data/config/nodejs.rb +44 -1
- data/config/ruby.rb +1 -1
- data/inch.gemspec +17 -17
- data/lib/inch.rb +13 -13
- data/lib/inch/api.rb +10 -10
- data/lib/inch/api/compare.rb +2 -2
- data/lib/inch/api/compare/code_objects.rb +1 -1
- data/lib/inch/api/diff.rb +1 -1
- data/lib/inch/api/options/suggest.rb +1 -1
- data/lib/inch/api/suggest.rb +1 -1
- data/lib/inch/cli.rb +6 -6
- data/lib/inch/cli/command.rb +15 -15
- data/lib/inch/cli/command/base.rb +5 -3
- data/lib/inch/cli/command/base_list.rb +0 -1
- data/lib/inch/cli/command/console.rb +5 -5
- data/lib/inch/cli/command/diff.rb +6 -6
- data/lib/inch/cli/command/inspect.rb +5 -5
- data/lib/inch/cli/command/list.rb +4 -4
- data/lib/inch/cli/command/options/base.rb +17 -15
- data/lib/inch/cli/command/options/base_list.rb +17 -17
- data/lib/inch/cli/command/options/base_object.rb +1 -1
- data/lib/inch/cli/command/options/console.rb +13 -13
- data/lib/inch/cli/command/options/diff.rb +19 -19
- data/lib/inch/cli/command/options/inspect.rb +5 -5
- data/lib/inch/cli/command/options/list.rb +7 -7
- data/lib/inch/cli/command/options/show.rb +5 -5
- data/lib/inch/cli/command/options/stats.rb +2 -2
- data/lib/inch/cli/command/options/suggest.rb +12 -12
- data/lib/inch/cli/command/output/base.rb +1 -1
- data/lib/inch/cli/command/output/diff.rb +9 -9
- data/lib/inch/cli/command/output/inspect.rb +13 -13
- data/lib/inch/cli/command/output/list.rb +1 -1
- data/lib/inch/cli/command/output/show.rb +4 -4
- data/lib/inch/cli/command/output/stats.rb +14 -14
- data/lib/inch/cli/command/output/suggest.rb +14 -14
- data/lib/inch/cli/command/show.rb +4 -4
- data/lib/inch/cli/command/stats.rb +4 -4
- data/lib/inch/cli/command/suggest.rb +4 -4
- data/lib/inch/cli/command_parser.rb +4 -4
- data/lib/inch/cli/sparkline_helper.rb +1 -1
- data/lib/inch/cli/trace_helper.rb +1 -1
- data/lib/inch/cli/yardopts_helper.rb +1 -1
- data/lib/inch/code_object.rb +3 -3
- data/lib/inch/code_object/provider.rb +3 -3
- data/lib/inch/code_object/proxy.rb +3 -4
- data/lib/inch/codebase.rb +5 -5
- data/lib/inch/codebase/object.rb +2 -1
- data/lib/inch/codebase/serializer.rb +2 -2
- data/lib/inch/config.rb +6 -6
- data/lib/inch/config/codebase.rb +5 -5
- data/lib/inch/core_ext.rb +1 -1
- data/lib/inch/core_ext/string.rb +1 -1
- data/lib/inch/evaluation.rb +8 -8
- data/lib/inch/evaluation/proxy.rb +2 -3
- data/lib/inch/evaluation/role.rb +1 -1
- data/lib/inch/language/elixir/code_object/base.rb +6 -4
- data/lib/inch/language/elixir/evaluation/base.rb +2 -1
- data/lib/inch/language/elixir/evaluation/function_object.rb +1 -1
- data/lib/inch/language/elixir/import.rb +14 -14
- data/lib/inch/language/elixir/provider/reader.rb +1 -1
- data/lib/inch/language/elixir/provider/reader/docstring.rb +13 -0
- data/lib/inch/language/elixir/provider/reader/object.rb +5 -5
- data/lib/inch/language/elixir/provider/reader/object/base.rb +13 -5
- data/lib/inch/language/elixir/provider/reader/object/function_object.rb +1 -1
- data/lib/inch/language/elixir/provider/reader/parser.rb +21 -7
- data/lib/inch/language/elixir/roles/base.rb +3 -3
- data/lib/inch/language/elixir/roles/function.rb +2 -1
- data/lib/inch/language/elixir/roles/object.rb +1 -1
- data/lib/inch/language/nodejs/code_object/base.rb +199 -0
- data/lib/inch/language/nodejs/code_object/function_object.rb +74 -0
- data/lib/inch/language/nodejs/code_object/member_object.rb +11 -0
- data/lib/inch/language/nodejs/code_object/module_object.rb +23 -0
- data/lib/inch/language/nodejs/evaluation/base.rb +29 -0
- data/lib/inch/language/nodejs/evaluation/function_object.rb +31 -0
- data/lib/inch/language/nodejs/evaluation/member_object.rb +11 -0
- data/lib/inch/language/nodejs/evaluation/module_object.rb +27 -0
- data/lib/inch/language/nodejs/import.rb +17 -1
- data/lib/inch/language/nodejs/provider/jsdoc.rb +1 -1
- data/lib/inch/language/nodejs/provider/jsdoc/docstring.rb +13 -0
- data/lib/inch/language/nodejs/provider/jsdoc/object.rb +16 -8
- data/lib/inch/language/nodejs/provider/jsdoc/object/base.rb +82 -45
- data/lib/inch/language/nodejs/provider/jsdoc/object/function_object.rb +18 -0
- data/lib/inch/language/nodejs/provider/jsdoc/object/member_object.rb +15 -0
- data/lib/inch/language/nodejs/provider/jsdoc/object/module_object.rb +22 -0
- data/lib/inch/language/nodejs/provider/jsdoc/parser.rb +9 -10
- data/lib/inch/language/nodejs/roles/base.rb +32 -0
- data/lib/inch/language/nodejs/roles/function.rb +113 -0
- data/lib/inch/language/nodejs/roles/member.rb +13 -0
- data/lib/inch/language/nodejs/roles/module.rb +64 -0
- data/lib/inch/language/nodejs/roles/object.rb +76 -0
- data/lib/inch/language/ruby/code_object/base.rb +6 -4
- data/lib/inch/language/ruby/evaluation/base.rb +2 -1
- data/lib/inch/language/ruby/evaluation/method_object.rb +2 -1
- data/lib/inch/language/ruby/import.rb +24 -24
- data/lib/inch/language/ruby/provider/yard.rb +10 -10
- data/lib/inch/language/ruby/provider/yard/nodoc_helper.rb +2 -2
- data/lib/inch/language/ruby/provider/yard/object.rb +9 -9
- data/lib/inch/language/ruby/provider/yard/object/base.rb +25 -28
- data/lib/inch/language/ruby/provider/yard/object/method_object.rb +4 -3
- data/lib/inch/language/ruby/provider/yard/object/method_parameter_object.rb +4 -3
- data/lib/inch/language/ruby/provider/yard/object/method_signature.rb +2 -2
- data/lib/inch/language/ruby/provider/yard/object/namespace_object.rb +2 -1
- data/lib/inch/language/ruby/provider/yard/parser.rb +2 -2
- data/lib/inch/language/ruby/roles/base.rb +1 -1
- data/lib/inch/language/ruby/roles/method.rb +2 -1
- data/lib/inch/language/ruby/roles/method_parameter.rb +1 -1
- data/lib/inch/language/ruby/roles/missing.rb +2 -2
- data/lib/inch/language/ruby/roles/object.rb +6 -6
- data/lib/inch/rake.rb +2 -2
- data/lib/inch/rake/suggest.rb +5 -5
- data/lib/inch/utils/code_location.rb +12 -0
- data/lib/inch/utils/read_write_methods.rb +2 -2
- data/lib/inch/utils/ui.rb +8 -8
- data/lib/inch/version.rb +1 -1
- data/test/fixtures/elixir/simple/all.json +321 -0
- data/test/integration/api/compare/codebases.rb +6 -6
- data/test/integration/cli/command/console_test.rb +13 -13
- data/test/integration/cli/command/diff_test.rb +12 -14
- data/test/integration/cli/command/inspect_test.rb +30 -30
- data/test/integration/cli/command/list_test.rb +34 -34
- data/test/integration/cli/command/show_test.rb +26 -26
- data/test/integration/cli/command/stats_test.rb +23 -23
- data/test/integration/cli/command/suggest_test.rb +58 -49
- data/test/integration/stats_options_test.rb +9 -9
- data/test/integration/visibility_options_test.rb +49 -45
- data/test/shared/base_list.rb +41 -41
- data/test/test_helper.rb +18 -10
- data/test/unit/api/filter_test.rb +9 -9
- data/test/unit/api/get_test.rb +6 -6
- data/test/unit/api/list_test.rb +3 -3
- data/test/unit/api/options/base_test.rb +6 -6
- data/test/unit/api/stats_test.rb +3 -3
- data/test/unit/api/suggest_test.rb +4 -4
- data/test/unit/cli/arguments_test.rb +25 -25
- data/test/unit/cli/command/base_test.rb +3 -3
- data/test/unit/cli/command/options/base_list_test.rb +14 -14
- data/test/unit/cli/command/options/base_object_test.rb +6 -6
- data/test/unit/cli/command/options/base_test.rb +3 -3
- data/test/unit/cli/command_parser_test.rb +29 -29
- data/test/unit/cli/trace_helper_test.rb +2 -2
- data/test/unit/cli/yardopts_helper_test.rb +35 -35
- data/test/unit/code_object/converter_test.rb +3 -3
- data/test/unit/code_object/provider_test.rb +2 -2
- data/test/unit/code_object/proxy_test.rb +11 -11
- data/test/unit/codebase/objects_test.rb +8 -8
- data/test/unit/codebase/proxy_test.rb +5 -5
- data/test/unit/config/codebase_test.rb +3 -3
- data/test/unit/config_test.rb +4 -4
- data/test/unit/evaluation/role_test.rb +8 -8
- data/test/unit/language/elixir/code_object/function_object_test.rb +35 -0
- data/test/unit/language/ruby/code_object/method_object_test.rb +128 -126
- data/test/unit/language/ruby/provider/yard/docstring_test.rb +27 -23
- data/test/unit/language/ruby/provider/yard/nodoc_helper_test.rb +21 -20
- data/test/unit/language/ruby/provider/yard/object/method_object_test.rb +20 -17
- data/test/unit/language/ruby/provider/yard_test.rb +4 -4
- data/test/unit/utils/buffered_ui_test.rb +20 -20
- data/test/unit/utils/ui_test.rb +20 -20
- data/test/unit/utils/weighted_list_test.rb +7 -7
- metadata +25 -2
@@ -20,7 +20,8 @@ module Inch
|
|
20
20
|
Role::Object::WithCodeExample => score_for(:code_example_single),
|
21
21
|
Role::Object::WithMultipleCodeExamples =>
|
22
22
|
score_for(:code_example_multi),
|
23
|
-
Role::Object::WithoutCodeExample =>
|
23
|
+
Role::Object::WithoutCodeExample =>
|
24
|
+
score_for(:code_example_single),
|
24
25
|
Role::Object::Tagged => score_for_unconsidered_tags,
|
25
26
|
Role::Object::TaggedAsAPI => nil,
|
26
27
|
Role::Object::TaggedAsInternalAPI => nil,
|
@@ -53,7 +53,8 @@ module Inch
|
|
53
53
|
|
54
54
|
def relevant_parameter_roles(param, per_param)
|
55
55
|
{
|
56
|
-
Role::MethodParameter::WithWrongMention =>
|
56
|
+
Role::MethodParameter::WithWrongMention =>
|
57
|
+
-score_for(:parameters),
|
57
58
|
Role::MethodParameter::WithMention => per_param * 0.5,
|
58
59
|
Role::MethodParameter::WithoutMention => per_param * 0.5,
|
59
60
|
Role::MethodParameter::WithType => per_param * 0.5,
|
@@ -5,30 +5,30 @@ module Inch
|
|
5
5
|
end
|
6
6
|
end
|
7
7
|
|
8
|
-
require
|
8
|
+
require 'inch/language/ruby/provider/yard'
|
9
9
|
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
10
|
+
require 'inch/language/ruby/code_object/base'
|
11
|
+
require 'inch/language/ruby/code_object/namespace_object'
|
12
|
+
require 'inch/language/ruby/code_object/class_object'
|
13
|
+
require 'inch/language/ruby/code_object/class_variable_object'
|
14
|
+
require 'inch/language/ruby/code_object/constant_object'
|
15
|
+
require 'inch/language/ruby/code_object/method_object'
|
16
|
+
require 'inch/language/ruby/code_object/method_parameter_object'
|
17
|
+
require 'inch/language/ruby/code_object/module_object'
|
18
18
|
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
19
|
+
require 'inch/language/ruby/evaluation/base'
|
20
|
+
require 'inch/language/ruby/evaluation/namespace_object'
|
21
|
+
require 'inch/language/ruby/evaluation/class_object'
|
22
|
+
require 'inch/language/ruby/evaluation/class_variable_object'
|
23
|
+
require 'inch/language/ruby/evaluation/constant_object'
|
24
|
+
require 'inch/language/ruby/evaluation/method_object'
|
25
|
+
require 'inch/language/ruby/evaluation/module_object'
|
26
26
|
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
33
|
-
require
|
34
|
-
require
|
27
|
+
require 'inch/language/ruby/roles/base'
|
28
|
+
require 'inch/language/ruby/roles/missing'
|
29
|
+
require 'inch/language/ruby/roles/object'
|
30
|
+
require 'inch/language/ruby/roles/method'
|
31
|
+
require 'inch/language/ruby/roles/method_parameter'
|
32
|
+
require 'inch/language/ruby/roles/namespace'
|
33
|
+
require 'inch/language/ruby/roles/constant'
|
34
|
+
require 'inch/language/ruby/roles/class_variable'
|
@@ -13,7 +13,7 @@ module Inch
|
|
13
13
|
if method.getter?
|
14
14
|
docstring.to_s == "Returns the value of attribute #{name}"
|
15
15
|
elsif method.setter?
|
16
|
-
basename = name.to_s.gsub(/(\=)$/,
|
16
|
+
basename = name.to_s.gsub(/(\=)$/, '')
|
17
17
|
docstring.to_s == "Sets the attribute #{basename}"
|
18
18
|
else
|
19
19
|
false
|
@@ -27,11 +27,11 @@ module Inch
|
|
27
27
|
def self.implicit_tag?(tag, method)
|
28
28
|
name = method.name
|
29
29
|
if method.getter?
|
30
|
-
tag.tag_name ==
|
30
|
+
tag.tag_name == 'return' &&
|
31
31
|
tag.text == "the current value of #{name}"
|
32
32
|
elsif method.setter?
|
33
|
-
tag.tag_name ==
|
34
|
-
tag.text ==
|
33
|
+
tag.tag_name == 'return' &&
|
34
|
+
tag.text == 'the newly set value'
|
35
35
|
else
|
36
36
|
false
|
37
37
|
end
|
@@ -47,12 +47,12 @@ module Inch
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
require
|
51
|
-
require
|
50
|
+
require 'logger'
|
51
|
+
require 'yard'
|
52
52
|
|
53
53
|
log.level = ::Logger::UNKNOWN # basically disable YARD's logging
|
54
54
|
|
55
|
-
require
|
56
|
-
require
|
57
|
-
require
|
58
|
-
require
|
55
|
+
require 'inch/language/ruby/provider/yard/parser'
|
56
|
+
require 'inch/language/ruby/provider/yard/docstring'
|
57
|
+
require 'inch/language/ruby/provider/yard/nodoc_helper'
|
58
|
+
require 'inch/language/ruby/provider/yard/object'
|
@@ -86,8 +86,8 @@ module Inch
|
|
86
86
|
line_number.times { f.gets }
|
87
87
|
result = $LAST_READ_LINE
|
88
88
|
f.close
|
89
|
-
result.encode(
|
90
|
-
invalid: :replace, undef: :replace, replace:
|
89
|
+
result.encode('UTF-8', 'binary',
|
90
|
+
invalid: :replace, undef: :replace, replace: '')
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -32,7 +32,7 @@ module Inch
|
|
32
32
|
# @param yard_object [YARD::CodeObject]
|
33
33
|
# @return [Class]
|
34
34
|
def class_for(yard_object)
|
35
|
-
class_name = yard_object.class.to_s.split(
|
35
|
+
class_name = yard_object.class.to_s.split('::').last
|
36
36
|
const_get(class_name)
|
37
37
|
rescue NameError
|
38
38
|
Base
|
@@ -53,11 +53,11 @@ module Inch
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
require
|
57
|
-
require
|
58
|
-
require
|
59
|
-
require
|
60
|
-
require
|
61
|
-
require
|
62
|
-
require
|
63
|
-
require
|
56
|
+
require 'inch/language/ruby/provider/yard/object/base'
|
57
|
+
require 'inch/language/ruby/provider/yard/object/namespace_object'
|
58
|
+
require 'inch/language/ruby/provider/yard/object/class_object'
|
59
|
+
require 'inch/language/ruby/provider/yard/object/class_variable_object'
|
60
|
+
require 'inch/language/ruby/provider/yard/object/constant_object'
|
61
|
+
require 'inch/language/ruby/provider/yard/object/method_object'
|
62
|
+
require 'inch/language/ruby/provider/yard/object/method_parameter_object'
|
63
|
+
require 'inch/language/ruby/provider/yard/object/module_object'
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require
|
1
|
+
require 'forwardable'
|
2
|
+
require 'inch/utils/code_location'
|
2
3
|
|
3
4
|
module Inch
|
4
5
|
module Language
|
@@ -59,8 +60,8 @@ module Inch
|
|
59
60
|
nil
|
60
61
|
end
|
61
62
|
|
62
|
-
# @return [Array,nil] the full names of the children of the
|
63
|
-
# object
|
63
|
+
# @return [Array,nil] the full names of the children of the
|
64
|
+
# current object
|
64
65
|
def children_fullnames
|
65
66
|
[]
|
66
67
|
end
|
@@ -75,11 +76,12 @@ module Inch
|
|
75
76
|
Array Bignum BasicObject Object Module Class Complex NilClass
|
76
77
|
Numeric String Float Fiber FiberError Continuation Dir File
|
77
78
|
Encoding Enumerator StopIteration Enumerator::Generator
|
78
|
-
Enumerator::Yielder Exception SystemExit SignalException
|
79
|
-
StandardError TypeError ArgumentError IndexError
|
80
|
-
RangeError ScriptError SyntaxError LoadError
|
81
|
-
NameError NoMethodError RuntimeError
|
82
|
-
EncodingError SystemCallError
|
79
|
+
Enumerator::Yielder Exception SystemExit SignalException
|
80
|
+
Interrupt StandardError TypeError ArgumentError IndexError
|
81
|
+
KeyError RangeError ScriptError SyntaxError LoadError
|
82
|
+
NotImplementedError NameError NoMethodError RuntimeError
|
83
|
+
SecurityError NoMemoryError EncodingError SystemCallError
|
84
|
+
Encoding::CompatibilityError
|
83
85
|
File::Stat IO Hash ENV IOError EOFError ARGF RubyVM
|
84
86
|
RubyVM::InstructionSequence Math::DomainError ZeroDivisionError
|
85
87
|
FloatDomainError Integer Fixnum Data TrueClass FalseClass Mutex
|
@@ -91,8 +93,9 @@ module Inch
|
|
91
93
|
Encoding::ConverterNotFoundError Encoding::Converter RubyVM::Env
|
92
94
|
|
93
95
|
Comparable Kernel File::Constants Enumerable Errno FileTest GC
|
94
|
-
ObjectSpace GC::Profiler IO::WaitReadable IO::WaitWritable
|
95
|
-
Math Process Process::UID Process::GID Process::Sys
|
96
|
+
ObjectSpace GC::Profiler IO::WaitReadable IO::WaitWritable
|
97
|
+
Marshal Math Process Process::UID Process::GID Process::Sys
|
98
|
+
Signal
|
96
99
|
)
|
97
100
|
def core?
|
98
101
|
RUBY_CORE.include?(name.to_s)
|
@@ -103,13 +106,13 @@ module Inch
|
|
103
106
|
@docstring ||= Docstring.new(object.docstring)
|
104
107
|
end
|
105
108
|
|
106
|
-
# Returns all files declaring the object in the form of an Array
|
107
|
-
# Arrays containing the location of their declaration.
|
109
|
+
# Returns all files declaring the object in the form of an Array
|
110
|
+
# of Arrays containing the location of their declaration.
|
108
111
|
#
|
109
112
|
# @return [Array<CodeLocation>]
|
110
113
|
def files
|
111
114
|
object.files.map do |(filename, line_no)|
|
112
|
-
CodeLocation.new(base_dir, filename, line_no)
|
115
|
+
Inch::Utils::CodeLocation.new(base_dir, filename, line_no)
|
113
116
|
end
|
114
117
|
rescue ::YARD::CodeObjects::ProxyMethodError
|
115
118
|
# this error is raised by YARD
|
@@ -117,19 +120,11 @@ module Inch
|
|
117
120
|
[]
|
118
121
|
end
|
119
122
|
|
120
|
-
# CodeLocation is a utility class to find declarations of objects in
|
121
|
-
# files
|
122
|
-
class CodeLocation < Struct.new(:base_dir, :relative_path, :line_no)
|
123
|
-
def filename
|
124
|
-
File.join(base_dir, relative_path)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
123
|
# Returns the name of the file where the object is declared first
|
129
124
|
# @return [String] a filename
|
130
125
|
def filename
|
131
|
-
# just checking the first file (which is the file where an
|
132
|
-
# is first declared)
|
126
|
+
# just checking the first file (which is the file where an
|
127
|
+
# object is first declared)
|
133
128
|
files.first && files.first.filename
|
134
129
|
end
|
135
130
|
|
@@ -182,8 +177,8 @@ module Inch
|
|
182
177
|
# ^ ^ ^ ^
|
183
178
|
# 1 << 2 << 3 << 4
|
184
179
|
#
|
185
|
-
# +depth+ answers the question "how many layers of code objects
|
186
|
-
# above this one?"
|
180
|
+
# +depth+ answers the question "how many layers of code objects
|
181
|
+
# are above this one?"
|
187
182
|
#
|
188
183
|
# @note top-level counts, that's why Foo has depth 1!
|
189
184
|
#
|
@@ -242,7 +237,8 @@ module Inch
|
|
242
237
|
depth == 1
|
243
238
|
end
|
244
239
|
|
245
|
-
# @return [Boolean] +true+ if the object has no documentation at
|
240
|
+
# @return [Boolean] +true+ if the object has no documentation at
|
241
|
+
# all
|
246
242
|
def undocumented?
|
247
243
|
original_docstring.empty?
|
248
244
|
end
|
@@ -270,7 +266,7 @@ module Inch
|
|
270
266
|
attr_reader :private_tag
|
271
267
|
|
272
268
|
def private_api_tag?
|
273
|
-
api_tag && api_tag.text ==
|
269
|
+
api_tag && api_tag.text == 'private'
|
274
270
|
end
|
275
271
|
|
276
272
|
def tag(name)
|
@@ -286,7 +282,8 @@ module Inch
|
|
286
282
|
end
|
287
283
|
|
288
284
|
# @return [Array]
|
289
|
-
# YARD tags that are not already covered by other wrapper
|
285
|
+
# YARD tags that are not already covered by other wrapper
|
286
|
+
# methods
|
290
287
|
def unconsidered_tags
|
291
288
|
@unconsidered_tags ||= tags.reject do |tag|
|
292
289
|
auto_generated_tag?(tag) ||
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'inch/language/ruby/provider/yard/object/method_signature'
|
2
2
|
|
3
3
|
module Inch
|
4
4
|
module Language
|
@@ -70,7 +70,8 @@ module Inch
|
|
70
70
|
# mentioned in the docstring (e.g. "Returns a String").
|
71
71
|
def return_mentioned?
|
72
72
|
return_tags.any? do |t|
|
73
|
-
!t.types.nil? && !t.types.empty? &&
|
73
|
+
!t.types.nil? && !t.types.empty? &&
|
74
|
+
!YARD.implicit_tag?(t, self)
|
74
75
|
end || docstring.mentions_return? && !implicit_docstring?
|
75
76
|
end
|
76
77
|
|
@@ -120,7 +121,7 @@ module Inch
|
|
120
121
|
|
121
122
|
# @return [MethodObject,nil]
|
122
123
|
def corresponding_getter
|
123
|
-
clean_name = name.to_s.gsub(/(\=)$/,
|
124
|
+
clean_name = name.to_s.gsub(/(\=)$/, '')
|
124
125
|
parent.child(clean_name.to_sym)
|
125
126
|
end
|
126
127
|
|
@@ -41,7 +41,8 @@ module Inch
|
|
41
41
|
described_by_tag? || described_by_docstring?
|
42
42
|
end
|
43
43
|
|
44
|
-
# @return [Boolean] +true+ if the parameter is mentioned in the
|
44
|
+
# @return [Boolean] +true+ if the parameter is mentioned in the
|
45
|
+
# docs
|
45
46
|
def mentioned?
|
46
47
|
!!@tag || mentioned_by_docstring?
|
47
48
|
end
|
@@ -72,7 +73,7 @@ module Inch
|
|
72
73
|
if @method.docstring.describes_parameter?(name)
|
73
74
|
true
|
74
75
|
else
|
75
|
-
unsplatted = name.gsub(/^[\&\*]/,
|
76
|
+
unsplatted = name.gsub(/^[\&\*]/, '')
|
76
77
|
@method.docstring.describes_parameter?(unsplatted)
|
77
78
|
end
|
78
79
|
end
|
@@ -81,7 +82,7 @@ module Inch
|
|
81
82
|
if @method.docstring.mentions_parameter?(name)
|
82
83
|
true
|
83
84
|
else
|
84
|
-
unsplatted = name.gsub(/^[\&\*]/,
|
85
|
+
unsplatted = name.gsub(/^[\&\*]/, '')
|
85
86
|
@method.docstring.mentions_parameter?(unsplatted)
|
86
87
|
end
|
87
88
|
end
|
@@ -60,7 +60,7 @@ module Inch
|
|
60
60
|
# Returns the actual signature of the method.
|
61
61
|
# @return [String]
|
62
62
|
def signature
|
63
|
-
relevant_object.signature.gsub(/^(def\ )/,
|
63
|
+
relevant_object.signature.gsub(/^(def\ )/, '')
|
64
64
|
end
|
65
65
|
|
66
66
|
private
|
@@ -95,7 +95,7 @@ module Inch
|
|
95
95
|
# @param name [String] parameter name
|
96
96
|
# @return [String]
|
97
97
|
def normalize_parameter_name(name)
|
98
|
-
name.gsub(/[\&\*\$\[\]]/,
|
98
|
+
name.gsub(/[\&\*\$\[\]]/, '')
|
99
99
|
end
|
100
100
|
|
101
101
|
def parameter_tag(param_name)
|
@@ -8,7 +8,8 @@ module Inch
|
|
8
8
|
# inside itself (e.g. classes and modules)
|
9
9
|
class NamespaceObject < Base
|
10
10
|
def attributes
|
11
|
-
object.class_attributes.values +
|
11
|
+
object.class_attributes.values +
|
12
|
+
object.instance_attributes.values
|
12
13
|
end
|
13
14
|
|
14
15
|
def children_fullnames
|
@@ -7,7 +7,7 @@ module Inch
|
|
7
7
|
class Base < Inch::Evaluation::Role
|
8
8
|
# Returns the type of the +object+ that is being evaluated.
|
9
9
|
def object_type
|
10
|
-
object.class.to_s.split(
|
10
|
+
object.class.to_s.split('::').last.gsub(/Object$/, '').downcase
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -17,7 +17,8 @@ module Inch
|
|
17
17
|
priority +2
|
18
18
|
end
|
19
19
|
|
20
|
-
# Role assigned to methods where the return value is typed in the
|
20
|
+
# Role assigned to methods where the return value is typed in the
|
21
|
+
# docs
|
21
22
|
class WithReturnType < Base
|
22
23
|
applicable_if :return_typed?
|
23
24
|
end
|
@@ -11,8 +11,8 @@ module Inch
|
|
11
11
|
end
|
12
12
|
|
13
13
|
# @return [Fixnum]
|
14
|
-
# a score that can be achieved by adding the missing thing
|
15
|
-
# by the role
|
14
|
+
# a score that can be achieved by adding the missing thing
|
15
|
+
# mentioned by the role
|
16
16
|
def potential_score
|
17
17
|
@value.to_i
|
18
18
|
end
|
@@ -45,15 +45,15 @@ module Inch
|
|
45
45
|
priority -7
|
46
46
|
end
|
47
47
|
|
48
|
-
# Role assigned to objects explicitly or implicitly tagged to be
|
49
|
-
# of an API. If the API is 'private'/'internal'
|
50
|
-
# assigned instead.
|
48
|
+
# Role assigned to objects explicitly or implicitly tagged to be
|
49
|
+
# part of an API. If the API is 'private'/'internal'
|
50
|
+
# TaggedAsInternalAPI is assigned instead.
|
51
51
|
class TaggedAsAPI < Base
|
52
52
|
applicable_if :api_tag?
|
53
53
|
end
|
54
54
|
|
55
|
-
# Role assigned to objects explicitly or implicitly tagged to be
|
56
|
-
# of a private API.
|
55
|
+
# Role assigned to objects explicitly or implicitly tagged to be
|
56
|
+
# part of a private API.
|
57
57
|
class TaggedAsInternalAPI < Base
|
58
58
|
applicable_if :tagged_as_internal_api?
|
59
59
|
priority -5
|
@@ -109,7 +109,7 @@ module Inch
|
|
109
109
|
applicable_unless :has_code_example?
|
110
110
|
|
111
111
|
def suggestion
|
112
|
-
|
112
|
+
'Add a code example (optional)'
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|