code_hunter 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +3 -3
- data/lib/code_hunter.rb +1 -0
- data/lib/code_hunter/brakeman/invoker.rb +6 -1
- data/lib/code_hunter/method_logger.rb +11 -0
- data/lib/code_hunter/pendaxes.rb +4 -1
- data/lib/code_hunter/rails_best_practices/invoker.rb +6 -1
- data/lib/code_hunter/renderer.rb +3 -0
- data/lib/code_hunter/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -54,9 +54,9 @@ If you want to ignore some warnings, write `# ignore` annotation as code comment
|
|
54
54
|
If the detected line hits `/#\s*ignore/i`, it is ignored.
|
55
55
|
|
56
56
|
```ruby
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
dangerous_but_necessary_code # ignore
|
58
|
+
dangerous_but_necessary_code # IGNORE
|
59
|
+
dangerous_but_necessary_code # Ignore for some reason
|
60
60
|
```
|
61
61
|
|
62
62
|
|
data/lib/code_hunter.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module CodeHunter
|
2
2
|
class Brakeman
|
3
3
|
class Invoker
|
4
|
+
extend MethodLogger
|
5
|
+
|
4
6
|
attr_reader :options
|
5
7
|
|
6
8
|
def initialize(options = {})
|
@@ -10,9 +12,12 @@ module CodeHunter
|
|
10
12
|
def invoke
|
11
13
|
system(
|
12
14
|
"brakeman",
|
13
|
-
"--output", Brakeman::TEMPORAL_PATHNAME.to_s
|
15
|
+
"--output", Brakeman::TEMPORAL_PATHNAME.to_s,
|
16
|
+
:out => IO::NULL,
|
17
|
+
:err => IO::NULL
|
14
18
|
)
|
15
19
|
end
|
20
|
+
log(:invoke)
|
16
21
|
end
|
17
22
|
end
|
18
23
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module CodeHunter
|
2
|
+
module MethodLogger
|
3
|
+
def log(method_name)
|
4
|
+
define_method("#{method_name}_with_log") do |*args, &block|
|
5
|
+
warn("#{Time.now} #{self.class}##{method_name}")
|
6
|
+
__send__("#{method_name}_without_log", *args, &block)
|
7
|
+
end
|
8
|
+
alias_method_chain method_name, :log
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/code_hunter/pendaxes.rb
CHANGED
@@ -2,6 +2,8 @@ require "json"
|
|
2
2
|
|
3
3
|
module CodeHunter
|
4
4
|
class Pendaxes
|
5
|
+
extend MethodLogger
|
6
|
+
|
5
7
|
attr_reader :options
|
6
8
|
|
7
9
|
def initialize(options = {})
|
@@ -15,8 +17,9 @@ module CodeHunter
|
|
15
17
|
private
|
16
18
|
|
17
19
|
def invoke
|
18
|
-
`pendaxes-oneshot #{options[:application_path]} --reporter json`
|
20
|
+
`pendaxes-oneshot #{options[:application_path]} --reporter json 2>/dev/null `
|
19
21
|
end
|
22
|
+
log(:invoke)
|
20
23
|
|
21
24
|
def summarize(json)
|
22
25
|
pendings = JSON.parse(json)["pendings"]
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module CodeHunter
|
2
2
|
class RailsBestPractices
|
3
3
|
class Invoker
|
4
|
+
extend MethodLogger
|
5
|
+
|
4
6
|
attr_reader :options
|
5
7
|
|
6
8
|
def initialize(options = {})
|
@@ -11,9 +13,12 @@ module CodeHunter
|
|
11
13
|
system(
|
12
14
|
"rails_best_practices",
|
13
15
|
"--format", "html",
|
14
|
-
"--output-file", RailsBestPractices::TEMPORAL_PATHNAME.to_s
|
16
|
+
"--output-file", RailsBestPractices::TEMPORAL_PATHNAME.to_s,
|
17
|
+
:out => IO::NULL,
|
18
|
+
:err => IO::NULL
|
15
19
|
)
|
16
20
|
end
|
21
|
+
log(:invoke)
|
17
22
|
end
|
18
23
|
end
|
19
24
|
end
|
data/lib/code_hunter/renderer.rb
CHANGED
@@ -5,6 +5,8 @@ module CodeHunter
|
|
5
5
|
# Render warnings to string with the specified format.
|
6
6
|
# As its format, AVAILABLE_FORMATS are available ("yaml" is default).
|
7
7
|
class Renderer
|
8
|
+
extend MethodLogger
|
9
|
+
|
8
10
|
AVAILABLE_FORMATS = %w[json yaml]
|
9
11
|
|
10
12
|
def self.render(*args)
|
@@ -26,6 +28,7 @@ module CodeHunter
|
|
26
28
|
raise ArgumentError, "format #{format} is not available. Use #{AVAILABLE_FORMATS}"
|
27
29
|
end
|
28
30
|
end
|
31
|
+
log(:render)
|
29
32
|
|
30
33
|
private
|
31
34
|
|
data/lib/code_hunter/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.5
|
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-
|
12
|
+
date: 2013-03-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- lib/code_hunter/brakeman/invoker.rb
|
144
144
|
- lib/code_hunter/brakeman/summarizer.rb
|
145
145
|
- lib/code_hunter/git_blamer.rb
|
146
|
+
- lib/code_hunter/method_logger.rb
|
146
147
|
- lib/code_hunter/option_parser.rb
|
147
148
|
- lib/code_hunter/pendaxes.rb
|
148
149
|
- lib/code_hunter/rails_best_practices.rb
|
@@ -176,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
177
|
version: '0'
|
177
178
|
requirements: []
|
178
179
|
rubyforge_project:
|
179
|
-
rubygems_version: 1.8.
|
180
|
+
rubygems_version: 1.8.23
|
180
181
|
signing_key:
|
181
182
|
specification_version: 3
|
182
183
|
summary: Code hunter
|
@@ -185,4 +186,3 @@ test_files:
|
|
185
186
|
- spec/code_hunter/renderer_spec.rb
|
186
187
|
- spec/code_hunter/runner_spec.rb
|
187
188
|
- spec/spec_helper.rb
|
188
|
-
has_rdoc:
|