danger-danger_plugin_lint 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/danger/danger_plugin_lint.rb +31 -2
- data/lib/danger_plugin_lint/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ecee1a27602e5a9482de8281996941ecf6ebc80b0b61be8dc39e7da4b5f7d7a
|
4
|
+
data.tar.gz: 432fdff0e74f4cc8363b25c3d7840d061c1cf32ca5617e46e1f3d63af07c25d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a354c5f83645d7ef0d545b62b623871f5f5ccfc42f56c91174510f6e17e1b78402bba587f5ba6da93723f83e40dfa7af55b097ebe26509f360c0ed19c45a1914
|
7
|
+
data.tar.gz: 7a0234d5e3ee8aeb86ef07faa6cf41e55439e2ed20911fb3f4cc25ca0e6f919b0155455e7ae524b328bb9e4eee6d579e8707e7dff3fc84b445bd0293c335c894
|
@@ -20,7 +20,8 @@ module Danger
|
|
20
20
|
# @param [Boolean] warnings_as_errors If `true`, treat all warnings as errors.
|
21
21
|
# @return [void]
|
22
22
|
def lint_docs(*refs, warnings_as_errors: false)
|
23
|
-
|
23
|
+
refs = refs.flatten.compact
|
24
|
+
file_resolver = PluginFileResolver.new(refs.empty? ? nil : refs)
|
24
25
|
data = file_resolver.resolve
|
25
26
|
|
26
27
|
parser = PluginParser.new(data[:paths], verbose: true)
|
@@ -37,10 +38,38 @@ module Danger
|
|
37
38
|
|
38
39
|
def display_rules(method, rules)
|
39
40
|
rules.each do |rule|
|
41
|
+
message = format_rule(rule)
|
40
42
|
abs_file, line = rule.metadata[:files][0]
|
41
43
|
file = Pathname.new(abs_file).relative_path_from(Dir.pwd).to_s
|
42
|
-
public_send(method,
|
44
|
+
public_send(method, message, file: file, line: line)
|
43
45
|
end
|
44
46
|
end
|
47
|
+
|
48
|
+
def format_rule(rule)
|
49
|
+
<<~HTML
|
50
|
+
<strong>#{rule.title}</strong> - <strong>#{rule.metadata[:name]}</strong> (#{rule.type}):
|
51
|
+
#{to_html(rule.description)}
|
52
|
+
#{link(rule.ref)}
|
53
|
+
HTML
|
54
|
+
end
|
55
|
+
|
56
|
+
def link(ref)
|
57
|
+
url = case ref
|
58
|
+
when Range
|
59
|
+
"https://github.com/dbgrandi/danger-prose/blob/v2.0.0/lib/danger_plugin.rb#L#{ref.min}-L#{ref.max}"
|
60
|
+
when Integer
|
61
|
+
"https://github.com/dbgrandi/danger-prose/blob/v2.0.0/lib/danger_plugin.rb#L#{ref}"
|
62
|
+
else
|
63
|
+
'https://github.com/dbgrandi/danger-prose/blob/v2.0.0/lib/danger_plugin.rb'
|
64
|
+
end
|
65
|
+
%(@see - <a href="#{url}">#{url}</a>)
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_html(markdown)
|
69
|
+
# As the current Danger uses nothing but backquotes in syntax of Markdown,
|
70
|
+
# this method just replaces backquotes to `<code>` tag.
|
71
|
+
# @see https://github.com/danger/danger/blob/v9.0.0/lib/danger/plugin_support/plugin_linter.rb#L93-L128
|
72
|
+
markdown.gsub(/`(.*?)`/, '<code>\1</code>')
|
73
|
+
end
|
45
74
|
end
|
46
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-danger_plugin_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryosuke Ito
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-plugin-api
|