complexipy 8.1.0__tar.gz → 8.3.0__tar.gz

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.
Files changed (135) hide show
  1. {complexipy-8.1.0 → complexipy-8.3.0}/Cargo.lock +28 -6
  2. {complexipy-8.1.0 → complexipy-8.3.0}/Cargo.toml +1 -1
  3. {complexipy-8.1.0 → complexipy-8.3.0}/PKG-INFO +9 -5
  4. {complexipy-8.1.0 → complexipy-8.3.0}/README.md +8 -4
  5. {complexipy-8.1.0 → complexipy-8.3.0}/complexipy/__init__.py +6 -3
  6. {complexipy-8.1.0 → complexipy-8.3.0}/complexipy/_complexipy.pyi +67 -19
  7. {complexipy-8.1.0 → complexipy-8.3.0}/complexipy/cli.py +10 -1
  8. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/Cargo.toml +4 -1
  9. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/args/tests.rs +14 -0
  10. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/args.rs +6 -0
  11. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/main.rs +8 -0
  12. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/output/diff/tests.rs +70 -6
  13. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/output/diff.rs +81 -15
  14. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/output/fix/tests.rs +13 -0
  15. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/output/fix.rs +119 -53
  16. complexipy-8.3.0/crates/complexipy-cli/src/output/messages/tests.rs +216 -0
  17. complexipy-8.3.0/crates/complexipy-cli/src/output/messages.rs +225 -0
  18. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/output/refactor/tests.rs +45 -4
  19. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/output/refactor.rs +78 -28
  20. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/output/render/tests.rs +105 -3
  21. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/output/render.rs +95 -37
  22. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/output/rows/tests.rs +166 -18
  23. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/output/rows.rs +98 -19
  24. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/output.rs +43 -5
  25. complexipy-8.3.0/crates/complexipy-cli/src/run/tests.rs +1038 -0
  26. complexipy-8.3.0/crates/complexipy-cli/src/run.rs +479 -0
  27. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/types.rs +41 -0
  28. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/utils/cache/tests.rs +112 -1
  29. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/utils/cache.rs +124 -71
  30. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/utils/config/tests.rs +143 -6
  31. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/utils/config.rs +91 -14
  32. complexipy-8.3.0/crates/complexipy-cli/src/utils/fingerprint.rs +59 -0
  33. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/utils/fix/tests.rs +95 -17
  34. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/utils/fix.rs +54 -27
  35. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/utils/gitlab/tests.rs +142 -0
  36. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/utils/gitlab.rs +49 -35
  37. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/utils/ignored/tests.rs +46 -15
  38. complexipy-8.3.0/crates/complexipy-cli/src/utils/ignored.rs +66 -0
  39. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/utils/sarif/tests.rs +231 -0
  40. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/utils/sarif.rs +89 -28
  41. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/utils/snapshot/tests.rs +163 -28
  42. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/utils/snapshot.rs +70 -21
  43. complexipy-8.3.0/crates/complexipy-cli/src/utils/toml.rs +31 -0
  44. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/utils.rs +1 -0
  45. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/src/api.rs +2 -0
  46. complexipy-8.3.0/crates/complexipy-core/src/classes.rs +243 -0
  47. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/src/cognitive_complexity.rs +302 -136
  48. complexipy-8.3.0/crates/complexipy-core/src/config.rs +378 -0
  49. complexipy-8.3.0/crates/complexipy-core/src/diff/tests.rs +1395 -0
  50. complexipy-8.3.0/crates/complexipy-core/src/diff.rs +1281 -0
  51. complexipy-8.3.0/crates/complexipy-core/src/encoding/tests.rs +86 -0
  52. complexipy-8.3.0/crates/complexipy-core/src/encoding.rs +165 -0
  53. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/src/fix.rs +37 -13
  54. complexipy-8.3.0/crates/complexipy-core/src/fs_guard/tests.rs +177 -0
  55. complexipy-8.3.0/crates/complexipy-core/src/fs_guard.rs +178 -0
  56. complexipy-8.3.0/crates/complexipy-core/src/helpers/exclude/tests.rs +439 -0
  57. complexipy-8.3.0/crates/complexipy-core/src/helpers/exclude.rs +459 -0
  58. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/src/lib.rs +5 -0
  59. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/src/refactor_plans.rs +6 -19
  60. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/src/rules/complexity/tests.rs +239 -54
  61. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/src/rules/complexity.rs +383 -377
  62. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/src/rules/registry/tests.rs +145 -7
  63. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/src/rules/registry.rs +105 -50
  64. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/src/rules/types.rs +11 -1
  65. complexipy-8.3.0/crates/complexipy-core/src/runner.rs +723 -0
  66. complexipy-8.3.0/crates/complexipy-core/src/sanitize/tests.rs +38 -0
  67. complexipy-8.3.0/crates/complexipy-core/src/sanitize.rs +44 -0
  68. complexipy-8.3.0/crates/complexipy-core/src/syntax_tree/tests.rs +92 -0
  69. complexipy-8.3.0/crates/complexipy-core/src/syntax_tree.rs +239 -0
  70. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/src/utils/export_tests.rs +18 -0
  71. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/src/utils/tests.rs +7 -3
  72. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/src/utils.rs +240 -123
  73. complexipy-8.3.0/crates/complexipy-core/tests/it/config.rs +368 -0
  74. complexipy-8.3.0/crates/complexipy-core/tests/it/deep_expressions.rs +95 -0
  75. complexipy-8.3.0/crates/complexipy-core/tests/it/discovery.rs +144 -0
  76. complexipy-8.3.0/crates/complexipy-core/tests/it/gate_coverage.rs +138 -0
  77. complexipy-8.3.0/crates/complexipy-core/tests/it/line_endings.rs +118 -0
  78. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/tests/it/main.rs +4 -0
  79. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-lsp/Cargo.toml +3 -0
  80. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-lsp/src/analysis.rs +206 -44
  81. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-lsp/src/documents.rs +47 -5
  82. complexipy-8.3.0/crates/complexipy-lsp/src/lib.rs +30 -0
  83. complexipy-8.3.0/crates/complexipy-lsp/src/main.rs +11 -0
  84. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-lsp/src/server/tests.rs +221 -28
  85. complexipy-8.3.0/crates/complexipy-lsp/src/server.rs +1112 -0
  86. complexipy-8.3.0/crates/complexipy-lsp/src/transport/tests.rs +146 -0
  87. complexipy-8.3.0/crates/complexipy-lsp/src/transport.rs +214 -0
  88. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-lsp/src/workspace/tests.rs +65 -0
  89. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-lsp/src/workspace.rs +52 -15
  90. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-lsp/tests/it/analysis.rs +190 -11
  91. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-lsp/tests/it/documents.rs +24 -1
  92. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-lsp/tests/it/protocol.rs +125 -13
  93. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-python/Cargo.toml +4 -0
  94. complexipy-8.3.0/crates/complexipy-python/src/lib.rs +341 -0
  95. complexipy-8.1.0/crates/complexipy-cli/src/output/messages/tests.rs +0 -105
  96. complexipy-8.1.0/crates/complexipy-cli/src/output/messages.rs +0 -70
  97. complexipy-8.1.0/crates/complexipy-cli/src/run/tests.rs +0 -307
  98. complexipy-8.1.0/crates/complexipy-cli/src/run.rs +0 -295
  99. complexipy-8.1.0/crates/complexipy-cli/src/utils/ignored.rs +0 -88
  100. complexipy-8.1.0/crates/complexipy-cli/src/utils/toml.rs +0 -19
  101. complexipy-8.1.0/crates/complexipy-core/src/classes.rs +0 -124
  102. complexipy-8.1.0/crates/complexipy-core/src/config.rs +0 -230
  103. complexipy-8.1.0/crates/complexipy-core/src/diff/tests.rs +0 -373
  104. complexipy-8.1.0/crates/complexipy-core/src/diff.rs +0 -299
  105. complexipy-8.1.0/crates/complexipy-core/src/helpers/exclude/tests.rs +0 -214
  106. complexipy-8.1.0/crates/complexipy-core/src/helpers/exclude.rs +0 -141
  107. complexipy-8.1.0/crates/complexipy-core/src/runner.rs +0 -288
  108. complexipy-8.1.0/crates/complexipy-core/tests/it/config.rs +0 -228
  109. complexipy-8.1.0/crates/complexipy-lsp/src/lib.rs +0 -14
  110. complexipy-8.1.0/crates/complexipy-lsp/src/main.rs +0 -3
  111. complexipy-8.1.0/crates/complexipy-lsp/src/server.rs +0 -649
  112. complexipy-8.1.0/crates/complexipy-python/src/lib.rs +0 -233
  113. {complexipy-8.1.0 → complexipy-8.3.0}/LICENSE +0 -0
  114. {complexipy-8.1.0 → complexipy-8.3.0}/complexipy/py.typed +0 -0
  115. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/lib.rs +0 -0
  116. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/types/tests.rs +0 -0
  117. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/utils/paths/tests.rs +0 -0
  118. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-cli/src/utils/paths.rs +0 -0
  119. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/Cargo.toml +0 -0
  120. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/src/api/tests.rs +0 -0
  121. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/src/fix/tests.rs +0 -0
  122. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/src/helpers.rs +0 -0
  123. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/src/rules/types/tests.rs +0 -0
  124. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/src/rules.rs +0 -0
  125. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/tests/it/exclude.rs +0 -0
  126. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/tests/it/lib_surface.rs +0 -0
  127. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/tests/it/plans_for_function.rs +0 -0
  128. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/tests/it/python315.rs +0 -0
  129. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-core/tests/it/syntax_error.rs +0 -0
  130. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-lsp/tests/it/main.rs +0 -0
  131. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-types/Cargo.toml +0 -0
  132. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-types/src/lib.rs +0 -0
  133. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-types/src/python/tests.rs +0 -0
  134. {complexipy-8.1.0 → complexipy-8.3.0}/crates/complexipy-types/src/python.rs +0 -0
  135. {complexipy-8.1.0 → complexipy-8.3.0}/pyproject.toml +0 -0
@@ -322,13 +322,14 @@ dependencies = [
322
322
 
323
323
  [[package]]
324
324
  name = "complexipy-cli"
325
- version = "8.1.0"
325
+ version = "8.3.0"
326
326
  dependencies = [
327
327
  "blake2",
328
328
  "clap",
329
329
  "comfy-table",
330
330
  "complexipy-core",
331
331
  "jsonschema",
332
+ "mimalloc",
332
333
  "owo-colors",
333
334
  "schemars",
334
335
  "serde",
@@ -344,7 +345,7 @@ dependencies = [
344
345
 
345
346
  [[package]]
346
347
  name = "complexipy-core"
347
- version = "8.1.0"
348
+ version = "8.3.0"
348
349
  dependencies = [
349
350
  "complexipy-types",
350
351
  "csv",
@@ -365,12 +366,13 @@ dependencies = [
365
366
 
366
367
  [[package]]
367
368
  name = "complexipy-lsp"
368
- version = "8.1.0"
369
+ version = "8.3.0"
369
370
  dependencies = [
370
371
  "complexipy-core",
371
372
  "crossbeam-channel",
372
373
  "lsp-server",
373
374
  "lsp-types",
375
+ "mimalloc",
374
376
  "serde",
375
377
  "serde_json",
376
378
  "tempfile",
@@ -378,19 +380,21 @@ dependencies = [
378
380
 
379
381
  [[package]]
380
382
  name = "complexipy-python"
381
- version = "8.1.0"
383
+ version = "8.3.0"
382
384
  dependencies = [
383
385
  "clap",
384
386
  "complexipy-cli",
385
387
  "complexipy-core",
386
388
  "complexipy-lsp",
387
389
  "complexipy-types",
390
+ "mimalloc",
388
391
  "pyo3",
392
+ "rayon",
389
393
  ]
390
394
 
391
395
  [[package]]
392
396
  name = "complexipy-types"
393
- version = "8.1.0"
397
+ version = "8.3.0"
394
398
  dependencies = [
395
399
  "pyo3",
396
400
  "serde",
@@ -398,7 +402,7 @@ dependencies = [
398
402
 
399
403
  [[package]]
400
404
  name = "complexipy-wasm"
401
- version = "8.1.0"
405
+ version = "8.3.0"
402
406
  dependencies = [
403
407
  "complexipy-core",
404
408
  "console_error_panic_hook",
@@ -1010,6 +1014,15 @@ version = "0.2.184"
1010
1014
  source = "registry+https://github.com/rust-lang/crates.io-index"
1011
1015
  checksum = "48f5d2a454e16a5ea0f4ced81bd44e4cfc7bd3a507b61887c99fd3538b28e4af"
1012
1016
 
1017
+ [[package]]
1018
+ name = "libmimalloc-sys"
1019
+ version = "0.1.46"
1020
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1021
+ checksum = "bc89deee4af0429081d2a518c0431ae068222a5a262a3bc6ff4d8535ec2e02fe"
1022
+ dependencies = [
1023
+ "cc",
1024
+ ]
1025
+
1013
1026
  [[package]]
1014
1027
  name = "linked-hash-map"
1015
1028
  version = "0.5.6"
@@ -1104,6 +1117,15 @@ version = "0.3.0"
1104
1117
  source = "registry+https://github.com/rust-lang/crates.io-index"
1105
1118
  checksum = "c2a86d3146ed3995b5913c414f6664344b9617457320782e64f0bb44afd49d74"
1106
1119
 
1120
+ [[package]]
1121
+ name = "mimalloc"
1122
+ version = "0.1.49"
1123
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1124
+ checksum = "aca3c01a711f395b4257b81674c0e90e8dd1f1e62c4b7db45f684cc7a4fcb18a"
1125
+ dependencies = [
1126
+ "libmimalloc-sys",
1127
+ ]
1128
+
1107
1129
  [[package]]
1108
1130
  name = "minimal-lexical"
1109
1131
  version = "0.2.1"
@@ -3,7 +3,7 @@ members = ["crates/*"]
3
3
  resolver = "2"
4
4
 
5
5
  [workspace.package]
6
- version = "8.1.0"
6
+ version = "8.3.0"
7
7
  edition = "2024"
8
8
  authors = ["Robin Quintero <rohaquinlop301@gmail.com>"]
9
9
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: complexipy
3
- Version: 8.1.0
3
+ Version: 8.3.0
4
4
  Classifier: Development Status :: 5 - Production/Stable
5
5
  Classifier: Environment :: Console
6
6
  Classifier: Intended Audience :: Developers
@@ -93,6 +93,10 @@ uv add complexipy
93
93
  uv tool install complexipy
94
94
  ```
95
95
 
96
+ The `--diff`, `--diff-only`, and `--staged` options require Git 2.30 or newer
97
+ on your `PATH`. Check your version with `git --version`. Git is not required
98
+ for analysis without these options.
99
+
96
100
  ## Quick Start
97
101
 
98
102
  ### Command Line
@@ -136,11 +140,11 @@ for func in result.functions:
136
140
  <summary><strong>🔧 GitHub Actions</strong></summary>
137
141
 
138
142
  ```yaml
139
- - uses: rohaquinlop/complexipy-action@v2
143
+ - uses: rohaquinlop/complexipy-action@v8
140
144
  with:
141
145
  paths: .
142
146
  max_complexity_allowed: 10
143
- output_format: json
147
+ output_json: true
144
148
  ```
145
149
 
146
150
  </details>
@@ -151,7 +155,7 @@ for func in result.functions:
151
155
  ```yaml
152
156
  repos:
153
157
  - repo: https://github.com/rohaquinlop/complexipy-pre-commit
154
- rev: v5.1.0
158
+ rev: v8.1.0
155
159
  hooks:
156
160
  - id: complexipy
157
161
  ```
@@ -161,7 +165,7 @@ repos:
161
165
  <details>
162
166
  <summary><strong>🔌 VS Code Extension</strong></summary>
163
167
 
164
- Install from the [marketplace](https://marketplace.visualstudio.com/items?itemName=rohaquinlop.complexipy) It runs the complexipy language server, so install `complexipy` too (`uv tool install complexipy`). Inlay hints, hover, and warnings update as you type.
168
+ Install from the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=rohaquinlop.complexipy) or [OpenVSX](https://open-vsx.org/extension/rohaquinlop/complexipy). It runs the complexipy language server, so install `complexipy` too (`uv tool install complexipy`). Inlay hints, hover, and warnings update as you type.
165
169
 
166
170
  </details>
167
171
 
@@ -55,6 +55,10 @@ uv add complexipy
55
55
  uv tool install complexipy
56
56
  ```
57
57
 
58
+ The `--diff`, `--diff-only`, and `--staged` options require Git 2.30 or newer
59
+ on your `PATH`. Check your version with `git --version`. Git is not required
60
+ for analysis without these options.
61
+
58
62
  ## Quick Start
59
63
 
60
64
  ### Command Line
@@ -98,11 +102,11 @@ for func in result.functions:
98
102
  <summary><strong>🔧 GitHub Actions</strong></summary>
99
103
 
100
104
  ```yaml
101
- - uses: rohaquinlop/complexipy-action@v2
105
+ - uses: rohaquinlop/complexipy-action@v8
102
106
  with:
103
107
  paths: .
104
108
  max_complexity_allowed: 10
105
- output_format: json
109
+ output_json: true
106
110
  ```
107
111
 
108
112
  </details>
@@ -113,7 +117,7 @@ for func in result.functions:
113
117
  ```yaml
114
118
  repos:
115
119
  - repo: https://github.com/rohaquinlop/complexipy-pre-commit
116
- rev: v5.1.0
120
+ rev: v8.1.0
117
121
  hooks:
118
122
  - id: complexipy
119
123
  ```
@@ -123,7 +127,7 @@ repos:
123
127
  <details>
124
128
  <summary><strong>🔌 VS Code Extension</strong></summary>
125
129
 
126
- Install from the [marketplace](https://marketplace.visualstudio.com/items?itemName=rohaquinlop.complexipy) It runs the complexipy language server, so install `complexipy` too (`uv tool install complexipy`). Inlay hints, hover, and warnings update as you type.
130
+ Install from the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=rohaquinlop.complexipy) or [OpenVSX](https://open-vsx.org/extension/rohaquinlop/complexipy). It runs the complexipy language server, so install `complexipy` too (`uv tool install complexipy`). Inlay hints, hover, and warnings update as you type.
127
131
 
128
132
  </details>
129
133
 
@@ -56,6 +56,7 @@ def file_complexity(
56
56
  file_path: str,
57
57
  check_script: bool = False,
58
58
  no_ignore: bool = False,
59
+ with_plans: bool = True,
59
60
  ) -> FileComplexity:
60
61
  """Analyze the cognitive complexity of a single Python source file.
61
62
 
@@ -66,15 +67,16 @@ def file_complexity(
66
67
  module-level (script) code as a '<module>' entry.
67
68
  no_ignore: If True, disregard all '# complexipy: ignore' and
68
69
  '# noqa: complexipy' comments, analyzing every function.
70
+ with_plans: If False, skip building refactor plans and leave every
71
+ 'refactor_plans' list empty.
69
72
 
70
73
  Returns:
71
74
  FileComplexity object containing complete analysis results for the
72
75
  file, including all functions found and their complexity scores.
73
76
 
74
77
  Raises:
75
- FileNotFoundError: If the specified file does not exist.
76
- PermissionError: If the file cannot be read due to permissions.
77
- SyntaxError: If the Python file contains syntax errors.
78
+ ValueError: If the file cannot be read, is not UTF-8 text, or
79
+ does not parse.
78
80
  """
79
81
  path = Path(file_path).resolve()
80
82
  cwd = Path.cwd().resolve()
@@ -89,4 +91,5 @@ def file_complexity(
89
91
  base_path.as_posix(),
90
92
  check_script,
91
93
  no_ignore,
94
+ with_plans,
92
95
  )
@@ -454,7 +454,10 @@ class RemovableIgnore:
454
454
  """The function's cognitive complexity measured without the ignore comment."""
455
455
 
456
456
  def code_complexity(
457
- code: str, check_script: bool = False, no_ignore: bool = False
457
+ code: str,
458
+ check_script: bool = False,
459
+ no_ignore: bool = False,
460
+ with_plans: bool = True,
458
461
  ) -> CodeComplexity:
459
462
  """
460
463
  Analyze cognitive complexity of Python code provided as a string.
@@ -472,13 +475,17 @@ def code_complexity(
472
475
  code: A string containing valid Python source code. The code should
473
476
  be properly formatted and syntactically correct. Syntax errors
474
477
  will cause the analysis to fail.
478
+ check_script: Also report module-level code as a '<module>' entry.
479
+ no_ignore: Disregard inline ignore comments.
480
+ with_plans: Build refactor plans. When False, every
481
+ 'refactor_plans' list is empty.
475
482
 
476
483
  Returns:
477
484
  CodeComplexity object containing the analysis results, including
478
485
  individual function complexity scores and total complexity.
479
486
 
480
487
  Raises:
481
- SyntaxError: If the provided code string contains invalid Python syntax.
488
+ ValueError: If the code does not parse, or on an internal error.
482
489
 
483
490
  Example:
484
491
  >>> code_sample = '''
@@ -511,6 +518,7 @@ def file_complexity(
511
518
  base_path: str,
512
519
  check_script: bool = False,
513
520
  no_ignore: bool = False,
521
+ with_plans: bool = True,
514
522
  ) -> FileComplexity:
515
523
  """
516
524
  Analyze cognitive complexity of a single Python source file.
@@ -531,16 +539,18 @@ def file_complexity(
531
539
  in the analysis results. This is typically the project
532
540
  root directory and affects the 'path' field in the
533
541
  returned FileComplexity object.
542
+ check_script: Also report module-level code as a '<module>' entry.
543
+ no_ignore: Disregard inline ignore comments.
544
+ with_plans: Build refactor plans. When False, every
545
+ 'refactor_plans' list is empty.
534
546
 
535
547
  Returns:
536
548
  FileComplexity object containing complete analysis results for the
537
549
  file, including all functions found and their complexity scores.
538
550
 
539
551
  Raises:
540
- FileNotFoundError: If the specified file_path does not exist.
541
- PermissionError: If the file cannot be read due to permissions.
542
- SyntaxError: If the Python file contains syntax errors.
543
- UnicodeDecodeError: If the file cannot be decoded as text.
552
+ ValueError: If the file cannot be read, is not UTF-8 text, or does
553
+ not parse, or on an internal error.
544
554
 
545
555
  Example:
546
556
  >>> # Analyze a specific file
@@ -568,12 +578,18 @@ def run_cli(argv: List[str], invocation_path: Optional[str] = None) -> int:
568
578
 
569
579
  Args:
570
580
  argv: Command-line arguments, excluding the program name.
571
- invocation_path: Working directory for the run; defaults to the
572
- current working directory.
581
+ invocation_path: Directory whose configuration file the run reads,
582
+ and under which it writes the cache, the snapshot, and the
583
+ reports; defaults to the current working directory. Relative
584
+ paths to analyze resolve against the process working
585
+ directory.
573
586
 
574
587
  Returns:
575
588
  Process exit code: 0 on success, 1 on gate failure, 2 on usage
576
589
  errors.
590
+
591
+ Raises:
592
+ RuntimeError: On an internal error.
577
593
  """
578
594
  ...
579
595
 
@@ -589,6 +605,9 @@ def run_lsp() -> int:
589
605
 
590
606
  Returns:
591
607
  Process exit code: 0 after a clean shutdown, 1 otherwise.
608
+
609
+ Raises:
610
+ RuntimeError: On an internal error.
592
611
  """
593
612
  ...
594
613
 
@@ -601,19 +620,33 @@ def compute_diff(
601
620
  Compare the current complexity results against *git_ref*.
602
621
 
603
622
  For each file in *current_files*, retrieves the file's content at
604
- *git_ref* using ``git show`` and re-analyses it. Functions that
605
- appear only in one version are marked NEW / REMOVED.
623
+ *git_ref*, at the same path, from the git repository that holds the
624
+ file and re-analyses it. A submodule, a repository that the repository
625
+ around it tracks as a gitlink, is read at the commit that the outer
626
+ repository pins for it, unless it holds *invocation_path*. Functions
627
+ that appear only in one version are marked NEW / REMOVED, except that
628
+ a function an ignore comment now hides is not marked REMOVED. A file
629
+ moved since *git_ref* is not followed to its old path, which is not in
630
+ *current_files*, so its functions are marked NEW, as are the functions
631
+ of a file that does not parse at *git_ref* or that was not a regular
632
+ file there, such as a symbolic link, of a file outside any repository,
633
+ of a file in a repository where *git_ref* names no commit, and of a
634
+ file in a submodule without a pinned commit it has.
606
635
 
607
636
  Args:
608
637
  current_files: Complexity results of the current analysis.
609
638
  git_ref: Git reference to compare against (branch, tag, or commit).
610
- invocation_path: Working directory for git commands; defaults to
611
- the current working directory.
639
+ invocation_path: Directory that relative file paths are taken
640
+ from, and whose repositories are read at *git_ref* even when
641
+ they are submodules; defaults to the current working directory.
612
642
 
613
643
  Returns:
614
644
  List of DiffEntry objects, one per function that changed or is
615
645
  new/removed. Unchanged functions are included so callers can
616
646
  choose how to filter.
647
+
648
+ Raises:
649
+ ValueError: On an internal error.
617
650
  """
618
651
  ...
619
652
 
@@ -624,7 +657,10 @@ def has_regressions(entries: List[DiffEntry], max_complexity: int) -> bool:
624
657
  A ratchet failure is a REGRESSED function whose new complexity
625
658
  exceeds *max_complexity*, or a NEW function whose complexity exceeds
626
659
  *max_complexity*. Modified functions that increase in complexity but
627
- stay at or below the threshold are not considered failures.
660
+ stay at or below the threshold are not considered failures. The
661
+ entries carry no function bodies, so a function that moved or was
662
+ renamed counts as NEW like any other; the `--diff` gate, which
663
+ compares the bodies, lets an exact copy through.
628
664
  """
629
665
  ...
630
666
 
@@ -649,19 +685,25 @@ def collect_all_ignored_locations(
649
685
  This is the backend for the --report-ignored CLI flag.
650
686
 
651
687
  Args:
652
- paths: List of file paths, directory paths, or Git repository URLs.
688
+ paths: List of file and directory paths.
653
689
  exclude: List of file/directory paths or globs to exclude from scanning.
654
- invocation_path: Working directory for resolving relative paths.
690
+ invocation_path: Directory that returned paths inside it are
691
+ relative to, and that exclude patterns also match against.
692
+ Relative paths to scan resolve against the process working
693
+ directory.
655
694
 
656
695
  Returns:
657
696
  A tuple of (ignored_locations, failed_paths) where:
658
697
  - ignored_locations: List of IgnoredLocation objects, sorted by (path, line).
659
698
  - failed_paths: List of paths that could not be processed.
660
699
 
700
+ Raises:
701
+ ValueError: On an internal error.
702
+
661
703
  Example:
662
704
  >>> locations, failed = collect_all_ignored_locations(
663
705
  ... paths=["/project/src"],
664
- ... exclude=["tests/"],
706
+ ... exclude=["tests/**"],
665
707
  ... )
666
708
  >>> for loc in locations:
667
709
  ... print(f"{loc.path}:{loc.line} {loc.comment}")
@@ -687,21 +729,27 @@ def collect_removable_ignored_locations(
687
729
  equal to `max_complexity_allowed`.
688
730
 
689
731
  Args:
690
- paths: List of file paths, directory paths, or Git repository URLs.
732
+ paths: List of file and directory paths.
691
733
  exclude: List of file/directory paths or globs to exclude from scanning.
692
734
  max_complexity_allowed: Complexity threshold; markers suppressing
693
735
  functions at or below this value are reported as removable.
694
- invocation_path: Working directory for resolving relative paths.
736
+ invocation_path: Directory that returned paths inside it are
737
+ relative to, and that exclude patterns also match against.
738
+ Relative paths to scan resolve against the process working
739
+ directory.
695
740
 
696
741
  Returns:
697
742
  A tuple of (removable_ignores, failed_paths) where:
698
743
  - removable_ignores: List of RemovableIgnore objects, sorted by (path, line).
699
744
  - failed_paths: List of paths that could not be processed.
700
745
 
746
+ Raises:
747
+ ValueError: On an internal error.
748
+
701
749
  Example:
702
750
  >>> removable, failed = collect_removable_ignored_locations(
703
751
  ... paths=["/project/src"],
704
- ... exclude=["tests/"],
752
+ ... exclude=["tests/**"],
705
753
  ... max_complexity_allowed=15,
706
754
  ... )
707
755
  >>> for rem in removable:
@@ -12,7 +12,9 @@ word reserves the command line, so a path named ``lsp`` needs
12
12
 
13
13
  from __future__ import annotations
14
14
 
15
+ import signal
15
16
  import sys
17
+ import threading
16
18
  from pathlib import Path
17
19
 
18
20
  from complexipy._complexipy import run_cli, run_lsp
@@ -40,7 +42,14 @@ def lsp_shadow_warning() -> str | None:
40
42
 
41
43
 
42
44
  def main() -> None:
43
- """Run the Rust CLI, or the language server for ``complexipy lsp``."""
45
+ """Run the Rust CLI, or the language server for ``complexipy lsp``.
46
+
47
+ Called from the main thread, Ctrl-C ends the process at once, also
48
+ while the Rust call runs. Called from another thread, it leaves the
49
+ SIGINT handler alone, since only the main thread can set it.
50
+ """
51
+ if threading.current_thread() is threading.main_thread():
52
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
44
53
  arguments = sys.argv[1:]
45
54
 
46
55
  if arguments[:1] == [LSP_ARGUMENT]:
@@ -23,7 +23,7 @@ test = false
23
23
  complexipy-core = { path = "../complexipy-core", features = ["config"] }
24
24
  clap = { workspace = true }
25
25
  serde = { workspace = true }
26
- serde_json = { workspace = true }
26
+ serde_json = { workspace = true, features = ["raw_value"] }
27
27
  toml = { workspace = true }
28
28
  blake2 = { workspace = true }
29
29
  sha2 = { workspace = true }
@@ -39,3 +39,6 @@ tempfile = { workspace = true }
39
39
  complexipy-core = { path = "../complexipy-core", features = ["config", "schema"] }
40
40
  schemars = { workspace = true }
41
41
  jsonschema = { workspace = true }
42
+
43
+ [target.'cfg(any(target_os = "macos", target_os = "windows", all(target_os = "linux", target_arch = "x86_64")))'.dependencies]
44
+ mimalloc = "0.1.49"
@@ -128,3 +128,17 @@ fn plain_equals_form_parses() {
128
128
  assert_eq!(cli.plain, Some(false));
129
129
  assert_eq!(cli.paths, vec!["src"]);
130
130
  }
131
+
132
+ #[test]
133
+ fn isolated_and_config_pin_the_config_source() {
134
+ let isolated = parse(&["complexipy", "--isolated", "src"]);
135
+ let named = parse(&["complexipy", "src", "--config", "ci.toml"]);
136
+
137
+ assert_eq!(isolated.isolated, Some(true));
138
+ assert_eq!(isolated.paths, vec!["src"]);
139
+ assert_eq!(named.config, Some("ci.toml".to_string()));
140
+ assert!(
141
+ CliArgs::try_parse_from(["complexipy", "src", "--isolated", "--config", "ci.toml"])
142
+ .is_err()
143
+ );
144
+ }
@@ -81,6 +81,12 @@ pub struct CliArgs {
81
81
 
82
82
  #[arg(long, num_args = 0..=1, default_missing_value = "true", require_equals = true)]
83
83
  pub report_ignored: Option<bool>,
84
+
85
+ #[arg(long, conflicts_with = "config", num_args = 0..=1, default_missing_value = "true", require_equals = true)]
86
+ pub isolated: Option<bool>,
87
+
88
+ #[arg(long, value_name = "PATH")]
89
+ pub config: Option<String>,
84
90
  }
85
91
 
86
92
  #[cfg(test)]
@@ -5,6 +5,14 @@ use clap::Parser;
5
5
  use complexipy_cli::args::CliArgs;
6
6
  use complexipy_cli::run::run_at;
7
7
 
8
+ #[cfg(any(
9
+ target_os = "macos",
10
+ target_os = "windows",
11
+ all(target_os = "linux", target_arch = "x86_64")
12
+ ))]
13
+ #[global_allocator]
14
+ static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
15
+
8
16
  fn main() -> ExitCode {
9
17
  let invocation_path = std::env::current_dir()
10
18
  .map(|path| path.to_string_lossy().into_owned())
@@ -1,5 +1,5 @@
1
1
  use crate::output::diff::format_diff;
2
- use complexipy_core::diff::DiffEntry;
2
+ use complexipy_core::diff::{DiffEntry, Verdict};
3
3
 
4
4
  fn strip_ansi(input: &str) -> String {
5
5
  let mut result = String::new();
@@ -29,7 +29,7 @@ fn entry(file_path: &str, func_name: &str, old: Option<u64>, new: Option<u64>) -
29
29
 
30
30
  #[test]
31
31
  fn no_entries_renders_no_changes() {
32
- let output = format_diff(&[], "main");
32
+ let output = format_diff(&[], "main", None);
33
33
 
34
34
  assert_eq!(output, "No functions changed relative to main.");
35
35
  }
@@ -38,7 +38,7 @@ fn no_entries_renders_no_changes() {
38
38
  fn unchanged_only_renders_no_changes() {
39
39
  let entries = vec![entry("a.py", "f", Some(5), Some(5))];
40
40
 
41
- let output = format_diff(&entries, "main");
41
+ let output = format_diff(&entries, "main", None);
42
42
 
43
43
  assert_eq!(output, "No functions changed relative to main.");
44
44
  }
@@ -52,7 +52,7 @@ fn table_contains_all_statuses() {
52
52
  entry("b.py", "gone", Some(5), None),
53
53
  ];
54
54
 
55
- let output = strip_ansi(&format_diff(&entries, "main"));
55
+ let output = strip_ansi(&format_diff(&entries, "main", None));
56
56
 
57
57
  assert!(output.contains("Complexity diff (vs main)"));
58
58
  assert!(output.contains("a.py::reg"));
@@ -75,7 +75,7 @@ fn summary_counts() {
75
75
  entry("b.py", "g1", Some(5), None),
76
76
  ];
77
77
 
78
- let output = strip_ansi(&format_diff(&entries, "main"));
78
+ let output = strip_ansi(&format_diff(&entries, "main", None));
79
79
 
80
80
  assert!(output.contains("2 regressed"));
81
81
  assert!(output.contains("1 improved"));
@@ -87,9 +87,73 @@ fn summary_counts() {
87
87
  fn status_ordering_in_summary() {
88
88
  let entries = vec![entry("a.py", "f", Some(3), Some(6))];
89
89
 
90
- let output = strip_ansi(&format_diff(&entries, "main"));
90
+ let output = strip_ansi(&format_diff(&entries, "main", None));
91
91
 
92
92
  let net_index = output.find("Net:").expect("net line");
93
93
  let summary = &output[net_index..];
94
94
  assert!(summary.contains("1 regressed"));
95
95
  }
96
+
97
+ #[test]
98
+ fn the_gate_column_names_both_sides_of_a_replacement() {
99
+ let entries = vec![
100
+ entry("b.py", "f", None, Some(20)),
101
+ entry("a.py", "f", Some(20), None),
102
+ ];
103
+ let verdicts = [Verdict::Replaces(1), Verdict::Passes];
104
+
105
+ let output = strip_ansi(&format_diff(&entries, "main", Some(&verdicts)));
106
+
107
+ assert!(output.contains("Gate"));
108
+ assert!(output.contains("replaces a.py::f"));
109
+ assert!(output.contains("replaced by b.py::f"));
110
+ }
111
+
112
+ fn header(output: &str) -> &str {
113
+ output
114
+ .lines()
115
+ .find(|line| line.contains("Status"))
116
+ .expect("header row")
117
+ }
118
+
119
+ #[test]
120
+ fn no_gate_column_without_a_gate_note() {
121
+ let entries = vec![entry("a.py", "f", Some(3), Some(4))];
122
+
123
+ let output = strip_ansi(&format_diff(&entries, "main", Some(&[Verdict::Passes])));
124
+
125
+ assert!(!header(&output).contains("Gate"));
126
+ assert!(output.ends_with("Gate: no function fails the gate."));
127
+ }
128
+
129
+ #[test]
130
+ fn the_gate_column_marks_each_entry_that_fails() {
131
+ let entries = vec![
132
+ entry("a.py", "worse", Some(31), Some(35)),
133
+ entry("a.py", "small", Some(0), Some(1)),
134
+ entry("b.py", "fresh", None, Some(20)),
135
+ ];
136
+ let verdicts = [Verdict::Fails, Verdict::Passes, Verdict::Fails];
137
+
138
+ let output = strip_ansi(&format_diff(&entries, "main", Some(&verdicts)));
139
+
140
+ assert!(header(&output).contains("Gate"));
141
+ let failing: Vec<&str> = output
142
+ .lines()
143
+ .filter(|line| line.contains("FAILS"))
144
+ .collect();
145
+ assert_eq!(failing.len(), 2);
146
+ assert!(failing[0].contains("a.py::worse"));
147
+ assert!(failing[1].contains("b.py::fresh"));
148
+ assert!(output.ends_with("Gate: 2 functions fail: REGRESSED or NEW above the threshold."));
149
+ }
150
+
151
+ #[test]
152
+ fn a_diff_only_table_has_no_gate() {
153
+ let entries = vec![entry("a.py", "worse", Some(31), Some(35))];
154
+
155
+ let output = strip_ansi(&format_diff(&entries, "main", None));
156
+
157
+ assert!(!output.contains("Gate"));
158
+ assert!(!output.contains("FAILS"));
159
+ }