Skip to content

Commit caceb78

Browse files
committed
Returning number of imports in dependencies list
1 parent f746ad0 commit caceb78

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

swift_code_metrics/_metrics.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from functional import seq
33
from warnings import warn
44

5+
56
class Metrics:
67

78
@staticmethod
@@ -102,7 +103,7 @@ def total_dependencies(framework):
102103
:return: The list of imported frameworks description
103104
"""
104105
return seq(framework.imports.items()) \
105-
.map(lambda f: f[0].compact_description) \
106+
.map(lambda f: f'{f[0].name}({str(f[1])})') \
106107
.list()
107108

108109
@staticmethod
@@ -241,10 +242,6 @@ def compact_name(self) -> str:
241242
def compact_name_description(self) -> str:
242243
return f'{self.compact_name} = {self.name}'
243244

244-
@property
245-
def compact_description(self) -> str:
246-
return f'{self.name}({str(self.number_of_files)})'
247-
248245

249246
class Dependency:
250247
def __init__(self, name: str, dependent_framework: str, number_of_imports: int = 0):

swift_code_metrics/tests/test_metrics.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ def test_compact_name_nocapitals(self):
2929
def test_compact_name_description(self):
3030
self.assertEqual(self.framework.compact_name_description, 'AN = AwesomeName')
3131

32-
def test_compact_description(self):
33-
self.assertEqual(self.framework.compact_description, 'AwesomeName(0)')
34-
3532
def test_imports(self):
3633
expected_imports = {self.frameworks[0]: 1,
3734
self.frameworks[2]: 1}
@@ -109,7 +106,7 @@ def test_total_dependencies(self):
109106
self.foundation_kit.append_import(sf)
110107
self.foundation_kit.append_import(self.design_kit)
111108

112-
expected_deps = ['RxSwift(0)', 'AwesomeDependency(0)', 'DesignKit(0)']
109+
expected_deps = ['RxSwift(1)', 'AwesomeDependency(1)', 'DesignKit(1)']
113110

114111
self.assertEqual(expected_deps,
115112
Metrics.total_dependencies(self.foundation_kit))

swift_code_metrics/tests/test_resources/expected_output.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"noi": 1,
1313
"analysis": "The code is under commented. Zone of Pain. Highly stable and concrete component - rigid, hard to extend (not abstract). This component should not be volatile (e.g. a stable foundation library such as Strings).",
1414
"dependencies": [
15-
"FoundationFramework(2)"
15+
"FoundationFramework(1)"
1616
],
1717
"fan_in": 1,
1818
"fan_out": 1,

0 commit comments

Comments
 (0)