inch 0.5.0.rc3 → 0.5.0.rc4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +15 -0
  3. data/.rubocop_todo.yml +94 -0
  4. data/CHANGELOG.md +26 -2
  5. data/Gemfile +5 -2
  6. data/README.md +3 -3
  7. data/Rakefile +6 -2
  8. data/bin/inch +3 -3
  9. data/config/{example.yml → .inch.yml.sample} +1 -0
  10. data/config/base.rb +53 -0
  11. data/config/elixir.rb +43 -0
  12. data/config/nodejs.rb +10 -0
  13. data/config/{defaults.rb → ruby.rb} +5 -54
  14. data/inch.gemspec +7 -7
  15. data/lib/inch.rb +14 -9
  16. data/lib/inch/api.rb +10 -10
  17. data/lib/inch/api/compare.rb +2 -2
  18. data/lib/inch/api/compare/code_objects.rb +2 -3
  19. data/lib/inch/api/compare/codebases.rb +1 -1
  20. data/lib/inch/api/diff.rb +13 -16
  21. data/lib/inch/api/filter.rb +1 -1
  22. data/lib/inch/api/get.rb +2 -2
  23. data/lib/inch/api/options/base.rb +4 -4
  24. data/lib/inch/api/options/filter.rb +0 -4
  25. data/lib/inch/api/options/suggest.rb +2 -6
  26. data/lib/inch/api/stats.rb +0 -1
  27. data/lib/inch/api/suggest.rb +9 -10
  28. data/lib/inch/cli.rb +6 -6
  29. data/lib/inch/cli/arguments.rb +2 -2
  30. data/lib/inch/cli/command.rb +15 -15
  31. data/lib/inch/cli/command/base.rb +30 -9
  32. data/lib/inch/cli/command/base_list.rb +2 -2
  33. data/lib/inch/cli/command/console.rb +5 -5
  34. data/lib/inch/cli/command/diff.rb +9 -9
  35. data/lib/inch/cli/command/inspect.rb +5 -4
  36. data/lib/inch/cli/command/list.rb +4 -4
  37. data/lib/inch/cli/command/options/base.rb +17 -16
  38. data/lib/inch/cli/command/options/base_list.rb +9 -5
  39. data/lib/inch/cli/command/options/console.rb +4 -3
  40. data/lib/inch/cli/command/options/diff.rb +8 -6
  41. data/lib/inch/cli/command/options/inspect.rb +2 -2
  42. data/lib/inch/cli/command/options/list.rb +3 -2
  43. data/lib/inch/cli/command/options/show.rb +2 -2
  44. data/lib/inch/cli/command/options/stats.rb +2 -1
  45. data/lib/inch/cli/command/options/suggest.rb +6 -3
  46. data/lib/inch/cli/command/output/base.rb +4 -6
  47. data/lib/inch/cli/command/output/console.rb +6 -7
  48. data/lib/inch/cli/command/output/diff.rb +6 -6
  49. data/lib/inch/cli/command/output/inspect.rb +6 -8
  50. data/lib/inch/cli/command/output/list.rb +0 -1
  51. data/lib/inch/cli/command/output/show.rb +4 -5
  52. data/lib/inch/cli/command/output/stats.rb +21 -21
  53. data/lib/inch/cli/command/output/suggest.rb +31 -28
  54. data/lib/inch/cli/command/show.rb +4 -4
  55. data/lib/inch/cli/command/stats.rb +4 -4
  56. data/lib/inch/cli/command/suggest.rb +6 -6
  57. data/lib/inch/cli/command_parser.rb +6 -5
  58. data/lib/inch/cli/sparkline_helper.rb +6 -6
  59. data/lib/inch/cli/trace_helper.rb +1 -1
  60. data/lib/inch/cli/yardopts_helper.rb +4 -3
  61. data/lib/inch/code_object.rb +3 -3
  62. data/lib/inch/code_object/converter.rb +6 -8
  63. data/lib/inch/code_object/provider.rb +11 -11
  64. data/lib/inch/code_object/proxy.rb +61 -30
  65. data/lib/inch/codebase.rb +7 -8
  66. data/lib/inch/codebase/object.rb +60 -0
  67. data/lib/inch/codebase/objects.rb +8 -10
  68. data/lib/inch/codebase/objects_filter.rb +7 -5
  69. data/lib/inch/codebase/proxy.rb +4 -4
  70. data/lib/inch/codebase/serializer.rb +3 -3
  71. data/lib/inch/config.rb +42 -11
  72. data/lib/inch/config/base.rb +8 -29
  73. data/lib/inch/config/codebase.rb +32 -7
  74. data/lib/inch/config/evaluation.rb +61 -0
  75. data/lib/inch/core_ext.rb +1 -1
  76. data/lib/inch/core_ext/string.rb +1 -1
  77. data/lib/inch/evaluation.rb +13 -21
  78. data/lib/inch/evaluation/file.rb +4 -2
  79. data/lib/inch/evaluation/grade_list.rb +4 -4
  80. data/lib/inch/evaluation/priority_range.rb +3 -0
  81. data/lib/inch/evaluation/proxy.rb +139 -14
  82. data/lib/inch/evaluation/role.rb +99 -0
  83. data/lib/inch/language.rb +3 -0
  84. data/lib/inch/language/elixir/code_object/base.rb +197 -0
  85. data/lib/inch/language/elixir/code_object/function_object.rb +74 -0
  86. data/lib/inch/language/elixir/code_object/module_object.rb +23 -0
  87. data/lib/inch/language/elixir/code_object/type_object.rb +11 -0
  88. data/lib/inch/language/elixir/evaluation/base.rb +28 -0
  89. data/lib/inch/language/elixir/evaluation/function_object.rb +31 -0
  90. data/lib/inch/language/elixir/evaluation/module_object.rb +27 -0
  91. data/lib/inch/language/elixir/evaluation/type_object.rb +11 -0
  92. data/lib/inch/language/elixir/import.rb +24 -0
  93. data/lib/inch/language/elixir/provider/reader.rb +19 -0
  94. data/lib/inch/language/elixir/provider/reader/object.rb +63 -0
  95. data/lib/inch/language/elixir/provider/reader/object/base.rb +191 -0
  96. data/lib/inch/language/elixir/provider/reader/object/function_object.rb +26 -0
  97. data/lib/inch/language/elixir/provider/reader/object/module_object.rb +22 -0
  98. data/lib/inch/language/elixir/provider/reader/object/type_object.rb +15 -0
  99. data/lib/inch/language/elixir/provider/reader/parser.rb +55 -0
  100. data/lib/inch/language/elixir/roles/base.rb +32 -0
  101. data/lib/inch/language/elixir/roles/function.rb +112 -0
  102. data/lib/inch/language/elixir/roles/module.rb +64 -0
  103. data/lib/inch/language/elixir/roles/object.rb +76 -0
  104. data/lib/inch/language/elixir/roles/type.rb +13 -0
  105. data/lib/inch/language/nodejs/import.rb +8 -0
  106. data/lib/inch/language/nodejs/provider/jsdoc.rb +19 -0
  107. data/lib/inch/language/nodejs/provider/jsdoc/object.rb +55 -0
  108. data/lib/inch/language/nodejs/provider/jsdoc/object/base.rb +191 -0
  109. data/lib/inch/language/nodejs/provider/jsdoc/parser.rb +59 -0
  110. data/lib/inch/language/ruby/code_object/base.rb +197 -0
  111. data/lib/inch/language/ruby/code_object/class_object.rb +10 -0
  112. data/lib/inch/language/ruby/code_object/class_variable_object.rb +10 -0
  113. data/lib/inch/language/ruby/code_object/constant_object.rb +10 -0
  114. data/lib/inch/language/ruby/code_object/method_object.rb +85 -0
  115. data/lib/inch/language/ruby/code_object/method_parameter_object.rb +64 -0
  116. data/lib/inch/language/ruby/code_object/module_object.rb +10 -0
  117. data/lib/inch/language/ruby/code_object/namespace_object.rb +35 -0
  118. data/lib/inch/language/ruby/evaluation/base.rb +45 -0
  119. data/lib/inch/language/ruby/evaluation/class_object.rb +10 -0
  120. data/lib/inch/language/ruby/evaluation/class_variable_object.rb +21 -0
  121. data/lib/inch/language/ruby/evaluation/constant_object.rb +21 -0
  122. data/lib/inch/language/ruby/evaluation/method_object.rb +74 -0
  123. data/lib/inch/language/ruby/evaluation/module_object.rb +10 -0
  124. data/lib/inch/language/ruby/evaluation/namespace_object.rb +30 -0
  125. data/lib/inch/language/ruby/import.rb +34 -0
  126. data/lib/inch/language/ruby/provider/yard.rb +58 -0
  127. data/lib/inch/language/ruby/provider/yard/docstring.rb +162 -0
  128. data/lib/inch/language/ruby/provider/yard/nodoc_helper.rb +97 -0
  129. data/lib/inch/language/ruby/provider/yard/object.rb +63 -0
  130. data/lib/inch/language/ruby/provider/yard/object/base.rb +325 -0
  131. data/lib/inch/language/ruby/provider/yard/object/class_object.rb +14 -0
  132. data/lib/inch/language/ruby/provider/yard/object/class_variable_object.rb +14 -0
  133. data/lib/inch/language/ruby/provider/yard/object/constant_object.rb +14 -0
  134. data/lib/inch/language/ruby/provider/yard/object/method_object.rb +170 -0
  135. data/lib/inch/language/ruby/provider/yard/object/method_parameter_object.rb +94 -0
  136. data/lib/inch/language/ruby/provider/yard/object/method_signature.rb +120 -0
  137. data/lib/inch/language/ruby/provider/yard/object/module_object.rb +14 -0
  138. data/lib/inch/language/ruby/provider/yard/object/namespace_object.rb +46 -0
  139. data/lib/inch/language/ruby/provider/yard/object/root_object.rb +14 -0
  140. data/lib/inch/language/ruby/provider/yard/parser.rb +71 -0
  141. data/lib/inch/language/ruby/roles/base.rb +17 -0
  142. data/lib/inch/language/ruby/roles/class_variable.rb +53 -0
  143. data/lib/inch/language/ruby/roles/constant.rb +53 -0
  144. data/lib/inch/language/ruby/roles/method.rb +112 -0
  145. data/lib/inch/language/ruby/roles/method_parameter.rb +84 -0
  146. data/lib/inch/language/ruby/roles/missing.rb +24 -0
  147. data/lib/inch/language/ruby/roles/namespace.rb +89 -0
  148. data/lib/inch/language/ruby/roles/object.rb +120 -0
  149. data/lib/inch/rake.rb +2 -2
  150. data/lib/inch/rake/suggest.rb +7 -2
  151. data/lib/inch/utils/buffered_ui.rb +16 -0
  152. data/lib/inch/utils/shell_helper.rb +1 -1
  153. data/lib/inch/utils/ui.rb +5 -5
  154. data/lib/inch/utils/weighted_list.rb +2 -3
  155. data/lib/inch/version.rb +1 -1
  156. data/test/fixtures/{code_examples → ruby/code_examples}/lib/foo.rb +0 -0
  157. data/test/fixtures/{diff1 → ruby/diff1}/lib/diff1.rb +0 -0
  158. data/test/fixtures/{diff2 → ruby/diff2}/lib/diff2.rb +0 -0
  159. data/test/fixtures/{inch-yml → ruby/inch-yml}/.inch.yml +0 -0
  160. data/test/fixtures/{inch-yml → ruby/inch-yml}/foo/bar.rb +0 -0
  161. data/test/fixtures/{inch-yml → ruby/inch-yml}/foo/vendor/base.rb +0 -0
  162. data/test/fixtures/{parameters → ruby/parameters}/lib/foo.rb +0 -0
  163. data/test/fixtures/{readme → ruby/readme}/lib/foo.rb +0 -0
  164. data/test/fixtures/{really_good → ruby/really_good}/lib/foo.rb +0 -0
  165. data/test/fixtures/{really_good_pedantic → ruby/really_good_pedantic}/lib/foo.rb +0 -0
  166. data/test/fixtures/{simple → ruby/simple}/README +0 -0
  167. data/test/fixtures/{simple → ruby/simple}/lib/broken.rb +11 -19
  168. data/test/fixtures/ruby/simple/lib/broken_ruby_2_0_features.rb +7 -0
  169. data/test/fixtures/ruby/simple/lib/directives.rb +8 -0
  170. data/test/fixtures/{simple → ruby/simple}/lib/foo.rb +22 -1
  171. data/test/fixtures/{simple → ruby/simple}/lib/nodoc.rb +0 -0
  172. data/test/fixtures/{simple → ruby/simple}/lib/role_methods.rb +0 -0
  173. data/test/fixtures/{simple → ruby/simple}/lib/role_namespaces.rb +0 -0
  174. data/test/fixtures/{visibility → ruby/visibility}/lib/foo.rb +0 -0
  175. data/test/fixtures/{yardopts → ruby/yardopts}/.yardopts +0 -0
  176. data/test/fixtures/{yardopts → ruby/yardopts}/foo/bar.rb +0 -0
  177. data/test/integration/api/compare/codebases.rb +3 -3
  178. data/test/integration/cli/command/console_test.rb +6 -6
  179. data/test/integration/cli/command/diff_test.rb +62 -0
  180. data/test/integration/cli/command/inspect_test.rb +5 -6
  181. data/test/integration/cli/command/list_test.rb +4 -5
  182. data/test/integration/cli/command/show_test.rb +5 -5
  183. data/test/integration/cli/command/stats_test.rb +3 -3
  184. data/test/integration/cli/command/suggest_test.rb +13 -13
  185. data/test/integration/stats_options_test.rb +4 -4
  186. data/test/integration/visibility_options_test.rb +14 -14
  187. data/test/shared/base_list.rb +4 -3
  188. data/test/test_helper.rb +13 -13
  189. data/test/unit/api/filter_test.rb +7 -7
  190. data/test/unit/api/get_test.rb +1 -1
  191. data/test/unit/api/list_test.rb +1 -1
  192. data/test/unit/api/options/base_test.rb +3 -3
  193. data/test/unit/api/stats_test.rb +1 -1
  194. data/test/unit/api/suggest_test.rb +3 -3
  195. data/test/unit/cli/arguments_test.rb +2 -2
  196. data/test/unit/cli/command/base_test.rb +1 -1
  197. data/test/unit/cli/command/options/base_list_test.rb +2 -2
  198. data/test/unit/cli/command/options/base_object_test.rb +1 -1
  199. data/test/unit/cli/command/options/base_test.rb +1 -1
  200. data/test/unit/cli/command_parser_test.rb +3 -3
  201. data/test/unit/cli/trace_helper_test.rb +1 -1
  202. data/test/unit/cli/yardopts_helper_test.rb +6 -5
  203. data/test/unit/code_object/converter_test.rb +1 -1
  204. data/test/unit/code_object/provider_test.rb +2 -2
  205. data/test/unit/code_object/proxy_test.rb +2 -2
  206. data/test/unit/codebase/objects_test.rb +2 -2
  207. data/test/unit/codebase/proxy_test.rb +7 -5
  208. data/test/unit/config/codebase_test.rb +4 -4
  209. data/test/unit/config_test.rb +28 -0
  210. data/test/unit/evaluation/{role/base_test.rb → role_test.rb} +7 -7
  211. data/test/unit/{code_object/proxy → language/ruby/code_object}/method_object_test.rb +66 -21
  212. data/test/unit/{code_object → language/ruby}/provider/yard/docstring_test.rb +74 -38
  213. data/test/unit/{code_object → language/ruby}/provider/yard/nodoc_helper_test.rb +9 -7
  214. data/test/unit/{code_object → language/ruby}/provider/yard/object/method_object_test.rb +21 -11
  215. data/test/unit/language/ruby/provider/yard_test.rb +25 -0
  216. data/test/unit/utils/buffered_ui_test.rb +48 -0
  217. data/test/unit/utils/ui_test.rb +7 -7
  218. data/test/unit/utils/weighted_list_test.rb +7 -4
  219. metadata +139 -93
  220. data/lib/inch/code_object/provider/yard.rb +0 -57
  221. data/lib/inch/code_object/provider/yard/docstring.rb +0 -133
  222. data/lib/inch/code_object/provider/yard/nodoc_helper.rb +0 -93
  223. data/lib/inch/code_object/provider/yard/object.rb +0 -60
  224. data/lib/inch/code_object/provider/yard/object/base.rb +0 -302
  225. data/lib/inch/code_object/provider/yard/object/class_object.rb +0 -12
  226. data/lib/inch/code_object/provider/yard/object/class_variable_object.rb +0 -12
  227. data/lib/inch/code_object/provider/yard/object/constant_object.rb +0 -12
  228. data/lib/inch/code_object/provider/yard/object/method_object.rb +0 -153
  229. data/lib/inch/code_object/provider/yard/object/method_parameter_object.rb +0 -88
  230. data/lib/inch/code_object/provider/yard/object/method_signature.rb +0 -114
  231. data/lib/inch/code_object/provider/yard/object/module_object.rb +0 -12
  232. data/lib/inch/code_object/provider/yard/object/namespace_object.rb +0 -47
  233. data/lib/inch/code_object/provider/yard/object/root_object.rb +0 -12
  234. data/lib/inch/code_object/provider/yard/parser.rb +0 -62
  235. data/lib/inch/code_object/proxy/base.rb +0 -241
  236. data/lib/inch/code_object/proxy/class_object.rb +0 -8
  237. data/lib/inch/code_object/proxy/class_variable_object.rb +0 -8
  238. data/lib/inch/code_object/proxy/constant_object.rb +0 -8
  239. data/lib/inch/code_object/proxy/method_object.rb +0 -82
  240. data/lib/inch/code_object/proxy/method_parameter_object.rb +0 -60
  241. data/lib/inch/code_object/proxy/module_object.rb +0 -8
  242. data/lib/inch/code_object/proxy/namespace_object.rb +0 -33
  243. data/lib/inch/evaluation/object_schema.rb +0 -30
  244. data/lib/inch/evaluation/proxy/base.rb +0 -164
  245. data/lib/inch/evaluation/proxy/class_object.rb +0 -8
  246. data/lib/inch/evaluation/proxy/class_variable_object.rb +0 -19
  247. data/lib/inch/evaluation/proxy/constant_object.rb +0 -19
  248. data/lib/inch/evaluation/proxy/method_object.rb +0 -65
  249. data/lib/inch/evaluation/proxy/module_object.rb +0 -8
  250. data/lib/inch/evaluation/proxy/namespace_object.rb +0 -27
  251. data/lib/inch/evaluation/role/base.rb +0 -92
  252. data/lib/inch/evaluation/role/class_variable.rb +0 -55
  253. data/lib/inch/evaluation/role/constant.rb +0 -55
  254. data/lib/inch/evaluation/role/method.rb +0 -126
  255. data/lib/inch/evaluation/role/method_parameter.rb +0 -91
  256. data/lib/inch/evaluation/role/missing.rb +0 -20
  257. data/lib/inch/evaluation/role/namespace.rb +0 -85
  258. data/lib/inch/evaluation/role/object.rb +0 -143
  259. data/test/unit/code_object/provider/yard_test.rb +0 -25
@@ -48,7 +48,7 @@ module Inch
48
48
  def print_code_info(o)
49
49
  if o.method?
50
50
  CommentAndAbbrevSource.new(o).lines.each do |line|
51
- echo line.gsub(/\n$/m, '').color(COMMENT_COLOR)
51
+ echo line.gsub(/\n$/m, "").color(COMMENT_COLOR)
52
52
  end
53
53
  echo separator
54
54
  end
@@ -66,13 +66,11 @@ module Inch
66
66
  end
67
67
 
68
68
  def print_role_info(role)
69
- name = role.class.to_s.split('::Role::').last
69
+ name = role.class.to_s.split("::Role::").last
70
70
  score = colored_role_score(role)
71
71
 
72
72
  priority = role.priority.to_s.rjust(4)
73
- if role.priority == 0
74
- priority = priority.dark
75
- end
73
+ priority = priority.dark if role.priority == 0
76
74
 
77
75
  echo name.ljust(40) + score + priority
78
76
  print_min_max_score(role)
@@ -133,7 +131,7 @@ module Inch
133
131
  end
134
132
 
135
133
  def to_s
136
- comments.join('') + abbrev_source
134
+ comments.join("") + abbrev_source
137
135
  end
138
136
 
139
137
  private
@@ -141,12 +139,12 @@ module Inch
141
139
  def abbrev_source
142
140
  lines = code_object.source.to_s.lines.to_a
143
141
  if lines.size >= 5
144
- indent = lines[1].scan(/^(\s+)/).flatten.join('')
142
+ indent = lines[1].scan(/^(\s+)/).flatten.join("")
145
143
  lines = lines[0..1] +
146
144
  ["#{indent}# ... snip ...\n"] +
147
145
  lines[-2..-1]
148
146
  end
149
- lines.join('')
147
+ lines.join("")
150
148
  end
151
149
 
152
150
  def comments
@@ -79,7 +79,6 @@ module Inch
79
79
  priority = object.priority
80
80
  "#{score} #{priority} #{object.fullname}"
81
81
  end
82
-
83
82
  end
84
83
  end
85
84
  end
@@ -42,10 +42,9 @@ module Inch
42
42
  if o.roles.empty?
43
43
  echo "No roles assigned.".dark
44
44
  else
45
- o.roles.each_with_index do |role, index|
46
- if role.suggestion
47
- echo "+".color(COLOR) + " #{role.suggestion}"
48
- end
45
+ o.roles.each do |role|
46
+ next unless role.suggestion
47
+ echo "+".color(COLOR) + " #{role.suggestion}"
49
48
  end
50
49
  end
51
50
  echo separator
@@ -61,7 +60,7 @@ module Inch
61
60
 
62
61
  def grade(score)
63
62
  grade_lists ||= Evaluation.new_grade_lists
64
- r = grade_lists.detect { |r| r.scores.include?(score) }
63
+ r = grade_lists.find { |v| v.scores.include?(score) }
65
64
  "#{r.grade} - #{r.label}".color(r.color)
66
65
  end
67
66
  end
@@ -1,5 +1,5 @@
1
- require 'json'
2
- require 'yaml'
1
+ require "json"
2
+ require "yaml"
3
3
 
4
4
  module Inch
5
5
  module CLI
@@ -11,10 +11,10 @@ module Inch
11
11
  attr_reader :objects
12
12
 
13
13
  PRIORITY_COLORS = [
14
- [213,212,211,210,210,209,209],
15
- [177],
16
- [203, 203, 204, 204, 205, 206, 207]
17
- ].flatten.map { |s| :"color#{s}" }
14
+ [213, 212, 211, 210, 210, 209, 209],
15
+ [177],
16
+ [203, 203, 204, 204, 205, 206, 207]
17
+ ].flatten.map { |s| :"color#{s}" }
18
18
 
19
19
  def initialize(options, objects, grade_lists)
20
20
  @options = options
@@ -31,25 +31,26 @@ module Inch
31
31
  print_grades_by_priority
32
32
  print_priorities
33
33
  puts
34
- puts 'Try `--format json|yaml` for raw numbers.'.dark
34
+ puts "Try `--format json|yaml` for raw numbers.".dark
35
35
  end
36
36
 
37
37
  def print_grades
38
- sparkline = grade_lists_sparkline(@grade_lists).to_s(' ')
38
+ sparkline = grade_lists_sparkline(@grade_lists).to_s(" ")
39
39
  puts
40
- puts 'Grade distribution: (undocumented, C, B, A)'
40
+ puts "Grade distribution: (undocumented, C, B, A)"
41
41
  puts
42
- puts " Overall: #{sparkline} #{objects.size.to_s.rjust(5)} objects"
42
+ puts " Overall: #{sparkline} #{objects.size.to_s.rjust(5)} " \
43
+ "objects"
43
44
  puts
44
45
  end
45
46
 
46
47
  def print_grades_by_priority
47
- puts 'Grade distribution by priority:'
48
+ puts "Grade distribution by priority:"
48
49
  puts
49
50
  Evaluation::PriorityRange.all.each do |priority_range|
50
51
  list = objects.select { |o| priority_range.include?(o.priority) }
51
- sparkline = grades_sparkline(list).to_s(' ')
52
- puts " #{priority_range.arrow} #{sparkline} " +
52
+ sparkline = grades_sparkline(list).to_s(" ")
53
+ puts " #{priority_range.arrow} #{sparkline} " \
53
54
  "#{list.size.to_s.rjust(5)} objects"
54
55
  puts
55
56
  end
@@ -64,10 +65,10 @@ module Inch
64
65
  end
65
66
 
66
67
  sparkline = Sparkr::Sparkline.new(priorities.values)
67
- sparkline.format do |tick, count, index|
68
- tick.color( PRIORITY_COLORS[index] )
68
+ sparkline.format do |tick, _count, index|
69
+ tick.color(PRIORITY_COLORS[index])
69
70
  end
70
- puts " #{grade_list.grade}: " + sparkline.to_s(' ') +
71
+ puts " #{grade_list.grade}: " + sparkline.to_s(" ") +
71
72
  " #{grade_list.objects.size.to_s.rjust(5)} objects"
72
73
  puts
73
74
  end
@@ -76,7 +77,7 @@ module Inch
76
77
  arrows = Evaluation::PriorityRange.all.map(&:arrow)
77
78
  puts "Priority distribution in grades: (low to high)"
78
79
  puts
79
- puts " #{arrows.reverse.join(' ')}"
80
+ puts " #{arrows.reverse.join(" ")}"
80
81
  @grade_lists.reverse.each do |grade_list|
81
82
  print_grade_list(grade_list)
82
83
  end
@@ -92,9 +93,9 @@ module Inch
92
93
 
93
94
  def stats_hash
94
95
  {
95
- 'grade_lists' => __grade_lists,
96
- 'scores' => __scores,
97
- 'priorities' => __priorities
96
+ "grade_lists" => __grade_lists,
97
+ "scores" => __scores,
98
+ "priorities" => __priorities
98
99
  }
99
100
  end
100
101
 
@@ -123,7 +124,6 @@ module Inch
123
124
  end
124
125
  hash
125
126
  end
126
-
127
127
  end
128
128
  end
129
129
  end
@@ -1,4 +1,4 @@
1
- require 'sparkr'
1
+ require "sparkr"
2
2
 
3
3
  module Inch
4
4
  module CLI
@@ -11,18 +11,20 @@ module Inch
11
11
 
12
12
  FILE_COLOR = :dark # TODO: store all colors somewhere
13
13
  RANGE_LABELS = {
14
- :A => "Nearly perfect:",
15
- :B => "Properly documented, could be improved:",
16
- :C => "Not properly documented:",
17
- :U => "Undocumented:",
14
+ A: "Nearly perfect:",
15
+ B: "Properly documented, could be improved:",
16
+ C: "Not properly documented:",
17
+ U: "Undocumented:"
18
18
  }
19
19
 
20
20
  # @param options [Command::Options::Suggest]
21
- # @param relevant_objects [Array<CodeObject::Proxy::Base>] the objects meeting the criteria defined in +options+
22
- # @param objects_to_display [Array<CodeObject::Proxy::Base>]
21
+ # @param relevant_objects [Array<CodeObject::Proxy>] the objects
22
+ # meeting the criteria defined in +options+
23
+ # @param objects_to_display [Array<CodeObject::Proxy>]
23
24
  # @param grade_lists [Array<Evaluation::GradeList>]
24
25
  # @param files [Array<Evaluation::File>]
25
- def initialize(options, relevant_objects, objects_to_display, grade_lists, files)
26
+ def initialize(options, relevant_objects, objects_to_display,
27
+ grade_lists, files)
26
28
  @options = options
27
29
  @objects = objects_to_display
28
30
  @relevant_objects = relevant_objects
@@ -45,7 +47,7 @@ module Inch
45
47
  end
46
48
 
47
49
  def display_distribution
48
- sparkline = grades_sparkline(@relevant_objects).to_s(' ')
50
+ sparkline = grades_sparkline(@relevant_objects).to_s(" ")
49
51
  puts "Grade distribution (undocumented, C, B, A): " + sparkline
50
52
  puts
51
53
  puts priority_filter_hint
@@ -54,10 +56,10 @@ module Inch
54
56
  def priority_filter_hint
55
57
  arrows = min_priority_arrows
56
58
  pretext = if @options.pedantic
57
- "Considering priority objects: #{arrows}"
58
- else
59
- "Only considering priority objects: #{arrows}"
60
- end
59
+ "Considering priority objects: #{arrows}"
60
+ else
61
+ "Only considering priority objects: #{arrows}"
62
+ end
61
63
  "#{pretext} (use `--help` for options).".dark
62
64
  end
63
65
 
@@ -67,7 +69,7 @@ module Inch
67
69
  ui.trace
68
70
 
69
71
  files.each do |file|
70
- filename = file.fullname.gsub(base_dir, '')
72
+ filename = file.fullname.gsub(base_dir, "")
71
73
  ui.edged(FILE_COLOR, filename.color(FILE_COLOR))
72
74
  end
73
75
  ui.trace
@@ -77,29 +79,30 @@ module Inch
77
79
  @options.grades_to_display.map do |grade|
78
80
  r = grade_list(grade)
79
81
  grade_objects = objects.select { |o| o.grade == r.grade }
80
- unless grade_objects.empty?
81
- ui.trace
82
- ui.header(RANGE_LABELS[r.grade.to_sym], r.color, r.bg_color)
83
- grade_objects.each do |o|
84
- grade = o.grade.to_s.ljust(2).color(r.color)
85
- priority = o.priority
86
- ui.sub(" #{grade} #{priority_arrow(priority, r.color)} #{o.fullname}")
87
- end
82
+ next if grade_objects.empty?
83
+ ui.trace
84
+ ui.header(RANGE_LABELS[r.grade.to_sym], r.color, r.bg_color)
85
+ grade_objects.each do |o|
86
+ grade = o.grade.to_s.ljust(2).color(r.color)
87
+ priority = o.priority
88
+ ui.sub(" #{grade} #{priority_arrow(priority, r.color)} " \
89
+ "#{o.fullname}")
88
90
  end
89
91
  end
90
92
  end
91
93
 
92
94
  def display_no_objects_hint
93
95
  hint = if @options.pedantic
94
- "Even by my standards."
95
- else
96
- "Try --pedantic to be excessively concerned with minor details and rules."
97
- end
96
+ "Even by my standards."
97
+ else
98
+ "Try --pedantic to be excessively concerned with minor " \
99
+ "details and rules."
100
+ end
98
101
  ui.trace "Nothing to suggest.".color(:green) + " #{hint}"
99
102
  end
100
103
 
101
104
  def min_priority_arrows
102
- priority_arrows_gte(@options.object_min_priority).join(' ')
105
+ priority_arrows_gte(@options.object_min_priority).join(" ")
103
106
  end
104
107
 
105
108
  def priority_arrows_gte(min_priority)
@@ -109,7 +112,7 @@ module Inch
109
112
  end
110
113
 
111
114
  def grade_list(grade_symbol)
112
- @grade_lists.detect { |r| r.grade.to_sym == grade_symbol }
115
+ @grade_lists.find { |r| r.grade.to_sym == grade_symbol }
113
116
  end
114
117
  end
115
118
  end
@@ -1,5 +1,5 @@
1
- require 'inch/cli/command/options/show'
2
- require 'inch/cli/command/output/show'
1
+ require "inch/cli/command/options/show"
2
+ require "inch/cli/command/output/show"
3
3
 
4
4
  module Inch
5
5
  module CLI
@@ -8,11 +8,11 @@ module Inch
8
8
  register_command_as :show
9
9
 
10
10
  def description
11
- 'Shows an object with its results'
11
+ "Shows an object with its results"
12
12
  end
13
13
 
14
14
  def usage
15
- 'Usage: inch show [paths] OBJECT_NAME [[OBJECT_NAME2] ...] [options]'
15
+ "Usage: inch show [paths] OBJECT_NAME [[OBJECT_NAME2] ...] [options]"
16
16
  end
17
17
 
18
18
  def run(*args)
@@ -1,5 +1,5 @@
1
- require 'inch/cli/command/options/stats'
2
- require 'inch/cli/command/output/stats'
1
+ require "inch/cli/command/options/stats"
2
+ require "inch/cli/command/output/stats"
3
3
 
4
4
  module Inch
5
5
  module CLI
@@ -8,11 +8,11 @@ module Inch
8
8
  register_command_as :stats
9
9
 
10
10
  def description
11
- 'Show statistics'
11
+ "Show statistics"
12
12
  end
13
13
 
14
14
  def usage
15
- 'Usage: inch stats [paths] [options]'
15
+ "Usage: inch stats [paths] [options]"
16
16
  end
17
17
 
18
18
  def run(*args)
@@ -1,5 +1,5 @@
1
- require 'inch/cli/command/options/suggest'
2
- require 'inch/cli/command/output/suggest'
1
+ require "inch/cli/command/options/suggest"
2
+ require "inch/cli/command/output/suggest"
3
3
 
4
4
  module Inch
5
5
  module CLI
@@ -8,11 +8,11 @@ module Inch
8
8
  register_command_as :suggest, true
9
9
 
10
10
  def description
11
- 'Suggests some objects to be documented (better)'
11
+ "Suggests some objects to be documented (better)"
12
12
  end
13
13
 
14
14
  def usage
15
- 'Usage: inch suggest [paths] [options]'
15
+ "Usage: inch suggest [paths] [options]"
16
16
  end
17
17
 
18
18
  # Runs the commandline utility, parsing arguments and displaying a
@@ -23,8 +23,8 @@ module Inch
23
23
  def run(*args)
24
24
  prepare_codebase(*args)
25
25
  context = API::Suggest.new(codebase, @options)
26
- Output::Suggest.new(@options, context.all_objects,
27
- context.objects, context.grade_lists, context.files)
26
+ Output::Suggest.new(@options, context.all_objects, context.objects,
27
+ context.grade_lists, context.files)
28
28
  end
29
29
  end
30
30
  end
@@ -1,6 +1,7 @@
1
1
  module Inch
2
2
  module CLI
3
- # CommandParser parses a command-line arguments to decide which Command to run.
3
+ # CommandParser parses a command-line arguments to decide which Command to
4
+ # run.
4
5
  #
5
6
  # The basic form translates this shell command
6
7
  #
@@ -55,7 +56,7 @@ module Inch
55
56
  # argument.
56
57
  # @return [Command::Base]
57
58
  def run(*args)
58
- if ['--help', '-h'].include?(args.join)
59
+ if ["--help", "-h"].include?(args.join)
59
60
  list_commands
60
61
  else
61
62
  run_command(*args)
@@ -72,9 +73,9 @@ module Inch
72
73
  ui.trace "Usage: inch <command> [options]"
73
74
  ui.trace
74
75
  ui.trace "Commands:"
75
- commands.keys.sort_by {|k| k.to_s }.each do |command_name|
76
+ commands.keys.sort_by { |k| k.to_s }.each do |command_name|
76
77
  command = commands[command_name].new
77
- ui.trace " %-8s %s" % [command_name, command.description]
78
+ ui.trace format(" %-8s %s", command_name, command.description)
78
79
  end
79
80
  end
80
81
 
@@ -87,7 +88,7 @@ module Inch
87
88
  else
88
89
  possible_command_name = args.first.to_sym
89
90
 
90
- if commands.has_key?(possible_command_name)
91
+ if commands.key?(possible_command_name)
91
92
  command_name = possible_command_name
92
93
  args.shift
93
94
  else
@@ -1,10 +1,10 @@
1
1
  module Inch
2
2
  module CLI
3
3
  module SparklineHelper
4
- def grade_lists_sparkline(_grade_lists)
5
- grade_lists = _grade_lists.reverse
6
- list = grade_lists.map { |r| r.objects.size }
7
- __sparkline(list, grade_lists)
4
+ def grade_lists_sparkline(grade_lists)
5
+ new_grade_lists = grade_lists.reverse
6
+ list = new_grade_lists.map { |r| r.objects.size }
7
+ __sparkline(list, new_grade_lists)
8
8
  end
9
9
 
10
10
  def grades_sparkline(objects)
@@ -21,9 +21,9 @@ module Inch
21
21
 
22
22
  def __sparkline(list, grade_lists)
23
23
  sparkline = Sparkr::Sparkline.new(list)
24
- sparkline.format do |tick, count, index|
24
+ sparkline.format do |tick, _count, index|
25
25
  t = tick.color(grade_lists[index].color)
26
- index == 0 ? t + ' ' : t
26
+ index == 0 ? t + " " : t
27
27
  end
28
28
  end
29
29
  end
@@ -1,4 +1,4 @@
1
- require 'inch/utils/ui'
1
+ require "inch/utils/ui"
2
2
 
3
3
  module Inch
4
4
  module CLI
@@ -8,7 +8,8 @@ module Inch
8
8
  attr_accessor :excluded
9
9
 
10
10
  VALID_YARD_SWITCHES = %w(--private --no-private --protected --no-public
11
- --plugin --load --safe --yardopts --no-yardopts --document --no-document)
11
+ --plugin --load --safe --yardopts --no-yardopts
12
+ --document --no-document)
12
13
 
13
14
  # Parses the option and gracefully handles invalid switches
14
15
  #
@@ -17,7 +18,7 @@ module Inch
17
18
  # array will be modified.
18
19
  # @return [void]
19
20
  def parse_yardopts_options(opts, args)
20
- wrapper = YardoptsWrapper.new()
21
+ wrapper = YardoptsWrapper.new
21
22
 
22
23
  dupped_args = args.dup
23
24
  dupped_args.delete("--help")
@@ -35,7 +36,7 @@ module Inch
35
36
  end
36
37
 
37
38
  def yardopts_options(opts)
38
- wrapper = YardoptsWrapper.new()
39
+ wrapper = YardoptsWrapper.new
39
40
  wrapper.add_yardoc_options(opts)
40
41
  end
41
42