|
2 | 2 |
|
3 | 3 | A sample project is provided in the `resources` folder:
|
4 | 4 |
|
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 | +``` |
6 | 8 |
|
7 |
| -### Source |
| 9 | +## Source |
8 | 10 |
|
9 | 11 | The library will start scanning the content under the `source` folder provided. Frameworks will be identified by their
|
10 | 12 | relative path to the root folder specified, meaning that the file system hierarchy will define the naming convention
|
11 | 13 | (e.g. if a class is under the path `SwiftCodeMetricsExample/BusinessLogic/Logic.swift`, the framework name will be identified
|
12 | 14 | as `BusinessLogic` since `SwiftCodeMetricsExample` is the root of the `source` parameter in the command above).
|
13 | 15 |
|
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 |
15 | 23 |
|
16 | 24 | Sometimes the folder structure is not enough to provide a description of the libraries involved, for instance when multiple frameworks are
|
17 | 25 | 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.
|
59 | 67 | The code in the `Shared` folder will contribute to the metrics of every single framework defined in the `libraries`
|
60 | 68 | array but it will be counted only once for the total aggregate data.
|
61 | 69 |
|
62 |
| -### Output format |
| 70 | +## Output format |
63 | 71 |
|
64 | 72 | The `output.json` file will contain the metrics related to all frameworks
|
65 | 73 | and an _aggregate_ result for the project.
|
66 | 74 |
|
67 | 75 | The example below is an excerpt from the example available [here](../swift_code_metrics/tests/test_resources/expected_output.json).
|
68 | 76 |
|
| 77 | +<details> |
| 78 | +<summary>Output.json example</summary> |
| 79 | + |
69 | 80 | ```json
|
70 | 81 | {
|
71 | 82 | "non-test-frameworks": [
|
72 | 83 | {
|
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, |
79 | 90 | "nom": 3,
|
80 | 91 | "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 | + }, |
86 | 173 | "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, |
90 | 177 | "d_3": 0.5
|
91 | 178 | }
|
92 | 179 | }
|
@@ -141,6 +228,7 @@ The example below is an excerpt from the example available [here](../swift_code_
|
141 | 228 | }
|
142 | 229 | }
|
143 | 230 | ```
|
| 231 | +</details> |
144 | 232 |
|
145 | 233 | KPIs legend:
|
146 | 234 |
|
@@ -197,4 +285,4 @@ For a more detailed description, please refer to the _Clean Architecture, Robert
|
197 | 285 |
|
198 | 286 | ### Code distribution
|
199 | 287 |
|
200 |
| -     |
| 288 | +      |
0 commit comments