oclint_translate_checkstyle_format 0.1.0
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/.coveralls.yml +1 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +51 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/oclint_translate_checkstyle_format +6 -0
- data/lib/oclint_translate_checkstyle_format.rb +5 -0
- data/lib/oclint_translate_checkstyle_format/cli.rb +34 -0
- data/lib/oclint_translate_checkstyle_format/translate.rb +46 -0
- data/lib/oclint_translate_checkstyle_format/version.rb +3 -0
- data/oclint_translate_checkstyle_format.gemspec +28 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e7d7a2f910e9f67bb165929689389c6fd115b556
|
4
|
+
data.tar.gz: f7308bcde381cc341ed024e063bb2f7e4d00d144
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fc38851b8a7496fa3e58799377325088fa8613cab90a1fe2373d7b413e784965f88ddc1fde4e4345aefac34fc95264dcc1d64701a0b646e1c095f330dd006c70
|
7
|
+
data.tar.gz: fb98d1b24bc4f43c1d0749a77f584302f6add9c830ebf45eef53ff555af48a493c1360c075922ece188b651581de9eef8cc43d166e20e9bfa93b90467c1d8307
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# OclintTranslateCheckstyleFormat
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/oclint_translate_checkstyle_format)
|
4
|
+
[](https://travis-ci.org/noboru-i/oclint_translate_checkstyle_format)
|
5
|
+
[](https://codeclimate.com/github/noboru-i/oclint_translate_checkstyle_format)
|
6
|
+
[](https://coveralls.io/r/noboru-i/oclint_translate_checkstyle_format)
|
7
|
+
|
8
|
+
Translate SwiftLint json format into checkstyle format.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'oclint_translate_checkstyle_format'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install oclint_translate_checkstyle_format
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
First, you install [OCLint](http://oclint.org/).
|
29
|
+
And execute it with option `-report-type json`.
|
30
|
+
|
31
|
+
### Use pipe
|
32
|
+
|
33
|
+
```
|
34
|
+
cat oclint.result.json | oclint_translate_checkstyle_format translate
|
35
|
+
```
|
36
|
+
|
37
|
+
### Use command-line option
|
38
|
+
|
39
|
+
```
|
40
|
+
oclint_translate_checkstyle_format translate --file="oclint.result.json"
|
41
|
+
|
42
|
+
|
43
|
+
## Development
|
44
|
+
|
45
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
46
|
+
|
47
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/oclint_translate_checkstyle_format.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "oclint_translate_checkstyle_format"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module OclintTranslateCheckstyleFormat
|
4
|
+
class CLI < Thor
|
5
|
+
include ::OclintTranslateCheckstyleFormat::Translate
|
6
|
+
desc 'translate', 'Exec Translate'
|
7
|
+
option :data
|
8
|
+
option :file
|
9
|
+
def translate
|
10
|
+
data = fetch_data(options)
|
11
|
+
parsed_data = parse(data)
|
12
|
+
checkstyle = trans(parsed_data)
|
13
|
+
checkstyle.write(STDOUT, 2)
|
14
|
+
end
|
15
|
+
|
16
|
+
no_commands do
|
17
|
+
def fetch_data(options)
|
18
|
+
data = \
|
19
|
+
if options[:data]
|
20
|
+
options[:data]
|
21
|
+
elsif options[:file]
|
22
|
+
File.read(options[:file])
|
23
|
+
elsif !$stdin.tty?
|
24
|
+
ARGV.clear
|
25
|
+
ARGF.read
|
26
|
+
end
|
27
|
+
|
28
|
+
fail NoInputError if !data || data.empty?
|
29
|
+
|
30
|
+
data
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'rexml/document'
|
3
|
+
|
4
|
+
module OclintTranslateCheckstyleFormat
|
5
|
+
module Translate
|
6
|
+
def parse(str)
|
7
|
+
JSON.load(str)
|
8
|
+
end
|
9
|
+
|
10
|
+
def trans(json)
|
11
|
+
doc = REXML::Document.new
|
12
|
+
doc << REXML::XMLDecl.new('1.0', 'UTF-8')
|
13
|
+
|
14
|
+
checkstyle = doc.add_element('checkstyle')
|
15
|
+
if json.empty?
|
16
|
+
OclintTranslateCheckstyleFormat::Translate.add_dummy(checkstyle)
|
17
|
+
return doc
|
18
|
+
end
|
19
|
+
|
20
|
+
json['violation'].each do |result|
|
21
|
+
file = checkstyle.add_element('file',
|
22
|
+
'name' => result['path']
|
23
|
+
)
|
24
|
+
file.add_element('error',
|
25
|
+
'line' => result['startLine'],
|
26
|
+
'severity' => 'error',
|
27
|
+
'message' => OclintTranslateCheckstyleFormat::Translate.create_message(result)
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
doc
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.add_dummy(checkstyle)
|
35
|
+
checkstyle.add_element('file',
|
36
|
+
'name' => ''
|
37
|
+
)
|
38
|
+
|
39
|
+
checkstyle
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.create_message(result)
|
43
|
+
"[#{result['category']}] #{result['rule']}\n#{result['message']}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'oclint_translate_checkstyle_format/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'oclint_translate_checkstyle_format'
|
8
|
+
spec.version = OclintTranslateCheckstyleFormat::VERSION
|
9
|
+
spec.authors = ["noboru-i"]
|
10
|
+
spec.email = ["ishikura.noboru@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = 'Translate OCLint json format into checkstyle format.'
|
13
|
+
spec.description = 'Translate OCLint json format into checkstyle format.'
|
14
|
+
spec.homepage = 'https://github.com/noboru-i/oclint_translate_checkstyle_format'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_runtime_dependency 'thor'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
spec.add_development_dependency 'coveralls'
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: oclint_translate_checkstyle_format
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- noboru-i
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Translate OCLint json format into checkstyle format.
|
84
|
+
email:
|
85
|
+
- ishikura.noboru@gmail.com
|
86
|
+
executables:
|
87
|
+
- oclint_translate_checkstyle_format
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".coveralls.yml"
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- ".travis.yml"
|
95
|
+
- Gemfile
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/console
|
99
|
+
- bin/setup
|
100
|
+
- exe/oclint_translate_checkstyle_format
|
101
|
+
- lib/oclint_translate_checkstyle_format.rb
|
102
|
+
- lib/oclint_translate_checkstyle_format/cli.rb
|
103
|
+
- lib/oclint_translate_checkstyle_format/translate.rb
|
104
|
+
- lib/oclint_translate_checkstyle_format/version.rb
|
105
|
+
- oclint_translate_checkstyle_format.gemspec
|
106
|
+
homepage: https://github.com/noboru-i/oclint_translate_checkstyle_format
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.6.4
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Translate OCLint json format into checkstyle format.
|
130
|
+
test_files: []
|