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.
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-pmd (0.2.0)
4
+ danger-pmd (1.0.2)
5
5
  danger-plugin-api (~> 1.0)
6
- oga (~> 2.10)
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.0)
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.2)
20
+ coderay (1.1.3)
21
21
  colored2 (3.1.2)
22
22
  cork (0.3.0)
23
23
  colored2 (~> 3.1)
24
- danger (6.1.0)
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 (~> 0.9)
29
+ faraday (>= 0.9.0, < 2.0)
30
30
  faraday-http-cache (~> 2.0)
31
- git (~> 1.5)
32
- kramdown (~> 2.0)
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 (~> 1)
36
+ terminal-table (>= 1, < 4)
37
37
  danger-plugin-api (1.0.0)
38
38
  danger (> 2.0)
39
- diff-lcs (1.3)
40
- faraday (0.17.1)
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
- faraday-http-cache (2.0.0)
43
- faraday (~> 0.8)
44
- ffi (1.11.3)
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.5.0)
47
- guard (2.16.1)
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
- jaro_winkler (1.5.4)
62
- kramdown (2.1.0)
65
+ kramdown (2.3.1)
66
+ rexml
63
67
  kramdown-parser-gfm (1.1.0)
64
68
  kramdown (~> 2.0)
65
- listen (3.0.7)
66
- rb-fsevent (>= 0.9.3)
67
- rb-inotify (>= 0.9.7)
68
- lumberjack (1.0.13)
69
- method_source (0.9.2)
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.14.0)
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.19.1)
84
- parser (2.6.5.0)
85
- ast (~> 2.4.0)
86
- pry (0.12.2)
87
- coderay (~> 1.1.0)
88
- method_source (~> 0.9.0)
89
- public_suffix (4.0.1)
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 (10.5.0)
92
- rb-fsevent (0.10.3)
96
+ rake (13.0.3)
97
+ rb-fsevent (0.10.4)
93
98
  rb-inotify (0.10.1)
94
99
  ffi (~> 1.0)
95
- rspec (3.9.0)
96
- rspec-core (~> 3.9.0)
97
- rspec-expectations (~> 3.9.0)
98
- rspec-mocks (~> 3.9.0)
99
- rspec-core (3.9.0)
100
- rspec-support (~> 3.9.0)
101
- rspec-expectations (3.9.0)
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.9.0)
104
- rspec-mocks (3.9.0)
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.9.0)
107
- rspec-support (3.9.0)
108
- rubocop (0.78.0)
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 (>= 2.6)
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, < 1.7)
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.10.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 (1.8.0)
141
+ terminal-table (3.0.0)
124
142
  unicode-display_width (~> 1.1, >= 1.1.1)
125
- thor (1.0.1)
126
- unicode-display_width (1.6.0)
127
- yard (0.9.20)
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 (~> 1.3)
151
+ bundler (~> 2.0)
134
152
  danger-pmd!
135
- guard (~> 2.14)
136
- guard-rspec (~> 4.7)
137
- listen (= 3.0.7)
138
- pry
139
- rake (~> 10.0)
140
- rspec (~> 3.4)
141
- rubocop (~> 0.75)
142
- yard (~> 0.9.20)
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
- 1.17.3
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
- Danger plugin for PMD formatted xml file. This plugin is inspired from https://github.com/kazy1991/danger-findbugs.
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 Gradle task or report file
21
- <pre>
22
- pmd.gradle_task = 'app:pmd' #defalut: 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 = ["modules/**/build/reports/pmd/pmd.xml", "app/build/reports/pmd/pmd.xml"]
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` - Location of the project root
52
- If your project root is different from git's top-level path.
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 ["app/build/reports/pmd/pmd.xml]".
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, send comment and return PMD issues.
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` or `report_files` cannot be found inside current directory.
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 = '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)/})
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.10'
22
+ spec.add_runtime_dependency 'oga', '~> 2.15'
23
23
 
24
24
  # General ruby development
25
- spec.add_development_dependency 'bundler', '~> 1.3'
26
- spec.add_development_dependency 'rake', '~> 10.0'
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.4'
29
+ spec.add_development_dependency 'rspec', '~> 3.10.0'
30
30
 
31
31
  # Linting code and docs
32
- spec.add_development_dependency 'rubocop', '~> 0.75'
33
- spec.add_development_dependency 'yard', '~> 0.9.20'
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.14'
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.7'
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
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "pmd/plugin"
3
+ require 'pmd/plugin'
data/lib/danger_pmd.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "pmd/gem_version"
3
+ require 'pmd/gem_version'
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Represent a PMD file.
3
4
  class PmdFile
4
- require_relative "./pmd_violation"
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("name").value.to_s
21
+ @absolute_path = file.attribute('name').value.to_s
21
22
 
22
- if prefix.end_with?(file_separator)
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
- @relative_path = @absolute_path[@prefix.length, @absolute_path.length - @prefix.length]
30
- else
31
- @relative_path = @absolute_path
32
- end
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("violation").map do |pmd_violation|
33
+ @violations ||= file.xpath('violation').map do |pmd_violation|
37
34
  PmdViolation.new(pmd_violation)
38
35
  end
39
36
  end