java-checkstyle 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/plugins/{pre-commit → pre_commit}/checks/checkstyle.rb +3 -3
- data/lib/plugins/{pre-commit → pre_commit}/domain/bad_file.rb +0 -0
- data/lib/plugins/{pre-commit → pre_commit}/domain/checkstyle.rb +0 -0
- data/lib/plugins/{pre-commit → pre_commit}/message/extractor.rb +0 -0
- data/lib/plugins/{pre-commit → pre_commit}/message/formatter.rb +0 -0
- data/lib/plugins/{pre-commit → pre_commit}/support/path.rb +1 -1
- data/lib/{pre-commit → pre_commit}/checkstyle/version.rb +1 -1
- metadata +11 -43
- data/.codeclimate.yml +0 -2
- data/.gitignore +0 -17
- data/.rspec +0 -2
- data/.travis.yml +0 -9
- data/DETAILED_TUTORIAL.md +0 -102
- data/Gemfile +0 -12
- data/LICENSE.txt +0 -22
- data/README.md +0 -93
- data/Rakefile +0 -6
- data/demo.png +0 -0
- data/java-checkstyle.gemspec +0 -28
- data/readmedemo.png +0 -0
- data/spec/fixtures/bad.java +0 -5
- data/spec/fixtures/bad2.java +0 -6
- data/spec/fixtures/good.java +0 -23
- data/spec/fixtures/output_one_bad_file.log +0 -8
- data/spec/fixtures/output_two_bad_files.log +0 -12
- data/spec/fixtures/sun_checks.xml +0 -177
- data/spec/plugins/pre_commit/checks/checkstyle_spec.rb +0 -49
- data/spec/plugins/pre_commit/message/extractor_spec.rb +0 -103
- data/spec/plugins/pre_commit/message/formatter_spec.rb +0 -62
- data/spec/spec_helper.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 154702209a4a34056e341763612d8f2b579621fd
|
4
|
+
data.tar.gz: 7178106c9490089b1faef4a9671696c7d8aa5879
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b1aef329a6b13a031f155e6b394ae106f92b231eceac65f8a590245ccbf97d61501ba0cd5e8b5a0444699139343c07f1e2d0340695a1e0d3ca292543a147b75
|
7
|
+
data.tar.gz: 807414b774d3914b0eb26dbc9eb94af927885b7c123cefd42daeb35a2f8458731ac46f9f99f00ec380b993dd19222cabae624a937d59b0b75e64d43c586daedd
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'pre-commit/checks/
|
1
|
+
require 'pre-commit/checks/shell'
|
2
2
|
require_relative '../message/extractor'
|
3
3
|
require_relative '../message/formatter'
|
4
4
|
require_relative '../support/path'
|
@@ -10,8 +10,8 @@ module PreCommit
|
|
10
10
|
#
|
11
11
|
# It provides a java checkstyle validation using checkstyle.jar
|
12
12
|
# for details see:
|
13
|
-
# lib/
|
14
|
-
class Checkstyle <
|
13
|
+
# lib/pre_commit/support/checkstyle
|
14
|
+
class Checkstyle < Shell
|
15
15
|
##
|
16
16
|
# Function called after pre-commit execution
|
17
17
|
# this method receive the +staged_files+ from git
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Support
|
2
2
|
##
|
3
3
|
# Responsible for provide relative paths to support files
|
4
|
-
# Files located under: /lib/plugin/
|
4
|
+
# Files located under: /lib/plugin/pre_commit/support/checkstyle*
|
5
5
|
module Path
|
6
6
|
##
|
7
7
|
# Return support path relative to a given +file+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: java-checkstyle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Allen Madsen
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-09-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pre-commit
|
@@ -111,37 +111,15 @@ executables: []
|
|
111
111
|
extensions: []
|
112
112
|
extra_rdoc_files: []
|
113
113
|
files:
|
114
|
-
-
|
115
|
-
-
|
116
|
-
-
|
117
|
-
-
|
118
|
-
-
|
119
|
-
-
|
120
|
-
-
|
121
|
-
- README.md
|
122
|
-
- Rakefile
|
123
|
-
- demo.png
|
124
|
-
- java-checkstyle.gemspec
|
125
|
-
- lib/plugins/pre-commit/checks/checkstyle.rb
|
126
|
-
- lib/plugins/pre-commit/domain/bad_file.rb
|
127
|
-
- lib/plugins/pre-commit/domain/checkstyle.rb
|
128
|
-
- lib/plugins/pre-commit/message/extractor.rb
|
129
|
-
- lib/plugins/pre-commit/message/formatter.rb
|
130
|
-
- lib/plugins/pre-commit/support/path.rb
|
131
|
-
- lib/pre-commit/checkstyle/version.rb
|
114
|
+
- lib/plugins/pre_commit/checks/checkstyle.rb
|
115
|
+
- lib/plugins/pre_commit/domain/bad_file.rb
|
116
|
+
- lib/plugins/pre_commit/domain/checkstyle.rb
|
117
|
+
- lib/plugins/pre_commit/message/extractor.rb
|
118
|
+
- lib/plugins/pre_commit/message/formatter.rb
|
119
|
+
- lib/plugins/pre_commit/support/path.rb
|
120
|
+
- lib/pre_commit/checkstyle/version.rb
|
132
121
|
- lib/resources/checkstyle/checkstyle-6.11-all.jar
|
133
122
|
- lib/resources/checkstyle/google_checks.xml
|
134
|
-
- readmedemo.png
|
135
|
-
- spec/fixtures/bad.java
|
136
|
-
- spec/fixtures/bad2.java
|
137
|
-
- spec/fixtures/good.java
|
138
|
-
- spec/fixtures/output_one_bad_file.log
|
139
|
-
- spec/fixtures/output_two_bad_files.log
|
140
|
-
- spec/fixtures/sun_checks.xml
|
141
|
-
- spec/plugins/pre_commit/checks/checkstyle_spec.rb
|
142
|
-
- spec/plugins/pre_commit/message/extractor_spec.rb
|
143
|
-
- spec/plugins/pre_commit/message/formatter_spec.rb
|
144
|
-
- spec/spec_helper.rb
|
145
123
|
homepage: https://github.com/CristianOliveira/java-checkstyle
|
146
124
|
licenses:
|
147
125
|
- MIT
|
@@ -162,18 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
140
|
version: '0'
|
163
141
|
requirements: []
|
164
142
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.
|
143
|
+
rubygems_version: 2.2.2
|
166
144
|
signing_key:
|
167
145
|
specification_version: 4
|
168
146
|
summary: Checkstyle linter plugin for pre-commit
|
169
|
-
test_files:
|
170
|
-
- spec/fixtures/bad.java
|
171
|
-
- spec/fixtures/bad2.java
|
172
|
-
- spec/fixtures/good.java
|
173
|
-
- spec/fixtures/output_one_bad_file.log
|
174
|
-
- spec/fixtures/output_two_bad_files.log
|
175
|
-
- spec/fixtures/sun_checks.xml
|
176
|
-
- spec/plugins/pre_commit/checks/checkstyle_spec.rb
|
177
|
-
- spec/plugins/pre_commit/message/extractor_spec.rb
|
178
|
-
- spec/plugins/pre_commit/message/formatter_spec.rb
|
179
|
-
- spec/spec_helper.rb
|
147
|
+
test_files: []
|
data/.codeclimate.yml
DELETED
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
data/DETAILED_TUTORIAL.md
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
### Java - Pre-Commit Checkstyle
|
2
|
-
|
3
|
-
## Detailed Installation Guide
|
4
|
-
|
5
|
-
This is a detailed version to install this useful hook.
|
6
|
-
|
7
|
-
# Let`s do it!
|
8
|
-
|
9
|
-
First install and setup the check in pre-commit:
|
10
|
-
### Pre-Commit Checkstyle
|
11
|
-
Install the gem
|
12
|
-
|
13
|
-
$ gem install pre-commit
|
14
|
-
|
15
|
-
### Install the Java-checkstyle gem
|
16
|
-
|
17
|
-
Add this line to your application's Gemfile:
|
18
|
-
|
19
|
-
gem 'java-checkstyle'
|
20
|
-
|
21
|
-
And then execute:
|
22
|
-
|
23
|
-
$ bundle
|
24
|
-
|
25
|
-
Or install it yourself as:
|
26
|
-
|
27
|
-
$ gem install java-checkstyle
|
28
|
-
|
29
|
-
Now your pre-commit hook has been installed.
|
30
|
-
|
31
|
-
## Using in your project
|
32
|
-
|
33
|
-
Create your project folder and start a git repository
|
34
|
-
|
35
|
-
```bash
|
36
|
-
mkdir awesome_project
|
37
|
-
cd awesome_project
|
38
|
-
git init
|
39
|
-
```
|
40
|
-
**Install the hook for this repository**
|
41
|
-
|
42
|
-
Use the pre-commit command to generate a stub pre-commit hook
|
43
|
-
```bash
|
44
|
-
# Inside of your project with git
|
45
|
-
pre-commit install
|
46
|
-
```
|
47
|
-
This creates a .git/hooks/pre-commit script which will check your git config and run checks that are enabled.
|
48
|
-
|
49
|
-
**Enable the java checkstyle checks**
|
50
|
-
|
51
|
-
``` bash
|
52
|
-
pre-commit enable git checks checkstyle
|
53
|
-
```
|
54
|
-
|
55
|
-
OR
|
56
|
-
|
57
|
-
``` bash
|
58
|
-
pre-commit enable yaml checks checkstyle
|
59
|
-
```
|
60
|
-
|
61
|
-
Then the pre commmit has been configured! For this your repository.
|
62
|
-
|
63
|
-
## Let`s test it!
|
64
|
-
Create a new java code with some style errors see: [Google checkstyle guide](http://google.github.io/styleguide/javaguide.html)
|
65
|
-
|
66
|
-
```java
|
67
|
-
class HelloWorld
|
68
|
-
{
|
69
|
-
public static void main(String[] args)
|
70
|
-
{
|
71
|
-
System.out.println("Hello World!");
|
72
|
-
}
|
73
|
-
}
|
74
|
-
```
|
75
|
-
Then add it and try commit
|
76
|
-
``` bash
|
77
|
-
git add .
|
78
|
-
git commit -m "Time's up, let's do this! Leeeeeeeeeeeeeroy Jjjjjjenkinsss!!"
|
79
|
-
```
|
80
|
-
|
81
|
-
Still don`t know our hero Leroy Jenkis? Oh man! see [here](https://www.youtube.com/watch?v=LkCNJRfSZBU)
|
82
|
-
|
83
|
-
![My awesome change has been catch. Oh boy!](https://raw.githubusercontent.com/CristianOliveiraDaRosa/java-checkstyle/master/demo.png)
|
84
|
-
|
85
|
-
---
|
86
|
-
## Installing with RVM
|
87
|
-
|
88
|
-
If you are using rvm you need to install pre-commit into the ```default``` gemset, because it does not use the ```current``` environment
|
89
|
-
|
90
|
-
$ rvm default do gem install pre-commit
|
91
|
-
|
92
|
-
Alternatively you can configure pre-commit to use the ```current``` rvm gemset
|
93
|
-
|
94
|
-
$ git config pre-commit.ruby "rvm `rvm current` do ruby"
|
95
|
-
|
96
|
-
More details about this part see on:
|
97
|
-
[pre-commit](https://github.com/jish/pre-commit)
|
98
|
-
|
99
|
-
## Authors:
|
100
|
-
- Allen Madsen (Original Version 0.0.1)
|
101
|
-
- Alex Rocha
|
102
|
-
- Cristian Oliveira
|
data/Gemfile
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in pre-commit-checkstyle.gemspec
|
4
|
-
gemspec
|
5
|
-
gem 'crack'
|
6
|
-
|
7
|
-
group :test do
|
8
|
-
gem "simplecov"
|
9
|
-
gem "codeclimate-test-reporter", require: nil
|
10
|
-
gem 'rubocop', require: false
|
11
|
-
# gem 'byebug' not add as default it is not compatible with ruby 2 >= version
|
12
|
-
end
|
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2014 Allen Madsen
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
## Java - Pre-Commit Checkstyle
|
2
|
-
[![Gem Version](https://badge.fury.io/rb/java-checkstyle.svg)](https://badge.fury.io/rb/java-checkstyle)
|
3
|
-
[![Build Status](https://travis-ci.org/cristianoliveira/java-checkstyle.svg)](https://travis-ci.org/CristianOliveiraDaRosa/java-checkstyle)
|
4
|
-
[![Code Climate](https://codeclimate.com/github/cristianoliveira/java-checkstyle/badges/gpa.svg)](https://codeclimate.com/github/cristianoliveira/java-checkstyle)
|
5
|
-
[![Test Coverage](https://codeclimate.com/github/cristianoliveira/java-checkstyle/badges/coverage.svg)](https://codeclimate.com/github/cristianoliveira/java-checkstyle/coverage)
|
6
|
-
|
7
|
-
Useful git pre-commit hook for linting Java code.
|
8
|
-
|
9
|
-
It uses as default [The Google Style Guide](https://google.github.io/styleguide/javaguide.html)
|
10
|
-
and the famous [Checkstyle](http://checkstyle.sourceforge.net/) linter as a plugin for [pre-commit](https://github.com/jish/pre-commit).
|
11
|
-
|
12
|
-
## Demo
|
13
|
-
|
14
|
-
![My awesome change has been catch. Oh boy!](https://raw.githubusercontent.com/cristianoliveira/java-checkstyle/master/readmedemo.png)
|
15
|
-
[Don't you know who is Leeroy Jenkins?](https://www.youtube.com/watch?v=mLyOj_QD4a4)
|
16
|
-
|
17
|
-
## Installation
|
18
|
-
|
19
|
-
First install the gems.
|
20
|
-
#### Pre-Commit Checkstyle
|
21
|
-
|
22
|
-
gem install pre-commit
|
23
|
-
|
24
|
-
#### Java Checkstyle Plugin
|
25
|
-
|
26
|
-
gem install java-checkstyle
|
27
|
-
|
28
|
-
##### (optional) If you use RVM
|
29
|
-
Take a look here [Install with RVM](https://github.com/jish/pre-commit#rvm)
|
30
|
-
|
31
|
-
### Configuring
|
32
|
-
Use the pre-commit command to generate a stub pre-commit hook.
|
33
|
-
Inside folder of your git repo:
|
34
|
-
|
35
|
-
```bash
|
36
|
-
pre-commit install
|
37
|
-
```
|
38
|
-
|
39
|
-
It will create a .git/hooks/pre-commit script which will check your git config and run checks that are enabled.
|
40
|
-
|
41
|
-
#### Enabling checks
|
42
|
-
|
43
|
-
``` bash
|
44
|
-
pre-commit enable git checks checkstyle
|
45
|
-
```
|
46
|
-
|
47
|
-
### Result
|
48
|
-
Every time you try to commit some java code with style errors it will validate
|
49
|
-
for you ensuring that your code will be always awesome.
|
50
|
-
|
51
|
-
---
|
52
|
-
#### Detailed version to install.
|
53
|
-
Still don't work? Try the detailed version [here](https://github.com/cristianoliveira/java-checkstyle/blob/master/DETAILED_TUTORIAL.md)
|
54
|
-
|
55
|
-
---
|
56
|
-
|
57
|
-
## Checkstyle Guide
|
58
|
-
|
59
|
-
It uses as default [The Google Style Guide](https://google.github.io/styleguide/javaguide.html).
|
60
|
-
|
61
|
-
## Tests
|
62
|
-
Running tests with rspec
|
63
|
-
|
64
|
-
Make sure you have been executed:
|
65
|
-
```bash
|
66
|
-
bundle install
|
67
|
-
```
|
68
|
-
Then run:
|
69
|
-
|
70
|
-
```bash
|
71
|
-
rspec
|
72
|
-
```
|
73
|
-
|
74
|
-
## Contributing
|
75
|
-
|
76
|
-
1. Fork it
|
77
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
78
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
79
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
80
|
-
5. Create new Pull Request
|
81
|
-
|
82
|
-
#### Codeclimate
|
83
|
-
Before push, make sure you have been executed rubocop
|
84
|
-
``` bash
|
85
|
-
rubocop lib/*
|
86
|
-
```
|
87
|
-
|
88
|
-
*Pull request should have Unit Tests*
|
89
|
-
|
90
|
-
## Authors:
|
91
|
-
- Allen Madsen (Original Version 0.0.1)
|
92
|
-
- Alex Rocha
|
93
|
-
- Cristian Oliveira
|
data/Rakefile
DELETED
data/demo.png
DELETED
Binary file
|
data/java-checkstyle.gemspec
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require './lib/pre-commit/checkstyle/version.rb'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "java-checkstyle"
|
8
|
-
spec.version = PreCommit::Checkstyle::VERSION
|
9
|
-
spec.authors = ["Allen Madsen", "Cristian Oliveira", "Alex Rocha"]
|
10
|
-
spec.email = ["blatyo@gmail.com", "contato@cristianoliveira.com.br", "alex.rochas@yahoo.com.br"]
|
11
|
-
spec.summary = %q{Checkstyle linter plugin for pre-commit}
|
12
|
-
spec.description = %q{Checkstyle linter plugin for pre-commit. Useful for linting Java code.}
|
13
|
-
spec.homepage = "https://github.com/CristianOliveira/java-checkstyle"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_dependency('pre-commit', '~> 0.26')
|
22
|
-
spec.add_dependency('crack', '~> 0.4.2')
|
23
|
-
|
24
|
-
spec.add_development_dependency("bundler", "~> 1.5")
|
25
|
-
spec.add_development_dependency("rake", '~> 10.4', '>= 10.4.2')
|
26
|
-
spec.add_development_dependency('rspec', '~> 3.3.0')
|
27
|
-
spec.add_development_dependency('rubocop', '~> 0.34.2')
|
28
|
-
end
|
data/readmedemo.png
DELETED
Binary file
|
data/spec/fixtures/bad.java
DELETED
data/spec/fixtures/bad2.java
DELETED
data/spec/fixtures/good.java
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Typical hello world example.
|
3
|
-
* It has a good style.
|
4
|
-
*/
|
5
|
-
final class Good {
|
6
|
-
/**
|
7
|
-
* Prevent class from being instantiated.
|
8
|
-
*
|
9
|
-
* @throws AssertionError if some smart guy try.
|
10
|
-
*/
|
11
|
-
public Good() {
|
12
|
-
throw new AssertionError("Instantiating utility class...");
|
13
|
-
}
|
14
|
-
|
15
|
-
/**
|
16
|
-
* Prints Hello World!
|
17
|
-
*
|
18
|
-
* @param args Command line arguments.
|
19
|
-
*/
|
20
|
-
public static void main(final String[] args) {
|
21
|
-
System.out.println("Hello World!");
|
22
|
-
}
|
23
|
-
}
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<checkstyle version="6.11">
|
3
|
-
<file name="/Users/cristianoliveira/work/java-checkstyle/spec/fixtures/bad.java">
|
4
|
-
<error line="1" severity="error" message="some error message" source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck"/>
|
5
|
-
<error line="11" column= "1 " severity= "warning" message="some error message" source="com.puppycrawl.tools.checkstyle.checks.design.HideUtilityClassConstructorCheck"/>
|
6
|
-
</file>
|
7
|
-
</checkstyle>
|
8
|
-
Checkstyle ends with 4 errors.
|
@@ -1,12 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<checkstyle version="6.11">
|
3
|
-
<file name="/Users/cristianoliveira/work/java-checkstyle/spec/fixtures/bad.java">
|
4
|
-
<error line="1" severity="error" message="some error message" source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck"/>
|
5
|
-
<error line="11" column= "1 " severity= "warning" message="some error message" source="com.puppycrawl.tools.checkstyle.checks.design.HideUtilityClassConstructorCheck"/>
|
6
|
-
</file>
|
7
|
-
<file name="/Users/cristianoliveira/work/java-checkstyle/spec/fixtures/bad2.java">
|
8
|
-
<error line="2 " column= "3 " severity= "error" message="some error message" source= "com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck "/>
|
9
|
-
<error line="2 " column= "27 " severity= "error" message="some error message" source= "com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck "/>
|
10
|
-
</file>
|
11
|
-
</checkstyle>
|
12
|
-
Checkstyle ends with 4 errors.
|
@@ -1,177 +0,0 @@
|
|
1
|
-
<?xml version="1.0"?>
|
2
|
-
<!DOCTYPE module PUBLIC
|
3
|
-
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
4
|
-
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
5
|
-
|
6
|
-
<!--
|
7
|
-
|
8
|
-
Checkstyle configuration that checks the sun coding conventions from:
|
9
|
-
|
10
|
-
- the Java Language Specification at
|
11
|
-
http://java.sun.com/docs/books/jls/second_edition/html/index.html
|
12
|
-
|
13
|
-
- the Sun Code Conventions at http://java.sun.com/docs/codeconv/
|
14
|
-
|
15
|
-
- the Javadoc guidelines at
|
16
|
-
http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
|
17
|
-
|
18
|
-
- the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html
|
19
|
-
|
20
|
-
- some best practices
|
21
|
-
|
22
|
-
Checkstyle is very configurable. Be sure to read the documentation at
|
23
|
-
http://checkstyle.sf.net (or in your downloaded distribution).
|
24
|
-
|
25
|
-
Most Checks are configurable, be sure to consult the documentation.
|
26
|
-
|
27
|
-
To completely disable a check, just comment it out or delete it from the file.
|
28
|
-
|
29
|
-
Finally, it is worth reading the documentation.
|
30
|
-
|
31
|
-
-->
|
32
|
-
|
33
|
-
<module name="Checker">
|
34
|
-
<!--
|
35
|
-
If you set the basedir property below, then all reported file
|
36
|
-
names will be relative to the specified directory. See
|
37
|
-
http://checkstyle.sourceforge.net/5.x/config.html#Checker
|
38
|
-
|
39
|
-
<property name="basedir" value="${basedir}"/>
|
40
|
-
-->
|
41
|
-
|
42
|
-
<!-- Checks that a package-info.java file exists for each package. -->
|
43
|
-
<!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage -->
|
44
|
-
<!-- <module name="JavadocPackage"/> -->
|
45
|
-
|
46
|
-
<!-- Checks whether files end with a new line. -->
|
47
|
-
<!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
|
48
|
-
<module name="NewlineAtEndOfFile"/>
|
49
|
-
|
50
|
-
<!-- Checks that property files contain the same keys. -->
|
51
|
-
<!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
|
52
|
-
<module name="Translation"/>
|
53
|
-
|
54
|
-
<!-- Checks for Size Violations. -->
|
55
|
-
<!-- See http://checkstyle.sf.net/config_sizes.html -->
|
56
|
-
<module name="FileLength"/>
|
57
|
-
|
58
|
-
<!-- Checks for whitespace -->
|
59
|
-
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
|
60
|
-
<module name="FileTabCharacter"/>
|
61
|
-
|
62
|
-
<!-- Miscellaneous other checks. -->
|
63
|
-
<!-- See http://checkstyle.sf.net/config_misc.html -->
|
64
|
-
<module name="RegexpSingleline">
|
65
|
-
<property name="format" value="\s+$"/>
|
66
|
-
<property name="minimum" value="0"/>
|
67
|
-
<property name="maximum" value="0"/>
|
68
|
-
<property name="message" value="Line has trailing spaces."/>
|
69
|
-
</module>
|
70
|
-
|
71
|
-
<!-- Checks for Headers -->
|
72
|
-
<!-- See http://checkstyle.sf.net/config_header.html -->
|
73
|
-
<!-- <module name="Header"> -->
|
74
|
-
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
|
75
|
-
<!-- <property name="fileExtensions" value="java"/> -->
|
76
|
-
<!-- </module> -->
|
77
|
-
|
78
|
-
<module name="TreeWalker">
|
79
|
-
|
80
|
-
<!-- Checks for Javadoc comments. -->
|
81
|
-
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
|
82
|
-
<module name="JavadocMethod"/>
|
83
|
-
<module name="JavadocType"/>
|
84
|
-
<module name="JavadocVariable"/>
|
85
|
-
<module name="JavadocStyle"/>
|
86
|
-
|
87
|
-
|
88
|
-
<!-- Checks for Naming Conventions. -->
|
89
|
-
<!-- See http://checkstyle.sf.net/config_naming.html -->
|
90
|
-
<module name="ConstantName"/>
|
91
|
-
<module name="LocalFinalVariableName"/>
|
92
|
-
<module name="LocalVariableName"/>
|
93
|
-
<module name="MemberName"/>
|
94
|
-
<module name="MethodName"/>
|
95
|
-
<module name="PackageName"/>
|
96
|
-
<module name="ParameterName"/>
|
97
|
-
<module name="StaticVariableName"/>
|
98
|
-
<module name="TypeName"/>
|
99
|
-
|
100
|
-
|
101
|
-
<!-- Checks for imports -->
|
102
|
-
<!-- See http://checkstyle.sf.net/config_import.html -->
|
103
|
-
<module name="AvoidStarImport"/>
|
104
|
-
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
|
105
|
-
<module name="RedundantImport"/>
|
106
|
-
<module name="UnusedImports"/>
|
107
|
-
|
108
|
-
|
109
|
-
<!-- Checks for Size Violations. -->
|
110
|
-
<!-- See http://checkstyle.sf.net/config_sizes.html -->
|
111
|
-
<module name="LineLength"/>
|
112
|
-
<module name="MethodLength"/>
|
113
|
-
<module name="ParameterNumber"/>
|
114
|
-
|
115
|
-
|
116
|
-
<!-- Checks for whitespace -->
|
117
|
-
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
|
118
|
-
<module name="EmptyForIteratorPad"/>
|
119
|
-
<module name="GenericWhitespace"/>
|
120
|
-
<module name="MethodParamPad"/>
|
121
|
-
<module name="NoWhitespaceAfter"/>
|
122
|
-
<module name="NoWhitespaceBefore"/>
|
123
|
-
<module name="OperatorWrap"/>
|
124
|
-
<module name="ParenPad"/>
|
125
|
-
<module name="TypecastParenPad"/>
|
126
|
-
<module name="WhitespaceAfter"/>
|
127
|
-
<module name="WhitespaceAround"/>
|
128
|
-
|
129
|
-
|
130
|
-
<!-- Modifier Checks -->
|
131
|
-
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
|
132
|
-
<module name="ModifierOrder"/>
|
133
|
-
<module name="RedundantModifier"/>
|
134
|
-
|
135
|
-
|
136
|
-
<!-- Checks for blocks. You know, those {}'s -->
|
137
|
-
<!-- See http://checkstyle.sf.net/config_blocks.html -->
|
138
|
-
<module name="AvoidNestedBlocks"/>
|
139
|
-
<module name="EmptyBlock"/>
|
140
|
-
<module name="LeftCurly"/>
|
141
|
-
<module name="NeedBraces"/>
|
142
|
-
<module name="RightCurly"/>
|
143
|
-
|
144
|
-
|
145
|
-
<!-- Checks for common coding problems -->
|
146
|
-
<!-- See http://checkstyle.sf.net/config_coding.html -->
|
147
|
-
<module name="AvoidInlineConditionals"/>
|
148
|
-
<module name="EmptyStatement"/>
|
149
|
-
<module name="EqualsHashCode"/>
|
150
|
-
<module name="HiddenField"/>
|
151
|
-
<module name="IllegalInstantiation"/>
|
152
|
-
<module name="InnerAssignment"/>
|
153
|
-
<module name="MagicNumber"/>
|
154
|
-
<module name="MissingSwitchDefault"/>
|
155
|
-
<!--<module name="RedundantThrows"/>-->
|
156
|
-
<module name="SimplifyBooleanExpression"/>
|
157
|
-
<module name="SimplifyBooleanReturn"/>
|
158
|
-
|
159
|
-
<!-- Checks for class design -->
|
160
|
-
<!-- See http://checkstyle.sf.net/config_design.html -->
|
161
|
-
<module name="DesignForExtension"/>
|
162
|
-
<module name="FinalClass"/>
|
163
|
-
<module name="HideUtilityClassConstructor"/>
|
164
|
-
<module name="InterfaceIsType"/>
|
165
|
-
<module name="VisibilityModifier"/>
|
166
|
-
|
167
|
-
|
168
|
-
<!-- Miscellaneous other checks. -->
|
169
|
-
<!-- See http://checkstyle.sf.net/config_misc.html -->
|
170
|
-
<module name="ArrayTypeStyle"/>
|
171
|
-
<module name="FinalParameters"/>
|
172
|
-
<module name="TodoComment"/>
|
173
|
-
<module name="UpperEll"/>
|
174
|
-
|
175
|
-
</module>
|
176
|
-
|
177
|
-
</module>
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'plugins/pre-commit/checks/checkstyle'
|
3
|
-
|
4
|
-
describe PreCommit::Checks::Checkstyle do
|
5
|
-
let(:config) {double(PreCommit::Configuration, get: '')}
|
6
|
-
let(:check) {PreCommit::Checks::Checkstyle.new(nil, config, [])}
|
7
|
-
|
8
|
-
it "succeds if nothing changed" do
|
9
|
-
expect(check.call([])).to be_nil
|
10
|
-
end
|
11
|
-
|
12
|
-
it "succeeds for good code" do
|
13
|
-
files = [fixture_file('Good.java')]
|
14
|
-
expect(check.call(files)).to be_nil
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should fail for bad formatted code" do
|
18
|
-
file = fixture_file("bad.java")
|
19
|
-
|
20
|
-
result = check.call([file])
|
21
|
-
|
22
|
-
expect(result).to include "File errors: #{file}"
|
23
|
-
expect(result).to include "line: 1: error:"
|
24
|
-
expect(result).to include "line: 1:7 error:"
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should accept multiple fails" do
|
28
|
-
# given
|
29
|
-
file = fixture_file("bad.java")
|
30
|
-
file2 = fixture_file("bad2.java")
|
31
|
-
|
32
|
-
# when
|
33
|
-
result = check.call([file, file2])
|
34
|
-
|
35
|
-
# then
|
36
|
-
expect(result).to include "File errors: #{file}"
|
37
|
-
expect(result).to include "File errors: #{file2}"
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should accept custom checkstyle" do
|
41
|
-
# given
|
42
|
-
ENV["CHECKSTYLE_CONFIG"] = "sun_checks.xml"
|
43
|
-
files = [fixture_file('bad.java')]
|
44
|
-
# when
|
45
|
-
result = check.call(files)
|
46
|
-
# then
|
47
|
-
expect(result).to_not be_nil
|
48
|
-
end
|
49
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'plugins/pre-commit/message/extractor'
|
3
|
-
require 'plugins/pre-commit/domain/checkstyle'
|
4
|
-
require 'plugins/pre-commit/domain/bad_file'
|
5
|
-
|
6
|
-
##
|
7
|
-
# Tests for PreCommit::Message::Extractor
|
8
|
-
describe PreCommit::Message::Extractor do
|
9
|
-
let(:extractor) { PreCommit::Message::Extractor.new }
|
10
|
-
|
11
|
-
context "When nil output" do
|
12
|
-
it "should be good" do
|
13
|
-
expect( extractor.extract(nil) ).to be_good
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context "When empty output" do
|
18
|
-
it "should be good" do
|
19
|
-
expect( extractor.extract('') ).to be_good
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context "When has one bad file" do
|
24
|
-
# given
|
25
|
-
let(:output) { IO.read(fixture_file("output_one_bad_file.log")) }
|
26
|
-
|
27
|
-
# when
|
28
|
-
before { @checkstyle = extractor.extract(output) }
|
29
|
-
|
30
|
-
# then
|
31
|
-
it "should not be good" do
|
32
|
-
expect( @checkstyle ).to_not be_good
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should contain one single file" do
|
36
|
-
expect( @checkstyle.bad_files ).to be_a Array
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should contain its errors" do
|
40
|
-
expect( @checkstyle.bad_files[0].errors.size ).to be 2
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should extract error details" do
|
44
|
-
expect( @checkstyle.bad_files[0].errors ).to eq(
|
45
|
-
[
|
46
|
-
{
|
47
|
-
"line"=>"1",
|
48
|
-
"severity"=>"error",
|
49
|
-
"message"=>"some error message",
|
50
|
-
"source"=>"com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck"
|
51
|
-
},
|
52
|
-
{
|
53
|
-
"line" => "11",
|
54
|
-
"column" => "1 ",
|
55
|
-
"severity" => "warning",
|
56
|
-
"message" => "some error message",
|
57
|
-
"source" => "com.puppycrawl.tools.checkstyle.checks.design.HideUtilityClassConstructorCheck"
|
58
|
-
}
|
59
|
-
]
|
60
|
-
)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context "When has multiple bad files" do
|
65
|
-
# given
|
66
|
-
let(:output) { IO.read(fixture_file("output_two_bad_files.log")) }
|
67
|
-
|
68
|
-
# when
|
69
|
-
before { @checkstyle = extractor.extract output }
|
70
|
-
|
71
|
-
# then
|
72
|
-
it "should not be good" do
|
73
|
-
expect( @checkstyle ).to_not be_good
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should extract multiple files" do
|
77
|
-
expect( @checkstyle.bad_files ).to be_a Array
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should extract their errors" do
|
81
|
-
expect( @checkstyle.bad_files[0].errors.size ).to be 2
|
82
|
-
expect( @checkstyle.bad_files[1].errors.size ).to be 2
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should extract error details" do
|
86
|
-
expect( @checkstyle.bad_files[0].errors ).to eq ([
|
87
|
-
{
|
88
|
-
"line"=>"1",
|
89
|
-
"severity"=>"error",
|
90
|
-
"message"=>"some error message",
|
91
|
-
"source"=>"com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck"
|
92
|
-
},
|
93
|
-
{
|
94
|
-
"line" => "11",
|
95
|
-
"column" => "1 ",
|
96
|
-
"severity" => "warning",
|
97
|
-
"message" => "some error message",
|
98
|
-
"source" => "com.puppycrawl.tools.checkstyle.checks.design.HideUtilityClassConstructorCheck"
|
99
|
-
}
|
100
|
-
])
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'plugins/pre-commit/message/formatter'
|
3
|
-
require 'plugins/pre-commit/domain/checkstyle'
|
4
|
-
require 'plugins/pre-commit/domain/bad_file'
|
5
|
-
|
6
|
-
##
|
7
|
-
# Tests for PreCommit::Message::Formatter
|
8
|
-
describe PreCommit::Message::Formatter do
|
9
|
-
let(:formatter) { PreCommit::Message::Formatter.new }
|
10
|
-
|
11
|
-
let(:file_error) {
|
12
|
-
Domain::BadFile.new('/some/path/file_name.java',
|
13
|
-
[{
|
14
|
-
"line"=>"1",
|
15
|
-
"severity"=>"error",
|
16
|
-
"message"=>"some error message",
|
17
|
-
"source"=>"com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck"
|
18
|
-
}])
|
19
|
-
}
|
20
|
-
|
21
|
-
let(:file_error_2) {
|
22
|
-
Domain::BadFile.new('/some/path/file_name2.java',
|
23
|
-
[{
|
24
|
-
"line"=>"11",
|
25
|
-
"column"=>"40",
|
26
|
-
"severity"=>"error",
|
27
|
-
"message"=>"some error message",
|
28
|
-
"source"=>"com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck"
|
29
|
-
}])
|
30
|
-
}
|
31
|
-
|
32
|
-
context "When has empty input" do
|
33
|
-
it {expect{ formatter.format(nil) }.to raise_error(ArgumentError)}
|
34
|
-
end
|
35
|
-
|
36
|
-
context "When has no errors" do
|
37
|
-
let(:good) { Domain::Checkstyle.good }
|
38
|
-
it { expect(formatter.format(good)).to be_nil }
|
39
|
-
end
|
40
|
-
|
41
|
-
context "When has one file" do
|
42
|
-
let(:errors) { Domain::Checkstyle.new( [ file_error ] ) }
|
43
|
-
|
44
|
-
before { @formatted_output = formatter.format(errors)}
|
45
|
-
|
46
|
-
it{ expect( @formatted_output ).to include "File errors: /some/path/file_name.java"}
|
47
|
-
it{ expect( @formatted_output ).to include " line: 1: error: some error message"}
|
48
|
-
end
|
49
|
-
|
50
|
-
context "When has more than one file" do
|
51
|
-
let(:errors) do
|
52
|
-
Domain::Checkstyle.new( [ file_error, file_error_2 ] )
|
53
|
-
end
|
54
|
-
|
55
|
-
before { @formatted_output = formatter.format(errors) }
|
56
|
-
|
57
|
-
it{ expect( @formatted_output ).to include "File errors: /some/path/file_name.java"}
|
58
|
-
it{ expect( @formatted_output ).to include " line: 1: error: some error message"}
|
59
|
-
it{ expect( @formatted_output ).to include "File errors: /some/path/file_name2.java"}
|
60
|
-
it{ expect( @formatted_output ).to include " line: 11:40 error: some error message"}
|
61
|
-
end
|
62
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require "simplecov"
|
2
|
-
SimpleCov.start
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
5
|
-
|
6
|
-
require 'pre-commit'
|
7
|
-
|
8
|
-
RSpec.configure do |config|
|
9
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
10
|
-
config.run_all_when_everything_filtered = true
|
11
|
-
config.filter_run :focus
|
12
|
-
|
13
|
-
# Run specs in random order to surface order dependencies. If you find an
|
14
|
-
# order dependency and want to debug it, you can fix the order by providing
|
15
|
-
# the seed, which is printed after each run.
|
16
|
-
# --seed 1234
|
17
|
-
config.order = 'random'
|
18
|
-
end
|
19
|
-
|
20
|
-
def fixture_file(file)
|
21
|
-
File.expand_path("../fixtures/#{file}", __FILE__)
|
22
|
-
end
|