java-checkstyle 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+ require 'plugins/pre_commit/message/extractor'
3
+ ##
4
+ # Tests for PreCommit::Message::Extractor
5
+ describe PreCommit::Message::Extractor do
6
+ let(:extractor) { PreCommit::Message::Extractor.new }
7
+ let(:output) {
8
+ '<?xml version="1.0" encoding="UTF-8"?>
9
+ <checkstyle version="6.11">
10
+ <file name="/Users/cristianoliveira/work/java-checkstyle/spec/fixtures/bad.java">
11
+ <error line="1" severity="error" message="some error message" source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck"/>
12
+ <error line="11" column= "1 " severity= "warning" message="some error message" source="com.puppycrawl.tools.checkstyle.checks.design.HideUtilityClassConstructorCheck"/>
13
+ </file>
14
+ <file name="/Users/cristianoliveira/work/java-checkstyle/spec/fixtures/bad2.java">
15
+ <error line="2 " column= "3 " severity= "error" message="some error message" source= "com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck "/>
16
+ <error line="2 " column= "27 " severity= "error" message="some error message" source= "com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck "/>
17
+ </file>
18
+ </checkstyle>
19
+ Checkstyle ends with 4 errors.' }
20
+
21
+ it "should return empty file for nil output" do
22
+ output = nil
23
+ result = extractor.extract output
24
+
25
+ expect(result['checkstyle']['file']).to be_empty
26
+ end
27
+
28
+ it "should extract files" do
29
+ result = extractor.extract output
30
+ expect(result['checkstyle']['file'].size).to eq 2
31
+ end
32
+
33
+ it "should extract errors" do
34
+ result = extractor.extract output
35
+ expect(result['checkstyle']['file'][0]['error'].size).to eq 2
36
+ end
37
+
38
+ it "should extract error details" do
39
+ expected = [
40
+ {
41
+ "line"=>"1",
42
+ "severity"=>"error",
43
+ "message"=>"some error message",
44
+ "source"=>"com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck"
45
+ },
46
+ {
47
+ "line" => "11",
48
+ "column" => "1 ",
49
+ "severity" => "warning",
50
+ "message" => "some error message",
51
+ "source" => "com.puppycrawl.tools.checkstyle.checks.design.HideUtilityClassConstructorCheck"
52
+ }
53
+ ]
54
+
55
+ result = extractor.extract output
56
+ errors = result['checkstyle']['file'][0]['error']
57
+ expect(errors).to eq expected
58
+ end
59
+ end
File without changes
@@ -0,0 +1,22 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.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
metadata ADDED
@@ -0,0 +1,164 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: java-checkstyle
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Allen Madsen
8
+ - Cristian Oliveira
9
+ - Alex Rocha
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2015-10-11 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: pre-commit
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '0.16'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '0.16'
29
+ - !ruby/object:Gem::Dependency
30
+ name: crack
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: 0.4.2
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: 0.4.2
43
+ - !ruby/object:Gem::Dependency
44
+ name: bundler
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.5'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '1.5'
57
+ - !ruby/object:Gem::Dependency
58
+ name: rake
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '10.4'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 10.4.2
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '10.4'
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 10.4.2
77
+ - !ruby/object:Gem::Dependency
78
+ name: rspec
79
+ requirement: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '3.3'
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 3.3.2
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: '3.3'
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 3.3.2
97
+ description: Checkstyle linter plugin for pre-commit. Useful for linting Java code.
98
+ email:
99
+ - blatyo@gmail.com
100
+ - contato@cristianoliveira.com.br
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".codeclimate.yml"
106
+ - ".gitignore"
107
+ - ".rspec"
108
+ - ".travis.yml"
109
+ - Gemfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - java-checkstyle.gemspec
114
+ - lib/plugins/pre_commit/checks/checkstyle.rb
115
+ - lib/plugins/pre_commit/message/extractor.rb
116
+ - lib/plugins/pre_commit/message/formatter.rb
117
+ - lib/plugins/pre_commit/support/path.rb
118
+ - lib/pre-commit/checkstyle/version.rb
119
+ - lib/pre-commit/support/checkstyle/checkstyle-5.7-all.jar
120
+ - lib/pre-commit/support/checkstyle/checkstyle-6.11-all.jar
121
+ - lib/pre-commit/support/checkstyle/google_checks.xml
122
+ - lib/pre-commit/support/checkstyle/sun_checks.xml
123
+ - spec/fixtures/bad.java
124
+ - spec/fixtures/bad2.java
125
+ - spec/fixtures/good.java
126
+ - spec/fixtures/google_checks.xml
127
+ - spec/plugins/pre_commit/checks/checkstyle_spec.rb
128
+ - spec/plugins/pre_commit/message/extractor_spec.rb
129
+ - spec/plugins/pre_commit/output/formatter.rb
130
+ - spec/spec_helper.rb
131
+ homepage: https://github.com/CristianOliveiraDaRosa/java-checkstyle
132
+ licenses:
133
+ - MIT
134
+ metadata: {}
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 2.4.8
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: Checkstyle linter plugin for pre-commit
155
+ test_files:
156
+ - spec/fixtures/bad.java
157
+ - spec/fixtures/bad2.java
158
+ - spec/fixtures/good.java
159
+ - spec/fixtures/google_checks.xml
160
+ - spec/plugins/pre_commit/checks/checkstyle_spec.rb
161
+ - spec/plugins/pre_commit/message/extractor_spec.rb
162
+ - spec/plugins/pre_commit/output/formatter.rb
163
+ - spec/spec_helper.rb
164
+ has_rdoc: