depcheck 0.2.0 → 0.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/Gemfile.lock +1 -1
- data/README.md +9 -3
- data/bin/depcheck +2 -0
- data/example/Example.xcodeproj/project.pbxproj +4 -0
- data/example/Example/ViewController.swift +1 -1
- data/example/graph.png +0 -0
- data/lib/depcheck.rb +1 -0
- data/lib/depcheck/analyzer.rb +12 -7
- data/lib/depcheck/command/analyze_command.rb +2 -1
- data/lib/depcheck/command/graph_command.rb +19 -0
- data/lib/depcheck/command/usage_command.rb +2 -1
- data/lib/depcheck/output/graph_output.rb +54 -0
- data/lib/depcheck/output/simple_output.rb +1 -1
- data/lib/depcheck/version.rb +1 -1
- data/spec/analyzer_spec.rb +54 -0
- data/spec/finder_spec.rb +36 -0
- data/spec/fixtures/Model1.swiftdeps +39 -0
- data/spec/fixtures/Model4.swiftdeps +33 -0
- data/spec/simple_output_spec.rb +36 -0
- data/spec/spec_helper.rb +15 -0
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6863c929258f574dcb55d2cf52c2a20ced2d5df0
|
4
|
+
data.tar.gz: c995b0f2409be6b1b1c4e8377bb9430f4c29625e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c07d8d12f4e96f1cf579685fc2af5c24b675ddc20424aceb103f6a6945e69c0f666bd7ba85689ff97b74a9589ff2dcaea96b078f620cbfc1ed850a18661dda85
|
7
|
+
data.tar.gz: 2a4e6d5a2c27a5e7d8666d0fd9f1f83890bb760aa2a4e7a8036e3228b1d771e596c5e880b409e13dc4eee873eaf74c2c49443833f74070f22b38ecf7d993929f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# Depcheck
|
2
2
|
|
3
|
-
`Depcheck` is a dependency analyzer tool for Swift projects. `Depcheck` reports dependencies per class, allowing you to easily detect classes that have too many dependencies. `Depcheck` can also report how many dependants a class have. Therefore you can spot the most used and unused classes.
|
3
|
+
`Depcheck` is a dependency analyzer tool for Swift projects. `Depcheck` reports dependencies per class, allowing you to easily detect classes that have too many dependencies. `Depcheck` can also report how many dependants a class have. Therefore you can spot the most used and unused classes. Additionaly you can generate *dependency graph* of your project.
|
4
4
|
|
5
|
-
<img src="https://github.com/wojteklu/depcheck/blob/master/example/analyze.png?raw=true">
|
5
|
+
<img src="https://github.com/wojteklu/depcheck/blob/master/example/analyze.png?raw=true" width="600px">
|
6
|
+
|
7
|
+
<img src="https://github.com/wojteklu/depcheck/blob/master/example/graph.png?raw=true" height="360px">
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
@@ -26,7 +28,7 @@ gem install depcheck
|
|
26
28
|
|
27
29
|
## Usage
|
28
30
|
|
29
|
-
`Analyze` command reports dependencies per classes. `Usage` command reports how many dependants a class have.
|
31
|
+
`Analyze` command reports dependencies per classes. `Usage` command reports how many dependants a class have. `Graph` command generates dependency graph.
|
30
32
|
|
31
33
|
Build your project, and then run:
|
32
34
|
|
@@ -45,6 +47,10 @@ $ depcheck analyze --workspace path/to/workspace.xcworkspace --scheme YourXcodeS
|
|
45
47
|
|
46
48
|
I’d love to see your ideas for improving this library! The best way to contribute is by submitting a pull request. I’ll do my best to respond to your patch as soon as possible. You can also submit a [new GitHub issue](https://github.com/wojteklu/depcheck/issues/new) if you find bugs or have questions.
|
47
49
|
|
50
|
+
## Author
|
51
|
+
|
52
|
+
Wojtek Lukaszuk [@wojteklu](http://twitter.com/wojteklu)
|
53
|
+
|
48
54
|
## License
|
49
55
|
|
50
56
|
This project is licensed under the terms of the MIT license. See the LICENSE file.
|
data/bin/depcheck
CHANGED
@@ -4,12 +4,14 @@ require 'yaml'
|
|
4
4
|
require_relative '../lib/depcheck'
|
5
5
|
require_relative '../lib/depcheck/command/analyze_command'
|
6
6
|
require_relative '../lib/depcheck/command/usage_command'
|
7
|
+
require_relative '../lib/depcheck/command/graph_command'
|
7
8
|
require_relative '../lib/depcheck/command/version_command'
|
8
9
|
|
9
10
|
class MainCommand < Clamp::Command
|
10
11
|
|
11
12
|
subcommand 'analyze', 'Reports dependencies per class', AnalyzeCommand
|
12
13
|
subcommand 'usage', 'Reports how many dependants a class have', UsageCommand
|
14
|
+
subcommand 'graph', 'Generates dependency graph', GraphCommand
|
13
15
|
subcommand 'version', 'Prints depcheck version', VersionCommand
|
14
16
|
end
|
15
17
|
|
@@ -119,6 +119,7 @@
|
|
119
119
|
TargetAttributes = {
|
120
120
|
2E845E151D638EFE0040B44C = {
|
121
121
|
CreatedOnToolsVersion = 7.3.1;
|
122
|
+
LastSwiftMigration = 0800;
|
122
123
|
};
|
123
124
|
};
|
124
125
|
};
|
@@ -283,6 +284,7 @@
|
|
283
284
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
284
285
|
PRODUCT_BUNDLE_IDENTIFIER = com.depcheck.Example;
|
285
286
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
287
|
+
SWIFT_VERSION = 3.0;
|
286
288
|
};
|
287
289
|
name = Debug;
|
288
290
|
};
|
@@ -294,6 +296,7 @@
|
|
294
296
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
295
297
|
PRODUCT_BUNDLE_IDENTIFIER = com.depcheck.Example;
|
296
298
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
299
|
+
SWIFT_VERSION = 3.0;
|
297
300
|
};
|
298
301
|
name = Release;
|
299
302
|
};
|
@@ -316,6 +319,7 @@
|
|
316
319
|
2E845E2A1D638EFE0040B44C /* Release */,
|
317
320
|
);
|
318
321
|
defaultConfigurationIsVisible = 0;
|
322
|
+
defaultConfigurationName = Release;
|
319
323
|
};
|
320
324
|
/* End XCConfigurationList section */
|
321
325
|
};
|
data/example/graph.png
ADDED
Binary file
|
data/lib/depcheck.rb
CHANGED
data/lib/depcheck/analyzer.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
|
3
3
|
module Depcheck
|
4
|
-
|
4
|
+
class Analyzer
|
5
5
|
|
6
|
-
def
|
6
|
+
def generate_dependencies(swiftdeps)
|
7
7
|
results = []
|
8
8
|
usage = {}
|
9
9
|
|
@@ -45,15 +45,20 @@ module Depcheck
|
|
45
45
|
results
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
49
|
-
!dep.nil? && !/^(<\s)?\w/.match(dep).nil? && !keyword?(dep) &&
|
48
|
+
def valid_dep?(dep)
|
49
|
+
!dep.nil? && !/^(<\s)?\w/.match(dep).nil? && !keyword?(dep) && !framework?(dep)
|
50
50
|
end
|
51
|
-
|
51
|
+
private :valid_dep?
|
52
52
|
|
53
|
-
def
|
53
|
+
def framework?(dep)
|
54
|
+
/^(CA|CF|CG|CI|CL|kCA|NS|UI)/.match(dep) != nil
|
55
|
+
end
|
56
|
+
private :framework?
|
57
|
+
|
58
|
+
def keyword?(dep)
|
54
59
|
/^(Any|AnyBidirectionalCollection|AnyBidirectionalIndex|AnyClass|AnyForwardCollection|AnyForwardIndex|AnyObject|AnyRandomAccessCollection|AnyRandomAccessIndex|AnySequence|Array|ArraySlice|AutoreleasingUnsafeMutablePointer|BOOL|Bool|BooleanLiteralType|CBool|CChar|CChar16|CChar32|CDouble|CFloat|CInt|CLong|CLongLong|COpaquePointer|CShort|CSignedChar|CUnsignedChar|CUnsignedInt|CUnsignedLong|CUnsignedLongLong|CUnsignedShort|CVaListPointer|CWideChar|Character|ClosedInterval|ClusterType|CollectionOfOne|ContiguousArray|DISPATCH_|Dictionary|DictionaryGenerator|DictionaryIndex|DictionaryLiteral|Double|EmptyGenerator|EnumerateGenerator|EnumerateSequence|ExtendedGraphemeClusterType|FlattenBidirectionalCollection|FlattenBidirectionalCollectionIndex|FlattenCollectionIndex|FlattenSequence|Float|Float32|Float64|FloatLiteralType|GeneratorSequence|HalfOpenInterval|IndexingGenerator|Int|Int16|Int32|Int64|Int8|IntMax|IntegerLiteralType|JoinGenerator|JoinSequence|LazyCollection|LazyFilterCollection|LazyFilterGenerator|LazyFilterIndex|LazyFilterSequence|LazyMapCollection|LazyMapGenerator|LazyMapSequence|LazySequence|LiteralType|ManagedBufferPointer|Mirror|MutableSlice|ObjectIdentifier|Optional|PermutationGenerator|Range|RangeGenerator|RawByte|Repeat|ReverseCollection|ReverseIndex|ReverseRandomAccessCollection|ReverseRandomAccessIndex|ScalarType|Set|SetGenerator|SetIndex|Slice|StaticString|StrideThrough|StrideThroughGenerator|StrideTo|StrideToGenerator|String|String.CharacterView|String.CharacterView.Index|String.UTF16View|String.UTF16View.Index|String.UTF8View|String.UTF8View.Index|String.UnicodeScalarView|String.UnicodeScalarView.Generator|String.UnicodeScalarView.Index|StringLiteralType|UInt|UInt16|UInt32|UInt64|UInt8|UIntMax|UTF16|UTF32|UTF8|UnicodeScalar|UnicodeScalarType|Unmanaged|UnsafeBufferPointer|UnsafeBufferPointerGenerator|UnsafeMutableBufferPointer|UnsafeMutablePointer|UnsafePointer|Void|Zip2Generator|Zip2Sequence|abs|alignof|alignofValue|anyGenerator|anyGenerator|assert|assertionFailure|debugPrint|debugPrint|dispatch_|dump|dump|fatalError|getVaList|isUniquelyReferenced|isUniquelyReferencedNonObjC|isUniquelyReferencedNonObjC|max|max|min|min|numericCast|numericCast|numericCast|numericCast|precondition|preconditionFailure|print|print|readLine|sizeof|sizeofValue|strideof|strideofValue|swap|transcode|unsafeAddressOf|unsafeBitCast|unsafeDowncast|unsafeUnwrap|withExtendedLifetime|withExtendedLifetime|withUnsafeMutablePointer|withUnsafeMutablePointers|withUnsafeMutablePointers|withUnsafePointer|withUnsafePointers|withUnsafePointers|withVaList|withVaList|zip)$/.match(dep) != nil
|
55
60
|
end
|
56
|
-
|
61
|
+
private :keyword?
|
57
62
|
|
58
63
|
end
|
59
64
|
end
|
@@ -11,7 +11,8 @@ class AnalyzeCommand < Clamp::Command
|
|
11
11
|
end
|
12
12
|
|
13
13
|
swiftdeps = Depcheck::Finder.find_swiftdeps(project, workspace, scheme)
|
14
|
-
|
14
|
+
analyzer = Depcheck::Analyzer.new
|
15
|
+
results = analyzer.generate_dependencies(swiftdeps)
|
15
16
|
Depcheck::SimpleOutput.post(results, verbose?)
|
16
17
|
end
|
17
18
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class GraphCommand < Clamp::Command
|
2
|
+
option ['--project'], 'PROJECT', 'Path to the xcodeproj'
|
3
|
+
option ['--scheme'], 'SCHEME', 'The scheme that the project was built in'
|
4
|
+
option ['--workspace'], 'WORKSPACE', 'Path to the workspace'
|
5
|
+
|
6
|
+
def execute
|
7
|
+
|
8
|
+
unless project || (workspace && scheme)
|
9
|
+
raise StandardError, 'Must provide project path or workspace path with scheme.'
|
10
|
+
end
|
11
|
+
|
12
|
+
swiftdeps = Depcheck::Finder.find_swiftdeps(project, workspace, scheme)
|
13
|
+
analyzer = Depcheck::Analyzer.new
|
14
|
+
results = analyzer.generate_dependencies(swiftdeps)
|
15
|
+
output = Depcheck::GraphOutput.new
|
16
|
+
output.post(results)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -10,7 +10,8 @@ class UsageCommand < Clamp::Command
|
|
10
10
|
end
|
11
11
|
|
12
12
|
swiftdeps = Depcheck::Finder.find_swiftdeps(project, workspace, scheme)
|
13
|
-
|
13
|
+
analyzer = Depcheck::Analyzer.new
|
14
|
+
results = analyzer.generate_dependencies(swiftdeps)
|
14
15
|
Depcheck::SimpleOutput.post_usage(results)
|
15
16
|
end
|
16
17
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Depcheck
|
2
|
+
class GraphOutput
|
3
|
+
|
4
|
+
def post(objs)
|
5
|
+
|
6
|
+
# installs graphviz if needed
|
7
|
+
system 'brew install graphviz' unless graphviz_installed?
|
8
|
+
|
9
|
+
# Check that this is in the user's PATH after installing
|
10
|
+
unless graphviz_installed?
|
11
|
+
fail "graphviz is not in the user's PATH, or it failed to install"
|
12
|
+
end
|
13
|
+
|
14
|
+
# generate graph description
|
15
|
+
graph = generate_graph_description(objs)
|
16
|
+
|
17
|
+
# create temporary graph dot file
|
18
|
+
file_name = 'graph'
|
19
|
+
File.open("#{file_name}.dot", 'w') do |f|
|
20
|
+
f.write(graph)
|
21
|
+
end
|
22
|
+
|
23
|
+
# run dot command
|
24
|
+
`dot -T png #{file_name}.dot > #{file_name}.png && open #{file_name}.png`
|
25
|
+
|
26
|
+
# remove temporary file
|
27
|
+
File.delete("#{file_name}.dot")
|
28
|
+
end
|
29
|
+
|
30
|
+
def generate_graph_description(objs)
|
31
|
+
nodes = []
|
32
|
+
objs.each do |obj|
|
33
|
+
obj.dependencies.each do |dep|
|
34
|
+
nodes << { source: obj.name, dep: dep }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
desc = "digraph dependencies {\n node [fontname=monospace, fontsize=9, shape=box, style=rounded]\n"
|
39
|
+
nodes.each do |node|
|
40
|
+
desc += " \"#{node[:source]}\" -> \"#{node[:dep]}\"\n"
|
41
|
+
end
|
42
|
+
desc += "}\n"
|
43
|
+
|
44
|
+
desc
|
45
|
+
end
|
46
|
+
private :generate_graph_description
|
47
|
+
|
48
|
+
def graphviz_installed?
|
49
|
+
`which dot`.strip.empty? == false
|
50
|
+
end
|
51
|
+
private :graphviz_installed?
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
data/lib/depcheck/version.rb
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
module Depcheck
|
4
|
+
|
5
|
+
describe Analyzer do
|
6
|
+
before :all do
|
7
|
+
Analyzer.send(:public, *Analyzer.private_instance_methods)
|
8
|
+
@analyzer = Analyzer.new
|
9
|
+
end
|
10
|
+
|
11
|
+
describe :generate_dependencies do
|
12
|
+
|
13
|
+
it 'generates dependencies for files' do
|
14
|
+
files = ["./spec/fixtures/Model1.swiftdeps", "./spec/fixtures/Model4.swiftdeps"]
|
15
|
+
results = @analyzer.generate_dependencies(files)
|
16
|
+
|
17
|
+
expect(results[0].name).to eq "Model1"
|
18
|
+
expect(results[0].usage).to eq 1
|
19
|
+
expect(results[0].dependencies.count).to eq 2
|
20
|
+
|
21
|
+
expect(results[1].name).to eq "Model4"
|
22
|
+
expect(results[1].usage).to eq 0
|
23
|
+
expect(results[1].dependencies.count).to eq 1
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
describe :valid_dep? do
|
29
|
+
before do
|
30
|
+
allow_any_instance_of(Analyzer).to receive(:keyword?).and_return(false)
|
31
|
+
allow_any_instance_of(Analyzer).to receive(:framework?).and_return(false)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'validates nil values' do
|
35
|
+
expect(@analyzer.valid_dep?(nil)).to eq false
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'validates keywords values' do
|
39
|
+
allow_any_instance_of(Analyzer).to receive(:keyword?).and_return(true)
|
40
|
+
expect(@analyzer.valid_dep?("test")).to eq false
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'validates non-alphanumeric values' do
|
44
|
+
expect(@analyzer.valid_dep?("*")).to eq false
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'validates framework prefixes' do
|
48
|
+
allow_any_instance_of(Analyzer).to receive(:framework?).and_return(true)
|
49
|
+
expect(@analyzer.valid_dep?("test")).to eq false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
data/spec/finder_spec.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
module Depcheck
|
4
|
+
|
5
|
+
describe Finder do
|
6
|
+
|
7
|
+
describe :find_derived_data_path do
|
8
|
+
before do
|
9
|
+
allow(Finder).to receive(:`).and_return(" OBJROOT = D/D\n PROJECT_NAME = P\n TARGET_NAME = T")
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'finds derived data path' do
|
13
|
+
expected = "D/D/P.build/**/T.build"
|
14
|
+
expect(Finder.find_derived_data_path("Test", nil, nil)).to eq expected
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe :find_swiftdeps do
|
19
|
+
before do
|
20
|
+
allow(Finder).to receive(:find_derived_data_path).and_return('')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'finds swiftdeps files' do
|
24
|
+
expected = 2.times.map(&:to_s)
|
25
|
+
allow(Dir).to receive(:glob).and_return(expected)
|
26
|
+
expect(Finder.find_swiftdeps("Test", nil, nil)).to eq expected
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'raises error if files not found' do
|
30
|
+
allow(Dir).to receive(:glob).and_return([])
|
31
|
+
expect{Finder.find_swiftdeps("Test", nil, nil)}.to raise_error(StandardError)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
### Swift dependencies file v0 ###
|
2
|
+
provides-top-level:
|
3
|
+
- "Model1"
|
4
|
+
provides-nominal:
|
5
|
+
- "V7Example6Model1"
|
6
|
+
provides-member:
|
7
|
+
- ["V7Example6Model1", ""]
|
8
|
+
provides-dynamic-lookup:
|
9
|
+
depends-top-level:
|
10
|
+
- "Model3"
|
11
|
+
- "Model1"
|
12
|
+
- "Model2"
|
13
|
+
depends-member:
|
14
|
+
- ["V7Example6Model1", "Model2"]
|
15
|
+
- ["V7Example6Model1", "Model3"]
|
16
|
+
- ["V7Example6Model1", "deinit"]
|
17
|
+
- ["V7Example6Model1", "init"]
|
18
|
+
- ["V7Example6Model1", "model2"]
|
19
|
+
- ["V7Example6Model1", "model3"]
|
20
|
+
- ["V7Example6Model2", "deinit"]
|
21
|
+
- ["V7Example6Model2", "init"]
|
22
|
+
- ["V7Example6Model3", "deinit"]
|
23
|
+
- ["V7Example6Model3", "init"]
|
24
|
+
depends-nominal:
|
25
|
+
- "V7Example6Model1"
|
26
|
+
- "V7Example6Model2"
|
27
|
+
- "V7Example6Model3"
|
28
|
+
depends-dynamic-lookup:
|
29
|
+
depends-external:
|
30
|
+
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule"
|
31
|
+
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule"
|
32
|
+
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule"
|
33
|
+
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule"
|
34
|
+
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule"
|
35
|
+
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule"
|
36
|
+
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule"
|
37
|
+
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule"
|
38
|
+
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule"
|
39
|
+
interface-hash: "b86f30e6f04586ded1dc6782a6a1fe20"
|
@@ -0,0 +1,33 @@
|
|
1
|
+
### Swift dependencies file v0 ###
|
2
|
+
provides-top-level:
|
3
|
+
- "Model4"
|
4
|
+
provides-nominal:
|
5
|
+
- "V7Example6Model4"
|
6
|
+
provides-member:
|
7
|
+
- ["V7Example6Model4", ""]
|
8
|
+
provides-dynamic-lookup:
|
9
|
+
depends-top-level:
|
10
|
+
- "Model1"
|
11
|
+
- "Model4"
|
12
|
+
depends-member:
|
13
|
+
- ["V7Example6Model1", "deinit"]
|
14
|
+
- ["V7Example6Model1", "init"]
|
15
|
+
- ["V7Example6Model4", "Model1"]
|
16
|
+
- ["V7Example6Model4", "deinit"]
|
17
|
+
- ["V7Example6Model4", "init"]
|
18
|
+
- ["V7Example6Model4", "model1"]
|
19
|
+
depends-nominal:
|
20
|
+
- "V7Example6Model1"
|
21
|
+
- "V7Example6Model4"
|
22
|
+
depends-dynamic-lookup:
|
23
|
+
depends-external:
|
24
|
+
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule"
|
25
|
+
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule"
|
26
|
+
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule"
|
27
|
+
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule"
|
28
|
+
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule"
|
29
|
+
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule"
|
30
|
+
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule"
|
31
|
+
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule"
|
32
|
+
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule"
|
33
|
+
interface-hash: "2d408e7605c6767ff621c9e3e9ba913e"
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
module Depcheck
|
4
|
+
|
5
|
+
describe SimpleOutput do
|
6
|
+
before :all do
|
7
|
+
@dependencies = 3.times.map do |i|
|
8
|
+
dep = DependencyInfo.new("A#{i}", "B#{i}", i.times.map(&:to_s))
|
9
|
+
dep.usage = 3-i
|
10
|
+
dep
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe :post do
|
15
|
+
|
16
|
+
it 'outputs results sorted by dependencies count' do
|
17
|
+
expected = "1. A2 - 2\n2. A1 - 1\n3. A0 - 0\n"
|
18
|
+
expect { Depcheck::SimpleOutput.post(@dependencies, false)}.to output(expected).to_stdout
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'outputs results with dependencies list' do
|
22
|
+
expected = "1. A2 - 2 - [0, 1]\n2. A1 - 1 - [0]\n3. A0 - 0 - []\n"
|
23
|
+
expect { Depcheck::SimpleOutput.post(@dependencies, true)}.to output(expected).to_stdout
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe :post_usage do
|
28
|
+
|
29
|
+
it 'outputs results sorted by usage count' do
|
30
|
+
expected = "1. A0 - 3\n2. A1 - 2\n3. A2 - 1\n"
|
31
|
+
expect { Depcheck::SimpleOutput.post_usage(@dependencies)}.to output(expected).to_stdout
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
3
|
+
$LOAD_PATH.unshift((ROOT + 'lib').to_s)
|
4
|
+
$LOAD_PATH.unshift((ROOT + 'spec').to_s)
|
5
|
+
|
6
|
+
require 'bundler/setup'
|
7
|
+
require 'rspec'
|
8
|
+
require 'depcheck'
|
9
|
+
|
10
|
+
# Use coloured output, it's the best.
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.filter_gems_from_backtrace 'bundler'
|
13
|
+
config.color = true
|
14
|
+
config.tty = true
|
15
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: depcheck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wojciech Lukaszuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08
|
11
|
+
date: 2016-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -99,16 +99,25 @@ files:
|
|
99
99
|
- example/Example/Models/Model5.swift
|
100
100
|
- example/Example/ViewController.swift
|
101
101
|
- example/analyze.png
|
102
|
+
- example/graph.png
|
102
103
|
- example/usage.png
|
103
104
|
- lib/depcheck.rb
|
104
105
|
- lib/depcheck/analyzer.rb
|
105
106
|
- lib/depcheck/command/analyze_command.rb
|
107
|
+
- lib/depcheck/command/graph_command.rb
|
106
108
|
- lib/depcheck/command/usage_command.rb
|
107
109
|
- lib/depcheck/command/version_command.rb
|
108
110
|
- lib/depcheck/dependency_info.rb
|
109
111
|
- lib/depcheck/finder.rb
|
112
|
+
- lib/depcheck/output/graph_output.rb
|
110
113
|
- lib/depcheck/output/simple_output.rb
|
111
114
|
- lib/depcheck/version.rb
|
115
|
+
- spec/analyzer_spec.rb
|
116
|
+
- spec/finder_spec.rb
|
117
|
+
- spec/fixtures/Model1.swiftdeps
|
118
|
+
- spec/fixtures/Model4.swiftdeps
|
119
|
+
- spec/simple_output_spec.rb
|
120
|
+
- spec/spec_helper.rb
|
112
121
|
homepage: https://github.com/wojteklu/depcheck
|
113
122
|
licenses:
|
114
123
|
- MIT
|
@@ -133,4 +142,10 @@ rubygems_version: 2.6.6
|
|
133
142
|
signing_key:
|
134
143
|
specification_version: 4
|
135
144
|
summary: Dependency analyzer tool for Swift projects
|
136
|
-
test_files:
|
145
|
+
test_files:
|
146
|
+
- spec/analyzer_spec.rb
|
147
|
+
- spec/finder_spec.rb
|
148
|
+
- spec/fixtures/Model1.swiftdeps
|
149
|
+
- spec/fixtures/Model4.swiftdeps
|
150
|
+
- spec/simple_output_spec.rb
|
151
|
+
- spec/spec_helper.rb
|