You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/build/smart-contracts/linter.mdx
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -444,3 +444,22 @@ public fun get_refs(): vector<ConstructorRef> {
444
444
// ... code that returns vector with ConstructorRef
445
445
}
446
446
```
447
+
448
+
## Experimental Checks
449
+
450
+
### `cyclomatic_complexity`
451
+
452
+
Cyclomatic complexity measures the number of linearly independent execution paths through a function. A high value generally correlates with code that is harder to test and maintain.
453
+
454
+
This linter performs an approximation while traversing the Move expression tree:
455
+
456
+
1. The complexity score starts at **1**.
457
+
2. The score is incremented for each control-flow decision point found:
458
+
- +1 for each `if`
459
+
- +1 for each `else if`
460
+
- +1 for each `loop`, `while`, or `for`
461
+
- +1 for each `break` or `continue`
462
+
- +1 for each `return` statement that is not the final expression in the function
463
+
- +n where n = (number of match arms - 1)
464
+
465
+
When the accumulated score exceeds the default threshold (currently **10**), the linter emits a diagnostic suggesting that the function be simplified or decomposed.
0 commit comments