codeclimate 0.2.12 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cc/analyzer/formatters.rb +1 -1
- data/lib/cc/analyzer/formatters/formatter.rb +2 -1
- data/lib/cc/analyzer/formatters/json_formatter.rb +2 -1
- data/lib/cc/analyzer/formatters/plain_text_formatter.rb +2 -1
- data/lib/cc/analyzer/location_description.rb +18 -24
- data/lib/cc/cli/analyze.rb +1 -1
- data/lib/cc/cli/init.rb +23 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae822f93038f3d619b712789705ffae7c208c4c4
|
4
|
+
data.tar.gz: b0e1790279fb9722a45a1d732aaeb742c6c31103
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7211c83e5b25b001e3ffe13e9cbc10d75a4261807d02fb9778cf2bb443738073eefb5171797654634b8553cbfa77483ae687720109444d0d8d6b7101980e5711
|
7
|
+
data.tar.gz: b292451406d827dd80bc3429e474c869a452fe1e4f48c9bee7efe2007a88a2adab5dcc41991f40f5fd85239611672711185ad0604cf6ba5d0717d41798109643
|
@@ -12,7 +12,7 @@ module CC
|
|
12
12
|
}.freeze
|
13
13
|
|
14
14
|
def self.resolve(name)
|
15
|
-
FORMATTERS[name.to_sym].new or raise InvalidFormatterError, "'#{name}' is not a valid formatter. Valid options are: #{FORMATTERS.keys.join(", ")}"
|
15
|
+
FORMATTERS[name.to_sym].new(ENV['FILESYSTEM_DIR']) or raise InvalidFormatterError, "'#{name}' is not a valid formatter. Valid options are: #{FORMATTERS.keys.join(", ")}"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -35,7 +35,8 @@ module CC
|
|
35
35
|
|
36
36
|
IssueSorter.new(file_issues).by_location.each do |issue|
|
37
37
|
if location = issue["location"]
|
38
|
-
|
38
|
+
source_buffer = @filesystem.source_buffer_for(location["path"])
|
39
|
+
print(colorize(LocationDescription.new(source_buffer, location, ": "), :cyan))
|
39
40
|
end
|
40
41
|
|
41
42
|
print(issue["description"])
|
@@ -1,26 +1,23 @@
|
|
1
1
|
module CC
|
2
2
|
module Analyzer
|
3
3
|
class LocationDescription
|
4
|
-
def initialize(location, suffix = "")
|
4
|
+
def initialize(source_buffer, location, suffix = "")
|
5
|
+
@source_buffer = source_buffer
|
5
6
|
@location = location
|
6
7
|
@suffix = suffix
|
7
8
|
end
|
8
9
|
|
9
10
|
def to_s
|
10
|
-
str = ""
|
11
11
|
if location["lines"]
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
str << "-"
|
18
|
-
str << render_position(positions["end"])
|
19
|
-
end
|
12
|
+
begin_line = location["lines"]["begin"]
|
13
|
+
end_line = location["lines"]["end"]
|
14
|
+
elsif location["positions"]
|
15
|
+
begin_line = position_to_line(location["positions"]["begin"])
|
16
|
+
end_line = position_to_line(location["positions"]["end"])
|
20
17
|
end
|
21
18
|
|
19
|
+
str = render_lines(begin_line, end_line)
|
22
20
|
str << suffix unless str.blank?
|
23
|
-
|
24
21
|
str
|
25
22
|
end
|
26
23
|
|
@@ -28,23 +25,20 @@ module CC
|
|
28
25
|
|
29
26
|
attr_reader :location, :suffix
|
30
27
|
|
31
|
-
def render_lines
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
def render_lines(begin_line, end_line)
|
29
|
+
if end_line == begin_line
|
30
|
+
begin_line.to_s
|
31
|
+
else
|
32
|
+
"#{begin_line}-#{end_line}"
|
33
|
+
end
|
35
34
|
end
|
36
35
|
|
37
|
-
def
|
38
|
-
str = ""
|
39
|
-
|
36
|
+
def position_to_line(position)
|
40
37
|
if position["line"]
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
str << position["offset"].to_s
|
38
|
+
position["line"]
|
39
|
+
else
|
40
|
+
@source_buffer.decompose_position(position["offset"]).first
|
45
41
|
end
|
46
|
-
|
47
|
-
str
|
48
42
|
end
|
49
43
|
end
|
50
44
|
end
|
data/lib/cc/cli/analyze.rb
CHANGED
data/lib/cc/cli/init.rb
CHANGED
@@ -11,6 +11,7 @@ module CC
|
|
11
11
|
else
|
12
12
|
create_codeclimate_yaml
|
13
13
|
say "Config file .codeclimate.yml successfully generated.\nEdit and then try running 'validate-config' to check configuration."
|
14
|
+
create_default_configs
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
@@ -33,6 +34,27 @@ module CC
|
|
33
34
|
filesystem.write_path(CODECLIMATE_YAML, config.to_yaml)
|
34
35
|
end
|
35
36
|
|
37
|
+
def create_default_configs
|
38
|
+
available_configs.each do |config_path|
|
39
|
+
file_name = File.basename(config_path)
|
40
|
+
if filesystem.exist?(file_name)
|
41
|
+
say "Skipping generating #{file_name} file (already exists)."
|
42
|
+
else
|
43
|
+
filesystem.write_path(file_name, File.read(config_path))
|
44
|
+
say "Config file #{file_name} successfully generated."
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def available_configs
|
50
|
+
all_paths = eligible_engines.flat_map do |engine_name, _|
|
51
|
+
engine_directory = File.expand_path("../../../../config/#{engine_name}", __FILE__)
|
52
|
+
Dir.glob("#{engine_directory}/*", File::FNM_DOTMATCH)
|
53
|
+
end
|
54
|
+
|
55
|
+
all_paths.reject { |path| ['.', '..'].include?(File.basename(path)) }
|
56
|
+
end
|
57
|
+
|
36
58
|
def exclude_paths(paths)
|
37
59
|
expanded_paths = []
|
38
60
|
paths.each do |dir|
|
@@ -52,7 +74,7 @@ module CC
|
|
52
74
|
end
|
53
75
|
|
54
76
|
def eligible_engines
|
55
|
-
engine_registry.list.each_with_object({}) do |(engine_name, config), result|
|
77
|
+
@eligible_engines ||= engine_registry.list.each_with_object({}) do |(engine_name, config), result|
|
56
78
|
if engine_eligible?(config)
|
57
79
|
result[engine_name] = config
|
58
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codeclimate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code Climate
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|