code_hunter 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # Code Hunter
2
- Hunt out weak spots in your rails application with 2 static metrics tools:
2
+ Hunt out weak spots in your rails application with 3 static metrics tools:
3
3
 
4
4
  * [Brakeman](https://github.com/presidentbeef/brakeman) - A static analysis security vulnerability scanner for Rails
5
5
  * [RailsBestPractices](https://github.com/railsbp/rails_best_practices) - A code metric tool for rails projects
6
+ * [Pendaxes](https://github.com/cookpad/pendaxes) - A tool to detect pendings in spec files
6
7
 
7
8
  ## Installation
8
9
 
@@ -10,14 +10,17 @@ module CodeHunter
10
10
  end
11
11
 
12
12
  def summarize
13
- warning_elements.map do |element|
14
- {
15
- :service => "brakeman",
16
- :line => find_line(element),
17
- :path => find_path(element),
18
- :message => find_message(element),
19
- }
20
- end
13
+ rows.map do |element|
14
+ if element.css(".warning_message").any?
15
+ {
16
+ :service => "brakeman",
17
+ :line => find_line(element),
18
+ :path => find_path(element),
19
+ :message => find_message(element),
20
+ :url => find_url(element),
21
+ }
22
+ end
23
+ end.compact
21
24
  end
22
25
 
23
26
  def find_line(element)
@@ -25,17 +28,25 @@ module CodeHunter
25
28
  end
26
29
 
27
30
  def find_message(element)
28
- element.child.text.strip
31
+ element.css(".warning_message").first.child.text.strip
29
32
  end
30
33
 
31
34
  def find_path(element)
32
- element.css("caption").text.strip
35
+ element.css(".warning_message").first.css("caption").text.strip
36
+ end
37
+
38
+ def find_url(element)
39
+ element.css("a").first.try(:attr, "href")
33
40
  end
34
41
 
35
42
  def warning_elements
36
43
  tree.css(".warning_message")
37
44
  end
38
45
 
46
+ def rows
47
+ tree.css("tr")
48
+ end
49
+
39
50
  def tree
40
51
  Nokogiri.HTML(content)
41
52
  end
@@ -20,7 +20,7 @@ module CodeHunter
20
20
  end
21
21
 
22
22
  def invoke
23
- `git blame #{File.realpath(@path)} -L #@line,+1 -l -e -p`
23
+ `git blame #{File.realpath(@path)} -L #@line,+1 -l -p`
24
24
  end
25
25
  end
26
26
  end
@@ -16,6 +16,7 @@ module CodeHunter
16
16
  :line => find_line(element),
17
17
  :path => find_path(element),
18
18
  :message => find_message(element),
19
+ :url => find_url(element),
19
20
  }
20
21
  end
21
22
  end
@@ -32,6 +33,10 @@ module CodeHunter
32
33
  element.css(".message").text.strip
33
34
  end
34
35
 
36
+ def find_url(element)
37
+ element.css("a").first.try(:attr, "href")
38
+ end
39
+
35
40
  def warning_elements
36
41
  tree.css(".result tbody tr")
37
42
  end
@@ -1,3 +1,3 @@
1
1
  module CodeHunter
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_hunter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-24 00:00:00.000000000 Z
12
+ date: 2013-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri