inch 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +15 -0
  3. data/.rubocop_todo.yml +113 -0
  4. data/CHANGELOG.md +6 -0
  5. data/Gemfile +5 -2
  6. data/README.md +2 -2
  7. data/Rakefile +2 -2
  8. data/bin/inch +3 -2
  9. data/config/defaults.rb +7 -0
  10. data/inch.gemspec +7 -7
  11. data/lib/inch.rb +9 -10
  12. data/lib/inch/api.rb +10 -10
  13. data/lib/inch/api/compare.rb +2 -2
  14. data/lib/inch/api/compare/code_objects.rb +2 -3
  15. data/lib/inch/api/compare/codebases.rb +1 -1
  16. data/lib/inch/api/diff.rb +6 -9
  17. data/lib/inch/api/options/base.rb +4 -4
  18. data/lib/inch/api/options/suggest.rb +1 -1
  19. data/lib/inch/api/stats.rb +0 -1
  20. data/lib/inch/api/suggest.rb +8 -9
  21. data/lib/inch/cli.rb +6 -6
  22. data/lib/inch/cli/command.rb +15 -15
  23. data/lib/inch/cli/command/base.rb +2 -2
  24. data/lib/inch/cli/command/console.rb +5 -5
  25. data/lib/inch/cli/command/diff.rb +7 -8
  26. data/lib/inch/cli/command/inspect.rb +5 -4
  27. data/lib/inch/cli/command/list.rb +4 -4
  28. data/lib/inch/cli/command/options/base.rb +8 -8
  29. data/lib/inch/cli/command/options/base_list.rb +9 -5
  30. data/lib/inch/cli/command/options/console.rb +4 -3
  31. data/lib/inch/cli/command/options/diff.rb +6 -4
  32. data/lib/inch/cli/command/options/inspect.rb +2 -2
  33. data/lib/inch/cli/command/options/list.rb +4 -3
  34. data/lib/inch/cli/command/options/show.rb +2 -2
  35. data/lib/inch/cli/command/options/stats.rb +2 -1
  36. data/lib/inch/cli/command/options/suggest.rb +6 -3
  37. data/lib/inch/cli/command/output/base.rb +2 -4
  38. data/lib/inch/cli/command/output/console.rb +4 -5
  39. data/lib/inch/cli/command/output/diff.rb +6 -6
  40. data/lib/inch/cli/command/output/inspect.rb +6 -8
  41. data/lib/inch/cli/command/output/list.rb +0 -1
  42. data/lib/inch/cli/command/output/show.rb +4 -5
  43. data/lib/inch/cli/command/output/stats.rb +21 -21
  44. data/lib/inch/cli/command/output/suggest.rb +28 -26
  45. data/lib/inch/cli/command/show.rb +4 -4
  46. data/lib/inch/cli/command/stats.rb +4 -4
  47. data/lib/inch/cli/command/suggest.rb +6 -6
  48. data/lib/inch/cli/command_parser.rb +6 -5
  49. data/lib/inch/cli/sparkline_helper.rb +2 -2
  50. data/lib/inch/cli/trace_helper.rb +1 -1
  51. data/lib/inch/cli/yardopts_helper.rb +4 -3
  52. data/lib/inch/code_object.rb +3 -3
  53. data/lib/inch/code_object/converter.rb +6 -8
  54. data/lib/inch/code_object/provider.rb +1 -1
  55. data/lib/inch/code_object/provider/yard.rb +10 -12
  56. data/lib/inch/code_object/provider/yard/docstring.rb +53 -21
  57. data/lib/inch/code_object/provider/yard/nodoc_helper.rb +3 -3
  58. data/lib/inch/code_object/provider/yard/object.rb +11 -9
  59. data/lib/inch/code_object/provider/yard/object/base.rb +33 -9
  60. data/lib/inch/code_object/provider/yard/object/class_variable_object.rb +12 -0
  61. data/lib/inch/code_object/provider/yard/object/method_object.rb +36 -11
  62. data/lib/inch/code_object/provider/yard/object/method_parameter_object.rb +2 -2
  63. data/lib/inch/code_object/provider/yard/object/method_signature.rb +11 -8
  64. data/lib/inch/code_object/provider/yard/object/namespace_object.rb +1 -4
  65. data/lib/inch/code_object/provider/yard/parser.rb +2 -2
  66. data/lib/inch/code_object/proxy.rb +10 -9
  67. data/lib/inch/code_object/proxy/base.rb +8 -8
  68. data/lib/inch/code_object/proxy/class_variable_object.rb +8 -0
  69. data/lib/inch/code_object/proxy/method_object.rb +3 -2
  70. data/lib/inch/code_object/proxy/method_parameter_object.rb +1 -1
  71. data/lib/inch/codebase.rb +4 -5
  72. data/lib/inch/codebase/objects_filter.rb +2 -4
  73. data/lib/inch/codebase/serializer.rb +3 -3
  74. data/lib/inch/config.rb +2 -2
  75. data/lib/inch/config/base.rb +0 -1
  76. data/lib/inch/config/codebase.rb +3 -3
  77. data/lib/inch/core_ext.rb +1 -1
  78. data/lib/inch/core_ext/string.rb +1 -1
  79. data/lib/inch/evaluation.rb +16 -15
  80. data/lib/inch/evaluation/grade_list.rb +2 -2
  81. data/lib/inch/evaluation/object_schema.rb +1 -1
  82. data/lib/inch/evaluation/proxy.rb +8 -7
  83. data/lib/inch/evaluation/proxy/base.rb +12 -7
  84. data/lib/inch/evaluation/proxy/class_variable_object.rb +19 -0
  85. data/lib/inch/evaluation/proxy/constant_object.rb +1 -1
  86. data/lib/inch/evaluation/proxy/method_object.rb +12 -5
  87. data/lib/inch/evaluation/proxy/module_object.rb +1 -1
  88. data/lib/inch/evaluation/proxy/namespace_object.rb +1 -1
  89. data/lib/inch/evaluation/role/base.rb +1 -1
  90. data/lib/inch/evaluation/role/class_variable.rb +55 -0
  91. data/lib/inch/evaluation/role/method.rb +0 -1
  92. data/lib/inch/evaluation/role/method_parameter.rb +2 -1
  93. data/lib/inch/evaluation/role/object.rb +2 -2
  94. data/lib/inch/rake.rb +2 -2
  95. data/lib/inch/rake/suggest.rb +2 -2
  96. data/lib/inch/utils/shell_helper.rb +1 -1
  97. data/lib/inch/utils/ui.rb +5 -5
  98. data/lib/inch/utils/weighted_list.rb +2 -3
  99. data/lib/inch/version.rb +1 -1
  100. data/test/fixtures/simple/lib/broken.rb +35 -7
  101. data/test/fixtures/simple/lib/broken_ruby_2_0_features.rb +7 -0
  102. data/test/fixtures/simple/lib/directives.rb +8 -0
  103. data/test/fixtures/simple/lib/foo.rb +17 -0
  104. data/test/integration/api/compare/codebases.rb +1 -1
  105. data/test/integration/cli/command/console_test.rb +5 -5
  106. data/test/integration/cli/command/inspect_test.rb +4 -5
  107. data/test/integration/cli/command/list_test.rb +3 -4
  108. data/test/integration/cli/command/show_test.rb +4 -4
  109. data/test/integration/cli/command/stats_test.rb +2 -2
  110. data/test/integration/cli/command/suggest_test.rb +7 -7
  111. data/test/integration/stats_options_test.rb +3 -3
  112. data/test/integration/visibility_options_test.rb +13 -13
  113. data/test/shared/base_list.rb +4 -3
  114. data/test/test_helper.rb +16 -5
  115. data/test/unit/api/filter_test.rb +7 -7
  116. data/test/unit/api/get_test.rb +1 -1
  117. data/test/unit/api/list_test.rb +1 -1
  118. data/test/unit/api/options/base_test.rb +3 -3
  119. data/test/unit/api/stats_test.rb +1 -1
  120. data/test/unit/api/suggest_test.rb +3 -3
  121. data/test/unit/cli/arguments_test.rb +1 -1
  122. data/test/unit/cli/command/base_test.rb +1 -1
  123. data/test/unit/cli/command/options/base_list_test.rb +2 -2
  124. data/test/unit/cli/command/options/base_object_test.rb +1 -1
  125. data/test/unit/cli/command/options/base_test.rb +1 -1
  126. data/test/unit/cli/command_parser_test.rb +2 -2
  127. data/test/unit/cli/trace_helper_test.rb +1 -1
  128. data/test/unit/cli/yardopts_helper_test.rb +4 -3
  129. data/test/unit/code_object/converter_test.rb +1 -1
  130. data/test/unit/code_object/provider/yard/docstring_test.rb +105 -28
  131. data/test/unit/code_object/provider/yard/nodoc_helper_test.rb +5 -5
  132. data/test/unit/code_object/provider/yard/object/method_object_test.rb +20 -10
  133. data/test/unit/code_object/provider/yard_test.rb +4 -4
  134. data/test/unit/code_object/provider_test.rb +1 -1
  135. data/test/unit/code_object/proxy/method_object_test.rb +366 -262
  136. data/test/unit/code_object/proxy_test.rb +1 -1
  137. data/test/unit/codebase/objects_test.rb +2 -2
  138. data/test/unit/codebase/proxy_test.rb +1 -1
  139. data/test/unit/config/codebase_test.rb +1 -1
  140. data/test/unit/evaluation/role/base_test.rb +1 -1
  141. data/test/unit/utils/ui_test.rb +4 -4
  142. data/test/unit/utils/weighted_list_test.rb +7 -4
  143. metadata +12 -2
@@ -67,7 +67,7 @@ module Inch
67
67
  if @method.docstring.describes_parameter?(name)
68
68
  true
69
69
  else
70
- unsplatted = name.gsub(/^[\&\*]/, '')
70
+ unsplatted = name.gsub(/^[\&\*]/, "")
71
71
  @method.docstring.describes_parameter?(unsplatted)
72
72
  end
73
73
  end
@@ -76,7 +76,7 @@ module Inch
76
76
  if @method.docstring.mentions_parameter?(name)
77
77
  true
78
78
  else
79
- unsplatted = name.gsub(/^[\&\*]/, '')
79
+ unsplatted = name.gsub(/^[\&\*]/, "")
80
80
  @method.docstring.mentions_parameter?(unsplatted)
81
81
  end
82
82
  end
@@ -8,11 +8,12 @@ module Inch
8
8
  attr_reader :method, :docstring
9
9
 
10
10
  # @param method [Provider::YARD::Object::MethodObject]
11
- # @param method [::YARD::Tags::Tag,nil] if nil, the method's normal signature is used
11
+ # @param yard_tag [::YARD::Tags::Tag,nil] if nil, the method's normal signature is used
12
12
  def initialize(method, yard_tag = nil)
13
13
  @method = method
14
14
  @yard_tag = yard_tag
15
- @docstring = Provider::YARD::Docstring.new(relevant_object.docstring)
15
+ @docstring =
16
+ Provider::YARD::Docstring.new(relevant_object.docstring)
16
17
  end
17
18
 
18
19
  def all_signature_parameter_names
@@ -43,26 +44,28 @@ module Inch
43
44
  # @param name [String,Symbol]
44
45
  # @return [MethodParameterObject]
45
46
  def parameter(name)
46
- parameters.detect { |p| p.name == name.to_s }
47
+ parameters.find { |p| p.name == name.to_s }
47
48
  end
48
49
 
49
50
  # Returns +true+ if the other signature is identical to self
50
51
  # @param other [MethodSignature]
51
52
  # @return [Boolean]
52
53
  def same?(other)
53
- all_signature_parameter_names == other.all_signature_parameter_names
54
+ all_signature_parameter_names ==
55
+ other.all_signature_parameter_names
54
56
  end
55
57
 
56
58
  # Returns the actual signature of the method.
57
59
  # @return [String]
58
60
  def signature
59
- relevant_object.signature.gsub(/^(def\ )/, '')
61
+ relevant_object.signature.gsub(/^(def\ )/, "")
60
62
  end
61
63
 
62
64
  private
63
65
 
64
66
  def all_parameter_names
65
- all_names = all_signature_parameter_names + parameter_tags.map(&:name)
67
+ all_names = all_signature_parameter_names +
68
+ parameter_tags.map(&:name)
66
69
  all_names.map do |name|
67
70
  normalize_parameter_name(name) if name
68
71
  end.compact.uniq
@@ -90,11 +93,11 @@ module Inch
90
93
  # @param name [String] parameter name
91
94
  # @return [String]
92
95
  def normalize_parameter_name(name)
93
- name.gsub(/[\&\*\$\[\]]/, '')
96
+ name.gsub(/[\&\*\$\[\]]/, "")
94
97
  end
95
98
 
96
99
  def parameter_tag(param_name)
97
- parameter_tags.detect do |tag|
100
+ parameter_tags.find do |tag|
98
101
  tag.name == param_name
99
102
  end
100
103
  end
@@ -28,9 +28,7 @@ module Inch
28
28
 
29
29
  # called by MethodObject#getter?
30
30
  def child(name)
31
- if children
32
- children.detect { |child| child.name == name }
33
- end
31
+ children.find { |child| child.name == name } if children
34
32
  end
35
33
 
36
34
  def children
@@ -38,7 +36,6 @@ module Inch
38
36
  YARD::Object.for(o)
39
37
  end
40
38
  end
41
-
42
39
  end
43
40
  end
44
41
  end
@@ -11,7 +11,7 @@ module Inch
11
11
  # @see #parse
12
12
  # @return [CodeObject::Provider::YARD::Parser] the instance that ran
13
13
  def self.parse(*args)
14
- parser = self.new
14
+ parser = new
15
15
  parser.parse(*args)
16
16
  parser
17
17
  end
@@ -46,7 +46,7 @@ module Inch
46
46
  object.base_dir = dir
47
47
 
48
48
  object.aliases_fullnames.each do |fullname|
49
- _alias = objects.detect { |o| o.fullname == fullname }
49
+ _alias = objects.find { |o| o.fullname == fullname }
50
50
  _alias.aliased_object_fullname = object.fullname
51
51
  end
52
52
  end
@@ -11,7 +11,7 @@ module Inch
11
11
  # @return [CodeObject::Proxy::Base]
12
12
  def for(code_object)
13
13
  attributes = Converter.to_hash(code_object)
14
- proxy_object = class_for(code_object).new(attributes)
14
+ class_for(code_object).new(attributes)
15
15
  end
16
16
 
17
17
  private
@@ -21,7 +21,7 @@ module Inch
21
21
  # @param code_object [YARD::CodeObject]
22
22
  # @return [Class]
23
23
  def class_for(code_object)
24
- class_name = code_object.class.to_s.split('::').last
24
+ class_name = code_object.class.to_s.split("::").last
25
25
  const_get(class_name)
26
26
  end
27
27
  end
@@ -29,10 +29,11 @@ module Inch
29
29
  end
30
30
  end
31
31
 
32
- require 'inch/code_object/proxy/base'
33
- require 'inch/code_object/proxy/namespace_object'
34
- require 'inch/code_object/proxy/class_object'
35
- require 'inch/code_object/proxy/constant_object'
36
- require 'inch/code_object/proxy/method_object'
37
- require 'inch/code_object/proxy/method_parameter_object'
38
- require 'inch/code_object/proxy/module_object'
32
+ require "inch/code_object/proxy/base"
33
+ require "inch/code_object/proxy/namespace_object"
34
+ require "inch/code_object/proxy/class_object"
35
+ require "inch/code_object/proxy/class_variable_object"
36
+ require "inch/code_object/proxy/constant_object"
37
+ require "inch/code_object/proxy/method_object"
38
+ require "inch/code_object/proxy/method_parameter_object"
39
+ require "inch/code_object/proxy/module_object"
@@ -1,4 +1,4 @@
1
- require 'forwardable'
1
+ require "forwardable"
2
2
 
3
3
  module Inch
4
4
  module CodeObject
@@ -42,9 +42,9 @@ module Inch
42
42
 
43
43
  # @return [Symbol]
44
44
  def grade
45
- @grade ||= Evaluation.new_grade_lists.detect { |range|
46
- range.scores.include?(score)
47
- }.grade
45
+ @grade ||= Evaluation.new_grade_lists.find do |range|
46
+ range.scores.include?(score)
47
+ end.grade
48
48
  end
49
49
 
50
50
  # @return [Boolean] if the current object is an alias for something else
@@ -54,7 +54,7 @@ module Inch
54
54
 
55
55
  # @return [CodeObject::Proxy::Base] the object the current object is an alias of
56
56
  def aliased_object
57
- object_lookup.find( self[:aliased_object_fullname] )
57
+ object_lookup.find(self[:aliased_object_fullname])
58
58
  end
59
59
 
60
60
  # @return [Boolean] +true+ if the object has an @api tag
@@ -172,7 +172,7 @@ module Inch
172
172
 
173
173
  # @return [CodeObject::Proxy::Base,nil] the parent of the current object or +nil+
174
174
  def parent
175
- object_lookup.find( self[:parent_fullname] )
175
+ object_lookup.find(self[:parent_fullname])
176
176
  end
177
177
 
178
178
  def private?
@@ -205,7 +205,7 @@ module Inch
205
205
  end
206
206
 
207
207
  def type
208
- self.class.to_s.gsub(/Object$/, '')
208
+ self.class.to_s.gsub(/Object$/, "")
209
209
  end
210
210
 
211
211
  # @return [Boolean] +true+ if the object has no documentation at all
@@ -233,7 +233,7 @@ module Inch
233
233
  end
234
234
 
235
235
  def inspect
236
- "#<#{self.class.to_s}: #{fullname}>"
236
+ "#<#{self.class}: #{fullname}>"
237
237
  end
238
238
  end
239
239
  end
@@ -0,0 +1,8 @@
1
+ module Inch
2
+ module CodeObject
3
+ module Proxy
4
+ class ClassVariableObject < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -36,7 +36,7 @@ module Inch
36
36
  end
37
37
 
38
38
  def parameter(name)
39
- parameters.detect { |p| p.name == name.to_s }
39
+ parameters.find { |p| p.name == name.to_s }
40
40
  end
41
41
 
42
42
  def parameters
@@ -50,7 +50,8 @@ module Inch
50
50
  end
51
51
 
52
52
  def overridden_method
53
- @overridden_method ||= object_lookup.find(self[:overridden_method_fullname])
53
+ @overridden_method ||=
54
+ object_lookup.find(self[:overridden_method_fullname])
54
55
  end
55
56
 
56
57
  def return_mentioned?
@@ -38,7 +38,7 @@ module Inch
38
38
  def name
39
39
  self[:name]
40
40
  end
41
- alias fullname name
41
+ alias_method :fullname, :name
42
42
 
43
43
  # @return [Boolean] +true+ if the parameter is a splat argument
44
44
  def splat?
@@ -15,8 +15,7 @@ module Inch
15
15
  end
16
16
  end
17
17
 
18
- require 'inch/codebase/proxy'
19
- require 'inch/codebase/objects'
20
- require 'inch/codebase/objects_filter'
21
- require 'inch/codebase/serializer'
22
-
18
+ require "inch/codebase/proxy"
19
+ require "inch/codebase/objects"
20
+ require "inch/codebase/objects_filter"
21
+ require "inch/codebase/serializer"
@@ -41,16 +41,14 @@ module Inch
41
41
  end
42
42
 
43
43
  def filter_depth
44
- if options.depth
45
- @list = @list.select { |o| o.depth <= options.depth }
46
- end
44
+ @list = @list.select { |o| o.depth <= options.depth } if options.depth
47
45
  end
48
46
 
49
47
  def filter_visibility
50
48
  @list = @list.select do |o|
51
49
  options.visibility.include?(o.visibility)
52
50
  end
53
- if !options.visibility.include?(:private)
51
+ unless options.visibility.include?(:private)
54
52
  @list = @list.reject do |o|
55
53
  o.tagged_as_private?
56
54
  end
@@ -9,12 +9,12 @@ module Inch
9
9
 
10
10
  def self.save(codebase, filename)
11
11
  content = Marshal.dump(codebase)
12
- FileUtils.mkdir_p( File.dirname(filename) )
13
- File.open(filename, 'wb') { |file| file.write(content) }
12
+ FileUtils.mkdir_p(File.dirname(filename))
13
+ File.open(filename, "wb") { |file| file.write(content) }
14
14
  end
15
15
 
16
16
  def self.load(filename)
17
- codebase = Marshal.load( File.binread(filename) )
17
+ codebase = Marshal.load(File.binread(filename))
18
18
  codebase.objects.each do |object|
19
19
  object.object_lookup = codebase.objects
20
20
  end
@@ -20,5 +20,5 @@ module Inch
20
20
  end
21
21
  end
22
22
 
23
- require 'inch/config/base'
24
- require 'inch/config/codebase'
23
+ require "inch/config/base"
24
+ require "inch/config/codebase"
@@ -4,7 +4,6 @@ module Inch
4
4
  # @see config/defaults.rb
5
5
  class Config
6
6
  class Base
7
-
8
7
  def update(&block)
9
8
  instance_eval(&block)
10
9
  end
@@ -57,9 +57,9 @@ module Inch
57
57
 
58
58
  def update_files(files)
59
59
  return if files.nil?
60
- include_files expand_files(files["included"]) if files["included"]
61
- exclude_files expand_files(files["excluded"]) if files["excluded"]
60
+ @included_files = expand_files(files["included"]) if files["included"]
61
+ @excluded_files = expand_files(files["excluded"]) if files["excluded"]
62
62
  end
63
63
  end
64
64
  end
65
- end
65
+ end
@@ -1 +1 @@
1
- require 'inch/core_ext/string'
1
+ require "inch/core_ext/string"
@@ -1,3 +1,3 @@
1
- require 'term/ansicolor'
1
+ require "term/ansicolor"
2
2
 
3
3
  String.send(:include, Term::ANSIColor)
@@ -9,26 +9,27 @@ module Inch
9
9
  private
10
10
 
11
11
  def self.class_for(code_object)
12
- class_name = code_object.class.to_s.split('::').last
12
+ class_name = code_object.class.to_s.split("::").last
13
13
  const_get(class_name)
14
14
  end
15
15
  end
16
16
  end
17
17
 
18
- require 'inch/utils/read_write_methods'
18
+ require "inch/utils/read_write_methods"
19
19
 
20
- require 'inch/evaluation/file'
21
- require 'inch/evaluation/grade'
22
- require 'inch/evaluation/grade_list'
23
- require 'inch/evaluation/object_schema'
24
- require 'inch/evaluation/priority_range'
20
+ require "inch/evaluation/file"
21
+ require "inch/evaluation/grade"
22
+ require "inch/evaluation/grade_list"
23
+ require "inch/evaluation/object_schema"
24
+ require "inch/evaluation/priority_range"
25
25
 
26
- require 'inch/evaluation/role/base'
27
- require 'inch/evaluation/role/missing'
28
- require 'inch/evaluation/role/object'
29
- require 'inch/evaluation/role/method'
30
- require 'inch/evaluation/role/method_parameter'
31
- require 'inch/evaluation/role/namespace'
32
- require 'inch/evaluation/role/constant'
26
+ require "inch/evaluation/role/base"
27
+ require "inch/evaluation/role/missing"
28
+ require "inch/evaluation/role/object"
29
+ require "inch/evaluation/role/method"
30
+ require "inch/evaluation/role/method_parameter"
31
+ require "inch/evaluation/role/namespace"
32
+ require "inch/evaluation/role/constant"
33
+ require "inch/evaluation/role/class_variable"
33
34
 
34
- require 'inch/evaluation/proxy'
35
+ require "inch/evaluation/proxy"
@@ -6,8 +6,8 @@ module Inch
6
6
  class GradeList < Struct.new(:grade)
7
7
  extend Forwardable
8
8
 
9
- def_delegators :grade, :scores, :label, :color, :bg_color,
10
- :to_s, :to_sym
9
+ def_delegators :grade,
10
+ :scores, :label, :color, :bg_color, :to_s, :to_sym
11
11
 
12
12
  # Returns code_objects that received a score with the defined +scores+
13
13
  attr_reader :objects
@@ -13,7 +13,7 @@ module Inch
13
13
  code_example_single
14
14
  code_example_multi
15
15
  unconsidered_tag
16
- )
16
+ )
17
17
 
18
18
  attr_reader :object
19
19
 
@@ -10,16 +10,17 @@ module Inch
10
10
  private
11
11
 
12
12
  def self.class_for(code_object)
13
- class_name = code_object.class.to_s.split('::').last
13
+ class_name = code_object.class.to_s.split("::").last
14
14
  const_get(class_name)
15
15
  end
16
16
  end
17
17
  end
18
18
  end
19
19
 
20
- require 'inch/evaluation/proxy/base'
21
- require 'inch/evaluation/proxy/namespace_object'
22
- require 'inch/evaluation/proxy/class_object'
23
- require 'inch/evaluation/proxy/constant_object'
24
- require 'inch/evaluation/proxy/method_object'
25
- require 'inch/evaluation/proxy/module_object'
20
+ require "inch/evaluation/proxy/base"
21
+ require "inch/evaluation/proxy/namespace_object"
22
+ require "inch/evaluation/proxy/class_object"
23
+ require "inch/evaluation/proxy/class_variable_object"
24
+ require "inch/evaluation/proxy/constant_object"
25
+ require "inch/evaluation/proxy/method_object"
26
+ require "inch/evaluation/proxy/module_object"
@@ -95,13 +95,19 @@ module Inch
95
95
  Role::Object::WithDoc => score_for(:docstring),
96
96
  Role::Object::WithoutDoc => score_for(:docstring),
97
97
  Role::Object::WithCodeExample => score_for(:code_example_single),
98
- Role::Object::WithMultipleCodeExamples => score_for(:code_example_multi),
98
+ Role::Object::WithMultipleCodeExamples =>
99
+ score_for(:code_example_multi),
99
100
  Role::Object::WithoutCodeExample => score_for(:code_example_single),
100
101
  Role::Object::Tagged => score_for_unconsidered_tags,
101
102
  Role::Object::TaggedAsAPI => nil,
102
103
  Role::Object::TaggedAsInternalAPI => nil,
103
104
  Role::Object::TaggedAsPrivate => nil,
104
- Role::Object::Alias => object.alias? ? object.aliased_object.score : nil,
105
+ Role::Object::Alias =>
106
+ if object.alias?
107
+ object.aliased_object.score
108
+ else
109
+ nil
110
+ end
105
111
  }
106
112
  end
107
113
 
@@ -124,9 +130,8 @@ module Inch
124
130
 
125
131
  def __evaluate(object, role_classes)
126
132
  role_classes.each do |role_class, score|
127
- if role_class.applicable?(object)
128
- add_role role_class.new(object, score)
129
- end
133
+ next unless role_class.applicable?(object)
134
+ add_role role_class.new(object, score)
130
135
  end
131
136
  end
132
137
 
@@ -144,7 +149,7 @@ module Inch
144
149
 
145
150
  # @return [Float]
146
151
  def __score
147
- value = @roles.inject(0) { |sum,r| sum + r.score.to_f }.to_i
152
+ value = @roles.reduce(0) { |sum, r| sum + r.score.to_f }.to_i
148
153
  if value < min_score
149
154
  min_score
150
155
  elsif value > max_score
@@ -156,7 +161,7 @@ module Inch
156
161
 
157
162
  # @return [Fixnum]
158
163
  def __priority
159
- @roles.inject(0) { |sum,r| sum + r.priority.to_i }
164
+ @roles.reduce(0) { |sum, r| sum + r.priority.to_i }
160
165
  end
161
166
  end
162
167
  end