merge_reviewer 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +16 -0
- data/lib/merge_reviewer.rb +8 -0
- data/lib/merge_reviewer/analyzer.rb +9 -0
- data/lib/merge_reviewer/flayer.rb +79 -0
- data/lib/merge_reviewer/flogger.rb +54 -0
- data/lib/merge_reviewer/version.rb +3 -0
- data/merge_reviewer.gemspec +26 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: be1351f513cc97e567ca4c4513128514f31e7f07
|
4
|
+
data.tar.gz: 67f831c8412e0f7d6081a334a9e3a40ed1e36e18
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 828970ac1fe3e166159d023f56e0b4c19838359d402c3f0e5e27ac795c28341d45203a5977e841d9307b21e1aacaee300dde8469a0732cbc538d31d1bf5c450a
|
7
|
+
data.tar.gz: 188bddac17d6659e84eac25b363b51b4b4672deb4064ee1b0c603ad9279086161b4c581ac8a311f9a968f79cfa8dd8654134c5a2b261fba17ba656ffaa6062d6
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
merge_reviewer
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.3
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jason Vanderhoof
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# MergeReviewer
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'merge_reviewer'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install merge_reviewer
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/merge_reviewer/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'merge_reviewer'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
namespace :test do
|
6
|
+
task :run do
|
7
|
+
path = '../masterdev/g3'
|
8
|
+
|
9
|
+
flay = Flayer.new(path)
|
10
|
+
puts flay.file_violations('boxes_controller').to_yaml
|
11
|
+
|
12
|
+
flog = Flogger.new(path)
|
13
|
+
puts flog.file_violations('spec/controllers/boxes_controller').to_yaml
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'flay'
|
2
|
+
|
3
|
+
class Flayer < Analyzer
|
4
|
+
def initialize(path)
|
5
|
+
files = Flay.expand_dirs_to_files(path)
|
6
|
+
flay = Flay.new
|
7
|
+
flay.process(*files)
|
8
|
+
file = Tempfile.new('flay-output')
|
9
|
+
flay.report(file)
|
10
|
+
file.rewind
|
11
|
+
@results = build_file_flog_score(file)
|
12
|
+
end
|
13
|
+
|
14
|
+
def parse_summary_line(line)
|
15
|
+
if line.match(/^(\d+)\)\s([a-z]+)\s.+(:[a-z]+)\s.+=\s(\d+)/i)
|
16
|
+
return [$1, {match: $2, type: $3, score: $4, similarities: []}]
|
17
|
+
end
|
18
|
+
raise "invalid line: #{line.inspect}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def parse_file_dup_line(line)
|
22
|
+
if line.match(/(.+):(\d+)/)
|
23
|
+
return {method_path: $1, line_number: $2, raw_line: line}
|
24
|
+
end
|
25
|
+
raise "invalid line: #{line.inspect}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def parse_file_to_hash(file)
|
29
|
+
result = {}
|
30
|
+
current_number = ''
|
31
|
+
file.each_line do |line|
|
32
|
+
line.strip!
|
33
|
+
next if line.empty?
|
34
|
+
if line.match(/^(\d+)/)
|
35
|
+
#puts line
|
36
|
+
current_number, result[current_number] = parse_summary_line(line)
|
37
|
+
elsif line.match(/Total score/)
|
38
|
+
next
|
39
|
+
else
|
40
|
+
result[current_number][:similarities] << parse_file_dup_line(line)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
result
|
44
|
+
end
|
45
|
+
|
46
|
+
def similar_combinations(arr)
|
47
|
+
rtn = {}
|
48
|
+
arr.each do |item|
|
49
|
+
rtn[item[:raw_line]] = arr.select{|i| i[:raw_line] != item[:raw_line]}
|
50
|
+
end
|
51
|
+
rtn
|
52
|
+
end
|
53
|
+
|
54
|
+
def duplication_number_hash_to_files(hsh)
|
55
|
+
result = {}
|
56
|
+
hsh.each do |number, match|
|
57
|
+
similar_combinations(match[:similarities]).each do |raw_line, similar_to|
|
58
|
+
next if result.has_key?(raw_line)
|
59
|
+
result[raw_line] ||= {
|
60
|
+
match: match[:match],
|
61
|
+
type: match[:type],
|
62
|
+
score: match[:score],
|
63
|
+
similar_to: similar_to
|
64
|
+
}
|
65
|
+
similar_to.each do |similar_item|
|
66
|
+
unless result[raw_line][:similar_to].include?(similar_item)
|
67
|
+
result[raw_line][:similar_to] << similar_item
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
result
|
73
|
+
end
|
74
|
+
|
75
|
+
def build_file_flog_score(file)
|
76
|
+
results_by_duplication_number = parse_file_to_hash(file)
|
77
|
+
duplication_number_hash_to_files(results_by_duplication_number)
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'flog'
|
2
|
+
require "flog_cli"
|
3
|
+
|
4
|
+
|
5
|
+
class Flogger < Analyzer
|
6
|
+
def initialize(folders)
|
7
|
+
flogger = FlogCLI.new(FlogCLI.parse_options(["-b", "-g"]))
|
8
|
+
flogger.flog(folders)
|
9
|
+
|
10
|
+
file = Tempfile.new('flog-output')
|
11
|
+
flogger.report(file)
|
12
|
+
file.rewind
|
13
|
+
@results = build_file_flog_score(file)
|
14
|
+
end
|
15
|
+
|
16
|
+
def set_class_flog_total(class_name, score)
|
17
|
+
@class_flog_scores ||= {}
|
18
|
+
@class_flog_scores[class_name] = score
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_class_flog_total(class_name)
|
22
|
+
@class_flog_scores[class_name]
|
23
|
+
end
|
24
|
+
|
25
|
+
def line_to_parts(line, mapper)
|
26
|
+
line.strip!
|
27
|
+
return mapper if line.empty?
|
28
|
+
if line.match(/(\d+\.\d+):\s(.+)\stotal/)
|
29
|
+
class_score, class_name = $1.to_f, $2
|
30
|
+
set_class_flog_total(class_name, class_score)
|
31
|
+
elsif line.match(/(\d+\.\d+):\s+(.+)#(.+)\s+(.+):(\d+)/)
|
32
|
+
method_score, class_name, method_name, method_path, line_number = $1.to_f, $2, $3, $4, $5
|
33
|
+
mapper[method_path] ||= {
|
34
|
+
class_name: class_name,
|
35
|
+
class_score: get_class_flog_total(class_name),
|
36
|
+
problems: []
|
37
|
+
}
|
38
|
+
mapper[method_path][:problems] << {
|
39
|
+
method_score: method_score,
|
40
|
+
method_name: method_name,
|
41
|
+
line_number: line_number
|
42
|
+
}
|
43
|
+
end
|
44
|
+
mapper
|
45
|
+
end
|
46
|
+
|
47
|
+
def build_file_flog_score(file)
|
48
|
+
mapper = {}
|
49
|
+
file.each_line do |line|
|
50
|
+
mapper = line_to_parts(line, mapper)
|
51
|
+
end
|
52
|
+
mapper
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'merge_reviewer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "merge_reviewer"
|
8
|
+
spec.version = MergeReviewer::VERSION
|
9
|
+
spec.authors = ["Jason Vanderhoof"]
|
10
|
+
spec.email = ["jvanderhoof@gmail.com"]
|
11
|
+
spec.summary = %q{Get complexity and duplication for a single file, or all of them.}
|
12
|
+
spec.description = %q{Gem that simplifies the process of getting complexity and duplication for a single file.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'flog'
|
22
|
+
spec.add_dependency 'flay'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: merge_reviewer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jason Vanderhoof
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: flog
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: flay
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: Gem that simplifies the process of getting complexity and duplication
|
70
|
+
for a single file.
|
71
|
+
email:
|
72
|
+
- jvanderhoof@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".ruby-gemset"
|
79
|
+
- ".ruby-version"
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- lib/merge_reviewer.rb
|
85
|
+
- lib/merge_reviewer/analyzer.rb
|
86
|
+
- lib/merge_reviewer/flayer.rb
|
87
|
+
- lib/merge_reviewer/flogger.rb
|
88
|
+
- lib/merge_reviewer/version.rb
|
89
|
+
- merge_reviewer.gemspec
|
90
|
+
homepage: ''
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.2.2
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Get complexity and duplication for a single file, or all of them.
|
114
|
+
test_files: []
|