jlint 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6813c93f52c5132c0563f58f28b5765881688eb
4
- data.tar.gz: 9e33d6836d5419f85f930b838944b25512ac193e
3
+ metadata.gz: 1dc85e460dbf3ca0098ab8c8364a9fbfd06ef17c
4
+ data.tar.gz: 45c220242b42d9a3f9ced119354afba3fdfbdf73
5
5
  SHA512:
6
- metadata.gz: 27c3d746cf4e26ec606298506de467807589cf2460159cd10d5f013fa3c55ea832b093f7b04fa7865233a700f62fa72150a5d11d1bb5a47c41251ce82bb1c11f
7
- data.tar.gz: 8158c782278d8a1460a7c7b2dc0241d4e808a85f9c53c9c948355cd3fe97a1ab206ddb572a3682d47c62851a74c22cb3964958494d2f873a058ea5eea2326cf6
6
+ metadata.gz: 07083e17bec494f19545e54cc91b64bb62f90642c126f213a098eebbc74bf64aca321df8ed56c6fb2b88e97707b7b010a4ea10758d51525210ca371267e3eb04
7
+ data.tar.gz: 01566ea4227f4bb4d95d5abf2eff6b109967dbdfda7e27f1a1a690e900f6c10ec77d3d8c187c7bc1c377d47bb820fedd370ca4ce5dc34288e57d443aab596507
data/.gitignore CHANGED
@@ -1 +1,3 @@
1
1
  jlint-0.0.1.gem
2
+ .build
3
+ .bundle
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.2.1
5
+ before_install:
6
+ - sudo apt-get update -qq
7
+ - sudo apt-get install -y openjdk-7-jre
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jlint (0.1.0)
4
+ jlint (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Jlint
2
2
 
3
+ ![](https://travis-ci.org/zlx/jlint.svg?branch=master)
4
+
3
5
  Ruby Warp for CheckStyle: https://github.com/checkstyle/checkstyle
4
6
 
5
7
  Provide more friendly interface for Rubist
data/Rakefile CHANGED
@@ -1,7 +1,8 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
3
 
4
+ task default: :test
5
+
4
6
  Rake::TestTask.new do |t|
5
- t.pattern = "test/jlint/test_*.rb"
7
+ t.pattern = 'test/jlint/test_*.rb'
6
8
  end
7
-
Binary file
@@ -41,7 +41,7 @@
41
41
 
42
42
  <!-- Checks that a package-info.java file exists for each package. -->
43
43
  <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage -->
44
- <module name="JavadocPackage"/>
44
+ <!--module name="JavadocPackage"/-->
45
45
 
46
46
  <!-- Checks whether files end with a new line. -->
47
47
  <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
@@ -50,11 +50,11 @@
50
50
  <!-- Checks that property files contain the same keys. -->
51
51
  <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
52
52
  <module name="Translation"/>
53
-
53
+
54
54
  <!-- Checks for Size Violations. -->
55
55
  <!-- See http://checkstyle.sf.net/config_sizes.html -->
56
56
  <module name="FileLength"/>
57
-
57
+
58
58
  <!-- Checks for whitespace -->
59
59
  <!-- See http://checkstyle.sf.net/config_whitespace.html -->
60
60
  <module name="FileTabCharacter"/>
@@ -154,7 +154,6 @@
154
154
  <module name="InnerAssignment"/>
155
155
  <module name="MagicNumber"/>
156
156
  <module name="MissingSwitchDefault"/>
157
- <module name="RedundantThrows"/>
158
157
  <module name="SimplifyBooleanExpression"/>
159
158
  <module name="SimplifyBooleanReturn"/>
160
159
 
@@ -1,4 +1,6 @@
1
1
  require 'tempfile'
2
+ require 'yaml'
3
+
2
4
  class Jlint
3
5
  def self.lint content
4
6
  new.lint content
@@ -32,7 +34,12 @@ class Jlint
32
34
  private
33
35
 
34
36
  def parse_lint command, config_path, file_path
35
- parse `java -jar #{checkstyle_command} -c #{config_path} #{file_path}`
37
+ output = `java -jar #{checkstyle_command} -c #{config_path} #{file_path}`
38
+ if /Unable to create Checker|Error loading configuration file/ =~ output
39
+ raise output
40
+ else
41
+ parse output
42
+ end
36
43
  end
37
44
 
38
45
  def as_file content, format = ".java"
@@ -49,7 +56,7 @@ class Jlint
49
56
  end
50
57
 
51
58
  def checkstyle_command
52
- File.join(File.dirname(__FILE__), '..', 'bin', 'checkstyle.jar')
59
+ File.join(File.dirname(__FILE__), '..', 'bin', 'current')
53
60
  end
54
61
 
55
62
  def checkstyle_config
@@ -1,3 +1,3 @@
1
1
  class Jlint
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -6,7 +6,7 @@ describe Jlint do
6
6
  file_path = File.join(File.dirname(__FILE__), "..", "support", "sample.java")
7
7
  result = Jlint.file_lint(file_path)
8
8
  assert result.is_a?(Array)
9
- assert result.include?(["Missing package-info.java file.", 0])
9
+ assert_equal(result.to_yaml, File.read('test/support/sample_errors.yml'))
10
10
  end
11
11
 
12
12
  it "should lint for file content with newline" do
@@ -20,12 +20,12 @@ describe Jlint do
20
20
  }]
21
21
  result = Jlint.lint(content)
22
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])
23
+ assert_equal(result.to_yaml, File.read('test/support/custom_config_errors.yml'))
25
24
  end
26
25
 
27
26
  it "should lint with custom config content" do
28
- content = %Q[public class Sample {
27
+ content = %Q[import java.util.*;
28
+ public class Sample {
29
29
  public static void Sample() {
30
30
  }
31
31
 
@@ -38,10 +38,51 @@ describe Jlint do
38
38
  "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
39
39
  "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
40
40
  <module name="Checker">
41
+ <module name="TreeWalker">
42
+ <module name="AvoidStarImport"/>
43
+ </module>
41
44
  </module>]
42
45
  result = Jlint.new(config_content).lint(content)
43
46
  assert result.is_a?(Array)
44
- assert !result.include?(["Missing package-info.java file.", 0])
47
+ assert result.include?(["Using the '.*' form of import should be avoided - java.util.*.", 1])
48
+ end
49
+
50
+ it "should error on bad custom config content" do
51
+ content = %Q[public class Sample {
52
+ public static void Sample() {
53
+ }
54
+
55
+ public void hi(long name) {
56
+ system.out.printf("Hi, " + name);
57
+ }
58
+ }]
59
+ config_content = %Q[<?xml version="1.0"?>
60
+ <!DOCTYPE module PUBLIC
61
+ "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
62
+ "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
63
+ <module name="Checker">
64
+ <module name="AvoidStarImport"/>
65
+ </module>]
66
+ assert_raises(RuntimeError) { Jlint.new(config_content).lint(content) }
67
+ end
68
+
69
+ it "should error on bad XML" do
70
+ content = %Q[public class Sample {
71
+ public static void Sample() {
72
+ }
73
+
74
+ public void hi(long name) {
75
+ system.out.printf("Hi, " + name);
76
+ }
77
+ }]
78
+ config_content = %Q[<?xml version="1.0"?>
79
+ <!DOCTYPE module PUBLIC
80
+ "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
81
+ "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
82
+ <module name="Checker">
83
+ <module name="AvoidStarImport"/>
84
+ </module]
85
+ assert_raises(RuntimeError) { Jlint.new(config_content).lint(content) }
45
86
  end
46
87
 
47
88
  end
@@ -0,0 +1,15 @@
1
+ ---
2
+ - - Missing a Javadoc comment.
3
+ - 1
4
+ - - Missing a Javadoc comment.
5
+ - 2
6
+ - - Method Name 'Sample' must not equal the enclosing class name.
7
+ - 2
8
+ - - Name 'Sample' must match pattern '^[a-z][a-zA-Z0-9]*$'.
9
+ - 2
10
+ - - Method 'hi' is not designed for extension - needs to be abstract, final or empty.
11
+ - 5
12
+ - - Missing a Javadoc comment.
13
+ - 5
14
+ - - Parameter name should be final.
15
+ - 5
@@ -0,0 +1,15 @@
1
+ ---
2
+ - - Missing a Javadoc comment.
3
+ - 1
4
+ - - Missing a Javadoc comment.
5
+ - 2
6
+ - - Method Name 'Sample' must not equal the enclosing class name.
7
+ - 2
8
+ - - Name 'Sample' must match pattern '^[a-z][a-zA-Z0-9]*$'.
9
+ - 2
10
+ - - Method 'hi' is not designed for extension - needs to be abstract, final or empty.
11
+ - 5
12
+ - - Missing a Javadoc comment.
13
+ - 5
14
+ - - Parameter name should be final.
15
+ - 5
metadata CHANGED
@@ -1,72 +1,75 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jlint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
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-22 00:00:00.000000000 Z
11
+ date: 2015-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.5'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: 'Ruby Warp for CheckStyle: https://github.com/checkstyle/checkstyle'
56
56
  email:
57
57
  - zlx.star@gmail.com
58
58
  executables:
59
- - checkstyle.jar
59
+ - checkstyle-6.5-all.jar
60
+ - current
60
61
  extensions: []
61
62
  extra_rdoc_files: []
62
63
  files:
63
- - .gitignore
64
+ - ".gitignore"
65
+ - ".travis.yml"
64
66
  - Gemfile
65
67
  - Gemfile.lock
66
68
  - LICENSE.txt
67
69
  - README.md
68
70
  - Rakefile
69
- - bin/checkstyle.jar
71
+ - bin/checkstyle-6.5-all.jar
72
+ - bin/current
70
73
  - doc/google_checks.xml
71
74
  - doc/sun_checks.xml
72
75
  - jlint.gemspec
@@ -74,7 +77,9 @@ files:
74
77
  - lib/jlint/version.rb
75
78
  - test/jlint/test_jlint.rb
76
79
  - test/support/custom.xml
80
+ - test/support/custom_config_errors.yml
77
81
  - test/support/sample.java
82
+ - test/support/sample_errors.yml
78
83
  - test/test_helper.rb
79
84
  homepage: ''
80
85
  licenses:
@@ -86,23 +91,24 @@ require_paths:
86
91
  - lib
87
92
  required_ruby_version: !ruby/object:Gem::Requirement
88
93
  requirements:
89
- - - '>='
94
+ - - ">="
90
95
  - !ruby/object:Gem::Version
91
96
  version: '0'
92
97
  required_rubygems_version: !ruby/object:Gem::Requirement
93
98
  requirements:
94
- - - '>='
99
+ - - ">="
95
100
  - !ruby/object:Gem::Version
96
101
  version: '0'
97
102
  requirements: []
98
103
  rubyforge_project:
99
- rubygems_version: 2.0.3
104
+ rubygems_version: 2.4.5
100
105
  signing_key:
101
106
  specification_version: 4
102
107
  summary: 'Ruby Warp for CheckStyle: https://github.com/checkstyle/checkstyle'
103
108
  test_files:
104
109
  - test/jlint/test_jlint.rb
105
110
  - test/support/custom.xml
111
+ - test/support/custom_config_errors.yml
106
112
  - test/support/sample.java
113
+ - test/support/sample_errors.yml
107
114
  - test/test_helper.rb
108
- has_rdoc:
Binary file