inch 0.5.0.rc3 → 0.5.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +15 -0
- data/.rubocop_todo.yml +94 -0
- data/CHANGELOG.md +26 -2
- data/Gemfile +5 -2
- data/README.md +3 -3
- data/Rakefile +6 -2
- data/bin/inch +3 -3
- data/config/{example.yml → .inch.yml.sample} +1 -0
- data/config/base.rb +53 -0
- data/config/elixir.rb +43 -0
- data/config/nodejs.rb +10 -0
- data/config/{defaults.rb → ruby.rb} +5 -54
- data/inch.gemspec +7 -7
- data/lib/inch.rb +14 -9
- data/lib/inch/api.rb +10 -10
- data/lib/inch/api/compare.rb +2 -2
- data/lib/inch/api/compare/code_objects.rb +2 -3
- data/lib/inch/api/compare/codebases.rb +1 -1
- data/lib/inch/api/diff.rb +13 -16
- data/lib/inch/api/filter.rb +1 -1
- data/lib/inch/api/get.rb +2 -2
- data/lib/inch/api/options/base.rb +4 -4
- data/lib/inch/api/options/filter.rb +0 -4
- data/lib/inch/api/options/suggest.rb +2 -6
- data/lib/inch/api/stats.rb +0 -1
- data/lib/inch/api/suggest.rb +9 -10
- data/lib/inch/cli.rb +6 -6
- data/lib/inch/cli/arguments.rb +2 -2
- data/lib/inch/cli/command.rb +15 -15
- data/lib/inch/cli/command/base.rb +30 -9
- data/lib/inch/cli/command/base_list.rb +2 -2
- data/lib/inch/cli/command/console.rb +5 -5
- data/lib/inch/cli/command/diff.rb +9 -9
- data/lib/inch/cli/command/inspect.rb +5 -4
- data/lib/inch/cli/command/list.rb +4 -4
- data/lib/inch/cli/command/options/base.rb +17 -16
- data/lib/inch/cli/command/options/base_list.rb +9 -5
- data/lib/inch/cli/command/options/console.rb +4 -3
- data/lib/inch/cli/command/options/diff.rb +8 -6
- data/lib/inch/cli/command/options/inspect.rb +2 -2
- data/lib/inch/cli/command/options/list.rb +3 -2
- data/lib/inch/cli/command/options/show.rb +2 -2
- data/lib/inch/cli/command/options/stats.rb +2 -1
- data/lib/inch/cli/command/options/suggest.rb +6 -3
- data/lib/inch/cli/command/output/base.rb +4 -6
- data/lib/inch/cli/command/output/console.rb +6 -7
- data/lib/inch/cli/command/output/diff.rb +6 -6
- data/lib/inch/cli/command/output/inspect.rb +6 -8
- data/lib/inch/cli/command/output/list.rb +0 -1
- data/lib/inch/cli/command/output/show.rb +4 -5
- data/lib/inch/cli/command/output/stats.rb +21 -21
- data/lib/inch/cli/command/output/suggest.rb +31 -28
- 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 +6 -6
- data/lib/inch/cli/command_parser.rb +6 -5
- data/lib/inch/cli/sparkline_helper.rb +6 -6
- data/lib/inch/cli/trace_helper.rb +1 -1
- data/lib/inch/cli/yardopts_helper.rb +4 -3
- data/lib/inch/code_object.rb +3 -3
- data/lib/inch/code_object/converter.rb +6 -8
- data/lib/inch/code_object/provider.rb +11 -11
- data/lib/inch/code_object/proxy.rb +61 -30
- data/lib/inch/codebase.rb +7 -8
- data/lib/inch/codebase/object.rb +60 -0
- data/lib/inch/codebase/objects.rb +8 -10
- data/lib/inch/codebase/objects_filter.rb +7 -5
- data/lib/inch/codebase/proxy.rb +4 -4
- data/lib/inch/codebase/serializer.rb +3 -3
- data/lib/inch/config.rb +42 -11
- data/lib/inch/config/base.rb +8 -29
- data/lib/inch/config/codebase.rb +32 -7
- data/lib/inch/config/evaluation.rb +61 -0
- data/lib/inch/core_ext.rb +1 -1
- data/lib/inch/core_ext/string.rb +1 -1
- data/lib/inch/evaluation.rb +13 -21
- data/lib/inch/evaluation/file.rb +4 -2
- data/lib/inch/evaluation/grade_list.rb +4 -4
- data/lib/inch/evaluation/priority_range.rb +3 -0
- data/lib/inch/evaluation/proxy.rb +139 -14
- data/lib/inch/evaluation/role.rb +99 -0
- data/lib/inch/language.rb +3 -0
- data/lib/inch/language/elixir/code_object/base.rb +197 -0
- data/lib/inch/language/elixir/code_object/function_object.rb +74 -0
- data/lib/inch/language/elixir/code_object/module_object.rb +23 -0
- data/lib/inch/language/elixir/code_object/type_object.rb +11 -0
- data/lib/inch/language/elixir/evaluation/base.rb +28 -0
- data/lib/inch/language/elixir/evaluation/function_object.rb +31 -0
- data/lib/inch/language/elixir/evaluation/module_object.rb +27 -0
- data/lib/inch/language/elixir/evaluation/type_object.rb +11 -0
- data/lib/inch/language/elixir/import.rb +24 -0
- data/lib/inch/language/elixir/provider/reader.rb +19 -0
- data/lib/inch/language/elixir/provider/reader/object.rb +63 -0
- data/lib/inch/language/elixir/provider/reader/object/base.rb +191 -0
- data/lib/inch/language/elixir/provider/reader/object/function_object.rb +26 -0
- data/lib/inch/language/elixir/provider/reader/object/module_object.rb +22 -0
- data/lib/inch/language/elixir/provider/reader/object/type_object.rb +15 -0
- data/lib/inch/language/elixir/provider/reader/parser.rb +55 -0
- data/lib/inch/language/elixir/roles/base.rb +32 -0
- data/lib/inch/language/elixir/roles/function.rb +112 -0
- data/lib/inch/language/elixir/roles/module.rb +64 -0
- data/lib/inch/language/elixir/roles/object.rb +76 -0
- data/lib/inch/language/elixir/roles/type.rb +13 -0
- data/lib/inch/language/nodejs/import.rb +8 -0
- data/lib/inch/language/nodejs/provider/jsdoc.rb +19 -0
- data/lib/inch/language/nodejs/provider/jsdoc/object.rb +55 -0
- data/lib/inch/language/nodejs/provider/jsdoc/object/base.rb +191 -0
- data/lib/inch/language/nodejs/provider/jsdoc/parser.rb +59 -0
- data/lib/inch/language/ruby/code_object/base.rb +197 -0
- data/lib/inch/language/ruby/code_object/class_object.rb +10 -0
- data/lib/inch/language/ruby/code_object/class_variable_object.rb +10 -0
- data/lib/inch/language/ruby/code_object/constant_object.rb +10 -0
- data/lib/inch/language/ruby/code_object/method_object.rb +85 -0
- data/lib/inch/language/ruby/code_object/method_parameter_object.rb +64 -0
- data/lib/inch/language/ruby/code_object/module_object.rb +10 -0
- data/lib/inch/language/ruby/code_object/namespace_object.rb +35 -0
- data/lib/inch/language/ruby/evaluation/base.rb +45 -0
- data/lib/inch/language/ruby/evaluation/class_object.rb +10 -0
- data/lib/inch/language/ruby/evaluation/class_variable_object.rb +21 -0
- data/lib/inch/language/ruby/evaluation/constant_object.rb +21 -0
- data/lib/inch/language/ruby/evaluation/method_object.rb +74 -0
- data/lib/inch/language/ruby/evaluation/module_object.rb +10 -0
- data/lib/inch/language/ruby/evaluation/namespace_object.rb +30 -0
- data/lib/inch/language/ruby/import.rb +34 -0
- data/lib/inch/language/ruby/provider/yard.rb +58 -0
- data/lib/inch/language/ruby/provider/yard/docstring.rb +162 -0
- data/lib/inch/language/ruby/provider/yard/nodoc_helper.rb +97 -0
- data/lib/inch/language/ruby/provider/yard/object.rb +63 -0
- data/lib/inch/language/ruby/provider/yard/object/base.rb +325 -0
- data/lib/inch/language/ruby/provider/yard/object/class_object.rb +14 -0
- data/lib/inch/language/ruby/provider/yard/object/class_variable_object.rb +14 -0
- data/lib/inch/language/ruby/provider/yard/object/constant_object.rb +14 -0
- data/lib/inch/language/ruby/provider/yard/object/method_object.rb +170 -0
- data/lib/inch/language/ruby/provider/yard/object/method_parameter_object.rb +94 -0
- data/lib/inch/language/ruby/provider/yard/object/method_signature.rb +120 -0
- data/lib/inch/language/ruby/provider/yard/object/module_object.rb +14 -0
- data/lib/inch/language/ruby/provider/yard/object/namespace_object.rb +46 -0
- data/lib/inch/language/ruby/provider/yard/object/root_object.rb +14 -0
- data/lib/inch/language/ruby/provider/yard/parser.rb +71 -0
- data/lib/inch/language/ruby/roles/base.rb +17 -0
- data/lib/inch/language/ruby/roles/class_variable.rb +53 -0
- data/lib/inch/language/ruby/roles/constant.rb +53 -0
- data/lib/inch/language/ruby/roles/method.rb +112 -0
- data/lib/inch/language/ruby/roles/method_parameter.rb +84 -0
- data/lib/inch/language/ruby/roles/missing.rb +24 -0
- data/lib/inch/language/ruby/roles/namespace.rb +89 -0
- data/lib/inch/language/ruby/roles/object.rb +120 -0
- data/lib/inch/rake.rb +2 -2
- data/lib/inch/rake/suggest.rb +7 -2
- data/lib/inch/utils/buffered_ui.rb +16 -0
- data/lib/inch/utils/shell_helper.rb +1 -1
- data/lib/inch/utils/ui.rb +5 -5
- data/lib/inch/utils/weighted_list.rb +2 -3
- data/lib/inch/version.rb +1 -1
- data/test/fixtures/{code_examples → ruby/code_examples}/lib/foo.rb +0 -0
- data/test/fixtures/{diff1 → ruby/diff1}/lib/diff1.rb +0 -0
- data/test/fixtures/{diff2 → ruby/diff2}/lib/diff2.rb +0 -0
- data/test/fixtures/{inch-yml → ruby/inch-yml}/.inch.yml +0 -0
- data/test/fixtures/{inch-yml → ruby/inch-yml}/foo/bar.rb +0 -0
- data/test/fixtures/{inch-yml → ruby/inch-yml}/foo/vendor/base.rb +0 -0
- data/test/fixtures/{parameters → ruby/parameters}/lib/foo.rb +0 -0
- data/test/fixtures/{readme → ruby/readme}/lib/foo.rb +0 -0
- data/test/fixtures/{really_good → ruby/really_good}/lib/foo.rb +0 -0
- data/test/fixtures/{really_good_pedantic → ruby/really_good_pedantic}/lib/foo.rb +0 -0
- data/test/fixtures/{simple → ruby/simple}/README +0 -0
- data/test/fixtures/{simple → ruby/simple}/lib/broken.rb +11 -19
- data/test/fixtures/ruby/simple/lib/broken_ruby_2_0_features.rb +7 -0
- data/test/fixtures/ruby/simple/lib/directives.rb +8 -0
- data/test/fixtures/{simple → ruby/simple}/lib/foo.rb +22 -1
- data/test/fixtures/{simple → ruby/simple}/lib/nodoc.rb +0 -0
- data/test/fixtures/{simple → ruby/simple}/lib/role_methods.rb +0 -0
- data/test/fixtures/{simple → ruby/simple}/lib/role_namespaces.rb +0 -0
- data/test/fixtures/{visibility → ruby/visibility}/lib/foo.rb +0 -0
- data/test/fixtures/{yardopts → ruby/yardopts}/.yardopts +0 -0
- data/test/fixtures/{yardopts → ruby/yardopts}/foo/bar.rb +0 -0
- data/test/integration/api/compare/codebases.rb +3 -3
- data/test/integration/cli/command/console_test.rb +6 -6
- data/test/integration/cli/command/diff_test.rb +62 -0
- data/test/integration/cli/command/inspect_test.rb +5 -6
- data/test/integration/cli/command/list_test.rb +4 -5
- data/test/integration/cli/command/show_test.rb +5 -5
- data/test/integration/cli/command/stats_test.rb +3 -3
- data/test/integration/cli/command/suggest_test.rb +13 -13
- data/test/integration/stats_options_test.rb +4 -4
- data/test/integration/visibility_options_test.rb +14 -14
- data/test/shared/base_list.rb +4 -3
- data/test/test_helper.rb +13 -13
- data/test/unit/api/filter_test.rb +7 -7
- data/test/unit/api/get_test.rb +1 -1
- data/test/unit/api/list_test.rb +1 -1
- data/test/unit/api/options/base_test.rb +3 -3
- data/test/unit/api/stats_test.rb +1 -1
- data/test/unit/api/suggest_test.rb +3 -3
- data/test/unit/cli/arguments_test.rb +2 -2
- data/test/unit/cli/command/base_test.rb +1 -1
- data/test/unit/cli/command/options/base_list_test.rb +2 -2
- data/test/unit/cli/command/options/base_object_test.rb +1 -1
- data/test/unit/cli/command/options/base_test.rb +1 -1
- data/test/unit/cli/command_parser_test.rb +3 -3
- data/test/unit/cli/trace_helper_test.rb +1 -1
- data/test/unit/cli/yardopts_helper_test.rb +6 -5
- data/test/unit/code_object/converter_test.rb +1 -1
- data/test/unit/code_object/provider_test.rb +2 -2
- data/test/unit/code_object/proxy_test.rb +2 -2
- data/test/unit/codebase/objects_test.rb +2 -2
- data/test/unit/codebase/proxy_test.rb +7 -5
- data/test/unit/config/codebase_test.rb +4 -4
- data/test/unit/config_test.rb +28 -0
- data/test/unit/evaluation/{role/base_test.rb → role_test.rb} +7 -7
- data/test/unit/{code_object/proxy → language/ruby/code_object}/method_object_test.rb +66 -21
- data/test/unit/{code_object → language/ruby}/provider/yard/docstring_test.rb +74 -38
- data/test/unit/{code_object → language/ruby}/provider/yard/nodoc_helper_test.rb +9 -7
- data/test/unit/{code_object → language/ruby}/provider/yard/object/method_object_test.rb +21 -11
- data/test/unit/language/ruby/provider/yard_test.rb +25 -0
- data/test/unit/utils/buffered_ui_test.rb +48 -0
- data/test/unit/utils/ui_test.rb +7 -7
- data/test/unit/utils/weighted_list_test.rb +7 -4
- metadata +139 -93
- data/lib/inch/code_object/provider/yard.rb +0 -57
- data/lib/inch/code_object/provider/yard/docstring.rb +0 -133
- data/lib/inch/code_object/provider/yard/nodoc_helper.rb +0 -93
- data/lib/inch/code_object/provider/yard/object.rb +0 -60
- data/lib/inch/code_object/provider/yard/object/base.rb +0 -302
- data/lib/inch/code_object/provider/yard/object/class_object.rb +0 -12
- data/lib/inch/code_object/provider/yard/object/class_variable_object.rb +0 -12
- data/lib/inch/code_object/provider/yard/object/constant_object.rb +0 -12
- data/lib/inch/code_object/provider/yard/object/method_object.rb +0 -153
- data/lib/inch/code_object/provider/yard/object/method_parameter_object.rb +0 -88
- data/lib/inch/code_object/provider/yard/object/method_signature.rb +0 -114
- data/lib/inch/code_object/provider/yard/object/module_object.rb +0 -12
- data/lib/inch/code_object/provider/yard/object/namespace_object.rb +0 -47
- data/lib/inch/code_object/provider/yard/object/root_object.rb +0 -12
- data/lib/inch/code_object/provider/yard/parser.rb +0 -62
- data/lib/inch/code_object/proxy/base.rb +0 -241
- data/lib/inch/code_object/proxy/class_object.rb +0 -8
- data/lib/inch/code_object/proxy/class_variable_object.rb +0 -8
- data/lib/inch/code_object/proxy/constant_object.rb +0 -8
- data/lib/inch/code_object/proxy/method_object.rb +0 -82
- data/lib/inch/code_object/proxy/method_parameter_object.rb +0 -60
- data/lib/inch/code_object/proxy/module_object.rb +0 -8
- data/lib/inch/code_object/proxy/namespace_object.rb +0 -33
- data/lib/inch/evaluation/object_schema.rb +0 -30
- data/lib/inch/evaluation/proxy/base.rb +0 -164
- data/lib/inch/evaluation/proxy/class_object.rb +0 -8
- data/lib/inch/evaluation/proxy/class_variable_object.rb +0 -19
- data/lib/inch/evaluation/proxy/constant_object.rb +0 -19
- data/lib/inch/evaluation/proxy/method_object.rb +0 -65
- data/lib/inch/evaluation/proxy/module_object.rb +0 -8
- data/lib/inch/evaluation/proxy/namespace_object.rb +0 -27
- data/lib/inch/evaluation/role/base.rb +0 -92
- data/lib/inch/evaluation/role/class_variable.rb +0 -55
- data/lib/inch/evaluation/role/constant.rb +0 -55
- data/lib/inch/evaluation/role/method.rb +0 -126
- data/lib/inch/evaluation/role/method_parameter.rb +0 -91
- data/lib/inch/evaluation/role/missing.rb +0 -20
- data/lib/inch/evaluation/role/namespace.rb +0 -85
- data/lib/inch/evaluation/role/object.rb +0 -143
- 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,
|
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(
|
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(
|
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
|
@@ -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.
|
46
|
-
|
47
|
-
|
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.
|
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
|
2
|
-
require
|
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
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
|
40
|
+
puts "Grade distribution: (undocumented, C, B, A)"
|
41
41
|
puts
|
42
|
-
puts " Overall: #{sparkline} #{objects.size.to_s.rjust(5)}
|
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
|
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,
|
68
|
-
tick.color(
|
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
|
-
|
96
|
-
|
97
|
-
|
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
|
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
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
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
|
22
|
-
#
|
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,
|
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
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
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
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
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.
|
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
|
2
|
-
require
|
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
|
-
|
11
|
+
"Shows an object with its results"
|
12
12
|
end
|
13
13
|
|
14
14
|
def usage
|
15
|
-
|
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
|
2
|
-
require
|
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
|
-
|
11
|
+
"Show statistics"
|
12
12
|
end
|
13
13
|
|
14
14
|
def usage
|
15
|
-
|
15
|
+
"Usage: inch stats [paths] [options]"
|
16
16
|
end
|
17
17
|
|
18
18
|
def run(*args)
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
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
|
-
|
11
|
+
"Suggests some objects to be documented (better)"
|
12
12
|
end
|
13
13
|
|
14
14
|
def usage
|
15
|
-
|
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
|
-
|
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
|
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 [
|
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"
|
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.
|
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(
|
5
|
-
|
6
|
-
list =
|
7
|
-
__sparkline(list,
|
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,
|
24
|
+
sparkline.format do |tick, _count, index|
|
25
25
|
t = tick.color(grade_lists[index].color)
|
26
|
-
index == 0 ? t +
|
26
|
+
index == 0 ? t + " " : t
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -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
|
-
|
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
|
|