findbugs_translate_checkstyle_format 0.1.6 → 0.2.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
  SHA1:
3
- metadata.gz: dec5b39073bfae8407421ca05ec98ac9536ec70f
4
- data.tar.gz: 2a5ba5b1d3783659f807c9d54f3d6fdab95b55dd
3
+ metadata.gz: c7867d159bd387785e12961f0aefc24dcf16b670
4
+ data.tar.gz: 2b3bae8fab45a7aba5c7eb0522894809fd47b2df
5
5
  SHA512:
6
- metadata.gz: f13b5356eed10c82ca1ed26f9c462a4b37e565cce4236ac7645bce2212846baacf9adacc1a9be143a0f1437d142665e1dd85ea0658c1aa09b3e6c66ecb5f5615
7
- data.tar.gz: e004ec9023b3b8ff31e8579b3c8ad4bf2cdc12ea9e3ffbaa4320bc4e8da0e430d86d7fc2cd2f4750b9680807972e4d55e0cef62f1ae948c039dcbccba232fa8b
6
+ metadata.gz: 2b8ed8a89965516a156fbf72984aa6858c07a8d5507b53fa46d7c540384afbe1b7159c416ae5e3b97ff3ce82224255cee79bae03c8e4ba94d30c95d986052db3
7
+ data.tar.gz: 22e0f4709d39530c9d5a3238a750a6e5e88497cbe3e0f90fd715567e9835dd9c9c3c26889d564db30d5f8fbb29f5429507c1088272d7c6aaf843fb839c0c8bb0
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore CHANGED
@@ -7,3 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+
11
+ /samples/
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ Metrics/LineLength:
2
+ Max: 120
3
+
4
+ Style/Documentation:
5
+ Enabled: false
6
+
7
+ Metrics/MethodLength:
8
+ Max: 30
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # FindbugsTranslateCheckstyleFormat
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/findbugs_translate_checkstyle_format`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [![Gem Version](https://badge.fury.io/rb/findbugs_translate_checkstyle_format.svg)](http://badge.fury.io/rb/findbugs_translate_checkstyle_format)
4
+ [![Build Status](https://travis-ci.org/noboru-i/findbugs_translate_checkstyle_format.svg?branch=master)](https://travis-ci.org/noboru-i/findbugs_translate_checkstyle_format)
5
+ [![Code Climate](https://codeclimate.com/github/noboru-i/findbugs_translate_checkstyle_format/badges/gpa.svg)](https://codeclimate.com/github/noboru-i/findbugs_translate_checkstyle_format)
6
+ [![Coverage Status](https://coveralls.io/repos/noboru-i/findbugs_translate_checkstyle_format/badge.svg)](https://coveralls.io/r/noboru-i/findbugs_translate_checkstyle_format)
4
7
 
5
- TODO: Delete this and the text above, and describe your gem
8
+ Translate findbugs format into checkstyle format.
6
9
 
7
10
  ## Installation
8
11
 
@@ -22,7 +25,17 @@ Or install it yourself as:
22
25
 
23
26
  ## Usage
24
27
 
25
- TODO: Write usage instructions here
28
+ ### Use pipe
29
+
30
+ ```
31
+ cat findbugs.xml | findbugs_translate_checkstyle_format translate
32
+ ```
33
+
34
+ ### Use command-line option
35
+
36
+ ```
37
+ findbugs_translate_checkstyle_format translate --file="findbugs.xml"
38
+ ```
26
39
 
27
40
  ## Development
28
41
 
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "findbugs_translate_checkstyle_format"
3
+ require 'bundler/setup'
4
+ require 'findbugs_translate_checkstyle_format'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "findbugs_translate_checkstyle_format"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start
@@ -3,4 +3,4 @@
3
3
  require 'findbugs_translate_checkstyle_format'
4
4
  require 'findbugs_translate_checkstyle_format/cli'
5
5
 
6
- FindbugsTranslateCheckstyleFormat::CLI.start
6
+ FindbugsTranslateCheckstyleFormat::CLI.start
@@ -4,25 +4,26 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'findbugs_translate_checkstyle_format/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "findbugs_translate_checkstyle_format"
7
+ spec.name = 'findbugs_translate_checkstyle_format'
8
8
  spec.version = FindbugsTranslateCheckstyleFormat::VERSION
9
- spec.authors = ["noboru-i"]
10
- spec.email = ["ishikura.noboru@gmail.com"]
9
+ spec.authors = ['noboru-i']
10
+ spec.email = ['ishikura.noboru@gmail.com']
11
11
 
12
- spec.summary = %q{Translate findbugs format into checkstyle format.}
13
- spec.description = %q{Translate findbugs format into checkstyle format.}
14
- spec.homepage = "https://github.com/noboru-i/findbugs_translate_checkstyle_format"
15
- spec.license = "MIT"
12
+ spec.summary = 'Translate findbugs format into checkstyle format.'
13
+ spec.description = 'Translate findbugs format into checkstyle format.'
14
+ spec.homepage = 'https://github.com/noboru-i/findbugs_translate_checkstyle_format'
15
+ spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
18
+ spec.bindir = 'exe'
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
20
+ spec.require_paths = ['lib']
21
21
 
22
22
  spec.add_runtime_dependency 'thor'
23
23
  spec.add_runtime_dependency 'nori'
24
24
 
25
- spec.add_development_dependency "bundler", "~> 1.10"
26
- spec.add_development_dependency "rake", "~> 10.0"
27
- spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency 'bundler', '~> 1.10'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'rspec'
28
+ spec.add_development_dependency 'coveralls'
28
29
  end
@@ -1,4 +1,5 @@
1
1
  require 'nori'
2
+ require 'rexml/document'
2
3
 
3
4
  module FindbugsTranslateCheckstyleFormat
4
5
  module Translate
@@ -9,39 +10,53 @@ module FindbugsTranslateCheckstyleFormat
9
10
  end
10
11
 
11
12
  def trans(xml)
12
- require 'rexml/document'
13
13
  doc = REXML::Document.new
14
14
  doc << REXML::XMLDecl.new('1.0', 'UTF-8')
15
15
 
16
- checkstyle = doc.add_element("checkstyle")
17
- if xml['BugCollection']['BugInstance']
18
- bugInstances = xml['BugCollection']['BugInstance'].is_a?(Array) ? xml['BugCollection']['BugInstance'] : [xml['BugCollection']['BugInstance']]
19
- bugInstances.each do |bugInstance|
20
- file = checkstyle.add_element("file", {
21
- 'name' => fqcn_to_path(bugInstance['SourceLine']['@classname'], xml)
22
- })
23
- file.add_element("error", {
24
- 'line' => bugInstance['SourceLine']['@start'],
25
- 'severity' => '',
26
- 'message' => "[#{bugInstance['@category']}] #{bugInstance['LongMessage']}"
27
- })
28
- end
29
- else
30
- # create dummy
31
- dummy_src_dir = xml['BugCollection']['Project']['SrcDir'].first
32
- file = checkstyle.add_element("file", {
33
- 'name' => dummy_src_dir
34
- })
16
+ checkstyle = doc.add_element('checkstyle')
17
+ bug_instances = xml['BugCollection']['BugInstance']
18
+ if bug_instances.blank?
19
+ FindbugsTranslateCheckstyleFormat::Translate.set_dummy(xml, checkstyle)
20
+ return doc
21
+ end
22
+
23
+ bug_instances = [bug_instances] if bug_instances.is_a?(Hash)
24
+ bug_instances.each do |bug_instance|
25
+ source_line = bug_instance['SourceLine']
26
+ file = checkstyle.add_element('file',
27
+ 'name' => FindbugsTranslateCheckstyleFormat::Translate.fqcn_to_path(source_line['@classname'], xml)
28
+ )
29
+ file.add_element('error',
30
+ 'line' => source_line['@start'],
31
+ 'severity' => 'error',
32
+ 'message' => FindbugsTranslateCheckstyleFormat::Translate.create_message(bug_instance)
33
+ )
35
34
  end
36
35
 
37
36
  doc
38
37
  end
39
38
 
40
- def fqcn_to_path(fqcn, xml)
41
- path = fqcn.gsub('.', '/') + '.java'
42
- xml['BugCollection']['Project']['SrcDir'].find do |src|
43
- src.index(path) != nil
44
- end
39
+ def self.fqcn_to_path(fqcn, xml)
40
+ path = fqcn.tr('.', '/') + '.java'
41
+ src_dirs = xml['BugCollection']['Project']['SrcDir']
42
+ src_dirs = [src_dirs] unless src_dirs.is_a?(Array)
43
+ src_dirs.find { |src| !src.index(path).nil? }
44
+ end
45
+
46
+ def self.set_dummy(xml, checkstyle)
47
+ dummy_src_dir = xml['BugCollection']['Project']['SrcDir']
48
+ dummy_src_dir = dummy_src_dir.first if dummy_src_dir.is_a?(Array)
49
+
50
+ checkstyle.add_element('file',
51
+ 'name' => dummy_src_dir
52
+ )
53
+
54
+ checkstyle
55
+ end
56
+
57
+ def self.create_message(bug_instance)
58
+ link = "http://findbugs.sourceforge.net/bugDescriptions.html##{bug_instance['@type']}"
59
+ "[#{bug_instance['@category']}][#{bug_instance['@type']}] #{bug_instance['LongMessage']}\n#{link}"
45
60
  end
46
61
  end
47
62
  end
@@ -1,3 +1,3 @@
1
1
  module FindbugsTranslateCheckstyleFormat
2
- VERSION = "0.1.6"
2
+ VERSION = '0.2.0'
3
3
  end
@@ -1,5 +1,5 @@
1
- require "findbugs_translate_checkstyle_format/version"
2
- require "findbugs_translate_checkstyle_format/translate"
1
+ require 'findbugs_translate_checkstyle_format/version'
2
+ require 'findbugs_translate_checkstyle_format/translate'
3
3
 
4
4
  module FindbugsTranslateCheckstyleFormat
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: findbugs_translate_checkstyle_format
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - noboru-i
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-12 00:00:00.000000000 Z
11
+ date: 2015-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: Translate findbugs format into checkstyle format.
84
98
  email:
85
99
  - ishikura.noboru@gmail.com
@@ -88,8 +102,10 @@ executables:
88
102
  extensions: []
89
103
  extra_rdoc_files: []
90
104
  files:
105
+ - ".coveralls.yml"
91
106
  - ".gitignore"
92
107
  - ".rspec"
108
+ - ".rubocop.yml"
93
109
  - ".travis.yml"
94
110
  - CODE_OF_CONDUCT.md
95
111
  - Gemfile
@@ -124,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
140
  version: '0'
125
141
  requirements: []
126
142
  rubyforge_project:
127
- rubygems_version: 2.4.8
143
+ rubygems_version: 2.4.5
128
144
  signing_key:
129
145
  specification_version: 4
130
146
  summary: Translate findbugs format into checkstyle format.