inch 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/inch/api/filter.rb +9 -2
- data/lib/inch/api/suggest.rb +4 -0
- data/lib/inch/cli/command/options/suggest.rb +9 -0
- data/lib/inch/cli/command/suggest.rb +6 -2
- data/lib/inch/codebase/proxy.rb +0 -9
- data/lib/inch/evaluation/proxy.rb +2 -2
- data/lib/inch/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba3a203a48459da4bf88d52ff9855712483543f7
|
4
|
+
data.tar.gz: 31403afde0e69710d5d6ab5c6f997f3940eee18f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5efa4c765863b66ddb2775f4b14027645bb3dfb6fb06701a4dec796506ef3e59924222810fa58c7ea321515dc274110cb5011828d152b7ce6ec6f5cfa53303be
|
7
|
+
data.tar.gz: 6b81968eeba91c2403550c649f877cc6d9f703afef025eb15e21162ba0e49e13375d5dc4d7c9f2486f63749c44099b7ed1605a841b0e7b27cf6388cc00af428d
|
data/lib/inch/api/filter.rb
CHANGED
@@ -4,13 +4,20 @@ module Inch
|
|
4
4
|
class Filter
|
5
5
|
attr_reader :codebase
|
6
6
|
attr_reader :objects
|
7
|
-
attr_reader :grade_lists
|
8
7
|
|
9
8
|
def initialize(codebase, options)
|
10
9
|
@codebase = codebase
|
11
10
|
codebase.objects.filter! Options::Filter.new(options)
|
12
11
|
@objects = codebase.objects.to_a
|
13
|
-
|
12
|
+
end
|
13
|
+
|
14
|
+
def grade_lists(_objects = objects)
|
15
|
+
lists = Evaluation.new_grade_lists
|
16
|
+
lists.each do |range|
|
17
|
+
list = _objects.select { |o| range.scores.include?(o.score) }
|
18
|
+
range.objects = Codebase::Objects.sort_by_priority(list)
|
19
|
+
end
|
20
|
+
lists
|
14
21
|
end
|
15
22
|
end
|
16
23
|
end
|
data/lib/inch/api/suggest.rb
CHANGED
@@ -3,6 +3,11 @@ module Inch
|
|
3
3
|
module Command
|
4
4
|
module Options
|
5
5
|
class Suggest < BaseList
|
6
|
+
FORMAT_TEXT = "text"
|
7
|
+
FORMATS = [FORMAT_TEXT] + %w(json yaml)
|
8
|
+
|
9
|
+
attribute :format, FORMATS.first
|
10
|
+
|
6
11
|
include API::Options::Suggest::DefaultAttributeValues
|
7
12
|
|
8
13
|
attribute :object_count, DEFAULT_OBJECT_COUNT
|
@@ -46,6 +51,10 @@ module Inch
|
|
46
51
|
opts.on('-n', '--objects [COUNT]', 'Show COUNT objects') do |count|
|
47
52
|
@object_count = count.to_i
|
48
53
|
end
|
54
|
+
opts.on('-f', '--format [FORMAT]', FORMATS,
|
55
|
+
'Set output FORMAT') do |format|
|
56
|
+
@format = format
|
57
|
+
end
|
49
58
|
opts.on('--pedantic',
|
50
59
|
'Be excessively concerned with minor details and rules') do
|
51
60
|
# all objects are considered a priority
|
@@ -23,8 +23,12 @@ module Inch
|
|
23
23
|
def run(*args)
|
24
24
|
prepare_codebase(*args)
|
25
25
|
context = API::Suggest.new(codebase, @options)
|
26
|
-
|
27
|
-
|
26
|
+
if @options.format == Options::Suggest::FORMAT_TEXT
|
27
|
+
Output::Suggest.new(@options, context.all_objects, context.objects,
|
28
|
+
context.grade_lists, context.files)
|
29
|
+
else
|
30
|
+
Output::Stats.new(@options, context.all_objects, context.grade_lists)
|
31
|
+
end
|
28
32
|
end
|
29
33
|
end
|
30
34
|
end
|
data/lib/inch/codebase/proxy.rb
CHANGED
@@ -7,15 +7,6 @@ module Inch
|
|
7
7
|
@objects = Codebase::Objects.new(language, provider.objects)
|
8
8
|
end
|
9
9
|
|
10
|
-
def grade_lists
|
11
|
-
lists = Evaluation.new_grade_lists
|
12
|
-
lists.each do |range|
|
13
|
-
list = objects.select { |o| range.scores.include?(o.score) }
|
14
|
-
range.objects = Objects.sort_by_priority(list)
|
15
|
-
end
|
16
|
-
lists
|
17
|
-
end
|
18
|
-
|
19
10
|
def self.parse(dir, config)
|
20
11
|
provider = CodeObject::Provider.parse(dir, config)
|
21
12
|
new(config.language, provider)
|
@@ -114,13 +114,13 @@ module Inch
|
|
114
114
|
# @return [Float] the max score that is assignable to +object+
|
115
115
|
def __max_score
|
116
116
|
arr = @roles.map(&:max_score).compact
|
117
|
-
[MAX_SCORE].concat(arr).min
|
117
|
+
[MAX_SCORE].concat(arr).min.to_i
|
118
118
|
end
|
119
119
|
|
120
120
|
# @return [Float] the max score that is assignable to +object+
|
121
121
|
def __min_score
|
122
122
|
arr = @roles.map(&:min_score).compact
|
123
|
-
[MIN_SCORE].concat(arr).max
|
123
|
+
[MIN_SCORE].concat(arr).max.to_i
|
124
124
|
end
|
125
125
|
|
126
126
|
# @return [Float]
|
data/lib/inch/version.rb
CHANGED