pronto-checkstyle 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: df42054679cdde689063004e950bc05babf55f2e946abe78a79e968c6e0b6d44
4
+ data.tar.gz: 6ab6338278afdda321c5aba6b74fa9997a95341dc2471f7e00a41887ff02f36a
5
+ SHA512:
6
+ metadata.gz: a5397af82fe336f4336fdcbc61c36ab55881bf25c5b964cf68eb8cb04e6c484576a9fd8a3b740afdbc4ccc2e5d3f40b27aa27250eadbd72d053664cc729945e1
7
+ data.tar.gz: 75d806268d7c73d3e06c2baf3b1ef033cff091c7d40df6062484bbb9b0f76100f334e2328b487b4239f2fe2743464f4b365c3b31be2b0a0f9464a604aa5f2945
@@ -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-checkstyle.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::Checkstyle
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/pronto-checkstyle.svg)](http://badge.fury.io/rb/pronto-checkstyle)
4
+ [![Build Status](https://travis-ci.org/seikichi/pronto-checkstyle.svg?branch=master)](https://travis-ci.org/seikichi/pronto-checkstyle)
5
+ [![Coverage Status](https://coveralls.io/repos/seikichi/pronto-checkstyle/badge.svg?branch=master&service=github)](https://coveralls.io/github/seikichi/pronto-checkstyle?branch=master)
6
+
7
+ [Pronto](https://github.com/mmozuras/pronto) runner for [checkstyle](http://checkstyle.sourceforge.net/).
8
+
9
+ ## Configuration
10
+
11
+ You need to specify location of checkstyle reports by passing `PRONTO_CHECKSTYLE_REPORTS_DIR` env variable e.g:
12
+
13
+ ```bash
14
+ PRONTO_CHECKSTYLE_REPORTS_DIR=build/reports/checkstyle/ pronto run --index
15
+ ```
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ ```ruby
22
+ gem 'pronto-checkstyle'
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install pronto-checkstyle
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-checkstyle.
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/checkstyle'
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,71 @@
1
+ require 'pronto'
2
+ require 'rexml/document'
3
+
4
+ module Pronto
5
+ class Checkstyle < 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 checkstyle_reports_dir
20
+ ENV['PRONTO_CHECKSTYLE_REPORTS_DIR'] || (raise 'Please set `PRONT_CHECKSTYLE_REPORTS_DIR` to use pronto-checkstyle')
21
+ end
22
+
23
+ def valid_patch?(patch)
24
+ patch.additions > 0
25
+ end
26
+
27
+ def inspect(patch)
28
+ offences = checkstyle_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 checkstyle_offences
38
+ @checkstyle_offences ||=
39
+ begin
40
+ pattern = File.join(checkstyle_reports_dir, '**', '*.xml')
41
+ Dir.glob(pattern).flat_map(&method(:read_checkstyle_report))
42
+ end
43
+ end
44
+
45
+ def read_checkstyle_report(path)
46
+ doc = REXML::Document.new(File.read(path))
47
+ REXML::XPath.match(doc, '/checkstyle/file').flat_map do |file|
48
+ REXML::XPath.match(file, 'error').map do |error|
49
+ Offence.new(path_from(file), line_from(error), message_from(error))
50
+ end
51
+ end
52
+ end
53
+
54
+ def path_from(file_node)
55
+ file_node.attribute('name').to_s
56
+ end
57
+
58
+ def line_from(error_node)
59
+ error_node.attribute('line').to_s.to_i
60
+ end
61
+
62
+ def message_from(error_node)
63
+ error_node.attribute('message').to_s
64
+ end
65
+
66
+ def new_message(offence, line)
67
+ path = line.patch.delta.new_file[:path]
68
+ Message.new(path, line, :warning, offence.message, nil, self.class)
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,5 @@
1
+ module Pronto
2
+ module CheckstyleVersion
3
+ VERSION = '0.1.0'.freeze
4
+ end
5
+ end
@@ -0,0 +1,35 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'pronto/checkstyle/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'pronto-checkstyle'
7
+ spec.version = Pronto::CheckstyleVersion::VERSION
8
+ spec.authors = ['Seiichi KONDO']
9
+ spec.email = ['seikichi@kmc.gr.jp']
10
+
11
+ spec.summary = 'Pronto runner for checkstyle / spotbugs'
12
+ spec.description = <<-DESCRIPTION
13
+ A pronto runner for checkstyle 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-checkstyle'
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 'pry'
31
+ spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'rubocop', '~> 0.62'
33
+ spec.add_development_dependency 'simplecov'
34
+ spec.add_development_dependency 'test-unit', '~> 3.2.8'
35
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pronto-checkstyle
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: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.62'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.62'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: test-unit
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 3.2.8
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 3.2.8
125
+ description: |2
126
+ A pronto runner for checkstyle and spotbugs.
127
+ Pronto runs analysis quickly by checking only the relevant changes.
128
+ Created to be used on pull requests, but suited for other scenarios as well.
129
+ email:
130
+ - seikichi@kmc.gr.jp
131
+ executables: []
132
+ extensions: []
133
+ extra_rdoc_files: []
134
+ files:
135
+ - ".gitignore"
136
+ - ".rubocop.yml"
137
+ - ".travis.yml"
138
+ - CODE_OF_CONDUCT.md
139
+ - Gemfile
140
+ - LICENSE.txt
141
+ - README.md
142
+ - Rakefile
143
+ - bin/console
144
+ - bin/setup
145
+ - lib/pronto/checkstyle.rb
146
+ - lib/pronto/checkstyle/version.rb
147
+ - pronto-checkstyle.gemspec
148
+ homepage: https://github.com/seikichi/pronto-checkstyle
149
+ licenses:
150
+ - MIT
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubygems_version: 3.0.3
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: Pronto runner for checkstyle / spotbugs
171
+ test_files: []