rubycritic 1.1.1 → 1.2.0
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 +4 -4
- data/.rubocop.yml +593 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +7 -0
- data/CONTRIBUTING.md +17 -15
- data/README.md +15 -4
- data/Rakefile +9 -6
- data/bin/rubycritic +2 -2
- data/lib/rubycritic.rb +21 -1
- data/lib/rubycritic/analysers/churn.rb +4 -2
- data/lib/rubycritic/analysers/helpers/ast_node.rb +4 -8
- data/lib/rubycritic/analysers/helpers/methods_counter.rb +2 -5
- data/lib/rubycritic/analysers/helpers/modules_locator.rb +2 -5
- data/lib/rubycritic/analysers/helpers/parser.rb +12 -0
- data/lib/rubycritic/analysers/helpers/reek.rb +6 -2
- data/lib/rubycritic/analysers/smells/reek.rb +1 -1
- data/lib/rubycritic/analysers_runner.rb +13 -7
- data/lib/rubycritic/cli/application.rb +24 -0
- data/lib/rubycritic/cli/options.rb +57 -0
- data/lib/rubycritic/commands/ci.rb +28 -0
- data/lib/rubycritic/commands/default.rb +30 -0
- data/lib/rubycritic/commands/help.rb +13 -0
- data/lib/rubycritic/commands/version.rb +11 -0
- data/lib/rubycritic/configuration.rb +19 -14
- data/lib/rubycritic/core/analysed_module.rb +1 -1
- data/lib/rubycritic/core/smell.rb +1 -1
- data/lib/rubycritic/report_generators/base.rb +1 -1
- data/lib/rubycritic/report_generators/line.rb +1 -1
- data/lib/rubycritic/report_generators/smells_index.rb +1 -0
- data/lib/rubycritic/report_generators/templates/code_file.html.erb +1 -1
- data/lib/rubycritic/report_generators/templates/smells_index.html.erb +6 -2
- data/lib/rubycritic/report_generators/templates/smelly_line.html.erb +1 -1
- data/lib/rubycritic/report_generators/view_helpers.rb +4 -4
- data/lib/rubycritic/reporters/base.rb +1 -1
- data/lib/rubycritic/revision_comparator.rb +14 -14
- data/lib/rubycritic/source_control_systems/base.rb +9 -32
- data/lib/rubycritic/source_control_systems/double.rb +6 -7
- data/lib/rubycritic/source_control_systems/git.rb +10 -16
- data/lib/rubycritic/source_control_systems/mercurial.rb +29 -0
- data/lib/rubycritic/source_locator.rb +4 -5
- data/lib/rubycritic/version.rb +1 -1
- data/rubycritic.gemspec +4 -3
- data/test/lib/rubycritic/analysers/churn_test.rb +5 -5
- data/test/lib/rubycritic/analysers/smells/flay_test.rb +1 -1
- data/test/lib/rubycritic/configuration_test.rb +8 -7
- data/test/lib/rubycritic/core/analysed_module_test.rb +2 -2
- data/test/lib/rubycritic/core/smell_test.rb +2 -2
- data/test/lib/rubycritic/source_control_systems/{source_control_system_test.rb → base_test.rb} +1 -1
- data/test/lib/rubycritic/source_control_systems/double_test.rb +11 -0
- data/test/lib/rubycritic/source_control_systems/git_test.rb +13 -0
- data/test/lib/rubycritic/source_control_systems/interfaces/basic.rb +7 -0
- data/test/lib/rubycritic/source_control_systems/interfaces/time_travel.rb +7 -0
- data/test/lib/rubycritic/source_control_systems/mercurial_test.rb +11 -0
- data/test/lib/rubycritic/source_locator_test.rb +8 -2
- data/test/test_helper.rb +29 -0
- metadata +49 -13
- data/lib/rubycritic/cli.rb +0 -46
- data/lib/rubycritic/modules_initializer.rb +0 -14
- data/lib/rubycritic/orchestrator.rb +0 -23
@@ -7,7 +7,7 @@ module Rubycritic
|
|
7
7
|
RUBY_FILES = File.join("**", "*#{RUBY_EXTENSION}")
|
8
8
|
|
9
9
|
def initialize(paths)
|
10
|
-
@initial_paths = paths
|
10
|
+
@initial_paths = Array(paths)
|
11
11
|
end
|
12
12
|
|
13
13
|
def paths
|
@@ -21,14 +21,13 @@ module Rubycritic
|
|
21
21
|
private
|
22
22
|
|
23
23
|
def expand_paths
|
24
|
-
@initial_paths.
|
24
|
+
@initial_paths.flat_map do |path|
|
25
25
|
if File.directory?(path)
|
26
26
|
Pathname.glob(File.join(path, RUBY_FILES))
|
27
|
-
elsif File.
|
27
|
+
elsif File.exist?(path) && File.extname(path) == RUBY_EXTENSION
|
28
28
|
Pathname.new(path)
|
29
29
|
end
|
30
|
-
end.
|
30
|
+
end.compact.map(&:cleanpath)
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
34
33
|
end
|
data/lib/rubycritic/version.rb
CHANGED
data/rubycritic.gemspec
CHANGED
@@ -16,19 +16,20 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.required_ruby_version = ">= 1.9.3"
|
17
17
|
|
18
18
|
spec.files = `git ls-files`.split("\n")
|
19
|
-
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
20
20
|
spec.test_files = `git ls-files -- test/*`.split("\n")
|
21
21
|
spec.require_path = "lib"
|
22
22
|
|
23
23
|
spec.add_runtime_dependency "virtus", "~> 1.0"
|
24
24
|
spec.add_runtime_dependency "flay", "2.4.0"
|
25
25
|
spec.add_runtime_dependency "flog", "4.2.1"
|
26
|
-
spec.add_runtime_dependency "reek", "1.
|
27
|
-
spec.add_runtime_dependency "parser", "
|
26
|
+
spec.add_runtime_dependency "reek", "1.6.0"
|
27
|
+
spec.add_runtime_dependency "parser", ">= 2.2.0.pre.5", "< 3.0"
|
28
28
|
spec.add_runtime_dependency "ruby2ruby", ">= 2.1.1", "< 3.0"
|
29
29
|
|
30
30
|
spec.add_development_dependency "bundler", "~> 1.3"
|
31
31
|
spec.add_development_dependency "rake"
|
32
32
|
spec.add_development_dependency "minitest", "~> 5.3"
|
33
33
|
spec.add_development_dependency "mocha", "~> 1.0"
|
34
|
+
spec.add_development_dependency "rubocop", "0.28.0"
|
34
35
|
end
|
@@ -5,18 +5,18 @@ require "rubycritic/source_control_systems/base"
|
|
5
5
|
describe Rubycritic::Analyser::Churn do
|
6
6
|
before do
|
7
7
|
@analysed_modules = [AnalysedModuleDouble.new(:path => "path_to_some_file.rb")]
|
8
|
-
|
8
|
+
analyser = Rubycritic::Analyser::Churn.new(@analysed_modules)
|
9
|
+
analyser.source_control_system = SourceControlSystemDouble.new
|
10
|
+
analyser.run
|
9
11
|
end
|
10
12
|
|
11
13
|
it "calculates the churn of each file and adds it to analysed_modules" do
|
12
|
-
Rubycritic::Analyser::Churn.new(@analysed_modules, @source_control_system).run
|
13
14
|
@analysed_modules.each do |analysed_module|
|
14
15
|
analysed_module.churn.must_equal 1
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
19
|
it "calculates the date of the last commit of each file and adds it to analysed_modules" do
|
19
|
-
Rubycritic::Analyser::Churn.new(@analysed_modules, @source_control_system).run
|
20
20
|
@analysed_modules.each do |analysed_module|
|
21
21
|
analysed_module.committed_at.must_equal "2013-10-09 12:52:49 +0100"
|
22
22
|
end
|
@@ -24,11 +24,11 @@ describe Rubycritic::Analyser::Churn do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
class SourceControlSystemDouble < Rubycritic::SourceControlSystem::Base
|
27
|
-
def revisions_count(
|
27
|
+
def revisions_count(_path)
|
28
28
|
1 # churn
|
29
29
|
end
|
30
30
|
|
31
|
-
def date_of_last_commit(
|
31
|
+
def date_of_last_commit(_path)
|
32
32
|
"2013-10-09 12:52:49 +0100"
|
33
33
|
end
|
34
34
|
end
|
@@ -6,7 +6,7 @@ require "pathname"
|
|
6
6
|
describe Rubycritic::Analyser::FlaySmells do
|
7
7
|
before do
|
8
8
|
@analysed_module = Rubycritic::AnalysedModule.new(
|
9
|
-
:pathname => Pathname.new("test/samples/flay/smelly.rb")
|
9
|
+
:pathname => Pathname.new("test/samples/flay/smelly.rb")
|
10
10
|
)
|
11
11
|
analysed_modules = [@analysed_module]
|
12
12
|
Rubycritic::Analyser::FlaySmells.new(analysed_modules).run
|
@@ -4,25 +4,26 @@ require "rubycritic/configuration"
|
|
4
4
|
describe Rubycritic::Configuration do
|
5
5
|
describe "#root" do
|
6
6
|
before do
|
7
|
-
|
7
|
+
Rubycritic::Config.set
|
8
|
+
@default = Rubycritic::Config.root
|
8
9
|
end
|
9
10
|
|
10
11
|
it "has a default" do
|
11
|
-
Rubycritic.
|
12
|
+
Rubycritic::Config.root.must_be_instance_of String
|
12
13
|
end
|
13
14
|
|
14
15
|
it "can be set to a relative path" do
|
15
|
-
Rubycritic.
|
16
|
-
Rubycritic.
|
16
|
+
Rubycritic::Config.root = "foo"
|
17
|
+
Rubycritic::Config.root.must_equal File.expand_path("foo")
|
17
18
|
end
|
18
19
|
|
19
20
|
it "can be set to an absolute path" do
|
20
|
-
Rubycritic.
|
21
|
-
Rubycritic.
|
21
|
+
Rubycritic::Config.root = "/foo"
|
22
|
+
Rubycritic::Config.root.must_equal "/foo"
|
22
23
|
end
|
23
24
|
|
24
25
|
after do
|
25
|
-
Rubycritic.
|
26
|
+
Rubycritic::Config.root = @default
|
26
27
|
end
|
27
28
|
end
|
28
29
|
end
|
@@ -68,10 +68,10 @@ describe Rubycritic::AnalysedModule do
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
describe "#
|
71
|
+
describe "#smells?" do
|
72
72
|
it "returns true if the analysed_module has at least one smell" do
|
73
73
|
analysed_module = Rubycritic::AnalysedModule.new(:smells => [SmellDouble.new])
|
74
|
-
analysed_module.
|
74
|
+
analysed_module.smells?.must_equal true
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
@@ -47,12 +47,12 @@ describe Rubycritic::Smell do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
describe "#
|
50
|
+
describe "#multiple_locations?" do
|
51
51
|
it "returns true if the smell has more than one location" do
|
52
52
|
location1 = Rubycritic::Location.new("./foo", "42")
|
53
53
|
location2 = Rubycritic::Location.new("./foo", "23")
|
54
54
|
smell = Rubycritic::Smell.new(:locations => [location1, location2])
|
55
|
-
smell.
|
55
|
+
smell.multiple_locations?.must_equal true
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
data/test/lib/rubycritic/source_control_systems/{source_control_system_test.rb → base_test.rb}
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
require "rubycritic/source_control_systems/base"
|
3
3
|
|
4
|
-
describe Rubycritic::SourceControlSystem do
|
4
|
+
describe Rubycritic::SourceControlSystem::Base do
|
5
5
|
before do
|
6
6
|
Rubycritic::SourceControlSystem::Base.systems.each do |system|
|
7
7
|
system.stubs(:supported?).returns(false)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "rubycritic/source_control_systems/base"
|
3
|
+
require_relative "interfaces/basic"
|
4
|
+
require_relative "interfaces/time_travel"
|
5
|
+
|
6
|
+
class GitTest < Minitest::Test
|
7
|
+
include BasicInterface
|
8
|
+
include TimeTravelInterface
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@system = Rubycritic::SourceControlSystem::Git.new
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "rubycritic/source_control_systems/base"
|
3
|
+
require_relative "interfaces/basic"
|
4
|
+
|
5
|
+
class MercurialTest < Minitest::Test
|
6
|
+
include BasicInterface
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@system = Rubycritic::SourceControlSystem::Mercurial.new
|
10
|
+
end
|
11
|
+
end
|
@@ -21,13 +21,13 @@ describe Rubycritic::SourceLocator do
|
|
21
21
|
|
22
22
|
it "finds files through multiple paths" do
|
23
23
|
paths = ["dir1/file1.rb", "file0.rb"]
|
24
|
-
Rubycritic::SourceLocator.new(paths).paths.
|
24
|
+
Rubycritic::SourceLocator.new(paths).paths.must_match_array paths
|
25
25
|
end
|
26
26
|
|
27
27
|
it "finds all the files" do
|
28
28
|
initial_paths = ["."]
|
29
29
|
final_paths = ["dir1/file1.rb", "file0.rb"]
|
30
|
-
Rubycritic::SourceLocator.new(initial_paths).paths.
|
30
|
+
Rubycritic::SourceLocator.new(initial_paths).paths.must_match_array final_paths
|
31
31
|
end
|
32
32
|
|
33
33
|
it "cleans paths of consecutive slashes and useless dots" do
|
@@ -47,6 +47,12 @@ describe Rubycritic::SourceLocator do
|
|
47
47
|
final_paths = []
|
48
48
|
Rubycritic::SourceLocator.new(initial_paths).paths.must_equal final_paths
|
49
49
|
end
|
50
|
+
|
51
|
+
it "can deal with nil paths" do
|
52
|
+
paths = nil
|
53
|
+
final_paths = []
|
54
|
+
Rubycritic::SourceLocator.new(paths).paths.must_equal final_paths
|
55
|
+
end
|
50
56
|
end
|
51
57
|
|
52
58
|
describe "#pathnames" do
|
data/test/test_helper.rb
CHANGED
@@ -15,3 +15,32 @@ ensure
|
|
15
15
|
$stdout = STDOUT
|
16
16
|
$stderr = STDERR
|
17
17
|
end
|
18
|
+
|
19
|
+
module MiniTest
|
20
|
+
module Assertions
|
21
|
+
##
|
22
|
+
# Fails unless <tt>exp</tt> and <tt>act</tt> are both arrays and
|
23
|
+
# contain the same elements.
|
24
|
+
#
|
25
|
+
# assert_matched_arrays [3,2,1], [1,2,3]
|
26
|
+
|
27
|
+
def assert_matched_arrays(exp, act)
|
28
|
+
exp_ary = exp.to_ary
|
29
|
+
assert_kind_of Array, exp_ary
|
30
|
+
act_ary = act.to_ary
|
31
|
+
assert_kind_of Array, act_ary
|
32
|
+
assert_equal exp_ary.sort, act_ary.sort
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module Expectations
|
37
|
+
##
|
38
|
+
# See MiniTest::Assertions#assert_matched_arrays
|
39
|
+
#
|
40
|
+
# [1,2,3].must_match_array [3,2,1]
|
41
|
+
#
|
42
|
+
# :method: must_match_array
|
43
|
+
|
44
|
+
infect_an_assertion :assert_matched_arrays, :must_match_array
|
45
|
+
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubycritic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guilherme Simoes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|
@@ -58,28 +58,34 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.6.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: 1.6.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: parser
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.2.0.pre.5
|
76
|
+
- - "<"
|
74
77
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
78
|
+
version: '3.0'
|
76
79
|
type: :runtime
|
77
80
|
prerelease: false
|
78
81
|
version_requirements: !ruby/object:Gem::Requirement
|
79
82
|
requirements:
|
80
|
-
- - "
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 2.2.0.pre.5
|
86
|
+
- - "<"
|
81
87
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
88
|
+
version: '3.0'
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: ruby2ruby
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,6 +162,20 @@ dependencies:
|
|
156
162
|
- - "~>"
|
157
163
|
- !ruby/object:Gem::Version
|
158
164
|
version: '1.0'
|
165
|
+
- !ruby/object:Gem::Dependency
|
166
|
+
name: rubocop
|
167
|
+
requirement: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - '='
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: 0.28.0
|
172
|
+
type: :development
|
173
|
+
prerelease: false
|
174
|
+
version_requirements: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - '='
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: 0.28.0
|
159
179
|
description: RubyCritic is a tool that wraps around various static analysis gems to
|
160
180
|
provide a quality report of your Ruby code.
|
161
181
|
email:
|
@@ -166,6 +186,7 @@ extensions: []
|
|
166
186
|
extra_rdoc_files: []
|
167
187
|
files:
|
168
188
|
- ".gitignore"
|
189
|
+
- ".rubocop.yml"
|
169
190
|
- ".travis.yml"
|
170
191
|
- CHANGELOG.md
|
171
192
|
- CONTRIBUTING.md
|
@@ -184,19 +205,23 @@ files:
|
|
184
205
|
- lib/rubycritic/analysers/helpers/flog.rb
|
185
206
|
- lib/rubycritic/analysers/helpers/methods_counter.rb
|
186
207
|
- lib/rubycritic/analysers/helpers/modules_locator.rb
|
208
|
+
- lib/rubycritic/analysers/helpers/parser.rb
|
187
209
|
- lib/rubycritic/analysers/helpers/reek.rb
|
188
210
|
- lib/rubycritic/analysers/smells/flay.rb
|
189
211
|
- lib/rubycritic/analysers/smells/flog.rb
|
190
212
|
- lib/rubycritic/analysers/smells/reek.rb
|
191
213
|
- lib/rubycritic/analysers_runner.rb
|
192
|
-
- lib/rubycritic/cli.rb
|
214
|
+
- lib/rubycritic/cli/application.rb
|
215
|
+
- lib/rubycritic/cli/options.rb
|
216
|
+
- lib/rubycritic/commands/ci.rb
|
217
|
+
- lib/rubycritic/commands/default.rb
|
218
|
+
- lib/rubycritic/commands/help.rb
|
219
|
+
- lib/rubycritic/commands/version.rb
|
193
220
|
- lib/rubycritic/configuration.rb
|
194
221
|
- lib/rubycritic/core/analysed_module.rb
|
195
222
|
- lib/rubycritic/core/location.rb
|
196
223
|
- lib/rubycritic/core/rating.rb
|
197
224
|
- lib/rubycritic/core/smell.rb
|
198
|
-
- lib/rubycritic/modules_initializer.rb
|
199
|
-
- lib/rubycritic/orchestrator.rb
|
200
225
|
- lib/rubycritic/report_generators/assets/javascripts/application.js
|
201
226
|
- lib/rubycritic/report_generators/assets/javascripts/highcharts.src-4.0.1.js
|
202
227
|
- lib/rubycritic/report_generators/assets/javascripts/jquery-2.1.0.js
|
@@ -232,6 +257,7 @@ files:
|
|
232
257
|
- lib/rubycritic/source_control_systems/base.rb
|
233
258
|
- lib/rubycritic/source_control_systems/double.rb
|
234
259
|
- lib/rubycritic/source_control_systems/git.rb
|
260
|
+
- lib/rubycritic/source_control_systems/mercurial.rb
|
235
261
|
- lib/rubycritic/source_locator.rb
|
236
262
|
- lib/rubycritic/version.rb
|
237
263
|
- rubycritic.gemspec
|
@@ -251,7 +277,12 @@ files:
|
|
251
277
|
- test/lib/rubycritic/report_generators/turbulence_test.rb
|
252
278
|
- test/lib/rubycritic/report_generators/view_helpers_test.rb
|
253
279
|
- test/lib/rubycritic/smells_status_setter_test.rb
|
254
|
-
- test/lib/rubycritic/source_control_systems/
|
280
|
+
- test/lib/rubycritic/source_control_systems/base_test.rb
|
281
|
+
- test/lib/rubycritic/source_control_systems/double_test.rb
|
282
|
+
- test/lib/rubycritic/source_control_systems/git_test.rb
|
283
|
+
- test/lib/rubycritic/source_control_systems/interfaces/basic.rb
|
284
|
+
- test/lib/rubycritic/source_control_systems/interfaces/time_travel.rb
|
285
|
+
- test/lib/rubycritic/source_control_systems/mercurial_test.rb
|
255
286
|
- test/lib/rubycritic/source_locator_test.rb
|
256
287
|
- test/lib/rubycritic/version_test.rb
|
257
288
|
- test/samples/empty.rb
|
@@ -309,7 +340,12 @@ test_files:
|
|
309
340
|
- test/lib/rubycritic/report_generators/turbulence_test.rb
|
310
341
|
- test/lib/rubycritic/report_generators/view_helpers_test.rb
|
311
342
|
- test/lib/rubycritic/smells_status_setter_test.rb
|
312
|
-
- test/lib/rubycritic/source_control_systems/
|
343
|
+
- test/lib/rubycritic/source_control_systems/base_test.rb
|
344
|
+
- test/lib/rubycritic/source_control_systems/double_test.rb
|
345
|
+
- test/lib/rubycritic/source_control_systems/git_test.rb
|
346
|
+
- test/lib/rubycritic/source_control_systems/interfaces/basic.rb
|
347
|
+
- test/lib/rubycritic/source_control_systems/interfaces/time_travel.rb
|
348
|
+
- test/lib/rubycritic/source_control_systems/mercurial_test.rb
|
313
349
|
- test/lib/rubycritic/source_locator_test.rb
|
314
350
|
- test/lib/rubycritic/version_test.rb
|
315
351
|
- test/samples/empty.rb
|
data/lib/rubycritic/cli.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require "optparse"
|
2
|
-
require "rubycritic"
|
3
|
-
require "rubycritic/reporters/main"
|
4
|
-
|
5
|
-
module Rubycritic
|
6
|
-
|
7
|
-
class Cli
|
8
|
-
STATUS_SUCCESS = 0
|
9
|
-
|
10
|
-
def initialize(argv)
|
11
|
-
@argv = argv
|
12
|
-
@argv << "." if @argv.empty?
|
13
|
-
@main_command = true
|
14
|
-
end
|
15
|
-
|
16
|
-
def execute
|
17
|
-
OptionParser.new do |opts|
|
18
|
-
opts.banner = "Usage: rubycritic [options] [paths]"
|
19
|
-
|
20
|
-
opts.on("-p", "--path [PATH]", "Set path where report will be saved (tmp/rubycritic by default)") do |path|
|
21
|
-
::Rubycritic.configuration.root = path
|
22
|
-
end
|
23
|
-
|
24
|
-
opts.on_tail("-v", "--version", "Show gem's version") do
|
25
|
-
require "rubycritic/version"
|
26
|
-
puts "RubyCritic #{VERSION}"
|
27
|
-
@main_command = false
|
28
|
-
end
|
29
|
-
|
30
|
-
opts.on_tail("-h", "--help", "Show this message") do
|
31
|
-
puts opts
|
32
|
-
@main_command = false
|
33
|
-
end
|
34
|
-
end.parse!(@argv)
|
35
|
-
|
36
|
-
if @main_command
|
37
|
-
analysed_modules = Orchestrator.new.critique(@argv)
|
38
|
-
report_location = Reporter::Main.new(analysed_modules).generate_report
|
39
|
-
puts "New critique at #{report_location}"
|
40
|
-
end
|
41
|
-
|
42
|
-
STATUS_SUCCESS
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|