danger-pmd 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a2d9f880fd61118eab5f466d22fa9a63d90e642cf3f3bec0f1afeb3365a7c84
4
- data.tar.gz: '0840aa8e767568221ffe52c5e8842900dce15cc8828255d0fa567752bb6d5c30'
3
+ metadata.gz: a1891cd48c4d313436dc6a38d0fe0bf26fd21dbd79555633777609fc6755c0f4
4
+ data.tar.gz: f6f2058ea738fa34b78a53af6376eb9d93ad4887fd803a8f535b58eaed5bd568
5
5
  SHA512:
6
- metadata.gz: 8986e2a6b8dfb31b5725e63477022c14d72aecfe9d28ed3754a08ad3d747b575e7263b1367fa8b0ed95f38cf5030f0bccfd268c56737180db2996e40ec1e6d43
7
- data.tar.gz: ba13a09f7402bcabdce873fae2047d81ee49fdfae3bba44d3c954bddfe2f5cc6115453eda265cf5969f1bb9a8a8fb79ef0ba5878be357a920c17e23d1e19fe90
6
+ metadata.gz: 75d23626c4d10bd650f4ac2bf6c5b210efaec64f49b86400de2b3cf89ff40c61384032567a9ceb7c02d67afeb3e13ade638c55d08affca736d4094317926825d
7
+ data.tar.gz: 5d270e5700d22cdd523fe41c0bac67ed0603fc82158000706f35ae7fc358af7cce5971f040dd3babb33dbde6e7c751e1ecfc27932517b6f3775b98d8186bdc07
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-pmd (0.2.1)
4
+ danger-pmd (0.2.2)
5
5
  danger-plugin-api (~> 1.0)
6
6
  oga (~> 2.10)
7
7
 
File without changes
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pmd
4
- VERSION = "0.2.2"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/pmd/plugin.rb CHANGED
@@ -34,7 +34,7 @@ module Danger
34
34
  # @tags java, android, pmd
35
35
 
36
36
  class DangerPmd < Plugin
37
- require_relative "./pmd_file"
37
+ require_relative "./entity/pmd_file"
38
38
 
39
39
  # Custom Gradle task to run.
40
40
  # This is useful when your project has different flavors.
@@ -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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-pmd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathieu Rul
@@ -183,10 +183,11 @@ files:
183
183
  - danger-pmd.gemspec
184
184
  - lib/danger_plugin.rb
185
185
  - lib/danger_pmd.rb
186
+ - lib/pmd/entity/pmd_file.rb
187
+ - lib/pmd/entity/pmd_violation.rb
186
188
  - lib/pmd/gem_version.rb
187
189
  - lib/pmd/plugin.rb
188
- - lib/pmd/pmd_file.rb
189
- - lib/pmd/pmd_violation.rb
190
+ - spec/entity/pmd_file_spec.rb
190
191
  - spec/fixtures/pmd_report.xml
191
192
  - spec/fixtures/report_1/pmd_sub_report.xml
192
193
  - spec/fixtures/report_2/pmd_sub_report.xml
@@ -216,6 +217,7 @@ signing_key:
216
217
  specification_version: 4
217
218
  summary: A Danger plugin for PMD (Programming Mistake Detector), see https://pmd.github.io.
218
219
  test_files:
220
+ - spec/entity/pmd_file_spec.rb
219
221
  - spec/fixtures/pmd_report.xml
220
222
  - spec/fixtures/report_1/pmd_sub_report.xml
221
223
  - spec/fixtures/report_2/pmd_sub_report.xml