codeclimate 0.44.0 → 0.45.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/engines.yml +10 -1
- data/lib/cc/analyzer/formatters/html_formatter.rb +374 -40
- metadata +3 -4
- data/config/.engines.yml.swp +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d44dd1c05b63256236f2262283aa00f4c1c629ac
|
4
|
+
data.tar.gz: 7cff0c14c73e7cb501c2038ba8d9e998d8ce42bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8381828b97b80d0400010a2d57c4093bd270a883a01ef66e8c8d7dbb75cfac91170ea1e356d535e7d20e9a294513f010a227a791a690e5231c0228e9b1c96a80
|
7
|
+
data.tar.gz: 38ca8a4dbc3eff1f78c14f1f5d1ffe87b42a5550afee622478aa68594cc561d0622b9e6314730bf3e4ed0c5e2f9865c1a19e92b857878adce621754b80d0629d
|
data/config/engines.yml
CHANGED
@@ -41,6 +41,15 @@ bundler-audit:
|
|
41
41
|
- ^Gemfile\.lock$
|
42
42
|
default_ratings_paths:
|
43
43
|
- Gemfile.lock
|
44
|
+
checkstyle:
|
45
|
+
channels:
|
46
|
+
beta: codeclimate/codeclimate-checkstyle:beta
|
47
|
+
description: Helps programmers write Java that adheres to a coding standard.
|
48
|
+
community: false
|
49
|
+
enable_regexps:
|
50
|
+
- \.java$
|
51
|
+
default_ratings_paths:
|
52
|
+
- "**.java"
|
44
53
|
csslint:
|
45
54
|
channels:
|
46
55
|
stable: codeclimate/codeclimate-csslint
|
@@ -131,7 +140,7 @@ flog:
|
|
131
140
|
beta: codeclimate/codeclimate-flog:beta
|
132
141
|
description: Easy to read reporting of complexity/pain for Ruby code.
|
133
142
|
community: true
|
134
|
-
|
143
|
+
enable_regexps:
|
135
144
|
- \.rb$
|
136
145
|
default_ratings_paths:
|
137
146
|
- "**.rb"
|
@@ -1,34 +1,395 @@
|
|
1
1
|
require "redcarpet"
|
2
|
-
require "active_support/number_helper"
|
3
2
|
|
4
3
|
module CC
|
5
4
|
module Analyzer
|
6
5
|
module Formatters
|
7
|
-
class HTMLFormatter < Formatter
|
6
|
+
class HTMLFormatter < Formatter # rubocop: disable Metrics/ClassLength
|
7
|
+
LANGUAGES = Hash.new { |_, ext| ext }.
|
8
|
+
merge(
|
9
|
+
# abap
|
10
|
+
# ada
|
11
|
+
"appraisals" => "ruby",
|
12
|
+
"as" => "actionscript",
|
13
|
+
"asm" => "nasm",
|
14
|
+
"bas" => "basic",
|
15
|
+
# c
|
16
|
+
"c++" => "cpp",
|
17
|
+
"capfile" => "ruby",
|
18
|
+
"cc" => "cpp",
|
19
|
+
"cfc" => "markup",
|
20
|
+
"cfm" => "markup",
|
21
|
+
"coffee" => "coffeescript",
|
22
|
+
"cp" => "cpp",
|
23
|
+
# cpp
|
24
|
+
"cr" => "crystal",
|
25
|
+
"cs" => "csharp",
|
26
|
+
"css" => %w[css css-extras],
|
27
|
+
"cu" => "cpp",
|
28
|
+
"cxx" => "cpp",
|
29
|
+
# d
|
30
|
+
# dart
|
31
|
+
# diff
|
32
|
+
"dockerfile" => "docker",
|
33
|
+
"dpr" => "pascal",
|
34
|
+
"erl" => "erlang",
|
35
|
+
"ex" => "elixir",
|
36
|
+
"f" => "fortran",
|
37
|
+
"f90" => "fortran",
|
38
|
+
"f95" => "fortran",
|
39
|
+
"feature" => "gherkin",
|
40
|
+
"for" => "fortran",
|
41
|
+
"fs" => "fsharp",
|
42
|
+
"fsi" => "fsharp",
|
43
|
+
"fsscript" => "fsharp",
|
44
|
+
"fsx" => "fsharp",
|
45
|
+
"gemfile" => "ruby",
|
46
|
+
"gemspec" => "ruby",
|
47
|
+
# glsl
|
48
|
+
# go
|
49
|
+
# groovy
|
50
|
+
"gvy" => "groovy",
|
51
|
+
"h" => "c",
|
52
|
+
"h++" => "cpp",
|
53
|
+
# haml
|
54
|
+
# handlebars
|
55
|
+
"hbr" => "handlebars",
|
56
|
+
"hh" => "cpp",
|
57
|
+
"hpp" => "cpp",
|
58
|
+
"hs" => "haskell",
|
59
|
+
"htm" => "markup",
|
60
|
+
"html" => "markup",
|
61
|
+
"hx" => "haxe",
|
62
|
+
"hxml" => "haxe",
|
63
|
+
"icn" => "icon",
|
64
|
+
"ijs" => "j",
|
65
|
+
# ini
|
66
|
+
"iol" => "jolie",
|
67
|
+
# java
|
68
|
+
"jl" => "julia",
|
69
|
+
"js" => "javascript",
|
70
|
+
# json
|
71
|
+
# jsx
|
72
|
+
"kt" => "kotlin",
|
73
|
+
"kts" => "kotlin",
|
74
|
+
# less
|
75
|
+
"lhs" => "haskell",
|
76
|
+
"lol" => "lolcode",
|
77
|
+
"lols" => "lolcode",
|
78
|
+
"ls" => "livescript",
|
79
|
+
# lua
|
80
|
+
"m" => "objective-c",
|
81
|
+
"mab" => "ruby",
|
82
|
+
# makefile
|
83
|
+
# markdown
|
84
|
+
"md" => "markdown",
|
85
|
+
# mel
|
86
|
+
"mkd" => "markdown",
|
87
|
+
"ml" => "ocaml",
|
88
|
+
"mli" => "ocaml",
|
89
|
+
"mm" => "objective-c",
|
90
|
+
# nim
|
91
|
+
# nix
|
92
|
+
"nsi" => "nsis",
|
93
|
+
"ol" => "jolie",
|
94
|
+
# oz
|
95
|
+
"pas" => "pascal",
|
96
|
+
"patch" => "diff",
|
97
|
+
"pde" => "processing",
|
98
|
+
"php" => %w[php php-extras],
|
99
|
+
"php3" => %w[php php-extras],
|
100
|
+
"php4" => %w[php php-extras],
|
101
|
+
"php5" => %w[php php-extras],
|
102
|
+
"phtml" => %w[php php-extras],
|
103
|
+
"pl" => "perl",
|
104
|
+
"pp" => "puppet",
|
105
|
+
"prawn" => "ruby",
|
106
|
+
"pro" => "prolog",
|
107
|
+
# properties
|
108
|
+
# pure
|
109
|
+
"py" => "python",
|
110
|
+
"py3" => "python",
|
111
|
+
"pyw" => "python",
|
112
|
+
"q" => "qore",
|
113
|
+
"qm" => "qore",
|
114
|
+
"qtest" => "qore",
|
115
|
+
# r
|
116
|
+
"rake" => "ruby",
|
117
|
+
"rakefile" => "ruby",
|
118
|
+
"rantfile" => "ruby",
|
119
|
+
"rb" => "ruby",
|
120
|
+
"rbw" => "ruby",
|
121
|
+
"rjs" => "ruby",
|
122
|
+
"rpdf" => "ruby",
|
123
|
+
"rs" => "rust",
|
124
|
+
"rst" => "rest",
|
125
|
+
"ru" => "ruby",
|
126
|
+
"rxml" => "ruby",
|
127
|
+
# sass
|
128
|
+
"sc" => "scala",
|
129
|
+
# scala
|
130
|
+
"scs" => "scheme",
|
131
|
+
# scss
|
132
|
+
"shader" => "glsl",
|
133
|
+
# sql
|
134
|
+
"ss" => "scheme",
|
135
|
+
"st" => "smalltalk",
|
136
|
+
"styl" => "stylus",
|
137
|
+
# swift
|
138
|
+
# tcl
|
139
|
+
"template" => "json",
|
140
|
+
"tex" => "latex",
|
141
|
+
# textile
|
142
|
+
"tmproj" => "markup",
|
143
|
+
"tpl" => "smarty",
|
144
|
+
"ts" => "typescript",
|
145
|
+
"v" => "verilog",
|
146
|
+
"vagrantfile" => "ruby",
|
147
|
+
"vhd" => "vhdl",
|
148
|
+
# vim
|
149
|
+
"xaml" => "markup",
|
150
|
+
"xhtml" => "markup",
|
151
|
+
"xml" => "markup",
|
152
|
+
# yaml
|
153
|
+
"yaws" => "erlang",
|
154
|
+
"yml" => "yaml",
|
155
|
+
).freeze
|
156
|
+
|
157
|
+
class Location
|
158
|
+
CONTEXT_LINES = 2
|
159
|
+
MAX_LINES = 10
|
160
|
+
|
161
|
+
def initialize(source_buffer, location)
|
162
|
+
@source_buffer = source_buffer
|
163
|
+
@location = location
|
164
|
+
end
|
165
|
+
|
166
|
+
def begin_line
|
167
|
+
@begin_line ||= line("begin")
|
168
|
+
end
|
169
|
+
|
170
|
+
def end_line
|
171
|
+
@end_line ||= line("end")
|
172
|
+
end
|
173
|
+
|
174
|
+
def to_s
|
175
|
+
[
|
176
|
+
begin_line,
|
177
|
+
end_line,
|
178
|
+
].uniq.join("-")
|
179
|
+
end
|
180
|
+
|
181
|
+
def start
|
182
|
+
[begin_line - CONTEXT_LINES, 1].max
|
183
|
+
end
|
184
|
+
|
185
|
+
def line_offset
|
186
|
+
start - 1
|
187
|
+
end
|
188
|
+
|
189
|
+
def code
|
190
|
+
first_line = start
|
191
|
+
last_line = [
|
192
|
+
end_line + CONTEXT_LINES,
|
193
|
+
begin_line + MAX_LINES + CONTEXT_LINES,
|
194
|
+
source_buffer.line_count,
|
195
|
+
].min
|
196
|
+
source_buffer.source.lines[(first_line - 1)..(last_line - 1)].join("")
|
197
|
+
end
|
198
|
+
|
199
|
+
private
|
200
|
+
|
201
|
+
attr_reader :location, :source_buffer
|
202
|
+
|
203
|
+
def line(type)
|
204
|
+
if location["lines"]
|
205
|
+
location["lines"][type]
|
206
|
+
elsif location["positions"]
|
207
|
+
position_to_line(location["positions"][type])
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def position_to_line(position)
|
212
|
+
if position["line"]
|
213
|
+
position["line"]
|
214
|
+
else
|
215
|
+
@source_buffer.decompose_position(position["offset"]).first
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
class SourceFile
|
221
|
+
def initialize(path, filesystem)
|
222
|
+
@path = path
|
223
|
+
@filesystem = filesystem
|
224
|
+
end
|
225
|
+
|
226
|
+
attr_reader :path
|
227
|
+
|
228
|
+
def syntaxes
|
229
|
+
ext = File.basename(path).split(".").last.downcase
|
230
|
+
Array(LANGUAGES[ext])
|
231
|
+
end
|
232
|
+
|
233
|
+
def code
|
234
|
+
filesystem.read_path(path)
|
235
|
+
end
|
236
|
+
|
237
|
+
def buffer
|
238
|
+
@buffer ||= SourceBuffer.new(path, code)
|
239
|
+
end
|
240
|
+
|
241
|
+
def location(loc)
|
242
|
+
Location.new(buffer, loc)
|
243
|
+
end
|
244
|
+
|
245
|
+
private
|
246
|
+
|
247
|
+
attr_reader :filesystem
|
248
|
+
end
|
249
|
+
|
250
|
+
class Issue
|
251
|
+
MARKDOWN_CONFIG = { autolink: true, fenced_code_blocks: true, no_intra_emphasis: true, tables: true }.freeze
|
252
|
+
|
253
|
+
def initialize(data, filesystem)
|
254
|
+
@data = data
|
255
|
+
@filesystem = filesystem
|
256
|
+
end
|
257
|
+
|
258
|
+
def description
|
259
|
+
data["description"]
|
260
|
+
end
|
261
|
+
|
262
|
+
def body
|
263
|
+
@body ||=
|
264
|
+
begin
|
265
|
+
text = data.fetch("content", {}).fetch("body", "").strip
|
266
|
+
unless text.empty?
|
267
|
+
markdown(text)
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
def source
|
273
|
+
@source ||= SourceFile.new(
|
274
|
+
data.fetch("location", {}).fetch("path", ""),
|
275
|
+
filesystem,
|
276
|
+
)
|
277
|
+
end
|
278
|
+
|
279
|
+
def location
|
280
|
+
@location ||=
|
281
|
+
Location.new(
|
282
|
+
source.buffer,
|
283
|
+
data["location"],
|
284
|
+
)
|
285
|
+
end
|
286
|
+
|
287
|
+
def other_locations
|
288
|
+
@other_locations ||=
|
289
|
+
begin
|
290
|
+
data.fetch("other_locations", []).map do |loc|
|
291
|
+
[SourceFile.new(loc["path"], filesystem), loc]
|
292
|
+
end.to_h
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
def categories
|
297
|
+
data.fetch("categories", [])
|
298
|
+
end
|
299
|
+
|
300
|
+
def engine_name
|
301
|
+
data["engine_name"]
|
302
|
+
end
|
303
|
+
|
304
|
+
private
|
305
|
+
|
306
|
+
attr_reader :data, :filesystem
|
307
|
+
|
308
|
+
def markdown(text)
|
309
|
+
html = Redcarpet::Render::HTML.new(
|
310
|
+
escape_html: false,
|
311
|
+
link_attributes: { target: "_blank" },
|
312
|
+
)
|
313
|
+
redcarpet = Redcarpet::Markdown.new(html, MARKDOWN_CONFIG)
|
314
|
+
redcarpet.render(text)
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
class IssueCollection
|
319
|
+
def initialize(filesystem)
|
320
|
+
@collection = []
|
321
|
+
@filesystem = filesystem
|
322
|
+
end
|
323
|
+
|
324
|
+
def each(&block)
|
325
|
+
collection.each(&block)
|
326
|
+
end
|
327
|
+
|
328
|
+
def <<(issue)
|
329
|
+
if issue.is_a? Hash
|
330
|
+
issue = Issue.new(issue, filesystem)
|
331
|
+
end
|
332
|
+
collection.push(issue)
|
333
|
+
end
|
334
|
+
|
335
|
+
def any?
|
336
|
+
collection.any?
|
337
|
+
end
|
338
|
+
|
339
|
+
def syntaxes
|
340
|
+
collection.flat_map do |issue|
|
341
|
+
issue.source.syntaxes
|
342
|
+
end.uniq.sort
|
343
|
+
end
|
344
|
+
|
345
|
+
def categories
|
346
|
+
collection.flat_map(&:categories).uniq.sort
|
347
|
+
end
|
348
|
+
|
349
|
+
def engines
|
350
|
+
collection.map(&:engine_name).uniq.compact.sort
|
351
|
+
end
|
352
|
+
|
353
|
+
private
|
354
|
+
|
355
|
+
attr_reader :collection, :filesystem
|
356
|
+
end
|
357
|
+
|
8
358
|
class ReportTemplate
|
9
359
|
include ERB::Util
|
10
|
-
|
360
|
+
attr_reader :issues
|
11
361
|
|
12
362
|
TEMPLATE_PATH = File.expand_path(File.join(File.dirname(__FILE__), "templates/html.erb"))
|
13
363
|
|
14
|
-
def initialize(
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@issue_count = issue_count
|
364
|
+
def initialize(issues, filesystem)
|
365
|
+
@issues = issues
|
366
|
+
@filesystem = filesystem
|
18
367
|
end
|
19
368
|
|
20
369
|
def render
|
21
|
-
|
370
|
+
template = File.read(TEMPLATE_PATH)
|
371
|
+
ERB.new(template, nil, "-").result(binding)
|
372
|
+
end
|
373
|
+
|
374
|
+
def project_name
|
375
|
+
File.basename(filesystem.root)
|
376
|
+
end
|
377
|
+
|
378
|
+
def param(str)
|
379
|
+
str.downcase.gsub(/\s+/, "-")
|
22
380
|
end
|
23
381
|
|
24
|
-
def
|
25
|
-
|
382
|
+
def params(values)
|
383
|
+
values.map { |c| param c }.join(" ")
|
26
384
|
end
|
385
|
+
|
386
|
+
private
|
387
|
+
|
388
|
+
attr_reader :filesystem
|
27
389
|
end
|
28
390
|
|
29
391
|
def finished
|
30
|
-
|
31
|
-
puts template.render
|
392
|
+
puts ReportTemplate.new(issues, @filesystem).render
|
32
393
|
end
|
33
394
|
|
34
395
|
def failed(_)
|
@@ -38,39 +399,12 @@ module CC
|
|
38
399
|
private
|
39
400
|
|
40
401
|
def issues
|
41
|
-
@issues ||=
|
42
|
-
end
|
43
|
-
|
44
|
-
def issues_by_path
|
45
|
-
issues.group_by { |i| i["location"]["path"] }.sort.each do |_, file_issues|
|
46
|
-
IssueSorter.new(file_issues).by_location.map do |issue|
|
47
|
-
source_buffer = @filesystem.source_buffer_for(issue["location"]["path"])
|
48
|
-
issue["location"] = LocationDescription.new(source_buffer, issue["location"], "")
|
49
|
-
issue["description"] = render_readup_markdown(issue["description"])
|
50
|
-
if issue["content"]
|
51
|
-
issue["content"]["body"] = render_readup_markdown(issue["content"]["body"])
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
402
|
+
@issues ||= IssueCollection.new(@filesystem)
|
55
403
|
end
|
56
404
|
|
57
405
|
def warnings
|
58
406
|
@warnings ||= []
|
59
407
|
end
|
60
|
-
|
61
|
-
def render_readup_markdown(body)
|
62
|
-
html = Redcarpet::Render::HTML.new(escape_html: false, link_attributes: { target: "_blank" })
|
63
|
-
Redcarpet::Markdown.new(html, markdown_options).render(body)
|
64
|
-
end
|
65
|
-
|
66
|
-
def markdown_options
|
67
|
-
{
|
68
|
-
autolink: true,
|
69
|
-
fenced_code_blocks: true,
|
70
|
-
no_intra_emphasis: true,
|
71
|
-
tables: true,
|
72
|
-
}
|
73
|
-
end
|
74
408
|
end
|
75
409
|
end
|
76
410
|
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.45.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: 2017-01-
|
11
|
+
date: 2017-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -158,7 +158,6 @@ files:
|
|
158
158
|
- bin/codeclimate-init
|
159
159
|
- bin/prep-release
|
160
160
|
- bin/release
|
161
|
-
- config/.engines.yml.swp
|
162
161
|
- config/coffeelint/coffeelint.json
|
163
162
|
- config/csslint/.csslintrc
|
164
163
|
- config/engines.yml
|
@@ -254,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
253
|
version: '0'
|
255
254
|
requirements: []
|
256
255
|
rubyforge_project:
|
257
|
-
rubygems_version: 2.
|
256
|
+
rubygems_version: 2.5.2
|
258
257
|
signing_key:
|
259
258
|
specification_version: 4
|
260
259
|
summary: Code Climate CLI
|
data/config/.engines.yml.swp
DELETED
Binary file
|