danger-phpmd 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.rubocop.yml +148 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +164 -0
- data/Guardfile +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +20 -0
- data/Rakefile +25 -0
- data/danger-phpmd.gemspec +50 -0
- data/lib/danger_phpmd.rb +3 -0
- data/lib/danger_plugin.rb +3 -0
- data/lib/phpmd/gem_version.rb +5 -0
- data/lib/phpmd/plugin.rb +64 -0
- data/spec/phpmd_spec.rb +47 -0
- data/spec/spec_helper.rb +67 -0
- metadata +200 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2efd89cd349c6125c7d8084c72c6c8a162dd8bd2411b19162275cff1c2ccecc9
|
|
4
|
+
data.tar.gz: d32b6626f470ac5b1627a4e41c0173cff7edbef9d2752fca301085bb89159732
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7332d278d2bdb0051ec433b2987f75a13f982bdf977f80a41d3b354fb811f1eaa6864293ccdc9d82fbc00bd71673771385ddd9623f93b42051ff778d2cefcfa9
|
|
7
|
+
data.tar.gz: f649bb361c793116c79e175be9f939b3fad953cfe33f431e354a92d6c420270ea27949a09319471a5c8e5c5298cbb1d4864439c78f6b7fcde7e485837f895613
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Defaults can be found here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
|
|
2
|
+
|
|
3
|
+
# If you don't like these settings, just delete this file :)
|
|
4
|
+
|
|
5
|
+
AllCops:
|
|
6
|
+
TargetRubyVersion: 2.6
|
|
7
|
+
|
|
8
|
+
Style/StringLiterals:
|
|
9
|
+
EnforcedStyle: double_quotes
|
|
10
|
+
Enabled: true
|
|
11
|
+
|
|
12
|
+
# kind_of? is a good way to check a type
|
|
13
|
+
Style/ClassCheck:
|
|
14
|
+
EnforcedStyle: kind_of?
|
|
15
|
+
|
|
16
|
+
# specs sometimes have useless assignments, which is fine
|
|
17
|
+
Lint/UselessAssignment:
|
|
18
|
+
Exclude:
|
|
19
|
+
- '**/spec/**/*'
|
|
20
|
+
|
|
21
|
+
# We could potentially enable the 2 below:
|
|
22
|
+
Layout/FirstHashElementIndentation:
|
|
23
|
+
Enabled: false
|
|
24
|
+
|
|
25
|
+
Layout/HashAlignment:
|
|
26
|
+
Enabled: false
|
|
27
|
+
|
|
28
|
+
# HoundCI doesn't like this rule
|
|
29
|
+
Layout/DotPosition:
|
|
30
|
+
Enabled: false
|
|
31
|
+
|
|
32
|
+
# We allow !! as it's an easy way to convert ot boolean
|
|
33
|
+
Style/DoubleNegation:
|
|
34
|
+
Enabled: false
|
|
35
|
+
|
|
36
|
+
# Cop supports --auto-correct.
|
|
37
|
+
Lint/UnusedBlockArgument:
|
|
38
|
+
Enabled: false
|
|
39
|
+
|
|
40
|
+
# We want to allow class Fastlane::Class
|
|
41
|
+
Style/ClassAndModuleChildren:
|
|
42
|
+
Enabled: false
|
|
43
|
+
|
|
44
|
+
Metrics/AbcSize:
|
|
45
|
+
Max: 60
|
|
46
|
+
|
|
47
|
+
# The %w might be confusing for new users
|
|
48
|
+
Style/WordArray:
|
|
49
|
+
MinSize: 19
|
|
50
|
+
|
|
51
|
+
# raise and fail are both okay
|
|
52
|
+
Style/SignalException:
|
|
53
|
+
Enabled: false
|
|
54
|
+
|
|
55
|
+
# Better too much 'return' than one missing
|
|
56
|
+
Style/RedundantReturn:
|
|
57
|
+
Enabled: false
|
|
58
|
+
|
|
59
|
+
# Having if in the same line might not always be good
|
|
60
|
+
Style/IfUnlessModifier:
|
|
61
|
+
Enabled: false
|
|
62
|
+
|
|
63
|
+
# and and or is okay
|
|
64
|
+
Style/AndOr:
|
|
65
|
+
Enabled: false
|
|
66
|
+
|
|
67
|
+
# Configuration parameters: CountComments.
|
|
68
|
+
Metrics/ClassLength:
|
|
69
|
+
Max: 350
|
|
70
|
+
|
|
71
|
+
Metrics/CyclomaticComplexity:
|
|
72
|
+
Max: 17
|
|
73
|
+
|
|
74
|
+
# Configuration parameters: AllowURI, URISchemes.
|
|
75
|
+
Layout/LineLength:
|
|
76
|
+
Max: 370
|
|
77
|
+
|
|
78
|
+
# Configuration parameters: CountKeywordArgs.
|
|
79
|
+
Metrics/ParameterLists:
|
|
80
|
+
Max: 10
|
|
81
|
+
|
|
82
|
+
Metrics/PerceivedComplexity:
|
|
83
|
+
Max: 18
|
|
84
|
+
|
|
85
|
+
# Sometimes it's easier to read without guards
|
|
86
|
+
Style/GuardClause:
|
|
87
|
+
Enabled: false
|
|
88
|
+
|
|
89
|
+
# something = if something_else
|
|
90
|
+
# that's confusing
|
|
91
|
+
Style/ConditionalAssignment:
|
|
92
|
+
Enabled: false
|
|
93
|
+
|
|
94
|
+
# Better to have too much self than missing a self
|
|
95
|
+
Style/RedundantSelf:
|
|
96
|
+
Enabled: false
|
|
97
|
+
|
|
98
|
+
Metrics/MethodLength:
|
|
99
|
+
Max: 60
|
|
100
|
+
|
|
101
|
+
# We're not there yet
|
|
102
|
+
Style/Documentation:
|
|
103
|
+
Enabled: false
|
|
104
|
+
|
|
105
|
+
# Adds complexity
|
|
106
|
+
Style/IfInsideElse:
|
|
107
|
+
Enabled: false
|
|
108
|
+
|
|
109
|
+
# danger specific
|
|
110
|
+
|
|
111
|
+
Style/BlockComments:
|
|
112
|
+
Enabled: false
|
|
113
|
+
|
|
114
|
+
Layout/MultilineMethodCallIndentation:
|
|
115
|
+
EnforcedStyle: indented
|
|
116
|
+
|
|
117
|
+
# FIXME: 25
|
|
118
|
+
Metrics/BlockLength:
|
|
119
|
+
Max: 345
|
|
120
|
+
Exclude:
|
|
121
|
+
- "**/*_spec.rb"
|
|
122
|
+
|
|
123
|
+
Style/MixinGrouping:
|
|
124
|
+
Enabled: false
|
|
125
|
+
|
|
126
|
+
Naming/FileName:
|
|
127
|
+
Enabled: false
|
|
128
|
+
|
|
129
|
+
Layout/HeredocIndentation:
|
|
130
|
+
Enabled: false
|
|
131
|
+
|
|
132
|
+
Style/SpecialGlobalVars:
|
|
133
|
+
Enabled: false
|
|
134
|
+
|
|
135
|
+
Style/PercentLiteralDelimiters:
|
|
136
|
+
PreferredDelimiters:
|
|
137
|
+
"%": ()
|
|
138
|
+
"%i": ()
|
|
139
|
+
"%q": ()
|
|
140
|
+
"%Q": ()
|
|
141
|
+
"%r": "{}"
|
|
142
|
+
"%s": ()
|
|
143
|
+
"%w": ()
|
|
144
|
+
"%W": ()
|
|
145
|
+
"%x": ()
|
|
146
|
+
|
|
147
|
+
Security/YAMLLoad:
|
|
148
|
+
Enabled: false
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
danger-phpmd (0.0.1)
|
|
5
|
+
danger-plugin-api (~> 1.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
addressable (2.8.0)
|
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
12
|
+
ast (2.4.2)
|
|
13
|
+
claide (1.0.3)
|
|
14
|
+
claide-plugins (0.9.2)
|
|
15
|
+
cork
|
|
16
|
+
nap
|
|
17
|
+
open4 (~> 1.3)
|
|
18
|
+
coderay (1.1.3)
|
|
19
|
+
colored2 (3.1.2)
|
|
20
|
+
cork (0.3.0)
|
|
21
|
+
colored2 (~> 3.1)
|
|
22
|
+
danger (8.4.1)
|
|
23
|
+
claide (~> 1.0)
|
|
24
|
+
claide-plugins (>= 0.9.2)
|
|
25
|
+
colored2 (~> 3.1)
|
|
26
|
+
cork (~> 0.1)
|
|
27
|
+
faraday (>= 0.9.0, < 2.0)
|
|
28
|
+
faraday-http-cache (~> 2.0)
|
|
29
|
+
git (~> 1.7)
|
|
30
|
+
kramdown (~> 2.3)
|
|
31
|
+
kramdown-parser-gfm (~> 1.0)
|
|
32
|
+
no_proxy_fix
|
|
33
|
+
octokit (~> 4.7)
|
|
34
|
+
terminal-table (>= 1, < 4)
|
|
35
|
+
danger-plugin-api (1.0.0)
|
|
36
|
+
danger (> 2.0)
|
|
37
|
+
diff-lcs (1.4.4)
|
|
38
|
+
faraday (1.8.0)
|
|
39
|
+
faraday-em_http (~> 1.0)
|
|
40
|
+
faraday-em_synchrony (~> 1.0)
|
|
41
|
+
faraday-excon (~> 1.1)
|
|
42
|
+
faraday-httpclient (~> 1.0.1)
|
|
43
|
+
faraday-net_http (~> 1.0)
|
|
44
|
+
faraday-net_http_persistent (~> 1.1)
|
|
45
|
+
faraday-patron (~> 1.0)
|
|
46
|
+
faraday-rack (~> 1.0)
|
|
47
|
+
multipart-post (>= 1.2, < 3)
|
|
48
|
+
ruby2_keywords (>= 0.0.4)
|
|
49
|
+
faraday-em_http (1.0.0)
|
|
50
|
+
faraday-em_synchrony (1.0.0)
|
|
51
|
+
faraday-excon (1.1.0)
|
|
52
|
+
faraday-http-cache (2.2.0)
|
|
53
|
+
faraday (>= 0.8)
|
|
54
|
+
faraday-httpclient (1.0.1)
|
|
55
|
+
faraday-net_http (1.0.1)
|
|
56
|
+
faraday-net_http_persistent (1.2.0)
|
|
57
|
+
faraday-patron (1.0.0)
|
|
58
|
+
faraday-rack (1.0.0)
|
|
59
|
+
ffi (1.15.4)
|
|
60
|
+
formatador (0.3.0)
|
|
61
|
+
git (1.9.1)
|
|
62
|
+
rchardet (~> 1.8)
|
|
63
|
+
guard (2.18.0)
|
|
64
|
+
formatador (>= 0.2.4)
|
|
65
|
+
listen (>= 2.7, < 4.0)
|
|
66
|
+
lumberjack (>= 1.0.12, < 2.0)
|
|
67
|
+
nenv (~> 0.1)
|
|
68
|
+
notiffany (~> 0.0)
|
|
69
|
+
pry (>= 0.13.0)
|
|
70
|
+
shellany (~> 0.0)
|
|
71
|
+
thor (>= 0.18.1)
|
|
72
|
+
guard-compat (1.2.1)
|
|
73
|
+
guard-rspec (4.7.3)
|
|
74
|
+
guard (~> 2.1)
|
|
75
|
+
guard-compat (~> 1.1)
|
|
76
|
+
rspec (>= 2.99.0, < 4.0)
|
|
77
|
+
kramdown (2.3.1)
|
|
78
|
+
rexml
|
|
79
|
+
kramdown-parser-gfm (1.1.0)
|
|
80
|
+
kramdown (~> 2.0)
|
|
81
|
+
listen (3.0.7)
|
|
82
|
+
rb-fsevent (>= 0.9.3)
|
|
83
|
+
rb-inotify (>= 0.9.7)
|
|
84
|
+
lumberjack (1.2.8)
|
|
85
|
+
method_source (1.0.0)
|
|
86
|
+
multipart-post (2.1.1)
|
|
87
|
+
nap (1.1.0)
|
|
88
|
+
nenv (0.3.0)
|
|
89
|
+
no_proxy_fix (0.1.2)
|
|
90
|
+
notiffany (0.1.3)
|
|
91
|
+
nenv (~> 0.1)
|
|
92
|
+
shellany (~> 0.0)
|
|
93
|
+
octokit (4.21.0)
|
|
94
|
+
faraday (>= 0.9)
|
|
95
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
|
96
|
+
open4 (1.3.4)
|
|
97
|
+
parallel (1.21.0)
|
|
98
|
+
parser (3.0.2.0)
|
|
99
|
+
ast (~> 2.4.1)
|
|
100
|
+
pry (0.14.1)
|
|
101
|
+
coderay (~> 1.1)
|
|
102
|
+
method_source (~> 1.0)
|
|
103
|
+
public_suffix (4.0.6)
|
|
104
|
+
rainbow (3.0.0)
|
|
105
|
+
rake (13.0.6)
|
|
106
|
+
rb-fsevent (0.11.0)
|
|
107
|
+
rb-inotify (0.10.1)
|
|
108
|
+
ffi (~> 1.0)
|
|
109
|
+
rchardet (1.8.0)
|
|
110
|
+
regexp_parser (2.1.1)
|
|
111
|
+
rexml (3.2.5)
|
|
112
|
+
rspec (3.10.0)
|
|
113
|
+
rspec-core (~> 3.10.0)
|
|
114
|
+
rspec-expectations (~> 3.10.0)
|
|
115
|
+
rspec-mocks (~> 3.10.0)
|
|
116
|
+
rspec-core (3.10.1)
|
|
117
|
+
rspec-support (~> 3.10.0)
|
|
118
|
+
rspec-expectations (3.10.1)
|
|
119
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
120
|
+
rspec-support (~> 3.10.0)
|
|
121
|
+
rspec-mocks (3.10.2)
|
|
122
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
123
|
+
rspec-support (~> 3.10.0)
|
|
124
|
+
rspec-support (3.10.3)
|
|
125
|
+
rubocop (1.22.3)
|
|
126
|
+
parallel (~> 1.10)
|
|
127
|
+
parser (>= 3.0.0.0)
|
|
128
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
129
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
130
|
+
rexml
|
|
131
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
|
132
|
+
ruby-progressbar (~> 1.7)
|
|
133
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
134
|
+
rubocop-ast (1.12.0)
|
|
135
|
+
parser (>= 3.0.1.1)
|
|
136
|
+
ruby-progressbar (1.11.0)
|
|
137
|
+
ruby2_keywords (0.0.5)
|
|
138
|
+
sawyer (0.8.2)
|
|
139
|
+
addressable (>= 2.3.5)
|
|
140
|
+
faraday (> 0.8, < 2.0)
|
|
141
|
+
shellany (0.0.1)
|
|
142
|
+
terminal-table (3.0.2)
|
|
143
|
+
unicode-display_width (>= 1.1.1, < 3)
|
|
144
|
+
thor (1.1.0)
|
|
145
|
+
unicode-display_width (2.1.0)
|
|
146
|
+
yard (0.9.26)
|
|
147
|
+
|
|
148
|
+
PLATFORMS
|
|
149
|
+
ruby
|
|
150
|
+
|
|
151
|
+
DEPENDENCIES
|
|
152
|
+
bundler (~> 2.0)
|
|
153
|
+
danger-phpmd!
|
|
154
|
+
guard (~> 2.14)
|
|
155
|
+
guard-rspec (~> 4.7)
|
|
156
|
+
listen (= 3.0.7)
|
|
157
|
+
pry
|
|
158
|
+
rake (~> 13.0)
|
|
159
|
+
rspec (~> 3.4)
|
|
160
|
+
rubocop
|
|
161
|
+
yard
|
|
162
|
+
|
|
163
|
+
BUNDLED WITH
|
|
164
|
+
2.1.4
|
data/Guardfile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# A guardfile for making Danger Plugins
|
|
4
|
+
# For more info see https://github.com/guard/guard#readme
|
|
5
|
+
|
|
6
|
+
# To run, use `bundle exec guard`.
|
|
7
|
+
|
|
8
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
|
9
|
+
require "guard/rspec/dsl"
|
|
10
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
|
11
|
+
|
|
12
|
+
# RSpec files
|
|
13
|
+
rspec = dsl.rspec
|
|
14
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
|
15
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
|
16
|
+
watch(rspec.spec_files)
|
|
17
|
+
|
|
18
|
+
# Ruby files
|
|
19
|
+
ruby = dsl.ruby
|
|
20
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
|
21
|
+
end
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2021 Kyosuke Takayama <loiseau@gmail.com>
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# danger-phpmd
|
|
2
|
+
|
|
3
|
+
[Danger](http://danger.systems/ruby/) plugin for [phpmd](https://phpmd.org/).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
$ gem install danger-phpmd
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
<blockquote>Run phpmd and send warn comment.
|
|
12
|
+
<pre>
|
|
13
|
+
phpmd.phpmd_path = "vendor/bin/phpmd"
|
|
14
|
+
phpmd.config_path = "rulesets.xml"
|
|
15
|
+
phpmd.run
|
|
16
|
+
</pre>
|
|
17
|
+
</blockquote>
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "rspec/core/rake_task"
|
|
5
|
+
require "rubocop/rake_task"
|
|
6
|
+
|
|
7
|
+
RSpec::Core::RakeTask.new(:specs)
|
|
8
|
+
|
|
9
|
+
task default: :specs
|
|
10
|
+
|
|
11
|
+
task :spec do
|
|
12
|
+
Rake::Task["specs"].invoke
|
|
13
|
+
Rake::Task["rubocop"].invoke
|
|
14
|
+
Rake::Task["spec_docs"].invoke
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc "Run RuboCop on the lib/specs directory"
|
|
18
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
|
19
|
+
task.patterns = ["lib/**/*.rb", "spec/**/*.rb"]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
desc "Ensure that the plugin passes `danger plugins lint`"
|
|
23
|
+
task :spec_docs do
|
|
24
|
+
sh "bundle exec danger plugins lint"
|
|
25
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
require "phpmd/gem_version"
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |spec|
|
|
8
|
+
spec.name = "danger-phpmd"
|
|
9
|
+
spec.version = Phpmd::VERSION
|
|
10
|
+
spec.authors = ["Kyosuke Takayama"]
|
|
11
|
+
spec.email = ["loiseau@gmail.com"]
|
|
12
|
+
spec.description = "Danger plugin for PHPMD."
|
|
13
|
+
spec.summary = "Danger plugin for PHPMD."
|
|
14
|
+
spec.homepage = "https://github.com/ktakayama/danger-phpmd"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files`.split($/)
|
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
20
|
+
spec.require_paths = ["lib"]
|
|
21
|
+
|
|
22
|
+
spec.add_runtime_dependency "danger-plugin-api", "~> 1.0"
|
|
23
|
+
|
|
24
|
+
# General ruby development
|
|
25
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
|
26
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
|
27
|
+
|
|
28
|
+
# Testing support
|
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.4"
|
|
30
|
+
|
|
31
|
+
# Linting code and docs
|
|
32
|
+
spec.add_development_dependency "rubocop"
|
|
33
|
+
spec.add_development_dependency "yard"
|
|
34
|
+
|
|
35
|
+
# Makes testing easy via `bundle exec guard`
|
|
36
|
+
spec.add_development_dependency "guard", "~> 2.14"
|
|
37
|
+
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
|
38
|
+
|
|
39
|
+
# If you want to work on older builds of ruby
|
|
40
|
+
spec.add_development_dependency "listen", "3.0.7"
|
|
41
|
+
|
|
42
|
+
# This gives you the chance to run a REPL inside your tests
|
|
43
|
+
# via:
|
|
44
|
+
#
|
|
45
|
+
# require 'pry'
|
|
46
|
+
# binding.pry
|
|
47
|
+
#
|
|
48
|
+
# This will stop test execution and let you inspect the results
|
|
49
|
+
spec.add_development_dependency "pry"
|
|
50
|
+
end
|
data/lib/danger_phpmd.rb
ADDED
data/lib/phpmd/plugin.rb
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
require "open3"
|
|
5
|
+
|
|
6
|
+
module Danger
|
|
7
|
+
# [Danger](http://danger.systems/ruby/) plugin for [phpmd](https://phpmd.org/).
|
|
8
|
+
#
|
|
9
|
+
# @example Run phpmd and send warn comment.
|
|
10
|
+
#
|
|
11
|
+
# phpmd.phpmd_path = "vendor/bin/phpmd"
|
|
12
|
+
# phpmd.config_path = "rulesets.xml"
|
|
13
|
+
# phpmd.run
|
|
14
|
+
#
|
|
15
|
+
# @see ktakayama/danger-phpmd
|
|
16
|
+
# @tags phpmd
|
|
17
|
+
#
|
|
18
|
+
class DangerPhpmd < Plugin
|
|
19
|
+
# phpmd path
|
|
20
|
+
# @return [String]
|
|
21
|
+
attr_accessor :phpmd_path
|
|
22
|
+
|
|
23
|
+
# phpmd.xml path
|
|
24
|
+
# @return [String]
|
|
25
|
+
attr_accessor :config_path
|
|
26
|
+
|
|
27
|
+
# Execute phpmd
|
|
28
|
+
# @return [void]
|
|
29
|
+
def run
|
|
30
|
+
return if target_files.empty?
|
|
31
|
+
cmd = phpmd_path || "phpmd"
|
|
32
|
+
json,e,s = Open3.capture3(cmd, target_files.join(","), "json", config_path)
|
|
33
|
+
results = parse(json)
|
|
34
|
+
results.each do |result|
|
|
35
|
+
warn(result[:message], file: result[:file], line: result[:line])
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def parse(json)
|
|
42
|
+
array = JSON.parse json
|
|
43
|
+
return if array.empty?
|
|
44
|
+
path = "#{Dir.pwd}/"
|
|
45
|
+
|
|
46
|
+
results = []
|
|
47
|
+
array['files'].each do |line|
|
|
48
|
+
file = line['file'].sub(path, "")
|
|
49
|
+
line['violations'].each do |violation|
|
|
50
|
+
results << {
|
|
51
|
+
message: violation['description'],
|
|
52
|
+
file: file,
|
|
53
|
+
line: violation['beginLine']
|
|
54
|
+
}
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
results
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def target_files
|
|
61
|
+
(git.added_files + (git.modified_files - git.deleted_files))
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
data/spec/phpmd_spec.rb
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.expand_path("spec_helper", __dir__)
|
|
4
|
+
|
|
5
|
+
module Danger
|
|
6
|
+
describe Danger::DangerPhpmd do
|
|
7
|
+
it "should be a plugin" do
|
|
8
|
+
expect(Danger::DangerPhpmd.new(nil)).to be_a Danger::Plugin
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
# You should test your custom attributes and methods here
|
|
13
|
+
#
|
|
14
|
+
describe "with Dangerfile" do
|
|
15
|
+
before do
|
|
16
|
+
@dangerfile = testing_dangerfile
|
|
17
|
+
@my_plugin = @dangerfile.phpmd
|
|
18
|
+
|
|
19
|
+
# mock the PR data
|
|
20
|
+
# you can then use this, eg. github.pr_author, later in the spec
|
|
21
|
+
json = File.read("#{File.dirname(__FILE__)}/support/fixtures/github_pr.json") # example json: `curl https://api.github.com/repos/danger/danger-plugin-template/pulls/18 > github_pr.json`
|
|
22
|
+
allow(@my_plugin.github).to receive(:pr_json).and_return(json)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Some examples for writing tests
|
|
26
|
+
# You should replace these with your own.
|
|
27
|
+
|
|
28
|
+
it "Warns on a monday" do
|
|
29
|
+
monday_date = Date.parse("2016-07-11")
|
|
30
|
+
allow(Date).to receive(:today).and_return monday_date
|
|
31
|
+
|
|
32
|
+
@my_plugin.warn_on_mondays
|
|
33
|
+
|
|
34
|
+
expect(@dangerfile.status_report[:warnings]).to eq(["Trying to merge code on a Monday"])
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "Does nothing on a tuesday" do
|
|
38
|
+
monday_date = Date.parse("2016-07-12")
|
|
39
|
+
allow(Date).to receive(:today).and_return monday_date
|
|
40
|
+
|
|
41
|
+
@my_plugin.warn_on_mondays
|
|
42
|
+
|
|
43
|
+
expect(@dangerfile.status_report[:warnings]).to eq([])
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "pathname"
|
|
4
|
+
ROOT = Pathname.new(File.expand_path("..", __dir__))
|
|
5
|
+
$:.unshift("#{ROOT}lib".to_s)
|
|
6
|
+
$:.unshift("#{ROOT}spec".to_s)
|
|
7
|
+
|
|
8
|
+
require "bundler/setup"
|
|
9
|
+
require "pry"
|
|
10
|
+
|
|
11
|
+
require "rspec"
|
|
12
|
+
require "danger"
|
|
13
|
+
|
|
14
|
+
if `git remote -v` == ""
|
|
15
|
+
puts "You cannot run tests without setting a local git remote on this repo"
|
|
16
|
+
puts "It's a weird side-effect of Danger's internals."
|
|
17
|
+
exit(0)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Use coloured output, it's the best.
|
|
21
|
+
RSpec.configure do |config|
|
|
22
|
+
config.filter_gems_from_backtrace "bundler"
|
|
23
|
+
config.color = true
|
|
24
|
+
config.tty = true
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
require "danger_plugin"
|
|
28
|
+
|
|
29
|
+
# These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
|
|
30
|
+
# If you are expanding these files, see if it's already been done ^.
|
|
31
|
+
|
|
32
|
+
# A silent version of the user interface,
|
|
33
|
+
# it comes with an extra function `.string` which will
|
|
34
|
+
# strip all ANSI colours from the string.
|
|
35
|
+
|
|
36
|
+
# rubocop:disable Lint/NestedMethodDefinition
|
|
37
|
+
def testing_ui
|
|
38
|
+
@output = StringIO.new
|
|
39
|
+
def @output.winsize
|
|
40
|
+
[20, 9999]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
cork = Cork::Board.new(out: @output)
|
|
44
|
+
def cork.string
|
|
45
|
+
out.string.gsub(/\e\[([;\d]+)?m/, "")
|
|
46
|
+
end
|
|
47
|
+
cork
|
|
48
|
+
end
|
|
49
|
+
# rubocop:enable Lint/NestedMethodDefinition
|
|
50
|
+
|
|
51
|
+
# Example environment (ENV) that would come from
|
|
52
|
+
# running a PR on TravisCI
|
|
53
|
+
def testing_env
|
|
54
|
+
{
|
|
55
|
+
"HAS_JOSH_K_SEAL_OF_APPROVAL" => "true",
|
|
56
|
+
"TRAVIS_PULL_REQUEST" => "800",
|
|
57
|
+
"TRAVIS_REPO_SLUG" => "artsy/eigen",
|
|
58
|
+
"TRAVIS_COMMIT_RANGE" => "759adcbd0d8f...13c4dc8bb61d",
|
|
59
|
+
"DANGER_GITHUB_API_TOKEN" => "123sbdq54erfsd3422gdfio"
|
|
60
|
+
}
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# A stubbed out Dangerfile for use in tests
|
|
64
|
+
def testing_dangerfile
|
|
65
|
+
env = Danger::EnvironmentManager.new(testing_env)
|
|
66
|
+
Danger::Dangerfile.new(env, testing_ui)
|
|
67
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: danger-phpmd
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Kyosuke Takayama
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2021-11-05 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: danger-plugin-api
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bundler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '2.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '2.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '13.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '13.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.4'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.4'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rubocop
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: yard
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: guard
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '2.14'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '2.14'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: guard-rspec
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '4.7'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '4.7'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: listen
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - '='
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: 3.0.7
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - '='
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: 3.0.7
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: pry
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - ">="
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0'
|
|
146
|
+
type: :development
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - ">="
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '0'
|
|
153
|
+
description: Danger plugin for PHPMD.
|
|
154
|
+
email:
|
|
155
|
+
- loiseau@gmail.com
|
|
156
|
+
executables: []
|
|
157
|
+
extensions: []
|
|
158
|
+
extra_rdoc_files: []
|
|
159
|
+
files:
|
|
160
|
+
- ".gitignore"
|
|
161
|
+
- ".rubocop.yml"
|
|
162
|
+
- Gemfile
|
|
163
|
+
- Gemfile.lock
|
|
164
|
+
- Guardfile
|
|
165
|
+
- LICENSE.txt
|
|
166
|
+
- README.md
|
|
167
|
+
- Rakefile
|
|
168
|
+
- danger-phpmd.gemspec
|
|
169
|
+
- lib/danger_phpmd.rb
|
|
170
|
+
- lib/danger_plugin.rb
|
|
171
|
+
- lib/phpmd/gem_version.rb
|
|
172
|
+
- lib/phpmd/plugin.rb
|
|
173
|
+
- spec/phpmd_spec.rb
|
|
174
|
+
- spec/spec_helper.rb
|
|
175
|
+
homepage: https://github.com/ktakayama/danger-phpmd
|
|
176
|
+
licenses:
|
|
177
|
+
- MIT
|
|
178
|
+
metadata: {}
|
|
179
|
+
post_install_message:
|
|
180
|
+
rdoc_options: []
|
|
181
|
+
require_paths:
|
|
182
|
+
- lib
|
|
183
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
184
|
+
requirements:
|
|
185
|
+
- - ">="
|
|
186
|
+
- !ruby/object:Gem::Version
|
|
187
|
+
version: '0'
|
|
188
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
|
+
requirements:
|
|
190
|
+
- - ">="
|
|
191
|
+
- !ruby/object:Gem::Version
|
|
192
|
+
version: '0'
|
|
193
|
+
requirements: []
|
|
194
|
+
rubygems_version: 3.0.3
|
|
195
|
+
signing_key:
|
|
196
|
+
specification_version: 4
|
|
197
|
+
summary: Danger plugin for PHPMD.
|
|
198
|
+
test_files:
|
|
199
|
+
- spec/phpmd_spec.rb
|
|
200
|
+
- spec/spec_helper.rb
|