Skip to content

Commit 585b3ea

Browse files
authored
Merge pull request #28 from matsoftware/updated-guide
Added reference to submodules
2 parents 7a33cc2 + 9947d5d commit 585b3ea

File tree

3 files changed

+108
-20
lines changed

3 files changed

+108
-20
lines changed

docs/GUIDE.md

Lines changed: 107 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@
22

33
A sample project is provided in the `resources` folder:
44

5-
`python3 swift-code-metrics-runner.py --source swift_code_metrics/tests/test_resources/ExampleProject/SwiftCodeMetricsExample --artifacts report --generate-graphs`
5+
```bash
6+
python3 swift-code-metrics-runner.py --source swift_code_metrics/tests/test_resources/ExampleProject/SwiftCodeMetricsExample --artifacts report --generate-graphs
7+
```
68

7-
### Source
9+
## Source
810

911
The library will start scanning the content under the `source` folder provided. Frameworks will be identified by their
1012
relative path to the root folder specified, meaning that the file system hierarchy will define the naming convention
1113
(e.g. if a class is under the path `SwiftCodeMetricsExample/BusinessLogic/Logic.swift`, the framework name will be identified
1214
as `BusinessLogic` since `SwiftCodeMetricsExample` is the root of the `source` parameter in the command above).
1315

14-
#### Project paths override
16+
### Submodules
17+
18+
A Submodule is a folder inside a framework and the library will perform an analysis of the synthetic metrics data for each submodule recursively.
19+
Please make sure that your project folder structure is consistent with your logical groups on Xcode to improve the quality of the analysis
20+
(you can use [synx](https://github.com/venmo/synx) to reconcile groups and local folders).
21+
22+
### Project paths override
1523

1624
Sometimes the folder structure is not enough to provide a description of the libraries involved, for instance when multiple frameworks are
1725
defined inside the same folder and they are reusing shared code. For these scenarios, it's possible to define a `scm.json`
@@ -59,34 +67,113 @@ The `libraries` array defines the list of frameworks with their relative path.
5967
The code in the `Shared` folder will contribute to the metrics of every single framework defined in the `libraries`
6068
array but it will be counted only once for the total aggregate data.
6169

62-
### Output format
70+
## Output format
6371

6472
The `output.json` file will contain the metrics related to all frameworks
6573
and an _aggregate_ result for the project.
6674

6775
The example below is an excerpt from the example available [here](../swift_code_metrics/tests/test_resources/expected_output.json).
6876

77+
<details>
78+
<summary>Output.json example</summary>
79+
6980
```json
7081
{
7182
"non-test-frameworks": [
7283
{
73-
"BusinessLogic": {
74-
"loc": 49,
75-
"noc": 7,
76-
"poc": 12.5,
77-
"n_a": 0,
78-
"n_c": 3,
84+
"FoundationFramework": {
85+
"loc": 27,
86+
"noc": 21,
87+
"poc": 43.75,
88+
"n_a": 1,
89+
"n_c": 2,
7990
"nom": 3,
8091
"not": 0,
81-
"noi": 1,
82-
"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).",
83-
"dependencies": [
84-
"FoundationFramework(1)"
85-
],
92+
"noi": 0,
93+
"analysis": "The code is over 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).",
94+
"dependencies": [],
95+
"submodules": {
96+
"FoundationFramework": {
97+
"n_of_files": 3,
98+
"metric": {
99+
"loc": 27,
100+
"noc": 21,
101+
"n_a": 1,
102+
"n_c": 2,
103+
"nom": 3,
104+
"not": 0,
105+
"poc": 43.75
106+
},
107+
"submodules": [
108+
{
109+
"Foundation": {
110+
"n_of_files": 3,
111+
"metric": {
112+
"loc": 27,
113+
"noc": 21,
114+
"n_a": 1,
115+
"n_c": 2,
116+
"nom": 3,
117+
"not": 0,
118+
"poc": 43.75
119+
},
120+
"submodules": [
121+
{
122+
"FoundationFramework": {
123+
"n_of_files": 2,
124+
"metric": {
125+
"loc": 23,
126+
"noc": 14,
127+
"n_a": 1,
128+
"n_c": 1,
129+
"nom": 2,
130+
"not": 0,
131+
"poc": 37.838
132+
},
133+
"submodules": [
134+
{
135+
"Interfaces": {
136+
"n_of_files": 1,
137+
"metric": {
138+
"loc": 12,
139+
"noc": 7,
140+
"n_a": 1,
141+
"n_c": 0,
142+
"nom": 1,
143+
"not": 0,
144+
"poc": 36.842
145+
},
146+
"submodules": []
147+
}
148+
}
149+
]
150+
}
151+
},
152+
{
153+
"Shared": {
154+
"n_of_files": 1,
155+
"metric": {
156+
"loc": 4,
157+
"noc": 7,
158+
"n_a": 0,
159+
"n_c": 1,
160+
"nom": 1,
161+
"not": 0,
162+
"poc": 63.636
163+
},
164+
"submodules": []
165+
}
166+
}
167+
]
168+
}
169+
}
170+
]
171+
}
172+
},
86173
"fan_in": 1,
87-
"fan_out": 1,
88-
"i": 0.5,
89-
"a": 0.0,
174+
"fan_out": 0,
175+
"i": 0.0,
176+
"a": 0.5,
90177
"d_3": 0.5
91178
}
92179
}
@@ -141,6 +228,7 @@ The example below is an excerpt from the example available [here](../swift_code_
141228
}
142229
}
143230
```
231+
</details>
144232

145233
KPIs legend:
146234

@@ -197,4 +285,4 @@ For a more detailed description, please refer to the _Clean Architecture, Robert
197285

198286
### Code distribution
199287

200-
![LOC](assets/lines_of_code_-_loc.jpeg) ![NOC](assets/number_of_comments_-_noc.jpeg) ![Nc](assets/n._of_classes_and_structs.jpeg) ![NOT](assets/number_of_tests_-_not.jpeg) ![Code distribution](assets/code_distribution.jpeg)
288+
![LOC](assets/lines_of_code_-_loc.jpeg) ![NOC](assets/number_of_comments_-_noc.jpeg) ![Nc](assets/n._of_classes_and_structs.jpeg) ![NOT](assets/number_of_tests_-_not.jpeg) ![Code distribution](assets/code_distribution.jpeg) ![Code distribution in submodules](assets/code_distribution_submodules.jpeg)
16.8 KB
Loading

swift_code_metrics/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = "1.4.1"
1+
VERSION = "1.5.0"

0 commit comments

Comments
 (0)