deathnote 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +44 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/deathnote.gemspec +28 -0
- data/exe/deathnote +9 -0
- data/lib/deathnote.rb +102 -0
- data/lib/deathnote/version.rb +3 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1ec82f2efc923d30e422f2d07c0257ccce1b3634
|
4
|
+
data.tar.gz: 2719c074d62e1e4dda1eaf6f00c761197ffb6ec0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cbeea4d13ec7b4c156a16dedb2a57dae566dc513e906cf7e5b273d17dd0609b9700eacdfdacfb93e2a1b086fbbfa1c9432741704fd52db3a7b9817a17922ff1a
|
7
|
+
data.tar.gz: 6ddaaef39ebe79754031ef9f26770fb0f228319a0cf096c985e561d429c3077de40431f78ef3dbb8e432bf00958e0f70f28dd2a864e67009e690af4264dfa773
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4.4
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
deathnote (0.1.0)
|
5
|
+
debride (~> 1.8)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
debride (1.8.1)
|
11
|
+
path_expander (~> 1.0)
|
12
|
+
ruby_parser (~> 3.6)
|
13
|
+
sexp_processor (~> 4.5)
|
14
|
+
diff-lcs (1.3)
|
15
|
+
path_expander (1.0.3)
|
16
|
+
rake (10.5.0)
|
17
|
+
rspec (3.7.0)
|
18
|
+
rspec-core (~> 3.7.0)
|
19
|
+
rspec-expectations (~> 3.7.0)
|
20
|
+
rspec-mocks (~> 3.7.0)
|
21
|
+
rspec-core (3.7.1)
|
22
|
+
rspec-support (~> 3.7.0)
|
23
|
+
rspec-expectations (3.7.0)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.7.0)
|
26
|
+
rspec-mocks (3.7.0)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.7.0)
|
29
|
+
rspec-support (3.7.1)
|
30
|
+
ruby_parser (3.11.0)
|
31
|
+
sexp_processor (~> 4.9)
|
32
|
+
sexp_processor (4.10.1)
|
33
|
+
|
34
|
+
PLATFORMS
|
35
|
+
ruby
|
36
|
+
|
37
|
+
DEPENDENCIES
|
38
|
+
bundler (~> 1.16)
|
39
|
+
deathnote!
|
40
|
+
rake (~> 10.0)
|
41
|
+
rspec (~> 3.0)
|
42
|
+
|
43
|
+
BUNDLED WITH
|
44
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Shia
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Deathnote
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/deathnote`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'deathnote'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install deathnote
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/deathnote.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "deathnote"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/deathnote.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "deathnote/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "deathnote"
|
8
|
+
spec.version = Deathnote::VERSION
|
9
|
+
spec.authors = ["Shia"]
|
10
|
+
spec.email = ["rise.shia@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Find out dead code between base branch and compare branch.}
|
13
|
+
spec.description = %q{Find out dead code between base branch and compare branch. This works on git.}
|
14
|
+
spec.homepage = "https://github.com/riseshia/deathnote"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
spec.add_dependency "debride", "~> 1.8"
|
28
|
+
end
|
data/exe/deathnote
ADDED
data/lib/deathnote.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'open3'
|
2
|
+
require 'optparse'
|
3
|
+
|
4
|
+
require 'deathnote/version'
|
5
|
+
require 'debride'
|
6
|
+
require 'path_expander'
|
7
|
+
|
8
|
+
module Deathnote
|
9
|
+
class << self
|
10
|
+
def run(argv)
|
11
|
+
options = parse_options(argv)
|
12
|
+
old_branch = Open3.popen3('git rev-parse --abbrev-ref HEAD') { |_i, o, _e, _t| o.read.chomp }
|
13
|
+
|
14
|
+
base_missing = DeadCodes.new(branch: 'master', options: options.deep_clone).run
|
15
|
+
pr_missing = DeadCodes.new(branch: 'refactoring', options: options.deep_clone).run
|
16
|
+
Open3.popen3("git checkout #{old_branch}")
|
17
|
+
|
18
|
+
pr_missing.
|
19
|
+
reject { |unused, _location| base_missing.has_key?(unused) }.
|
20
|
+
each { |unused, location| puts "#{unused} #{location}" }
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def parse_options(argv)
|
26
|
+
options = { base_branch: 'master' }
|
27
|
+
OptionParser.new do |opts|
|
28
|
+
opts.banner = 'Usage: deathnote [options] files_or_dirs'
|
29
|
+
|
30
|
+
opts.on('-h', '--help', 'Display this help.') do
|
31
|
+
puts opts
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
opts.on('-b', '--base branch_name', 'Specify base branch name. Default is "master"') do |base_branch|
|
35
|
+
options[:base_branch] = base_branch
|
36
|
+
end
|
37
|
+
opts.on('-c', '--compare branch_name', 'Specify compare branch name.') do |compare_branch|
|
38
|
+
options[:compare_branch] = compare_branch
|
39
|
+
end
|
40
|
+
opts.on('-r', '--rails', 'Filter some rails call conversions.') do
|
41
|
+
options[:rails] = true
|
42
|
+
end
|
43
|
+
opts.on('-e', '--exclude FILE1,FILE2,ETC', Array, 'Exclude files or directories in comma-separated list.') do |list|
|
44
|
+
options[:exclude] = list
|
45
|
+
end
|
46
|
+
end.parse!
|
47
|
+
options[:target_paths] = argv
|
48
|
+
|
49
|
+
options
|
50
|
+
rescue OptionParser::InvalidOption => e
|
51
|
+
warn op.to_s
|
52
|
+
warn ""
|
53
|
+
warn e.message
|
54
|
+
exit 1
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class DeadCodes
|
59
|
+
def initialize(branch:, options:)
|
60
|
+
@branch = branch
|
61
|
+
@options = options
|
62
|
+
end
|
63
|
+
|
64
|
+
def run
|
65
|
+
Open3.popen3("git checkout #{@branch}")
|
66
|
+
to_list(run_debride)
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def run_debride
|
72
|
+
debride = Debride.new(@options)
|
73
|
+
|
74
|
+
extensions = Debride.file_extensions
|
75
|
+
glob = "**/*.{#{extensions.join(",")}}"
|
76
|
+
expander = PathExpander.new(@options[:target_paths], glob)
|
77
|
+
files = expander.process
|
78
|
+
excl = debride.option[:exclude]
|
79
|
+
files = expander.filter_files files, StringIO.new(excl.join "\n") if excl
|
80
|
+
|
81
|
+
debride.run(files)
|
82
|
+
debride
|
83
|
+
end
|
84
|
+
|
85
|
+
def to_list(debride)
|
86
|
+
unuseds = {}
|
87
|
+
method_locations = debride.method_locations
|
88
|
+
|
89
|
+
debride.missing.each do |klass, meths|
|
90
|
+
meths.each do |meth|
|
91
|
+
type = method_locations["#{klass}##{meth}"].nil? ? '::' : '#'
|
92
|
+
location = method_locations["#{klass}#{type}#{meth}"]
|
93
|
+
path = location[/(.+):\d+$/, 1]
|
94
|
+
|
95
|
+
unuseds["#{klass}#{type}#{meth}"] = location
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
unuseds
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: deathnote
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shia
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: debride
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.8'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.8'
|
69
|
+
description: Find out dead code between base branch and compare branch. This works
|
70
|
+
on git.
|
71
|
+
email:
|
72
|
+
- rise.shia@gmail.com
|
73
|
+
executables:
|
74
|
+
- deathnote
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- ".rspec"
|
80
|
+
- ".ruby-version"
|
81
|
+
- ".travis.yml"
|
82
|
+
- Gemfile
|
83
|
+
- Gemfile.lock
|
84
|
+
- LICENSE.txt
|
85
|
+
- README.md
|
86
|
+
- Rakefile
|
87
|
+
- bin/console
|
88
|
+
- bin/setup
|
89
|
+
- deathnote.gemspec
|
90
|
+
- exe/deathnote
|
91
|
+
- lib/deathnote.rb
|
92
|
+
- lib/deathnote/version.rb
|
93
|
+
homepage: https://github.com/riseshia/deathnote
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.6.14.1
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: Find out dead code between base branch and compare branch.
|
117
|
+
test_files: []
|