xcpretty-pmd-formatter 0.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 +7 -0
- data/LICENSE +21 -0
- data/README.md +48 -0
- data/bin/xcpretty-pmd-formatter +3 -0
- data/lib/pmd_formatter.rb +163 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cf766e59bcf20f61efaa1adcae057abf3bde4334
|
4
|
+
data.tar.gz: 312cea82cc46907955ed4413c10698be8208ac74
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fb5cabfa272bb56ef03b0041a73a8ee8be906b8cd0ae5ca949fdf415803d2ad0d5d0faede0d9d452eac13cc62c804fd77ce7719ea74e3a7e385075e4b1ad3e3d
|
7
|
+
data.tar.gz: 34abd32e125740c9b5f441a1705ed7209f3fc2d908abf2ec12d2bf488848498ca6a25f700c572eefd79b75041693d639236a5407a8dfc7405a693b6bc4cad199
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 szigetics
|
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
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# XCPretty PMD Formatter
|
2
|
+
xcpretty custom formatter for parsing warnings and static analyzer issues easily from "xcodebuild ... clean build analyze" output
|
3
|
+
|
4
|
+
[](LICENSE.txt)
|
5
|
+
|
6
|
+
Custom formatter for [xcpretty](https://github.com/supermarin/xcpretty) that saves on a PMD file all the errors, and warnings, so you can process them easily later.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
This formatter is distributed via RubyGems, and depends on a version of `xcpretty` >= 0.0.7 (when custom formatters were introduced). Run:
|
11
|
+
|
12
|
+
gem install xcpretty-pmd-formatter
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
Specify `xcpretty-pmd-formatter` as a custom formatter to `xcpretty`:
|
17
|
+
|
18
|
+
```bash
|
19
|
+
#!/bin/bash
|
20
|
+
|
21
|
+
xcodebuild | xcpretty -f `xcpretty-pmd-formatter`
|
22
|
+
```
|
23
|
+
|
24
|
+
By default, `xcpretty-pmd-formatter` writes the result in `build/reports/errors.pmd`, but you can change that with an environment variable:
|
25
|
+
|
26
|
+
```bash
|
27
|
+
#!/bin/bash
|
28
|
+
|
29
|
+
xcodebuild | XCPRETTY_PMD_FILE_OUTPUT=result.pmd xcpretty -f `xcpretty-pmd-formatter`
|
30
|
+
```
|
31
|
+
|
32
|
+
## Output format
|
33
|
+
|
34
|
+
You can check some example PMDs in the [fixtures folder](spec/fixtures).
|
35
|
+
|
36
|
+
## Thanks
|
37
|
+
|
38
|
+
* [Marin Usalj](http://github.com/supermarin) and [Delisa Mason](http://github.com/kattrali) for creating [xcpretty](https://github.com/supermarin/xcpretty).
|
39
|
+
* [Delisa Mason](http://github.com/kattrali) for creating [xcpretty-travis-formatter](https://github.com/kattrali/xcpretty-travis-formatter), which I used as a guide.
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/szigetics/xcpretty-pmd-formatter.
|
44
|
+
|
45
|
+
|
46
|
+
## License
|
47
|
+
|
48
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -0,0 +1,163 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'xml'
|
3
|
+
|
4
|
+
class PMDFormatter < XCPretty::Simple
|
5
|
+
FILE_PATH = 'build/reports/errors.pmd'.freeze
|
6
|
+
|
7
|
+
def initialize(use_unicode, colorize)
|
8
|
+
super
|
9
|
+
@warnings = []
|
10
|
+
@ld_warnings = []
|
11
|
+
@compile_warnings = []
|
12
|
+
@errors = []
|
13
|
+
@compile_errors = []
|
14
|
+
@file_missing_errors = []
|
15
|
+
@undefined_symbols_errors = []
|
16
|
+
@duplicate_symbols_errors = []
|
17
|
+
@failures = {}
|
18
|
+
end
|
19
|
+
|
20
|
+
def format_ld_warning(message)
|
21
|
+
@ld_warnings << message
|
22
|
+
write_to_file_if_needed
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
def format_warning(message)
|
27
|
+
@warnings << message
|
28
|
+
write_to_file_if_needed
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
def format_compile_warning(file_name, file_path, reason, line, cursor)
|
33
|
+
@compile_warnings << {
|
34
|
+
file_name: file_name,
|
35
|
+
file_path: file_path,
|
36
|
+
reason: reason,
|
37
|
+
line: line,
|
38
|
+
cursor: cursor
|
39
|
+
}
|
40
|
+
write_to_file_if_needed
|
41
|
+
super
|
42
|
+
end
|
43
|
+
|
44
|
+
def format_error(message)
|
45
|
+
@errors << message
|
46
|
+
write_to_file_if_needed
|
47
|
+
super
|
48
|
+
end
|
49
|
+
|
50
|
+
def format_compile_error(file, file_path, reason, line, cursor)
|
51
|
+
@compile_errors << {
|
52
|
+
file_name: file,
|
53
|
+
file_path: file_path,
|
54
|
+
reason: reason,
|
55
|
+
line: line,
|
56
|
+
cursor: cursor
|
57
|
+
}
|
58
|
+
write_to_file_if_needed
|
59
|
+
super
|
60
|
+
end
|
61
|
+
|
62
|
+
def format_file_missing_error(reason, file_path)
|
63
|
+
@file_missing_errors << {
|
64
|
+
file_path: file_path,
|
65
|
+
reason: reason
|
66
|
+
}
|
67
|
+
write_to_file_if_needed
|
68
|
+
super
|
69
|
+
end
|
70
|
+
|
71
|
+
def format_undefined_symbols(message, symbol, reference)
|
72
|
+
@undefined_symbols_errors = {
|
73
|
+
message: message,
|
74
|
+
symbol: symbol,
|
75
|
+
reference: reference
|
76
|
+
}
|
77
|
+
write_to_file_if_needed
|
78
|
+
super
|
79
|
+
end
|
80
|
+
|
81
|
+
def format_duplicate_symbols(message, file_paths)
|
82
|
+
@duplicate_symbols_errors = {
|
83
|
+
message: message,
|
84
|
+
file_paths: file_paths
|
85
|
+
}
|
86
|
+
write_to_file_if_needed
|
87
|
+
super
|
88
|
+
end
|
89
|
+
|
90
|
+
def format_test_summary(message, failures_per_suite)
|
91
|
+
super
|
92
|
+
end
|
93
|
+
|
94
|
+
def finish
|
95
|
+
write_to_file
|
96
|
+
super
|
97
|
+
end
|
98
|
+
|
99
|
+
def pmd_output
|
100
|
+
{
|
101
|
+
warnings: @warnings,
|
102
|
+
ld_warnings: @ld_warnings,
|
103
|
+
compile_warnings: @compile_warnings,
|
104
|
+
errors: @errors,
|
105
|
+
compile_errors: @compile_errors,
|
106
|
+
file_missing_errors: @file_missing_errors,
|
107
|
+
undefined_symbols_errors: @undefined_symbols_errors,
|
108
|
+
duplicate_symbols_errors: @duplicate_symbols_errors
|
109
|
+
}
|
110
|
+
end
|
111
|
+
|
112
|
+
def write_to_file_if_needed
|
113
|
+
write_to_file unless XCPretty::Formatter.method_defined? :finish
|
114
|
+
end
|
115
|
+
|
116
|
+
def write_to_file
|
117
|
+
file_name = ENV['XCPRETTY_PMD_FILE_OUTPUT'] || FILE_PATH
|
118
|
+
dirname = File.dirname(file_name)
|
119
|
+
FileUtils.mkdir_p dirname
|
120
|
+
|
121
|
+
doc = XML::Document.new
|
122
|
+
rootnode = XML::Node.new('pmd')
|
123
|
+
rootnode['version'] = 'xcpretty-pmd-formatter'
|
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)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
PMDFormatter
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xcpretty-pmd-formatter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Csaba Szigeti
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: xcpretty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.2'
|
20
|
+
- - '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.0.7
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.2'
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.0.7
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: bundler
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ~>
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.11'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.11'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '10.0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ~>
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '10.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rspec
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rubocop
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ~>
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0.38'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ~>
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0.38'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: libxml-ruby
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ~>
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 2.9.0
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ~>
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.9.0
|
103
|
+
description: Custom formatter for xcpretty that saves on a PMD file all the errors,
|
104
|
+
and warnings, so you can process them easily later.
|
105
|
+
email:
|
106
|
+
- szigetics@gmail.com
|
107
|
+
executables:
|
108
|
+
- xcpretty-pmd-formatter
|
109
|
+
extensions: []
|
110
|
+
extra_rdoc_files: []
|
111
|
+
files:
|
112
|
+
- README.md
|
113
|
+
- LICENSE
|
114
|
+
- lib/pmd_formatter.rb
|
115
|
+
- bin/xcpretty-pmd-formatter
|
116
|
+
homepage: https://github.com/szigetics/xcpretty-pmd-formatter
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.0.14.1
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: xcpretty custom formatter for parsing warnings and static analyzer issues
|
140
|
+
easily from "xcodebuild ... clean build analyze" output
|
141
|
+
test_files: []
|