rubycritic 1.2.1 → 1.3.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/CHANGELOG.md +7 -1
- data/README.md +2 -1
- data/lib/rubycritic.rb +3 -3
- data/lib/rubycritic/cli/options.rb +6 -0
- data/lib/rubycritic/commands/ci.rb +7 -8
- data/lib/rubycritic/commands/default.rb +8 -9
- data/lib/rubycritic/commands/help.rb +3 -3
- data/lib/rubycritic/configuration.rb +2 -1
- data/lib/rubycritic/source_locator.rb +19 -2
- data/lib/rubycritic/version.rb +1 -1
- data/rubycritic.gemspec +1 -2
- data/test/lib/rubycritic/source_locator_test.rb +10 -1
- data/test/samples/location/file0_symlink.rb +0 -0
- data/test/samples/reek/not_smelly.rb +1 -1
- metadata +6 -25
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 88e1add4a91ef2551d93ccec55b2991033b7c2f0
|
|
4
|
+
data.tar.gz: 4d2b5928a03eff96fc1e5b97529e73e9538affa7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5bd3e6a0658fbdc874d740a3efc1b1b2649d69224218017bef6071447653ab18796b0a86ceddf5fb3199b4904f00655bac7ec70ec4ab6c43b52681896a48c072
|
|
7
|
+
data.tar.gz: 449e90f3900e888dd4995135ca4d96a4da595b0d40a7e860d432d20eb358b1354c2ada9fce1a22a4b0a291247489a07d5eda42c75bf1acab2ea2e2238d434d06
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
# 1.3.0 2015-02-16
|
|
2
|
+
|
|
3
|
+
* [FEATURE] New CLI option `--deduplicate-symlinks` to deduplicate symlinks (by LeeXGreen)
|
|
4
|
+
* [CHANGE] Update to Reek 1.6.5 (from 1.6.3)
|
|
5
|
+
* [CHANGE] Remove ruby2ruby dependency
|
|
6
|
+
|
|
1
7
|
# 1.2.1 / 2015-01-17
|
|
2
8
|
|
|
3
9
|
* [FEATURE] Support Ruby 2.2
|
|
@@ -8,7 +14,7 @@
|
|
|
8
14
|
|
|
9
15
|
* [FEATURE] Add CI mode that only analyses the last commit
|
|
10
16
|
* [FEATURE] Add partial support for Mercurial
|
|
11
|
-
* [FEATURE] Allow using
|
|
17
|
+
* [FEATURE] Allow using RubyCritic programatically
|
|
12
18
|
* [CHANGE] Update to Reek 1.6.0 (from 1.3.8)
|
|
13
19
|
|
|
14
20
|
# 1.1.1 / 2014-07-29
|
data/README.md
CHANGED
|
@@ -3,7 +3,7 @@ RubyCritic
|
|
|
3
3
|
|
|
4
4
|
[](http://badge.fury.io/rb/rubycritic)
|
|
5
5
|
[](https://travis-ci.org/whitesmith/rubycritic)
|
|
6
|
-
[](https://codeclimate.com/github/whitesmith/rubycritic)
|
|
7
7
|
|
|
8
8
|
<img src="http://i.imgur.com/66HACCD.png" alt="RubyCritic Icon" align="right" />
|
|
9
9
|
RubyCritic is a gem that wraps around static analysis gems such as [Reek][1], [Flay][2] and [Flog][3] to provide a quality report of your Ruby code.
|
|
@@ -91,6 +91,7 @@ $ rubycritic --help
|
|
|
91
91
|
| `-v/--version` | Displays the current version and exits |
|
|
92
92
|
| `-p/--path` | Sets the output directory (tmp/rubycritic by default) |
|
|
93
93
|
| `-m/--mode-ci` | Uses CI mode (faster, but only analyses last commit) |
|
|
94
|
+
| `--deduplicate-symlinks` | De-duplicate symlinks based on their final target |
|
|
94
95
|
|
|
95
96
|
Alternative Usage Methods
|
|
96
97
|
-------------------------
|
data/lib/rubycritic.rb
CHANGED
|
@@ -10,13 +10,13 @@ module Rubycritic
|
|
|
10
10
|
Command::Version.new
|
|
11
11
|
when :help
|
|
12
12
|
require "rubycritic/commands/help"
|
|
13
|
-
Command::Help.new(options)
|
|
13
|
+
Command::Help.new(options.help_text)
|
|
14
14
|
when :ci
|
|
15
15
|
require "rubycritic/commands/ci"
|
|
16
|
-
Command::Ci.new(options_hash)
|
|
16
|
+
Command::Ci.new(options_hash[:paths])
|
|
17
17
|
else
|
|
18
18
|
require "rubycritic/commands/default"
|
|
19
|
-
Command::Default.new(options_hash)
|
|
19
|
+
Command::Default.new(options_hash[:paths])
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
end
|
|
@@ -8,6 +8,7 @@ module Rubycritic
|
|
|
8
8
|
@parser = OptionParser.new
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
+
# rubocop:disable Metrics/MethodLength
|
|
11
12
|
def parse
|
|
12
13
|
@parser.new do |opts|
|
|
13
14
|
opts.banner = "Usage: rubycritic [options] [paths]"
|
|
@@ -20,6 +21,10 @@ module Rubycritic
|
|
|
20
21
|
@mode = :ci
|
|
21
22
|
end
|
|
22
23
|
|
|
24
|
+
opts.on("--deduplicate-symlinks", "De-duplicate symlinks based on their final target") do
|
|
25
|
+
@deduplicate_symlinks = true
|
|
26
|
+
end
|
|
27
|
+
|
|
23
28
|
opts.on_tail("-v", "--version", "Show gem's version") do
|
|
24
29
|
@mode = :version
|
|
25
30
|
end
|
|
@@ -39,6 +44,7 @@ module Rubycritic
|
|
|
39
44
|
{
|
|
40
45
|
:mode => @mode,
|
|
41
46
|
:root => @root,
|
|
47
|
+
:deduplicate_symlinks => @deduplicate_symlinks,
|
|
42
48
|
:paths => paths
|
|
43
49
|
}
|
|
44
50
|
end
|
|
@@ -5,22 +5,21 @@ require "rubycritic/reporters/main"
|
|
|
5
5
|
module Rubycritic
|
|
6
6
|
module Command
|
|
7
7
|
class Ci
|
|
8
|
-
def initialize(
|
|
9
|
-
@paths =
|
|
8
|
+
def initialize(paths)
|
|
9
|
+
@paths = paths
|
|
10
10
|
Config.source_control_system = SourceControlSystem::Base.create
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def execute
|
|
14
|
-
critique
|
|
15
|
-
report
|
|
14
|
+
report(critique)
|
|
16
15
|
end
|
|
17
16
|
|
|
18
|
-
def critique
|
|
19
|
-
|
|
17
|
+
def critique
|
|
18
|
+
AnalysersRunner.new(@paths).run
|
|
20
19
|
end
|
|
21
20
|
|
|
22
|
-
def report
|
|
23
|
-
report_location = Reporter::Main.new(
|
|
21
|
+
def report(analysed_modules)
|
|
22
|
+
report_location = Reporter::Main.new(analysed_modules).generate_report
|
|
24
23
|
puts "New critique at #{report_location}"
|
|
25
24
|
end
|
|
26
25
|
end
|
|
@@ -6,23 +6,22 @@ require "rubycritic/reporters/main"
|
|
|
6
6
|
module Rubycritic
|
|
7
7
|
module Command
|
|
8
8
|
class Default
|
|
9
|
-
def initialize(
|
|
10
|
-
@paths =
|
|
9
|
+
def initialize(paths)
|
|
10
|
+
@paths = paths
|
|
11
11
|
Config.source_control_system = SourceControlSystem::Base.create
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def execute
|
|
15
|
-
critique
|
|
16
|
-
report
|
|
15
|
+
report(critique)
|
|
17
16
|
end
|
|
18
17
|
|
|
19
|
-
def critique
|
|
20
|
-
|
|
21
|
-
RevisionComparator.new(paths).set_statuses(
|
|
18
|
+
def critique
|
|
19
|
+
analysed_modules = AnalysersRunner.new(@paths).run
|
|
20
|
+
RevisionComparator.new(@paths).set_statuses(analysed_modules)
|
|
22
21
|
end
|
|
23
22
|
|
|
24
|
-
def report
|
|
25
|
-
report_location = Reporter::Main.new(
|
|
23
|
+
def report(analysed_modules)
|
|
24
|
+
report_location = Reporter::Main.new(analysed_modules).generate_report
|
|
26
25
|
puts "New critique at #{report_location}"
|
|
27
26
|
end
|
|
28
27
|
end
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
module Rubycritic
|
|
2
2
|
class Configuration
|
|
3
3
|
attr_reader :root
|
|
4
|
-
attr_accessor :source_control_system, :mode
|
|
4
|
+
attr_accessor :source_control_system, :mode, :deduplicate_symlinks
|
|
5
5
|
|
|
6
6
|
def set(options)
|
|
7
7
|
self.mode = options[:mode] || :default
|
|
8
8
|
self.root = options[:root] || "tmp/rubycritic"
|
|
9
|
+
self.deduplicate_symlinks = options[:deduplicate_symlinks] || false
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
def root=(path)
|
|
@@ -20,14 +20,31 @@ module Rubycritic
|
|
|
20
20
|
|
|
21
21
|
private
|
|
22
22
|
|
|
23
|
+
def deduplicate_symlinks(path_list)
|
|
24
|
+
# sort the symlinks to the end so files are preferred
|
|
25
|
+
path_list.sort_by! { |path| File.symlink?(path.cleanpath) ? "z" : "a" }
|
|
26
|
+
if defined?(JRUBY_VERSION)
|
|
27
|
+
require "java"
|
|
28
|
+
path_list.uniq! do |path|
|
|
29
|
+
java.io.File.new(path.realpath.to_s).canonical_path
|
|
30
|
+
end
|
|
31
|
+
else
|
|
32
|
+
path_list.uniq!(&:realpath)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
23
36
|
def expand_paths
|
|
24
|
-
@initial_paths.flat_map do |path|
|
|
37
|
+
path_list = @initial_paths.flat_map do |path|
|
|
25
38
|
if File.directory?(path)
|
|
26
39
|
Pathname.glob(File.join(path, RUBY_FILES))
|
|
27
40
|
elsif File.exist?(path) && File.extname(path) == RUBY_EXTENSION
|
|
28
41
|
Pathname.new(path)
|
|
29
42
|
end
|
|
30
|
-
end.compact
|
|
43
|
+
end.compact
|
|
44
|
+
|
|
45
|
+
deduplicate_symlinks(path_list) if Config.deduplicate_symlinks
|
|
46
|
+
|
|
47
|
+
path_list.map(&:cleanpath)
|
|
31
48
|
end
|
|
32
49
|
end
|
|
33
50
|
end
|
data/lib/rubycritic/version.rb
CHANGED
data/rubycritic.gemspec
CHANGED
|
@@ -23,9 +23,8 @@ Gem::Specification.new do |spec|
|
|
|
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.6.
|
|
26
|
+
spec.add_runtime_dependency "reek", "1.6.5"
|
|
27
27
|
spec.add_runtime_dependency "parser", ">= 2.2.0", "< 3.0"
|
|
28
|
-
spec.add_runtime_dependency "ruby2ruby", ">= 2.1.1", "< 3.0"
|
|
29
28
|
|
|
30
29
|
spec.add_development_dependency "bundler", "~> 1.3"
|
|
31
30
|
spec.add_development_dependency "rake"
|
|
@@ -26,10 +26,19 @@ describe Rubycritic::SourceLocator do
|
|
|
26
26
|
|
|
27
27
|
it "finds all the files" do
|
|
28
28
|
initial_paths = ["."]
|
|
29
|
-
final_paths = ["dir1/file1.rb", "file0.rb"]
|
|
29
|
+
final_paths = ["dir1/file1.rb", "file0.rb", "file0_symlink.rb"]
|
|
30
30
|
Rubycritic::SourceLocator.new(initial_paths).paths.must_match_array final_paths
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
+
context "when configured to deduplicate symlinks" do
|
|
34
|
+
it "it favors a file over a symlink if they both point to the same target" do
|
|
35
|
+
Rubycritic::Config.stubs(:deduplicate_symlinks).returns(true)
|
|
36
|
+
initial_paths = ["file0.rb", "file0_symlink.rb"]
|
|
37
|
+
final_paths = ["file0.rb"]
|
|
38
|
+
Rubycritic::SourceLocator.new(initial_paths).paths.must_match_array final_paths
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
33
42
|
it "cleans paths of consecutive slashes and useless dots" do
|
|
34
43
|
initial_paths = [".//file0.rb"]
|
|
35
44
|
final_paths = ["file0.rb"]
|
|
File without changes
|
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.3.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: 2015-
|
|
11
|
+
date: 2015-02-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: virtus
|
|
@@ -58,14 +58,14 @@ dependencies:
|
|
|
58
58
|
requirements:
|
|
59
59
|
- - '='
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 1.6.
|
|
61
|
+
version: 1.6.5
|
|
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.6.
|
|
68
|
+
version: 1.6.5
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: parser
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -86,26 +86,6 @@ dependencies:
|
|
|
86
86
|
- - "<"
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
88
|
version: '3.0'
|
|
89
|
-
- !ruby/object:Gem::Dependency
|
|
90
|
-
name: ruby2ruby
|
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
|
92
|
-
requirements:
|
|
93
|
-
- - ">="
|
|
94
|
-
- !ruby/object:Gem::Version
|
|
95
|
-
version: 2.1.1
|
|
96
|
-
- - "<"
|
|
97
|
-
- !ruby/object:Gem::Version
|
|
98
|
-
version: '3.0'
|
|
99
|
-
type: :runtime
|
|
100
|
-
prerelease: false
|
|
101
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
102
|
-
requirements:
|
|
103
|
-
- - ">="
|
|
104
|
-
- !ruby/object:Gem::Version
|
|
105
|
-
version: 2.1.1
|
|
106
|
-
- - "<"
|
|
107
|
-
- !ruby/object:Gem::Version
|
|
108
|
-
version: '3.0'
|
|
109
89
|
- !ruby/object:Gem::Dependency
|
|
110
90
|
name: bundler
|
|
111
91
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -291,6 +271,7 @@ files:
|
|
|
291
271
|
- test/samples/flog/smelly.rb
|
|
292
272
|
- test/samples/location/dir1/file1.rb
|
|
293
273
|
- test/samples/location/file0.rb
|
|
274
|
+
- test/samples/location/file0_symlink.rb
|
|
294
275
|
- test/samples/location/file_with_different_extension.py
|
|
295
276
|
- test/samples/location/file_with_no_extension
|
|
296
277
|
- test/samples/methods_count.rb
|
|
@@ -354,6 +335,7 @@ test_files:
|
|
|
354
335
|
- test/samples/flog/smelly.rb
|
|
355
336
|
- test/samples/location/dir1/file1.rb
|
|
356
337
|
- test/samples/location/file0.rb
|
|
338
|
+
- test/samples/location/file0_symlink.rb
|
|
357
339
|
- test/samples/location/file_with_different_extension.py
|
|
358
340
|
- test/samples/location/file_with_no_extension
|
|
359
341
|
- test/samples/methods_count.rb
|
|
@@ -362,4 +344,3 @@ test_files:
|
|
|
362
344
|
- test/samples/reek/smelly.rb
|
|
363
345
|
- test/samples/unparsable.rb
|
|
364
346
|
- test/test_helper.rb
|
|
365
|
-
has_rdoc:
|