danger-pmd 0.2.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/publish.yml +35 -0
- data/.github/workflows/test.yml +24 -0
- data/.rubocop.yml +4777 -99
- data/Gemfile.lock +83 -63
- data/LICENSE +21 -0
- data/README.md +34 -21
- data/danger-pmd.gemspec +24 -22
- data/lib/danger_plugin.rb +1 -1
- data/lib/danger_pmd.rb +1 -1
- data/lib/pmd/{pmd_file.rb → entity/pmd_file.rb} +10 -13
- data/lib/pmd/{pmd_violation.rb → entity/pmd_violation.rb} +5 -4
- data/lib/pmd/gem_version.rb +1 -1
- data/lib/pmd/plugin.rb +35 -32
- data/spec/entity/pmd_file_spec.rb +48 -0
- data/spec/pmd_spec.rb +58 -64
- data/spec/spec_helper.rb +18 -18
- metadata +62 -31
- data/.travis.yml +0 -10
- data/LICENSE.txt +0 -22
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
danger-pmd (0.2
|
4
|
+
danger-pmd (1.0.2)
|
5
5
|
danger-plugin-api (~> 1.0)
|
6
|
-
oga (~> 2.
|
6
|
+
oga (~> 2.15)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
@@ -11,40 +11,44 @@ GEM
|
|
11
11
|
addressable (2.7.0)
|
12
12
|
public_suffix (>= 2.0.2, < 5.0)
|
13
13
|
ansi (1.5.0)
|
14
|
-
ast (2.4.
|
14
|
+
ast (2.4.2)
|
15
15
|
claide (1.0.3)
|
16
16
|
claide-plugins (0.9.2)
|
17
17
|
cork
|
18
18
|
nap
|
19
19
|
open4 (~> 1.3)
|
20
|
-
coderay (1.1.
|
20
|
+
coderay (1.1.3)
|
21
21
|
colored2 (3.1.2)
|
22
22
|
cork (0.3.0)
|
23
23
|
colored2 (~> 3.1)
|
24
|
-
danger (
|
24
|
+
danger (8.2.3)
|
25
25
|
claide (~> 1.0)
|
26
26
|
claide-plugins (>= 0.9.2)
|
27
27
|
colored2 (~> 3.1)
|
28
28
|
cork (~> 0.1)
|
29
|
-
faraday (
|
29
|
+
faraday (>= 0.9.0, < 2.0)
|
30
30
|
faraday-http-cache (~> 2.0)
|
31
|
-
git (~> 1.
|
32
|
-
kramdown (~> 2.
|
31
|
+
git (~> 1.7)
|
32
|
+
kramdown (~> 2.3)
|
33
33
|
kramdown-parser-gfm (~> 1.0)
|
34
34
|
no_proxy_fix
|
35
35
|
octokit (~> 4.7)
|
36
|
-
terminal-table (
|
36
|
+
terminal-table (>= 1, < 4)
|
37
37
|
danger-plugin-api (1.0.0)
|
38
38
|
danger (> 2.0)
|
39
|
-
diff-lcs (1.
|
40
|
-
faraday (
|
39
|
+
diff-lcs (1.4.4)
|
40
|
+
faraday (1.3.0)
|
41
|
+
faraday-net_http (~> 1.0)
|
41
42
|
multipart-post (>= 1.2, < 3)
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
ruby2_keywords
|
44
|
+
faraday-http-cache (2.2.0)
|
45
|
+
faraday (>= 0.8)
|
46
|
+
faraday-net_http (1.0.1)
|
47
|
+
ffi (1.15.0)
|
45
48
|
formatador (0.2.5)
|
46
|
-
git (1.
|
47
|
-
|
49
|
+
git (1.8.1)
|
50
|
+
rchardet (~> 1.8)
|
51
|
+
guard (2.16.2)
|
48
52
|
formatador (>= 0.2.4)
|
49
53
|
listen (>= 2.7, < 4.0)
|
50
54
|
lumberjack (>= 1.0.12, < 2.0)
|
@@ -58,15 +62,15 @@ GEM
|
|
58
62
|
guard (~> 2.1)
|
59
63
|
guard-compat (~> 1.1)
|
60
64
|
rspec (>= 2.99.0, < 4.0)
|
61
|
-
|
62
|
-
|
65
|
+
kramdown (2.3.1)
|
66
|
+
rexml
|
63
67
|
kramdown-parser-gfm (1.1.0)
|
64
68
|
kramdown (~> 2.0)
|
65
|
-
listen (3.0.
|
66
|
-
rb-fsevent (>= 0.9.
|
67
|
-
rb-inotify (>= 0.9.7)
|
68
|
-
lumberjack (1.
|
69
|
-
method_source (0.
|
69
|
+
listen (3.0.8)
|
70
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
71
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
72
|
+
lumberjack (1.2.8)
|
73
|
+
method_source (1.0.0)
|
70
74
|
multipart-post (2.1.1)
|
71
75
|
nap (1.1.0)
|
72
76
|
nenv (0.3.0)
|
@@ -74,72 +78,88 @@ GEM
|
|
74
78
|
notiffany (0.1.3)
|
75
79
|
nenv (~> 0.1)
|
76
80
|
shellany (~> 0.0)
|
77
|
-
octokit (4.
|
81
|
+
octokit (4.20.0)
|
82
|
+
faraday (>= 0.9)
|
78
83
|
sawyer (~> 0.8.0, >= 0.5.3)
|
79
84
|
oga (2.15)
|
80
85
|
ast
|
81
86
|
ruby-ll (~> 2.1)
|
82
87
|
open4 (1.3.4)
|
83
|
-
parallel (1.
|
84
|
-
parser (
|
85
|
-
ast (~> 2.4.
|
86
|
-
pry (0.
|
87
|
-
coderay (~> 1.1
|
88
|
-
method_source (~>
|
89
|
-
public_suffix (4.0.
|
88
|
+
parallel (1.20.1)
|
89
|
+
parser (3.0.0.0)
|
90
|
+
ast (~> 2.4.1)
|
91
|
+
pry (0.14.0)
|
92
|
+
coderay (~> 1.1)
|
93
|
+
method_source (~> 1.0)
|
94
|
+
public_suffix (4.0.6)
|
90
95
|
rainbow (3.0.0)
|
91
|
-
rake (
|
92
|
-
rb-fsevent (0.10.
|
96
|
+
rake (13.0.3)
|
97
|
+
rb-fsevent (0.10.4)
|
93
98
|
rb-inotify (0.10.1)
|
94
99
|
ffi (~> 1.0)
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
rspec-
|
101
|
-
|
100
|
+
rchardet (1.8.0)
|
101
|
+
regexp_parser (2.1.1)
|
102
|
+
rexml (3.2.4)
|
103
|
+
rspec (3.10.0)
|
104
|
+
rspec-core (~> 3.10.0)
|
105
|
+
rspec-expectations (~> 3.10.0)
|
106
|
+
rspec-mocks (~> 3.10.0)
|
107
|
+
rspec-core (3.10.1)
|
108
|
+
rspec-support (~> 3.10.0)
|
109
|
+
rspec-expectations (3.10.1)
|
102
110
|
diff-lcs (>= 1.2.0, < 2.0)
|
103
|
-
rspec-support (~> 3.
|
104
|
-
rspec-mocks (3.
|
111
|
+
rspec-support (~> 3.10.0)
|
112
|
+
rspec-mocks (3.10.2)
|
105
113
|
diff-lcs (>= 1.2.0, < 2.0)
|
106
|
-
rspec-support (~> 3.
|
107
|
-
rspec-support (3.
|
108
|
-
rubocop (
|
109
|
-
jaro_winkler (~> 1.5.1)
|
114
|
+
rspec-support (~> 3.10.0)
|
115
|
+
rspec-support (3.10.2)
|
116
|
+
rubocop (1.11.0)
|
110
117
|
parallel (~> 1.10)
|
111
|
-
parser (>=
|
118
|
+
parser (>= 3.0.0.0)
|
112
119
|
rainbow (>= 2.2.2, < 4.0)
|
120
|
+
regexp_parser (>= 1.8, < 3.0)
|
121
|
+
rexml
|
122
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
113
123
|
ruby-progressbar (~> 1.7)
|
114
|
-
unicode-display_width (>= 1.4.0, <
|
124
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
125
|
+
rubocop-ast (1.4.1)
|
126
|
+
parser (>= 2.7.1.5)
|
127
|
+
rubocop-rake (0.5.1)
|
128
|
+
rubocop
|
129
|
+
rubocop-rspec (2.2.0)
|
130
|
+
rubocop (~> 1.0)
|
131
|
+
rubocop-ast (>= 1.1.0)
|
115
132
|
ruby-ll (2.1.2)
|
116
133
|
ansi
|
117
134
|
ast
|
118
|
-
ruby-progressbar (1.
|
135
|
+
ruby-progressbar (1.11.0)
|
136
|
+
ruby2_keywords (0.0.4)
|
119
137
|
sawyer (0.8.2)
|
120
138
|
addressable (>= 2.3.5)
|
121
139
|
faraday (> 0.8, < 2.0)
|
122
140
|
shellany (0.0.1)
|
123
|
-
terminal-table (
|
141
|
+
terminal-table (3.0.0)
|
124
142
|
unicode-display_width (~> 1.1, >= 1.1.1)
|
125
|
-
thor (1.0
|
126
|
-
unicode-display_width (1.
|
127
|
-
yard (0.9.
|
143
|
+
thor (1.1.0)
|
144
|
+
unicode-display_width (1.7.0)
|
145
|
+
yard (0.9.26)
|
128
146
|
|
129
147
|
PLATFORMS
|
130
148
|
ruby
|
131
149
|
|
132
150
|
DEPENDENCIES
|
133
|
-
bundler (~>
|
151
|
+
bundler (~> 2.0)
|
134
152
|
danger-pmd!
|
135
|
-
guard (~> 2.
|
136
|
-
guard-rspec (~> 4.7)
|
137
|
-
listen (
|
138
|
-
pry
|
139
|
-
rake (~>
|
140
|
-
rspec (~> 3.
|
141
|
-
rubocop (~> 0
|
142
|
-
|
153
|
+
guard (~> 2.16.2)
|
154
|
+
guard-rspec (~> 4.7.3)
|
155
|
+
listen (~> 3.0.8)
|
156
|
+
pry (~> 0.14.0)
|
157
|
+
rake (~> 13.0)
|
158
|
+
rspec (~> 3.10.0)
|
159
|
+
rubocop (~> 1.11.0)
|
160
|
+
rubocop-rake (~> 0.5.1)
|
161
|
+
rubocop-rspec (~> 2.2.0)
|
162
|
+
yard (~> 0.9.26)
|
143
163
|
|
144
164
|
BUNDLED WITH
|
145
|
-
|
165
|
+
2.2.14
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 Mathieu Rul <mathroule@gmail.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Danger PMD
|
2
2
|
|
3
|
-
|
3
|
+
Checks on your Gradle project's Java source files.
|
4
|
+
This is done using [PMD](https://pmd.github.io)
|
5
|
+
Results are passed out as tables in markdown.
|
6
|
+
|
7
|
+
This plugin is inspired from https://github.com/kazy1991/danger-findbugs.
|
4
8
|
|
5
9
|
## Installation
|
6
10
|
|
@@ -12,31 +16,38 @@ Danger plugin for PMD formatted xml file. This plugin is inspired from https://g
|
|
12
16
|
your `Dangerfile` under the `pmd` namespace.
|
13
17
|
|
14
18
|
<blockquote>Running PMD with its basic configuration
|
15
|
-
<pre>
|
19
|
+
<pre>
|
20
|
+
pmd.report
|
21
|
+
</pre>
|
22
|
+
</blockquote>
|
23
|
+
|
24
|
+
<blockquote>Running PMD with a specific Gradle task or report file (glob accepted)
|
25
|
+
<pre>
|
26
|
+
pmd.gradle_task = 'app:pmd' # default: pmd
|
27
|
+
pmd.report_file = 'module/build/reports/pmd/pmd.xml' # default: app/build/reports/pmd/pmd.xml
|
16
28
|
pmd.report
|
17
|
-
</pre>
|
29
|
+
</pre>
|
18
30
|
</blockquote>
|
19
31
|
|
20
|
-
<blockquote>Running PMD with a specific
|
21
|
-
<pre>
|
22
|
-
pmd.
|
23
|
-
pmd.report_file = "app/build/reports/pmd/pmd.xml"
|
32
|
+
<blockquote>Running PMD with a specific root path
|
33
|
+
<pre>
|
34
|
+
pmd.root_path = '/Users/developer/project'
|
24
35
|
pmd.report
|
25
|
-
</pre>
|
36
|
+
</pre>
|
26
37
|
</blockquote>
|
27
38
|
|
28
|
-
<blockquote>Running PMD with an array of report files
|
29
|
-
<pre>
|
30
|
-
pmd.report_files = [
|
39
|
+
<blockquote>Running PMD with an array of report files (glob accepted)
|
40
|
+
<pre>
|
41
|
+
pmd.report_files = ['modules/**/build/reports/pmd/pmd.xml', 'app/build/reports/pmd/pmd.xml']
|
31
42
|
pmd.report
|
32
|
-
</pre>
|
43
|
+
</pre>
|
33
44
|
</blockquote>
|
34
45
|
|
35
46
|
<blockquote>Running PMD without running a Gradle task
|
36
|
-
<pre>
|
47
|
+
<pre>
|
37
48
|
pmd.skip_gradle_task = true
|
38
49
|
pmd.report
|
39
|
-
</pre>
|
50
|
+
</pre>
|
40
51
|
</blockquote>
|
41
52
|
|
42
53
|
#### Attributes
|
@@ -47,24 +58,26 @@ Defaults to "pmd".
|
|
47
58
|
|
48
59
|
`skip_gradle_task` - Skip Gradle task.
|
49
60
|
If you skip Gradle task, for example project does not manage Gradle.
|
61
|
+
Defaults to `false`.
|
50
62
|
|
51
|
-
`root_path` -
|
52
|
-
|
63
|
+
`root_path` - An absolute path to a root.
|
64
|
+
To comment errors to VCS, this needs to know relative path of files from the root.
|
53
65
|
Defaults to result of "git rev-parse --show-toplevel".
|
54
66
|
|
55
|
-
`report_file` - Location of report file
|
67
|
+
`report_file` - Location of report file.
|
56
68
|
If your pmd task outputs to a different location, you can specify it here.
|
57
69
|
Defaults to "app/build/reports/pmd/pmd.xml".
|
58
70
|
|
59
|
-
`report_files` - Location of report files
|
71
|
+
`report_files` - Location of report files.
|
60
72
|
If your pmd task outputs to a different location, you can specify it here.
|
61
|
-
Defaults to [
|
73
|
+
Defaults to ['app/build/reports/pmd/pmd.xml'].
|
62
74
|
|
63
75
|
#### Methods
|
64
76
|
|
65
|
-
`report` - Calls PMD task of your Gradle project
|
77
|
+
`report` - Calls PMD task of your Gradle project.
|
66
78
|
It fails if `gradlew` cannot be found inside current directory.
|
67
|
-
It fails if `report_file`
|
79
|
+
It fails if `report_file` cannot be found inside current directory.
|
80
|
+
It fails if `report_files` is empty.
|
68
81
|
|
69
82
|
`gradle_task` - A getter for `gradle_task`, returning Gradle task report.
|
70
83
|
|
data/danger-pmd.gemspec
CHANGED
@@ -4,40 +4,42 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'pmd/gem_version.rb'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
11
|
-
spec.description
|
12
|
-
spec.summary
|
13
|
-
spec.homepage
|
14
|
-
spec.license
|
15
|
-
|
16
|
-
spec.files
|
17
|
-
spec.executables
|
18
|
-
spec.test_files
|
7
|
+
spec.name = 'danger-pmd'
|
8
|
+
spec.version = Pmd::VERSION
|
9
|
+
spec.authors = ['Mathieu Rul']
|
10
|
+
spec.email = ['mathroule@gmail.com']
|
11
|
+
spec.description = 'A Danger plugin for PMD.'
|
12
|
+
spec.summary = 'A Danger plugin for PMD (Programming Mistake Detector), see https://pmd.github.io.'
|
13
|
+
spec.homepage = 'https://github.com/mathroule/danger-pmd'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
21
|
spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
|
22
|
-
spec.add_runtime_dependency 'oga', '~> 2.
|
22
|
+
spec.add_runtime_dependency 'oga', '~> 2.15'
|
23
23
|
|
24
24
|
# General ruby development
|
25
|
-
spec.add_development_dependency 'bundler', '~>
|
26
|
-
spec.add_development_dependency 'rake', '~>
|
25
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
26
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
27
27
|
|
28
28
|
# Testing support
|
29
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.10.0'
|
30
30
|
|
31
31
|
# Linting code and docs
|
32
|
-
spec.add_development_dependency 'rubocop', '~> 0
|
33
|
-
spec.add_development_dependency '
|
32
|
+
spec.add_development_dependency 'rubocop', '~> 1.11.0'
|
33
|
+
spec.add_development_dependency 'rubocop-rake', '~> 0.5.1'
|
34
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.2.0'
|
35
|
+
spec.add_development_dependency 'yard', '~> 0.9.26'
|
34
36
|
|
35
37
|
# Makes testing easy via `bundle exec guard`
|
36
|
-
spec.add_development_dependency 'guard', '~> 2.
|
37
|
-
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
38
|
+
spec.add_development_dependency 'guard', '~> 2.16.2'
|
39
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7.3'
|
38
40
|
|
39
41
|
# If you want to work on older builds of ruby
|
40
|
-
spec.add_development_dependency 'listen', '3.0.
|
42
|
+
spec.add_development_dependency 'listen', '~> 3.0.8'
|
41
43
|
|
42
44
|
# This gives you the chance to run a REPL inside your tests
|
43
45
|
# via:
|
@@ -46,5 +48,5 @@ Gem::Specification.new do |spec|
|
|
46
48
|
# binding.pry
|
47
49
|
#
|
48
50
|
# This will stop test execution and let you inspect the results
|
49
|
-
spec.add_development_dependency 'pry'
|
51
|
+
spec.add_development_dependency 'pry', '~> 0.14.0'
|
50
52
|
end
|
data/lib/danger_plugin.rb
CHANGED
data/lib/danger_pmd.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Represent a PMD file.
|
3
4
|
class PmdFile
|
4
|
-
require_relative
|
5
|
+
require_relative './pmd_violation'
|
5
6
|
|
6
7
|
attr_accessor :file
|
7
8
|
|
@@ -17,23 +18,19 @@ class PmdFile
|
|
17
18
|
|
18
19
|
def initialize(prefix, file)
|
19
20
|
@file = file
|
20
|
-
@absolute_path = file.attribute(
|
21
|
+
@absolute_path = file.attribute('name').value.to_s
|
21
22
|
|
22
|
-
|
23
|
-
@prefix = prefix
|
24
|
-
else
|
25
|
-
@prefix = prefix + file_separator
|
26
|
-
end
|
23
|
+
@prefix = prefix + (prefix.end_with?(file_separator) ? '' : file_separator)
|
27
24
|
|
28
|
-
if @absolute_path.start_with?(@prefix)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
@relative_path = if @absolute_path.start_with?(@prefix)
|
26
|
+
@absolute_path[@prefix.length, @absolute_path.length - @prefix.length]
|
27
|
+
else
|
28
|
+
@absolute_path
|
29
|
+
end
|
33
30
|
end
|
34
31
|
|
35
32
|
def violations
|
36
|
-
@violations ||= file.xpath(
|
33
|
+
@violations ||= file.xpath('violation').map do |pmd_violation|
|
37
34
|
PmdViolation.new(pmd_violation)
|
38
35
|
end
|
39
36
|
end
|