xcpretty-pmd-formatter 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pmd_formatter.rb +39 -35
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf766e59bcf20f61efaa1adcae057abf3bde4334
4
- data.tar.gz: 312cea82cc46907955ed4413c10698be8208ac74
3
+ metadata.gz: ec36e1232cb11b638da63719a419979865997236
4
+ data.tar.gz: 614b6dcf2a8816aa61d121e515c80d630e206c8a
5
5
  SHA512:
6
- metadata.gz: fb5cabfa272bb56ef03b0041a73a8ee8be906b8cd0ae5ca949fdf415803d2ad0d5d0faede0d9d452eac13cc62c804fd77ce7719ea74e3a7e385075e4b1ad3e3d
7
- data.tar.gz: 34abd32e125740c9b5f441a1705ed7209f3fc2d908abf2ec12d2bf488848498ca6a25f700c572eefd79b75041693d639236a5407a8dfc7405a693b6bc4cad199
6
+ metadata.gz: d14771ae44d95a8363e0ec980d1ab95b661d1790fdb35c2f343f339581a4332ac1a62f668a8b8b1dcf582530164e1df5b262b1bbbdcc06e68824b2109f664bfc
7
+ data.tar.gz: 4c6939f002cf9f386c08a5fad9ce695020307053dc45ca2a1a45cf0936e50927e172d47f6f0d9557147418bce02acd355b5ca052df9acd98cebef2fe7439f94a
data/lib/pmd_formatter.rb CHANGED
@@ -122,41 +122,45 @@ class PMDFormatter < XCPretty::Simple
122
122
  rootnode = XML::Node.new('pmd')
123
123
  rootnode['version'] = 'xcpretty-pmd-formatter'
124
124
  doc.root = rootnode
125
-
126
- fileNode1 = XML::Node.new('file')
127
- fileNode1['name'] = 'AppDelegate.m'
128
- violation1 = XML::Node.new('violation')
129
- violation1['begincolumn'] = '5'
130
- violation1['endcolumn'] = '0'
131
- violation1['beginline'] = '28'
132
- violation1['endline'] = '0'
133
- violation1['priority'] = '1'
134
- violation1['rule'] = 'clang static analyzer'
135
- violation1['ruleset'] = 'clang static analyzer'
136
- violation1.content = 'code will never be executed [-Wunreachable-code]'
137
- fileNode1 << violation1
138
- doc.root << fileNode1
139
-
140
- fileNode2 = XML::Node.new('file')
141
- fileNode2['name'] = 'BGE/AppDelegate.m'
142
- violation2 = XML::Node.new('violation')
143
- violation2['begincolumn'] = '23'
144
- violation2['endcolumn'] = '0'
145
- violation2['beginline'] = '20'
146
- violation2['endline'] = '0'
147
- violation2['priority'] = '1'
148
- violation2['rule'] = 'clang static analyzer'
149
- violation2['ruleset'] = 'clang static analyzer'
150
- violation2.content = "Potential leak of an object stored into 'key'"
151
- fileNode2 << violation2
152
- doc.root << fileNode2
153
-
154
- docAsStr = doc.to_s
155
- # result = docAsStr.gsub(/xml/, 'pmd')
156
- # doc.save(file_name, :indent => true, :encoding => XML::Encoding::UTF_8)
157
-
158
- puts(docAsStr)
159
- File.write(file_name, docAsStr)
125
+
126
+ pmd_output.each do |key1, array|
127
+ unless array.count
128
+ next
129
+ end
130
+ file_node = XML::Node.new('file')
131
+ violation = XML::Node.new('violation')
132
+ array.each do |x|
133
+ x.each do |key, value|
134
+ if key.to_s == 'file_path'
135
+ file_node = XML::Node.new('file')
136
+ file_node['name'] = value.split(':')[0]
137
+ violation = XML::Node.new('violation')
138
+ violation['begincolumn'] = value.split(':')[2]
139
+ violation['endcolumn'] = '0'
140
+ violation['beginline'] = value.split(':')[1]
141
+ violation['endline'] = '0'
142
+ end
143
+ violation['priority'] = '1'
144
+ violation['rule'] = 'clang static analyzer'
145
+ violation['ruleset'] = 'clang static analyzer'
146
+ if key.to_s == 'reason'
147
+ violation.content = value
148
+ end
149
+ has_everything = !violation.parent && violation['begincolumn']
150
+ has_everything &&= violation['endcolumn']
151
+ has_everything &&= violation['beginline'] && violation['endline'] && violation.content
152
+ if has_everything
153
+ file_node << violation
154
+ end
155
+ if file_node['name']
156
+ doc.root << file_node
157
+ end
158
+ end
159
+ end
160
+ end
161
+ doc_as_str = doc.to_s
162
+ # puts doc_as_str
163
+ File.write(file_name, doc_as_str)
160
164
  end
161
165
  end
162
166
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcpretty-pmd-formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Csaba Szigeti