jlint 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +19 -0
- data/README.md +4 -0
- data/Rakefile +6 -0
- data/bin/checkstyle.jar +0 -0
- data/jlint.gemspec +1 -0
- data/lib/jlint.rb +6 -26
- data/lib/jlint/base.rb +44 -0
- data/lib/jlint/version.rb +1 -1
- data/test/jlint/test_jlint.rb +27 -0
- data/test/support/sample.java +8 -0
- data/test/test_helper.rb +5 -0
- metadata +25 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac58a70f61ad72118a655e61ce7344dbe4aeb162
|
4
|
+
data.tar.gz: c62d20259cef8cf7f5aecc578d3c54a16111fc0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b3719d2be30d246557136348841b52f1d30b9781fe1a70e5011164beb09c7b4f531e33f1c68ea82b83af17acf3ffc9ffd105954b26ab435c9f3121fac6931bc
|
7
|
+
data.tar.gz: e28edb10669f82f1afb4018ec3f1981247c0c03869b015d6d101281eff71f95e781fb8fd1cf2f0c88b2b505f494e6c3ca9eda8212ac78e000efc48b274944440
|
data/Gemfile.lock
ADDED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/bin/checkstyle.jar
CHANGED
File without changes
|
data/jlint.gemspec
CHANGED
data/lib/jlint.rb
CHANGED
@@ -1,30 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require 'jlint/base'
|
2
|
+
module Jlint
|
3
|
+
def self.lint content, config
|
4
|
+
Base.new.lint content, config
|
4
5
|
end
|
5
6
|
|
6
|
-
def
|
7
|
-
|
8
|
-
|
9
|
-
def lint file_path, config
|
10
|
-
parse `java -jar #{checkstyle_command} -c #{checkstyle_config} #{file_path}`
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
def checkstyle_command
|
15
|
-
File.join(File.dirname(__FILE__), '..', 'bin', 'checkstyle.jar')
|
16
|
-
end
|
17
|
-
|
18
|
-
def checkstyle_config
|
19
|
-
File.join(File.dirname(__FILE__), '..', 'doc', 'sun_checks.xml')
|
20
|
-
end
|
21
|
-
|
22
|
-
def parse results
|
23
|
-
array = results.split("\n")
|
24
|
-
array.reject! { |s| s == 'Starting audit...' || s == 'Audit done.' }
|
25
|
-
array.map! do |msg|
|
26
|
-
msgs = msg.split(":")
|
27
|
-
[msgs.last.strip, msgs[1]]
|
28
|
-
end
|
7
|
+
def self.file_lint file_path, config
|
8
|
+
Base.new.file_lint file_path, config
|
29
9
|
end
|
30
10
|
end
|
data/lib/jlint/base.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
3
|
+
module Jlint
|
4
|
+
class Base
|
5
|
+
def initialize
|
6
|
+
end
|
7
|
+
|
8
|
+
def lint content, config
|
9
|
+
file = Tempfile.new(["temp", ".java"])
|
10
|
+
begin
|
11
|
+
file.puts content
|
12
|
+
file.rewind
|
13
|
+
file.close
|
14
|
+
|
15
|
+
file_lint file.path, config
|
16
|
+
ensure
|
17
|
+
file.unlink
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def file_lint file_path, config
|
22
|
+
parse `java -jar #{checkstyle_command} -c #{checkstyle_config} #{file_path}`
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def checkstyle_command
|
28
|
+
File.join(File.dirname(__FILE__), '..', '..', 'bin', 'checkstyle.jar')
|
29
|
+
end
|
30
|
+
|
31
|
+
def checkstyle_config
|
32
|
+
File.join(File.dirname(__FILE__), '..', '..', 'doc', 'sun_checks.xml')
|
33
|
+
end
|
34
|
+
|
35
|
+
def parse results
|
36
|
+
array = results.split("\n")
|
37
|
+
array.reject! { |s| s == 'Starting audit...' || s == 'Audit done.' }
|
38
|
+
array.map! do |msg|
|
39
|
+
msgs = msg.split(":")
|
40
|
+
[msgs.last.strip, msgs[1].to_i]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/jlint/version.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
describe Jlint do
|
4
|
+
|
5
|
+
it "should lint for file_path" do
|
6
|
+
file_path = File.join(File.dirname(__FILE__), "..", "support", "sample.java")
|
7
|
+
result = Jlint.file_lint(file_path, "")
|
8
|
+
assert result.is_a?(Array)
|
9
|
+
assert result.include?(["Missing package-info.java file.", 0])
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should lint for file content with newline" do
|
13
|
+
content = %Q[public class Sample {
|
14
|
+
public static void Sample() {
|
15
|
+
}
|
16
|
+
|
17
|
+
public void hi(long name) {
|
18
|
+
system.out.printf("Hi, " + name);
|
19
|
+
}
|
20
|
+
}]
|
21
|
+
result = Jlint.lint(content, "")
|
22
|
+
assert result.is_a?(Array)
|
23
|
+
assert !result.include?(["File does not end with a newline.", 0])
|
24
|
+
assert result.include?(["Missing package-info.java file.", 0])
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jlint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- soffolk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
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'
|
41
55
|
description: 'Ruby Warp for CheckStyle: https://github.com/checkstyle/checkstyle'
|
42
56
|
email:
|
43
57
|
- zlx.star@gmail.com
|
@@ -48,6 +62,7 @@ extra_rdoc_files: []
|
|
48
62
|
files:
|
49
63
|
- .gitignore
|
50
64
|
- Gemfile
|
65
|
+
- Gemfile.lock
|
51
66
|
- LICENSE.txt
|
52
67
|
- README.md
|
53
68
|
- Rakefile
|
@@ -56,7 +71,11 @@ files:
|
|
56
71
|
- doc/sun_checks.xml
|
57
72
|
- jlint.gemspec
|
58
73
|
- lib/jlint.rb
|
74
|
+
- lib/jlint/base.rb
|
59
75
|
- lib/jlint/version.rb
|
76
|
+
- test/jlint/test_jlint.rb
|
77
|
+
- test/support/sample.java
|
78
|
+
- test/test_helper.rb
|
60
79
|
homepage: ''
|
61
80
|
licenses:
|
62
81
|
- MIT
|
@@ -81,5 +100,8 @@ rubygems_version: 2.0.3
|
|
81
100
|
signing_key:
|
82
101
|
specification_version: 4
|
83
102
|
summary: 'Ruby Warp for CheckStyle: https://github.com/checkstyle/checkstyle'
|
84
|
-
test_files:
|
103
|
+
test_files:
|
104
|
+
- test/jlint/test_jlint.rb
|
105
|
+
- test/support/sample.java
|
106
|
+
- test/test_helper.rb
|
85
107
|
has_rdoc:
|