jruby-lint 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  tmp
6
+ lint-spec-report.html
@@ -1,3 +1,7 @@
1
+ === 0.3.0 / 2011-07-04
2
+
3
+ - html reports
4
+
1
5
  === 0.2.0 / 2011-06-03
2
6
 
3
7
  - #system('ruby') and #timeout checkers, thanks Matthew Kirk (hexgnu)!
data/README.md CHANGED
@@ -31,12 +31,15 @@ Here is a list of the current checks implemented:
31
31
  - Report behavior difference when using system('ruby'), which launches
32
32
  the command in-process in a new copy of the interpreter for speed
33
33
 
34
+ ## Reports
35
+
36
+ JRuby-lint supports text and html reports. Run jrlint with the option --html
37
+ to generate an html report with the results.
38
+
34
39
  ## TODO
35
40
 
36
41
  Here is a list of checks and options we'd like to implement:
37
42
 
38
- - Options to save report off to a file.
39
- - Text, HTML formats
40
43
  - Add in check for `` to make sure not execing ruby ...
41
44
  - Report on more threading and concurrency issues/antipatterns
42
45
  - arr.each {|x| arr.delete(x) }
@@ -23,6 +23,18 @@ module JRuby
23
23
  @options.eval << v
24
24
  end
25
25
 
26
+ opts.on('--text', 'print report as text') do
27
+ @options.text = true
28
+ end
29
+
30
+ opts.on('--ansi', 'print report as ansi text') do
31
+ @options.ansi = true
32
+ end
33
+
34
+ opts.on('--html [REPORT_FILE]', 'print report as html file') do |file|
35
+ @options.html = file || 'jruby-lint.html'
36
+ end
37
+
26
38
  opts.on_tail("-v", "--version", "Print version and exit") do
27
39
  require 'jruby/lint/version'
28
40
  puts "JRuby-Lint version #{VERSION}"
@@ -8,6 +8,14 @@ module JRuby::Lint
8
8
  super
9
9
  end
10
10
 
11
+ def error?
12
+ tags.include?('error')
13
+ end
14
+
15
+ def warning?
16
+ tags.include?('warning')
17
+ end
18
+
11
19
  def to_s
12
20
  "#{file}:#{line}: [#{tags.join(', ')}] #{message}"
13
21
  end
@@ -19,7 +19,7 @@ module JRuby::Lint
19
19
 
20
20
  @sources = options.files || (options.eval ? [] : Dir['./**/*'])
21
21
  load_collectors
22
- load_reporters
22
+ load_reporters(options)
23
23
  load_libraries
24
24
  end
25
25
 
@@ -30,6 +30,7 @@ module JRuby::Lint
30
30
  reporters.each {|r| r.report(c.findings)}
31
31
  @findings += c.findings
32
32
  end
33
+ reporters.each {|r| r.print_report(@findings) if r.respond_to?(:print_report) }
33
34
  end
34
35
 
35
36
  private
@@ -45,8 +46,11 @@ module JRuby::Lint
45
46
  end
46
47
  end
47
48
 
48
- def load_reporters
49
- @reporters = [(STDOUT.tty? ? Reporters::ANSIColor : Reporters::Text).new(self, STDOUT)]
49
+ def load_reporters(options)
50
+ @reporters = []
51
+ @reporters << Reporters::Html.new(self, options.html) if options.html
52
+ @reporters << Reporters::ANSIColor.new(self, STDOUT) if options.ansi || STDOUT.tty?
53
+ @reporters << Reporters::Text.new(self, STDOUT) if options.text || @reporters.empty?
50
54
  end
51
55
 
52
56
  def load_libraries
@@ -1,35 +1,7 @@
1
- require 'term/ansicolor'
2
-
3
1
  module JRuby::Lint
4
2
  module Reporters
5
- class Text
6
- def initialize(project, output)
7
- @tags, @output = project.tags, output
8
- end
9
-
10
- def report(findings)
11
- findings.each do |finding|
12
- puts finding unless (@tags & finding.tags).empty?
13
- end
14
- end
15
-
16
- def puts(finding)
17
- @output.puts finding.to_s
18
- end
19
- end
20
-
21
- class ANSIColor < Text
22
- include Term::ANSIColor
23
- def puts(finding)
24
- msg = if finding.tags.include?("error")
25
- red(finding.to_s)
26
- elsif finding.tags.include?("warning")
27
- yellow(finding.to_s)
28
- else
29
- finding.to_s
30
- end
31
- @output.puts msg
32
- end
33
- end
34
3
  end
35
4
  end
5
+
6
+ require 'jruby/lint/reporters/text'
7
+ require 'jruby/lint/reporters/html'
@@ -0,0 +1,27 @@
1
+ module JRuby::Lint
2
+ module Reporters
3
+ class Html
4
+ require 'erb'
5
+
6
+ def initialize(project, output)
7
+ @tags = project.tags
8
+ @output = output
9
+ @template = ERB.new(File.read(File.expand_path('../jruby-lint.html.erb', __FILE__)))
10
+ end
11
+
12
+ def report(findings)
13
+ end
14
+
15
+ def print_report(findings)
16
+ @findings = []
17
+ findings.each do |finding|
18
+ @findings << finding unless (@tags & finding.tags).empty?
19
+ end
20
+
21
+ File.open(@output, 'w') do |file|
22
+ file.write @template.result(binding)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,48 @@
1
+ <html>
2
+ <head>
3
+ <title>JRuby-lint diagnostics report</title>
4
+ <style>
5
+ ul { padding: 0px; }
6
+ li { list-style: none; margin: 0px; padding: 0px; display: list-item; }
7
+ body { font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif; font-size:10.5pt; margin: 0; }
8
+
9
+ h1 { color: #383838; font-size: 4em; }
10
+ p { color: #383838; font-size: 1.8em; }
11
+ .site { width: 70em; margin: 0 auto; padding: .1em 5em; }
12
+ nav { position: relative; }
13
+ #findings li { position: relative; padding: .5em 1em; margin-top: .3em; }
14
+ #congrats { padding-top: 2em; }
15
+ .message { border-left: 5px solid silver; background: #EEE; }
16
+ .error { border-left: 5px solid #b22222; background: #E6BCB5; }
17
+ .warning { border-left: 5px solid #FF9900; background: #FFFF99; }
18
+ </style>
19
+ </head>
20
+ <body>
21
+ <a href="http://github.com/jruby/jruby-lint"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://d3nwyuy0nl342s.cloudfront.net/img/e6bef7a091f5f3138b8cd40bc3e114258dd68ddf/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67" alt="Fork me on GitHub"></a>
22
+ <div class="site">
23
+ <nav>
24
+ <h1>JRuby diagnostics</h1>
25
+ </nav>
26
+ <div id="findings">
27
+ <% unless @findings.empty? %>
28
+ <ul>
29
+ <% @findings.each do |finding| %>
30
+ <% if finding.error? %>
31
+ <li class="error"><%= finding %></li>
32
+ <% elsif finding.warning? %>
33
+ <li class="warning"><%= finding %></li>
34
+ <% else %>
35
+ <li class="message"><%= finding %></li>
36
+ <% end %>
37
+ <% end %>
38
+ </ul>
39
+ <% else %>
40
+ <div id="congrats">
41
+ <p>Congratulations!</p>
42
+ <p>We didn't find any issue and your application should run just fine with JRuby.</p>
43
+ </div> <!-- div#congrats -->
44
+ <% end %>
45
+ </div> <!-- div#findings -->
46
+ </div> <!-- div.site -->
47
+ </body>
48
+ </html>
@@ -0,0 +1,34 @@
1
+ module JRuby::Lint
2
+ module Reporters
3
+ class Text
4
+ def initialize(project, output)
5
+ @tags, @output = project.tags, output
6
+ end
7
+
8
+ def report(findings)
9
+ findings.each do |finding|
10
+ puts finding unless (@tags & finding.tags).empty?
11
+ end
12
+ end
13
+
14
+ def puts(finding)
15
+ @output.puts finding.to_s
16
+ end
17
+ end
18
+
19
+ class ANSIColor < Text
20
+ require 'term/ansicolor'
21
+ include Term::ANSIColor
22
+ def puts(finding)
23
+ msg = if finding.error?
24
+ red(finding.to_s)
25
+ elsif finding.warning?
26
+ yellow(finding.to_s)
27
+ else
28
+ finding.to_s
29
+ end
30
+ @output.puts msg
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,5 +1,5 @@
1
1
  module JRuby
2
2
  module Lint
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -8,12 +8,12 @@
8
8
  <head>
9
9
  <meta charset='utf-8'>
10
10
  <meta http-equiv="X-UA-Compatible" content="chrome=1">
11
- <script>var NREUMQ=[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script>
11
+ <script type="text/javascript">var NREUMQ=[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script>
12
12
  <title>C Extension Alternatives - GitHub</title>
13
13
  <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub" />
14
14
  <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub" />
15
15
 
16
- <link href="https://d3nwyuy0nl342s.cloudfront.net/709540747571a12d9ee0e981881190bbacde01fe/stylesheets/bundle_github.css" media="screen" rel="stylesheet" type="text/css" />
16
+ <link href="https://a248.e.akamai.net/assets.github.com/b061594e73bd47cde0b406f0ccd1cee8b0aa96ec/stylesheets/bundle_github.css" media="screen" rel="stylesheet" type="text/css" />
17
17
 
18
18
 
19
19
  <script type="text/javascript">
@@ -22,13 +22,13 @@
22
22
  </script>
23
23
  <script type="text/javascript" charset="utf-8">
24
24
  var GitHub = {
25
- assetHost: 'https://d3nwyuy0nl342s.cloudfront.net'
25
+ assetHost: 'https://a248.e.akamai.net/assets.github.com'
26
26
  }
27
27
  var github_user = null
28
28
 
29
29
  </script>
30
- <script src="https://d3nwyuy0nl342s.cloudfront.net/javascripts/jquery/jquery-1.4.2.min.js" type="text/javascript"></script>
31
- <script src="https://d3nwyuy0nl342s.cloudfront.net/32997e5cd4ce47f6467e629aedf849edcf5a7376/javascripts/bundle_github.js" type="text/javascript"></script>
30
+ <script src="https://a248.e.akamai.net/assets.github.com/javascripts/jquery/jquery-1.6.1.min.js" type="text/javascript"></script>
31
+ <script src="https://a248.e.akamai.net/assets.github.com/9a8d4d0be567a85129ca26f93f40eb76dcc8bfbb/javascripts/bundle_github.js" type="text/javascript"></script>
32
32
 
33
33
 
34
34
 
@@ -40,7 +40,7 @@
40
40
 
41
41
 
42
42
  <link href="https://github.com/jruby/jruby/commits/master.atom" rel="alternate" title="Recent Commits to jruby:master" type="application/atom+xml" />
43
- <script src="https://d3nwyuy0nl342s.cloudfront.net/a5293f39de14a50f19260ef05b2ae4a145b2cbce/javascripts/bundle_wiki.js" type="text/javascript"></script>
43
+ <script src="https://a248.e.akamai.net/assets.github.com/9efa4f408d844eccca76d5687e85d5b519597f1f/javascripts/bundle_wiki.js" type="text/javascript"></script>
44
44
 
45
45
  <script src="/javascripts/other/MathJax/MathJax.js" type="text/javascript">
46
46
  if (window.location.protocol == "https:") {
@@ -57,7 +57,7 @@
57
57
  <script type="text/javascript">
58
58
  GitHub.nameWithOwner = GitHub.nameWithOwner || "jruby/jruby";
59
59
  GitHub.currentRef = 'master';
60
- GitHub.commitSHA = "f03b829c28c581c661f8916b54978b552cc03ff5";
60
+ GitHub.commitSHA = "24aad97afc34e25047c06298ea0f2559f90c14d2";
61
61
  GitHub.currentPath = '';
62
62
  GitHub.masterBranch = "master";
63
63
 
@@ -91,16 +91,14 @@
91
91
 
92
92
 
93
93
 
94
-
95
-
96
94
  <div class="subnavd" id="main">
97
95
  <div id="header" class="true">
98
96
 
99
97
  <a class="logo boring" href="https://github.com">
100
98
 
101
- <img alt="github" class="default" height="45" src="https://d3nwyuy0nl342s.cloudfront.net/images/modules/header/logov5.png" />
99
+ <img alt="github" class="default" height="45" src="https://a248.e.akamai.net/assets.github.com/images/modules/header/logov5.png" />
102
100
  <!--[if (gt IE 8)|!(IE)]><!-->
103
- <img alt="github" class="hover" height="45" src="https://d3nwyuy0nl342s.cloudfront.net/images/modules/header/logov5-hover.png" />
101
+ <img alt="github" class="hover" height="45" src="https://a248.e.akamai.net/assets.github.com/images/modules/header/logov5-hover.png" />
104
102
  <!--<![endif]-->
105
103
  </a>
106
104
 
@@ -145,12 +143,12 @@
145
143
 
146
144
  <li class="for-owner" style="display:none"><a href="/jruby/jruby/admin" class="minibutton btn-admin "><span><span class="icon"></span>Admin</span></a></li>
147
145
  <li>
148
- <a href="/jruby/jruby/toggle_watch" class="minibutton btn-watch " id="watch_button" onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var s = document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', 'authenticity_token'); s.setAttribute('value', '39136b986bbed8c260a8aa8d9ff8b1c9bd2b9ac8'); f.appendChild(s);f.submit();return false;" style="display:none"><span><span class="icon"></span>Watch</span></a>
149
- <a href="/jruby/jruby/toggle_watch" class="minibutton btn-watch " id="unwatch_button" onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var s = document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', 'authenticity_token'); s.setAttribute('value', '39136b986bbed8c260a8aa8d9ff8b1c9bd2b9ac8'); f.appendChild(s);f.submit();return false;" style="display:none"><span><span class="icon"></span>Unwatch</span></a>
146
+ <a href="/jruby/jruby/toggle_watch" class="minibutton btn-watch " id="watch_button" onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var s = document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', 'authenticity_token'); s.setAttribute('value', 'a12af8eb75d6148a6d430d76ce52736db893dd3d'); f.appendChild(s);f.submit();return false;" style="display:none"><span><span class="icon"></span>Watch</span></a>
147
+ <a href="/jruby/jruby/toggle_watch" class="minibutton btn-watch " id="unwatch_button" onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var s = document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', 'authenticity_token'); s.setAttribute('value', 'a12af8eb75d6148a6d430d76ce52736db893dd3d'); f.appendChild(s);f.submit();return false;" style="display:none"><span><span class="icon"></span>Unwatch</span></a>
150
148
  </li>
151
149
 
152
150
 
153
- <li class="for-notforked" style="display:none"><a href="/jruby/jruby/fork" class="minibutton btn-fork " id="fork_button" onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var s = document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', 'authenticity_token'); s.setAttribute('value', '39136b986bbed8c260a8aa8d9ff8b1c9bd2b9ac8'); f.appendChild(s);f.submit();return false;"><span><span class="icon"></span>Fork</span></a></li>
151
+ <li class="for-notforked" style="display:none"><a href="/jruby/jruby/fork" class="minibutton btn-fork " id="fork_button" onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var s = document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', 'authenticity_token'); s.setAttribute('value', 'a12af8eb75d6148a6d430d76ce52736db893dd3d'); f.appendChild(s);f.submit();return false;"><span><span class="icon"></span>Fork</span></a></li>
154
152
  <li class="for-hasfork" style="display:none"><a href="#" class="minibutton btn-fork " id="your_fork_button"><span><span class="icon"></span>Your Fork</span></a></li>
155
153
 
156
154
 
@@ -160,8 +158,8 @@
160
158
 
161
159
  <li class="repostats">
162
160
  <ul class="repo-stats">
163
- <li class="watchers"><a href="/jruby/jruby/watchers" title="Watchers" class="tooltipped downwards">512</a></li>
164
- <li class="forks"><a href="/jruby/jruby/network" title="Forks" class="tooltipped downwards">114</a></li>
161
+ <li class="watchers"><a href="/jruby/jruby/watchers" title="Watchers" class="tooltipped downwards">551</a></li>
162
+ <li class="forks"><a href="/jruby/jruby/network" title="Forks" class="tooltipped downwards">125</a></li>
165
163
  </ul>
166
164
  </li>
167
165
  </ul>
@@ -179,10 +177,12 @@
179
177
 
180
178
 
181
179
 
182
- <li><a href="/jruby/jruby/wiki" class="selected" highlight="repo_wiki">Wiki (117)</a></li>
180
+ <li><a href="/jruby/jruby/wiki" class="selected" highlight="repo_wiki">Wiki (118)</a></li>
183
181
 
184
182
  <li><a href="/jruby/jruby/graphs" highlight="repo_graphs">Graphs</a></li>
185
183
 
184
+
185
+
186
186
  <li class="contextswitch nochoices">
187
187
  <span class="toggle leftwards" >
188
188
  <em>Branch:</em>
@@ -287,10 +287,10 @@
287
287
  </div>
288
288
  <div id="gollum-footer">
289
289
  <p id="last-edit">
290
- Last edited by headius, <abbr class="relatize" title="2011-05-15 17:25:54">Sun May 15 17:25:54 -0700 2011</abbr>
290
+ Last edited by headius, <time class="js-relative-date" datetime="2011-05-15T17:25:54-07:00" title="2011-05-15 17:25:54">May 15, 2011</time>
291
291
  </p>
292
292
  <p id="delete-link">
293
- <a href="/jruby/jruby/wiki/C-Extension-Alternatives" onclick="if (confirm('Are you sure you want to delete this page?')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);var s = document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', 'authenticity_token'); s.setAttribute('value', '39136b986bbed8c260a8aa8d9ff8b1c9bd2b9ac8'); f.appendChild(s);f.submit(); };return false;"><span>Delete this Page</span></a>
293
+ <a href="/jruby/jruby/wiki/C-Extension-Alternatives" onclick="if (confirm('Are you sure you want to delete this page?')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);var s = document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', 'authenticity_token'); s.setAttribute('value', 'a12af8eb75d6148a6d430d76ce52736db893dd3d'); f.appendChild(s);f.submit(); };return false;"><span>Delete this Page</span></a>
294
294
  </p>
295
295
  </div>
296
296
  </div>
@@ -306,7 +306,7 @@
306
306
 
307
307
  <div class="sponsor">
308
308
  <a href="http://www.rackspace.com" class="logo">
309
- <img alt="Dedicated Server" height="36" src="https://d3nwyuy0nl342s.cloudfront.net/images/modules/footer/rackspace_logo.png?v2" width="38" />
309
+ <img alt="Dedicated Server" height="36" src="https://a248.e.akamai.net/assets.github.com/images/modules/footer/rackspace_logo.png?v2" width="38" />
310
310
  </a>
311
311
  Powered by the <a href="http://www.rackspace.com ">Dedicated
312
312
  Servers</a> and<br/> <a href="http://www.rackspacecloud.com">Cloud
@@ -327,7 +327,7 @@
327
327
 
328
328
  </ul>
329
329
  <ul class="sosueme">
330
- <li class="main">&copy; 2011 <span id="_rrt" title="0.09826s from fe4.rs.github.com">GitHub</span> Inc. All rights reserved.</li>
330
+ <li class="main">&copy; 2011 <span id="_rrt" title="0.11973s from fe1.rs.github.com">GitHub</span> Inc. All rights reserved.</li>
331
331
  <li><a href="/site/terms">Terms of Service</a></li>
332
332
  <li><a href="/site/privacy">Privacy</a></li>
333
333
  <li><a href="https://github.com/security">Security</a></li>
@@ -335,7 +335,7 @@
335
335
  </div>
336
336
  </div><!-- /#footer -->
337
337
 
338
- <script>window._auth_token = "39136b986bbed8c260a8aa8d9ff8b1c9bd2b9ac8"</script>
338
+ <script>window._auth_token = "a12af8eb75d6148a6d430d76ce52736db893dd3d"</script>
339
339
 
340
340
 
341
341
  <div id="keyboard_shortcuts_pane" class="instapaper_ignore readability-extra" style="display:none">
@@ -599,7 +599,7 @@ As Kanye West said:
599
599
 
600
600
  <h3>Code Examples in Markdown</h3>
601
601
  <div class="col">
602
- <p>Syntax highlighting with <a href="http://github.github.com/github-flavored-markdown/" title="GitHub Flavored Markdown">GFM</a></p>
602
+ <p>Syntax highlighting with <a href="http://github.github.com/github-flavored-markdown/" title="GitHub Flavored Markdown" target="_blank">GFM</a></p>
603
603
  <pre>
604
604
  ```javascript
605
605
  function fancyAlert(arg) {
@@ -646,7 +646,7 @@ I think you should use an
646
646
 
647
647
 
648
648
 
649
- <script>(function(){var d=document;var e=d.createElement("script");e.async=true;e.src="https://d1ros97qkrwjf5.cloudfront.net/10/eum/rum.js ";var s=d.getElementsByTagName("script")[0];s.parentNode.insertBefore(e,s);})();NREUMQ.push(["nrf2","beacon-3.newrelic.com","2f94e4d8c2",64799,"dw1bEBZcX1RWRhoBFFUSXRdLQ1JKR11WDxZVFlwLCg==",0,151,new Date().getTime()])</script>
649
+ <script type="text/javascript">(function(){var d=document;var e=d.createElement("script");e.async=true;e.src="https://d1ros97qkrwjf5.cloudfront.net/14/eum/rum.js ";e.type="text/javascript";var s=d.getElementsByTagName("script")[0];s.parentNode.insertBefore(e,s);})();NREUMQ.push(["nrf2","beacon-1.newrelic.com","2f94e4d8c2",64799,"dw1bEBZcX1RWRhoRD18LGhcMXEQ=",0.0,118,new Date().getTime()])</script>
650
650
  </body>
651
651
  </html>
652
652
 
@@ -28,4 +28,16 @@ describe JRuby::Lint::Finding do
28
28
  When { @finding = JRuby::Lint::Finding.new(message, tags, file, line) }
29
29
  Then { @finding.tags.should == ["1", "two", "3.0"] }
30
30
  end
31
+
32
+ context "with error tags" do
33
+ Given(:tags) { [:error] }
34
+ When { @finding = JRuby::Lint::Finding.new(message, tags, file, line) }
35
+ Then { @finding.should be_error }
36
+ end
37
+
38
+ context "with warnings tags" do
39
+ Given(:tags) { [:warning] }
40
+ When { @finding = JRuby::Lint::Finding.new(message, tags, file, line) }
41
+ Then { @finding.should be_warning }
42
+ end
31
43
  end
@@ -67,6 +67,11 @@ describe JRuby::Lint::Project do
67
67
  end
68
68
  end
69
69
 
70
+ When do
71
+ reporter.stub!(:print_report)
72
+ reporter.should_receive(:print_report).with([finding])
73
+ end
74
+
70
75
  When do
71
76
  project.collectors.replace [collector]
72
77
  project.reporters.replace [reporter]
@@ -74,4 +79,48 @@ describe JRuby::Lint::Project do
74
79
 
75
80
  Then { project.run }
76
81
  end
82
+
83
+ context 'loading reporters' do
84
+ context 'with html option' do
85
+ Given(:options) { OpenStruct.new(:html => 'report.html') }
86
+ Given(:project) { in_current_dir { JRuby::Lint::Project.new(options) } }
87
+ Then { project.reporters.should have(1).reporter }
88
+ Then { project.reporters.first.should be_an_instance_of(JRuby::Lint::Reporters::Html) }
89
+ end
90
+
91
+ context 'with ansi option' do
92
+ Given(:options) { OpenStruct.new(:ansi => true) }
93
+ Given(:project) { in_current_dir { JRuby::Lint::Project.new(options) } }
94
+ Then { project.reporters.should have(1).reporter }
95
+ Then { project.reporters.first.should be_an_instance_of(JRuby::Lint::Reporters::ANSIColor) }
96
+ end
97
+
98
+ context 'with text option' do
99
+ Given(:options) { OpenStruct.new(:text => true) }
100
+ Given(:project) { in_current_dir { JRuby::Lint::Project.new(options) } }
101
+ Then { project.reporters.should have(1).reporter }
102
+ Then { project.reporters.first.should be_an_instance_of(JRuby::Lint::Reporters::Text) }
103
+ end
104
+
105
+ context 'with tty' do
106
+ Given { STDOUT.stub(:tty?).and_return(true) }
107
+ Given(:project) { in_current_dir { JRuby::Lint::Project.new } }
108
+ Then { project.reporters.should have(1).reporter }
109
+ Then { project.reporters.first.should be_an_instance_of(JRuby::Lint::Reporters::ANSIColor) }
110
+ end
111
+
112
+ context 'without any option' do
113
+ Given(:project) { in_current_dir { JRuby::Lint::Project.new } }
114
+ Then { project.reporters.should have(1).reporter }
115
+ Then { project.reporters.first.should be_an_instance_of(JRuby::Lint::Reporters::Text) }
116
+ end
117
+
118
+ context 'with several options' do
119
+ Given(:options) { OpenStruct.new(:ansi => true, :html => 'report.html') }
120
+ Given(:project) { in_current_dir { JRuby::Lint::Project.new(options) } }
121
+ Then { project.reporters.should have(2).reporter }
122
+ Then { project.reporters.map(&:class).should include(JRuby::Lint::Reporters::ANSIColor) }
123
+ Then { project.reporters.map(&:class).should include(JRuby::Lint::Reporters::Html) }
124
+ end
125
+ end
77
126
  end
@@ -26,17 +26,38 @@ describe JRuby::Lint::Reporters do
26
26
  Given(:reporter) { JRuby::Lint::Reporters::ANSIColor.new(project, output) }
27
27
 
28
28
  context "shows a finding tagged 'error' in red" do
29
- Given(:finding) { double "finding", :to_s => "hello", :tags => %w(error) }
29
+ Given(:finding) { double "finding", :to_s => "hello", :tags => %w(error), :error? => true }
30
30
  Given(:output) { double("output").tap {|o| o.should_receive(:puts).with(red("hello")) } }
31
31
 
32
32
  Then { reporter.report [finding] }
33
33
  end
34
34
 
35
35
  context "shows a finding tagged 'warning' in yellow" do
36
- Given(:finding) { double "finding", :to_s => "hello", :tags => %w(warning) }
36
+ Given(:finding) { double "finding", :to_s => "hello", :tags => %w(warning), :error? => false, :warning? => true }
37
37
  Given(:output) { double("output").tap {|o| o.should_receive(:puts).with(yellow("hello")) } }
38
38
 
39
39
  Then { reporter.report [finding] }
40
40
  end
41
41
  end
42
+
43
+ context "Html reporter" do
44
+ Given(:reporter) { JRuby::Lint::Reporters::Html.new(project, 'lint-spec-report.html') }
45
+
46
+ context "shows a finding tagged 'error' in red" do
47
+ Given(:finding) { double "finding", :to_s => "hello", :tags => %w(error), :error? => true }
48
+ Then { reporter.print_report [finding] }
49
+ Then { File.read('lint-spec-report.html').should include('<li class="error">hello</li>') }
50
+ end
51
+
52
+ context "shows a finding tagged 'warning' in yellow" do
53
+ Given(:finding) { double "finding", :to_s => "hello", :tags => %w(warning), :error? => false, :warning? => true }
54
+ Then { reporter.print_report [finding] }
55
+ Then { File.read('lint-spec-report.html').should include('<li class="warning">hello</li>') }
56
+ end
57
+
58
+ context "shows a nice message when we don't find any issue" do
59
+ When { reporter.print_report [] }
60
+ Then { File.read('lint-spec-report.html').should include('Congratulations!') }
61
+ end
62
+ end
42
63
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: jruby-lint
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.0
5
+ version: 0.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nick Sieger
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-03 00:00:00 -05:00
13
+ date: 2011-07-05 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -136,6 +136,9 @@ files:
136
136
  - lib/jruby/lint/libraries.rb
137
137
  - lib/jruby/lint/project.rb
138
138
  - lib/jruby/lint/reporters.rb
139
+ - lib/jruby/lint/reporters/html.rb
140
+ - lib/jruby/lint/reporters/jruby-lint.html.erb
141
+ - lib/jruby/lint/reporters/text.rb
139
142
  - lib/jruby/lint/version.rb
140
143
  - spec/fixtures/C-Extension-Alternatives.html
141
144
  - spec/jruby/lint/ast_spec.rb