pronto-findbugs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ed4ac82507a1784b6cff41655daab9599389289002b5fe03e3c2cc32c187f676
4
+ data.tar.gz: 1bf1269ad798364745c4c93a8140f37516433b2e95840454fef8bde5c811dc56
5
+ SHA512:
6
+ metadata.gz: 59813692ea5fb7a59677c86aef6c4d3d5cc561bf5282ca5343c08632ebf3e6fc8644942bc3dad8e7a0440aef2805932b7f03924f36a60d1416ba0ee8d40b3b57
7
+ data.tar.gz: 3236a82831de3358a70756df9c4ea491c9c7e1cddbcec17556e2d6dca44b34141aff9b52aab57e59c0e9b9d9dfe2c1bc93dcad30442eab009fb9bc6c29d5c624
@@ -0,0 +1,60 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
10
+
11
+ ### https://raw.github.com/github/gitignore/18654b47c86bef38add5cd091ec2dac7d6e6e37b/Global/Emacs.gitignore
12
+
13
+ # -*- mode: gitignore; -*-
14
+ *~
15
+ \#*\#
16
+ /.emacs.desktop
17
+ /.emacs.desktop.lock
18
+ *.elc
19
+ auto-save-list
20
+ tramp
21
+ .\#*
22
+
23
+ # Org-mode
24
+ .org-id-locations
25
+ *_archive
26
+
27
+ # flymake-mode
28
+ *_flymake.*
29
+
30
+ # eshell files
31
+ /eshell/history
32
+ /eshell/lastdir
33
+
34
+ # elpa packages
35
+ /elpa/
36
+
37
+ # reftex files
38
+ *.rel
39
+
40
+ # AUCTeX auto folder
41
+ /auto/
42
+
43
+ # cask packages
44
+ .cask/
45
+ dist/
46
+
47
+ # Flycheck
48
+ flycheck_*.el
49
+
50
+ # server auth directory
51
+ /server/
52
+
53
+ # projectiles files
54
+ .projectile
55
+
56
+ # directory configuration
57
+ .dir-locals.el
58
+
59
+ # network security
60
+ /network-security.data
@@ -0,0 +1,5 @@
1
+ Style/Documentation:
2
+ Enabled: false
3
+
4
+ Metrics/LineLength:
5
+ Max: 120
@@ -0,0 +1,7 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.2
5
+ before_install:
6
+ - gem update --system
7
+ - gem install bundler
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at seikichi@kmc.gr.jp. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in pronto-findbugs.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Seiichi KONDO
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,47 @@
1
+ # Pronto::Findbugs
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/pronto-findbugs.svg)](http://badge.fury.io/rb/pronto-findbugs)
4
+ [![Build Status](https://travis-ci.org/seikichi/pronto-findbugs.svg?branch=master)](https://travis-ci.org/seikichi/pronto-findbugs)
5
+ [![Coverage Status](https://coveralls.io/repos/seikichi/pronto-findbugs/badge.svg?branch=master&service=github)](https://coveralls.io/github/seikichi/pronto-findbugs?branch=master)
6
+
7
+ [Pronto](https://github.com/mmozuras/pronto) runner for [findbugs](http://findbugs.sourceforge.net/) or [spotbugs](https://spotbugs.github.io/) reports.
8
+
9
+ ## Configuration
10
+
11
+ You need to specify location of findbugs reports by passing `PRONTO_FINDBUGS_REPORTS_DIR` env variable e.g:
12
+
13
+ ```bash
14
+ PRONTO_FINDBUGS_REPORTS_DIR=build/reports/spotbugs/ pronto run --index
15
+ ```
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ ```ruby
22
+ gem 'pronto-findbugs'
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install pronto-findbugs
32
+
33
+ ## Development
34
+
35
+ After checking out the repo, run `bundle` to install dependencies. Then, run `rake test` to run the tests.
36
+
37
+ To install this gem onto your local machine, run `bundle exec rake install`.
38
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,
39
+ 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).
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/seikichi/pronto-findbugs.
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task default: :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'pronto/findbugs'
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(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,81 @@
1
+ require 'pronto'
2
+ require 'rexml/document'
3
+
4
+ module Pronto
5
+ class Findbugs < Runner
6
+ def run
7
+ return [] unless @patches
8
+
9
+ @patches
10
+ .select(&method(:valid_patch?))
11
+ .flat_map(&method(:inspect))
12
+ .compact
13
+ end
14
+
15
+ private
16
+
17
+ Offence = Struct.new(:path, :line, :message)
18
+
19
+ def findbugs_reports_dir
20
+ ENV['PRONTO_FINDBUGS_REPORTS_DIR'] || (raise 'Please set `PRONT_FINDBUGS_REPORTS_DIR` to use pronto-findbugs')
21
+ end
22
+
23
+ def valid_patch?(patch)
24
+ patch.additions > 0
25
+ end
26
+
27
+ def inspect(patch)
28
+ offences = findbugs_offences.select { |offence| offence.path == patch.new_file_full_path.to_s }
29
+
30
+ offences.flat_map do |offence|
31
+ patch.added_lines
32
+ .select { |line| line.new_lineno == offence.line }
33
+ .map { |line| new_message(offence, line) }
34
+ end
35
+ end
36
+
37
+ def findbugs_offences
38
+ @findbugs_offences ||=
39
+ begin
40
+ pattern = File.join(findbugs_reports_dir, '**', '*.xml')
41
+ Dir.glob(pattern).flat_map(&method(:read_findbugs_report))
42
+ end
43
+ end
44
+
45
+ def read_findbugs_report(path)
46
+ doc = REXML::Document.new(File.read(path))
47
+ src_dirs = REXML::XPath.match(doc, '/BugCollection/Project/SrcDir/text()')
48
+ return [] unless src_dirs.size == 1
49
+
50
+ src = src_dirs.first.to_s
51
+ REXML::XPath.match(doc, '/BugCollection/BugInstance').map do |bug|
52
+ Offence.new(path_from(bug, src), line_from(bug), message_from(bug))
53
+ end
54
+ end
55
+
56
+ def path_from(bug_node, root)
57
+ source_line = REXML::XPath.first(bug_node, 'SourceLine')
58
+ path = source_line.attribute('sourcepath').to_s
59
+ File.join(root, path)
60
+ end
61
+
62
+ def line_from(bug_node)
63
+ source_line = REXML::XPath.first(bug_node, 'SourceLine')
64
+ source_line.attribute('start').to_s.to_i
65
+ end
66
+
67
+ def message_from(bug_node)
68
+ long_message = REXML::XPath.first(bug_node, 'LongMessage')
69
+ return long_message.text if long_message
70
+
71
+ bug_type = bug_node.attribute('type').to_s
72
+ bug_category = bug_node.attribute('category').to_s
73
+ "type=#{bug_type} category=#{bug_category}"
74
+ end
75
+
76
+ def new_message(offence, line)
77
+ path = line.patch.delta.new_file[:path]
78
+ Message.new(path, line, :warning, offence.message, nil, self.class)
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,5 @@
1
+ module Pronto
2
+ module FindbugsVersion
3
+ VERSION = '0.1.0'.freeze
4
+ end
5
+ end
@@ -0,0 +1,34 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'pronto/findbugs/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'pronto-findbugs'
7
+ spec.version = Pronto::FindbugsVersion::VERSION
8
+ spec.authors = ['Seiichi KONDO']
9
+ spec.email = ['seikichi@kmc.gr.jp']
10
+
11
+ spec.summary = 'Pronto runner for findbugs / spotbugs'
12
+ spec.description = <<-DESCRIPTION
13
+ A pronto runner for findbugs and spotbugs.
14
+ Pronto runs analysis quickly by checking only the relevant changes.
15
+ Created to be used on pull requests, but suited for other scenarios as well.
16
+ DESCRIPTION
17
+ spec.homepage = 'https://github.com/seikichi/pronto-findbugs'
18
+ spec.license = 'MIT'
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(test|spec|features)/})
22
+ end
23
+ spec.bindir = 'exe'
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ['lib']
26
+
27
+ spec.add_runtime_dependency 'pronto', '~> 0.9.5'
28
+ spec.add_development_dependency 'bundler', '~> 2.0'
29
+ spec.add_development_dependency 'coveralls'
30
+ spec.add_development_dependency 'rake', '~> 10.0'
31
+ spec.add_development_dependency 'rubocop', '~> 0.62'
32
+ spec.add_development_dependency 'simplecov'
33
+ spec.add_development_dependency 'test-unit', '~> 3.2.8'
34
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pronto-findbugs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Seiichi KONDO
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-05-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pronto
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: coveralls
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.62'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.62'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
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'
97
+ - !ruby/object:Gem::Dependency
98
+ name: test-unit
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 3.2.8
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 3.2.8
111
+ description: |2
112
+ A pronto runner for findbugs and spotbugs.
113
+ Pronto runs analysis quickly by checking only the relevant changes.
114
+ Created to be used on pull requests, but suited for other scenarios as well.
115
+ email:
116
+ - seikichi@kmc.gr.jp
117
+ executables: []
118
+ extensions: []
119
+ extra_rdoc_files: []
120
+ files:
121
+ - ".gitignore"
122
+ - ".rubocop.yml"
123
+ - ".travis.yml"
124
+ - CODE_OF_CONDUCT.md
125
+ - Gemfile
126
+ - LICENSE.txt
127
+ - README.md
128
+ - Rakefile
129
+ - bin/console
130
+ - bin/setup
131
+ - lib/pronto/findbugs.rb
132
+ - lib/pronto/findbugs/version.rb
133
+ - pronto-findbugs.gemspec
134
+ homepage: https://github.com/seikichi/pronto-findbugs
135
+ licenses:
136
+ - MIT
137
+ metadata: {}
138
+ post_install_message:
139
+ rdoc_options: []
140
+ require_paths:
141
+ - lib
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ requirements: []
153
+ rubygems_version: 3.0.3
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: Pronto runner for findbugs / spotbugs
157
+ test_files: []