xcpretty-pmd-formatter 0.0.3 → 0.0.4

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 +42 -26
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14ebd47b17bf430c5edde7efbdbfc19defb4a819
4
- data.tar.gz: 2a9595318640acf730d09bc3b2513349e9aa4768
3
+ metadata.gz: cf0585341c17f83f2b221be685f1c90718496080
4
+ data.tar.gz: d611f313a2774760c8348af100e26589edf90724
5
5
  SHA512:
6
- metadata.gz: d5b1cb57bed1d89653a06715a451991d6c9e09af0ad8d0a9e23b682c79b06c85047a3de0cb950464493bd9b14b1762478186081dba1faf57e03349013b89d7d5
7
- data.tar.gz: bbfddfd967744d65745a0d602af9ee05bfb7ab4836eaaa8cb1efaab529b0bcb10e595466c15b55086da4daf0990e4ba5f10740146c49269d6634c10cbd34f610
6
+ metadata.gz: 0b7f3fef5fc71f0fb28d2fe978748a3cea26d163dc084236fe76df35583e8b87a9a883c15dae3495223c8c083b274c5641db0075d4132f0a5b28ed43812be311
7
+ data.tar.gz: 7410723a3f0c7a4e9099358ad28dfbbe9884f902a9b753d848aee8c6d33e8fa1b143f4f03f00dcb646cf1161d29a6d32db899ac3df07b8f8c73bb57ff7db3934
data/lib/pmd_formatter.rb CHANGED
@@ -130,35 +130,51 @@ class PMDFormatter < XCPretty::Simple
130
130
  file_node = XML::Node.new('file')
131
131
  violation = XML::Node.new('violation')
132
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
- if key1.to_s == "compile_errors"
144
- violation['priority'] = '1'
145
- else
146
- violation['priority'] = '2'
133
+ if x.kind_of?(Hash)
134
+ x.each do |key, value|
135
+ if key.to_s == 'file_path'
136
+ file_node = XML::Node.new('file')
137
+ file_node['name'] = value.split(':')[0]
138
+ violation = XML::Node.new('violation')
139
+ violation['begincolumn'] = value.split(':')[2]
140
+ violation['endcolumn'] = '0'
141
+ violation['beginline'] = value.split(':')[1]
142
+ violation['endline'] = '0'
143
+ end
144
+ if key1.to_s == 'compile_errors'
145
+ violation['priority'] = '1'
146
+ else
147
+ violation['priority'] = '2'
148
+ end
149
+ violation['rule'] = 'clang static analyzer'
150
+ violation['ruleset'] = 'clang static analyzer'
151
+ if key.to_s == 'reason'
152
+ violation.content = value
153
+ end
154
+ has_everything = !violation.parent && violation['begincolumn']
155
+ has_everything &&= violation['endcolumn']
156
+ has_everything &&= violation['beginline'] && violation['endline'] && violation.content
157
+ if has_everything
158
+ file_node << violation
159
+ end
160
+ if file_node['name']
161
+ doc.root << file_node
162
+ end
147
163
  end
164
+ elsif x.kind_of?(String)
165
+ file_node = XML::Node.new('file')
166
+ file_node['name'] = ''
167
+ violation = XML::Node.new('violation')
168
+ violation['begincolumn'] = '0'
169
+ violation['endcolumn'] = '0'
170
+ violation['beginline'] = '0'
171
+ violation['endline'] = '0'
172
+ violation['priority'] = '2'
148
173
  violation['rule'] = 'clang static analyzer'
149
174
  violation['ruleset'] = 'clang static analyzer'
150
- if key.to_s == 'reason'
151
- violation.content = value
152
- end
153
- has_everything = !violation.parent && violation['begincolumn']
154
- has_everything &&= violation['endcolumn']
155
- has_everything &&= violation['beginline'] && violation['endline'] && violation.content
156
- if has_everything
157
- file_node << violation
158
- end
159
- if file_node['name']
160
- doc.root << file_node
161
- end
175
+ violation.content = x
176
+ file_node << violation
177
+ doc.root << file_node
162
178
  end
163
179
  end
164
180
  end
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Csaba Szigeti