**Cyclomatic Complexity Analysis** Cyclomatic Complexity is a software metric used to indicate the complexity of a program. The metric measures the number of linearly independent paths through a program's source code. A higher value means the code is more complex and potentially harder to test and maintain. Values above 10 are generally considered a warning sign. --- ### Analysis of `.\Samples\ComplexSample.ps1` - **Total Complexity:** 11 (Threshold is typically 10) - **File:** `.\Samples\ComplexSample.ps1` --- ### Insights - **Value 11:** Indicates this file exceeds recommended cyclomatic complexity. - The code likely contains multiple conditional branches (if, switch, loops), which make the program harder to test or reason about. - Files with high complexity should be considered for refactoring ΓÇô breaking down functions, simplifying logic, or separating concerns. --- ### Details from the File **To provide the lines meeting complex criteria** (e.g., branch points, decision statements), we need to identify the exact lines where decision points occur. However, since you haven't provided the content of `ComplexSample.ps1`, I'll provide a template for how this analysis would look if the source was available: | Line No. | Code Snippet | Complexity Contributor (Type) | |----------|--------------------------------------------------------|-------------------------------| | 5 | `if ($a -gt $b)` | Branch (if) | | 12 | `foreach ($item in $collection)` | Loop (foreach) | | 15 | `switch ($choice)` | Multi-branch (switch) | | 18 | `elseif ($x -eq 1)` | Branch (elseif) | | 20 | `case 1 { ... }` | Switch case | | 25 | `while ($continue)` | Loop (while) | | 28 | `if ($error)` | Branch (if) | | 29 | `try { ... } catch { ... }` | Exception (try/catch) | | 36 | `for ($i=0; $i -lt $count; $i++)` | Loop (for) | | 38 | `if ($flag)` | Branch (if) | | 42 | `return $result` | Path end (return) | *(The list above is illustrative; actual lines may differ.)* **Types contributing to complexity:** - `if`, `elseif`, `else` - Loops: `for`, `foreach`, `while` - `switch` statements - Exception handling: `try/catch` --- ### Suggestion - **Refactor Large Functions:** Split long methods into smaller ones. - **Reduce Nested Logic:** Flatten deep conditional or loop nesting. - **Increase Readability:** Add comments; rethink complex decision branches. - **Unit Tests:** Ensure comprehensive test coverage. --- **Want line-by-line analysis?** If you provide the actual code of `ComplexSample.ps1`, I can list the real lines contributing to cyclomatic complexity in table format. Let me know if you'd like to proceed!