danger-pmd 0.2.0 → 1.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 +4 -4
- data/.github/workflows/publish.yml +35 -0
- data/.github/workflows/test.yml +21 -0
- data/.rubocop.yml +1 -1
- data/Gemfile.lock +24 -15
- data/LICENSE +21 -0
- data/README.md +34 -21
- data/danger-pmd.gemspec +1 -1
- data/lib/pmd/{pmd_file.rb → entity/pmd_file.rb} +0 -0
- data/lib/pmd/{pmd_violation.rb → entity/pmd_violation.rb} +1 -1
- data/lib/pmd/gem_version.rb +1 -1
- data/lib/pmd/plugin.rb +9 -10
- data/spec/entity/pmd_file_spec.rb +48 -0
- data/spec/pmd_spec.rb +1 -1
- metadata +12 -9
- data/.travis.yml +0 -10
- data/LICENSE.txt +0 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4cc9fb89231f4e208ace7fecad1dc8efc13a5cbc762a044ce10e280cfa8bf4cf
|
|
4
|
+
data.tar.gz: e7aa70238501b80d9106bb088ae8da08f816fdf7f0f21f13e64ac1a37f667686
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dacdaeac8a0bbcdc9776876c3ddb6aca4e7124771de19389ed2a3b242fbfa451461190777350195ea6c77ffa51cc6e0a781387fb086b925ee0c49d1180a3875b
|
|
7
|
+
data.tar.gz: b3c230a67ea00f6bef06997204e142f6a5dbcb36a50b9ae814183e479bb736eb27e3e85bcf6d8ff9e748fb9b2d6d6637171edb9fa4874a4ea3eb90572002437a
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
name: Publish gem
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v2
|
|
13
|
+
- name: Set up Ruby
|
|
14
|
+
uses: ruby/setup-ruby@v1
|
|
15
|
+
with:
|
|
16
|
+
ruby-version: '2.6'
|
|
17
|
+
bundler-cache: true
|
|
18
|
+
- name: Run tests
|
|
19
|
+
run: bundle exec rake spec
|
|
20
|
+
- name: Publish gem
|
|
21
|
+
uses: dawidd6/action-publish-gem@v1
|
|
22
|
+
with:
|
|
23
|
+
api_key: ${{secrets.RUBYGEMS_API_KEY}}
|
|
24
|
+
- name: Create git tag
|
|
25
|
+
uses: duderman/gh-gem-tag-action@v1
|
|
26
|
+
id: release_info
|
|
27
|
+
with:
|
|
28
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
29
|
+
- uses: xresloader/upload-to-github-release@v1
|
|
30
|
+
env:
|
|
31
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
32
|
+
with:
|
|
33
|
+
tag_name: ${{ steps.release_info.outputs.tag }}
|
|
34
|
+
draft: false
|
|
35
|
+
file: '*.gem'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
name: Test
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v2
|
|
15
|
+
- name: Set up Ruby
|
|
16
|
+
uses: ruby/setup-ruby@v1
|
|
17
|
+
with:
|
|
18
|
+
ruby-version: '2.6'
|
|
19
|
+
bundler-cache: true
|
|
20
|
+
- name: Run tests
|
|
21
|
+
run: bundle exec rake spec
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
danger-pmd (0.1
|
|
4
|
+
danger-pmd (1.0.1)
|
|
5
5
|
danger-plugin-api (~> 1.0)
|
|
6
6
|
oga (~> 2.10)
|
|
7
7
|
|
|
@@ -21,15 +21,15 @@ GEM
|
|
|
21
21
|
colored2 (3.1.2)
|
|
22
22
|
cork (0.3.0)
|
|
23
23
|
colored2 (~> 3.1)
|
|
24
|
-
danger (
|
|
24
|
+
danger (8.2.2)
|
|
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)
|
|
@@ -37,13 +37,17 @@ GEM
|
|
|
37
37
|
danger-plugin-api (1.0.0)
|
|
38
38
|
danger (> 2.0)
|
|
39
39
|
diff-lcs (1.3)
|
|
40
|
-
faraday (
|
|
40
|
+
faraday (1.3.0)
|
|
41
|
+
faraday-net_http (~> 1.0)
|
|
41
42
|
multipart-post (>= 1.2, < 3)
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
ruby2_keywords
|
|
44
|
+
faraday-http-cache (2.2.0)
|
|
45
|
+
faraday (>= 0.8)
|
|
46
|
+
faraday-net_http (1.0.1)
|
|
44
47
|
ffi (1.11.3)
|
|
45
48
|
formatador (0.2.5)
|
|
46
|
-
git (1.
|
|
49
|
+
git (1.8.1)
|
|
50
|
+
rchardet (~> 1.8)
|
|
47
51
|
guard (2.16.1)
|
|
48
52
|
formatador (>= 0.2.4)
|
|
49
53
|
listen (>= 2.7, < 4.0)
|
|
@@ -59,7 +63,8 @@ GEM
|
|
|
59
63
|
guard-compat (~> 1.1)
|
|
60
64
|
rspec (>= 2.99.0, < 4.0)
|
|
61
65
|
jaro_winkler (1.5.4)
|
|
62
|
-
kramdown (2.
|
|
66
|
+
kramdown (2.3.0)
|
|
67
|
+
rexml
|
|
63
68
|
kramdown-parser-gfm (1.1.0)
|
|
64
69
|
kramdown (~> 2.0)
|
|
65
70
|
listen (3.0.7)
|
|
@@ -74,7 +79,8 @@ GEM
|
|
|
74
79
|
notiffany (0.1.3)
|
|
75
80
|
nenv (~> 0.1)
|
|
76
81
|
shellany (~> 0.0)
|
|
77
|
-
octokit (4.
|
|
82
|
+
octokit (4.20.0)
|
|
83
|
+
faraday (>= 0.9)
|
|
78
84
|
sawyer (~> 0.8.0, >= 0.5.3)
|
|
79
85
|
oga (2.15)
|
|
80
86
|
ast
|
|
@@ -86,12 +92,14 @@ GEM
|
|
|
86
92
|
pry (0.12.2)
|
|
87
93
|
coderay (~> 1.1.0)
|
|
88
94
|
method_source (~> 0.9.0)
|
|
89
|
-
public_suffix (4.0.
|
|
95
|
+
public_suffix (4.0.6)
|
|
90
96
|
rainbow (3.0.0)
|
|
91
|
-
rake (
|
|
97
|
+
rake (13.0.1)
|
|
92
98
|
rb-fsevent (0.10.3)
|
|
93
99
|
rb-inotify (0.10.1)
|
|
94
100
|
ffi (~> 1.0)
|
|
101
|
+
rchardet (1.8.0)
|
|
102
|
+
rexml (3.2.4)
|
|
95
103
|
rspec (3.9.0)
|
|
96
104
|
rspec-core (~> 3.9.0)
|
|
97
105
|
rspec-expectations (~> 3.9.0)
|
|
@@ -116,6 +124,7 @@ GEM
|
|
|
116
124
|
ansi
|
|
117
125
|
ast
|
|
118
126
|
ruby-progressbar (1.10.1)
|
|
127
|
+
ruby2_keywords (0.0.4)
|
|
119
128
|
sawyer (0.8.2)
|
|
120
129
|
addressable (>= 2.3.5)
|
|
121
130
|
faraday (> 0.8, < 2.0)
|
|
@@ -136,10 +145,10 @@ DEPENDENCIES
|
|
|
136
145
|
guard-rspec (~> 4.7)
|
|
137
146
|
listen (= 3.0.7)
|
|
138
147
|
pry
|
|
139
|
-
rake (~>
|
|
148
|
+
rake (~> 13.0)
|
|
140
149
|
rspec (~> 3.4)
|
|
141
150
|
rubocop (~> 0.75)
|
|
142
151
|
yard (~> 0.9.20)
|
|
143
152
|
|
|
144
153
|
BUNDLED WITH
|
|
145
|
-
|
|
154
|
+
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
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
|
23
23
|
|
|
24
24
|
# General ruby development
|
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
|
26
|
-
spec.add_development_dependency 'rake', '~>
|
|
26
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
|
27
27
|
|
|
28
28
|
# Testing support
|
|
29
29
|
spec.add_development_dependency 'rspec', '~> 3.4'
|
|
File without changes
|
data/lib/pmd/gem_version.rb
CHANGED
data/lib/pmd/plugin.rb
CHANGED
|
@@ -11,18 +11,18 @@ module Danger
|
|
|
11
11
|
#
|
|
12
12
|
# @example Running PMD with a specific Gradle task or report file (glob accepted)
|
|
13
13
|
#
|
|
14
|
-
# pmd.gradle_task = 'app:pmd' #
|
|
15
|
-
# pmd.report_file =
|
|
14
|
+
# pmd.gradle_task = 'app:pmd' # default: pmd
|
|
15
|
+
# pmd.report_file = 'module/build/reports/pmd/pmd.xml' # default: app/build/reports/pmd/pmd.xml
|
|
16
16
|
# pmd.report
|
|
17
17
|
#
|
|
18
18
|
# @example Running PMD with a specific root path
|
|
19
19
|
#
|
|
20
|
-
# pmd.root_path = '/Users/developer/project
|
|
20
|
+
# pmd.root_path = '/Users/developer/project'
|
|
21
21
|
# pmd.report
|
|
22
22
|
#
|
|
23
23
|
# @example Running PMD with an array of report files (glob accepted)
|
|
24
24
|
#
|
|
25
|
-
# pmd.report_files = [
|
|
25
|
+
# pmd.report_files = ['modules/**/build/reports/pmd/pmd.xml', 'app/build/reports/pmd/pmd.xml']
|
|
26
26
|
# pmd.report
|
|
27
27
|
#
|
|
28
28
|
# @example Running PMD without running a Gradle task
|
|
@@ -32,9 +32,8 @@ module Danger
|
|
|
32
32
|
#
|
|
33
33
|
# @see mathroule/danger-pmd
|
|
34
34
|
# @tags java, android, pmd
|
|
35
|
-
|
|
36
35
|
class DangerPmd < Plugin
|
|
37
|
-
require_relative "./pmd_file"
|
|
36
|
+
require_relative "./entity/pmd_file"
|
|
38
37
|
|
|
39
38
|
# Custom Gradle task to run.
|
|
40
39
|
# This is useful when your project has different flavors.
|
|
@@ -101,7 +100,7 @@ module Danger
|
|
|
101
100
|
# It fails if `report_file` cannot be found inside current directory.
|
|
102
101
|
# It fails if `report_files` is empty.
|
|
103
102
|
# @return [Array[PmdFile]]
|
|
104
|
-
def report(
|
|
103
|
+
def report(inline_mode = true)
|
|
105
104
|
unless skip_gradle_task
|
|
106
105
|
return fail("Could not find `gradlew` inside current directory") unless gradlew_exists?
|
|
107
106
|
|
|
@@ -111,7 +110,7 @@ module Danger
|
|
|
111
110
|
report_files_expanded = Dir.glob(report_files).sort
|
|
112
111
|
return fail("Could not find matching PMD report files for #{report_files} inside current directory") if report_files_expanded.empty?
|
|
113
112
|
|
|
114
|
-
do_comment(report_files_expanded,
|
|
113
|
+
do_comment(report_files_expanded, inline_mode)
|
|
115
114
|
end
|
|
116
115
|
|
|
117
116
|
private
|
|
@@ -157,7 +156,7 @@ module Danger
|
|
|
157
156
|
|
|
158
157
|
# Generate report and send inline comment with Danger's warn or fail method.
|
|
159
158
|
# @return [Array[PmdFile]]
|
|
160
|
-
def do_comment(report_files,
|
|
159
|
+
def do_comment(report_files, inline_mode = true)
|
|
161
160
|
pmd_issues = []
|
|
162
161
|
|
|
163
162
|
report_files.each do |report_file|
|
|
@@ -167,7 +166,7 @@ module Danger
|
|
|
167
166
|
pmd_issues.push(pmd_file)
|
|
168
167
|
|
|
169
168
|
pmd_file.violations.each do |pmd_violation|
|
|
170
|
-
if
|
|
169
|
+
if inline_mode
|
|
171
170
|
send(pmd_violation.type, pmd_violation.description, file: pmd_file.relative_path, line: pmd_violation.line)
|
|
172
171
|
else
|
|
173
172
|
send(pmd_violation.type, "#{pmd_file.relative_path} : #{pmd_violation.description} at #{pmd_violation.line}")
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../spec_helper"
|
|
4
|
+
|
|
5
|
+
module Pmd
|
|
6
|
+
require "oga"
|
|
7
|
+
|
|
8
|
+
describe PmdFile do
|
|
9
|
+
it "should initialize relative path ending with file separator" do
|
|
10
|
+
xml = Oga.parse_xml(File.open("spec/fixtures/pmd_report.xml"))
|
|
11
|
+
pmd_file = PmdFile.new("/Users/developer/sample/", xml.xpath("//file").first)
|
|
12
|
+
|
|
13
|
+
expect(pmd_file.absolute_path).to eq("/Users/developer/sample/app/src/main/java/com/android/sample/Tools.java")
|
|
14
|
+
expect(pmd_file.relative_path).to eq("app/src/main/java/com/android/sample/Tools.java")
|
|
15
|
+
expect(pmd_file.violations).not_to be_nil
|
|
16
|
+
expect(pmd_file.violations.length).to eq(1)
|
|
17
|
+
expect(pmd_file.violations.first).not_to be_nil
|
|
18
|
+
expect(pmd_file.violations.first.line).to eq(5)
|
|
19
|
+
expect(pmd_file.violations.first.description).to eq("The utility class name 'Tools' doesn't match '[A-Z][a-zA-Z0-9]+(Utils?|Helper)'")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should initialize relative path not ending with file separator" do
|
|
23
|
+
xml = Oga.parse_xml(File.open("spec/fixtures/pmd_report.xml"))
|
|
24
|
+
pmd_file = PmdFile.new("/Users/developer/sample", xml.xpath("//file").first)
|
|
25
|
+
|
|
26
|
+
expect(pmd_file.absolute_path).to eq("/Users/developer/sample/app/src/main/java/com/android/sample/Tools.java")
|
|
27
|
+
expect(pmd_file.relative_path).to eq("app/src/main/java/com/android/sample/Tools.java")
|
|
28
|
+
expect(pmd_file.violations).not_to be_nil
|
|
29
|
+
expect(pmd_file.violations.length).to eq(1)
|
|
30
|
+
expect(pmd_file.violations.first).not_to be_nil
|
|
31
|
+
expect(pmd_file.violations.first.line).to eq(5)
|
|
32
|
+
expect(pmd_file.violations.first.description).to eq("The utility class name 'Tools' doesn't match '[A-Z][a-zA-Z0-9]+(Utils?|Helper)'")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should initialize relative path not prefixed" do
|
|
36
|
+
xml = Oga.parse_xml(File.open("spec/fixtures/pmd_report.xml"))
|
|
37
|
+
pmd_file = PmdFile.new("/Users/developer/something", xml.xpath("//file").first)
|
|
38
|
+
|
|
39
|
+
expect(pmd_file.absolute_path).to eq("/Users/developer/sample/app/src/main/java/com/android/sample/Tools.java")
|
|
40
|
+
expect(pmd_file.relative_path).to eq("/Users/developer/sample/app/src/main/java/com/android/sample/Tools.java")
|
|
41
|
+
expect(pmd_file.violations).not_to be_nil
|
|
42
|
+
expect(pmd_file.violations.length).to eq(1)
|
|
43
|
+
expect(pmd_file.violations.first).not_to be_nil
|
|
44
|
+
expect(pmd_file.violations.first.line).to eq(5)
|
|
45
|
+
expect(pmd_file.violations.first.description).to eq("The utility class name 'Tools' doesn't match '[A-Z][a-zA-Z0-9]+(Utils?|Helper)'")
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
data/spec/pmd_spec.rb
CHANGED
|
@@ -176,7 +176,7 @@ module Danger
|
|
|
176
176
|
allow_any_instance_of(Danger::DangerPmd).to receive(:target_files).and_return(target_files)
|
|
177
177
|
|
|
178
178
|
@pmd.report_files = ["spec/fixtures/pmd_report.xml", "spec/fixtures/**/pmd_sub_report.xml"]
|
|
179
|
-
@pmd.root_path = "/Users/developer/sample"
|
|
179
|
+
@pmd.root_path = "/Users/developer/sample/"
|
|
180
180
|
@pmd.skip_gradle_task = true
|
|
181
181
|
|
|
182
182
|
pmd_issues = @pmd.report
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: danger-pmd
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mathieu Rul
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-03-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: danger-plugin-api
|
|
@@ -58,14 +58,14 @@ dependencies:
|
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
61
|
+
version: '13.0'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
68
|
+
version: '13.0'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: rspec
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -171,22 +171,24 @@ executables: []
|
|
|
171
171
|
extensions: []
|
|
172
172
|
extra_rdoc_files: []
|
|
173
173
|
files:
|
|
174
|
+
- ".github/workflows/publish.yml"
|
|
175
|
+
- ".github/workflows/test.yml"
|
|
174
176
|
- ".gitignore"
|
|
175
177
|
- ".rubocop.yml"
|
|
176
|
-
- ".travis.yml"
|
|
177
178
|
- Gemfile
|
|
178
179
|
- Gemfile.lock
|
|
179
180
|
- Guardfile
|
|
180
|
-
- LICENSE
|
|
181
|
+
- LICENSE
|
|
181
182
|
- README.md
|
|
182
183
|
- Rakefile
|
|
183
184
|
- danger-pmd.gemspec
|
|
184
185
|
- lib/danger_plugin.rb
|
|
185
186
|
- lib/danger_pmd.rb
|
|
187
|
+
- lib/pmd/entity/pmd_file.rb
|
|
188
|
+
- lib/pmd/entity/pmd_violation.rb
|
|
186
189
|
- lib/pmd/gem_version.rb
|
|
187
190
|
- lib/pmd/plugin.rb
|
|
188
|
-
-
|
|
189
|
-
- lib/pmd/pmd_violation.rb
|
|
191
|
+
- spec/entity/pmd_file_spec.rb
|
|
190
192
|
- spec/fixtures/pmd_report.xml
|
|
191
193
|
- spec/fixtures/report_1/pmd_sub_report.xml
|
|
192
194
|
- spec/fixtures/report_2/pmd_sub_report.xml
|
|
@@ -211,11 +213,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
211
213
|
- !ruby/object:Gem::Version
|
|
212
214
|
version: '0'
|
|
213
215
|
requirements: []
|
|
214
|
-
rubygems_version: 3.0.
|
|
216
|
+
rubygems_version: 3.0.3
|
|
215
217
|
signing_key:
|
|
216
218
|
specification_version: 4
|
|
217
219
|
summary: A Danger plugin for PMD (Programming Mistake Detector), see https://pmd.github.io.
|
|
218
220
|
test_files:
|
|
221
|
+
- spec/entity/pmd_file_spec.rb
|
|
219
222
|
- spec/fixtures/pmd_report.xml
|
|
220
223
|
- spec/fixtures/report_1/pmd_sub_report.xml
|
|
221
224
|
- spec/fixtures/report_2/pmd_sub_report.xml
|
data/.travis.yml
DELETED
data/LICENSE.txt
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2019 Mathieu Rul <mathroule@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.
|