Skip to content

Commit f7a5c61

Browse files
github-actions[bot]Copilotrijeshagithub-actions
authored
Creating Release: 2.0.2 (#170)
* Implement unused code detection feature for static analysis (command-line only) (#121) * Initial plan * Implement comprehensive unused code detection feature Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com> * Remove VS Code extension command for unused code detection - Removed command definition from package.json - Removed command registration from extension.ts - Removed unused spawn import - Keeping npm script and detection functionality available --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com> * Update issue templates * Added files .vscodeignore and added bundling to release.yml (#159) * Added files .vscodeignore and added bundling to release.yml * Further chanages to .vscodeignore * 2.0.1 (#162) - Testing new packaging Co-authored-by: github-actions <github-actions@github.com> * Reorganize repository structure - separate build scripts from extension resources (#158) * Initial plan * Reorganize repository structure - separate build scripts from extension resources Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com> * Address feedback: restore media files, keep Windows scripts in scripts/, move templates to resources/ Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com> * Move Windows helper files from scripts/ to resources/ Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com> * Fixed prompt for additional arguments from -mr to --mr (#166) * Made west narrow false by default with an option in settings to make it true (#168) * Fixed issue where workspace would not set up if zephyr folder was used directly (#167) * Fixed issue where workspace would not set up if zephyr folder was used directly * Using zephyrDir for python requirements install * 2.0.2 (#169) Co-authored-by: github-actions <github-actions@github.com> --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com>
1 parent eec0718 commit f7a5c61

32 files changed

+578
-33
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: Maintenance
3+
about: Code maintenance related issues
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+

.github/workflows/release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ jobs:
4040

4141
# Optional build (ensure dist/extension.js exists if using bundler)
4242
- name: Build Extension
43-
run: npm run esbuild --if-present
43+
run: npm run esbuild
44+
45+
- name: Package extension
46+
run: npx vsce package
4447

4548
# Capture version from package.json for later release creation
4649
- name: Extract Version

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,9 @@ dist
33
node_modules
44
.vscode-test/
55
*.vsix
6-
.vscode/zephyr-ide.json
6+
.vscode/zephyr-ide.json
7+
8+
# Python
9+
__pycache__/
10+
*.py[cod]
11+
*$py.class

.vscodeignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
.vscode/**
22
.vscode-test/**
3-
3+
.git/
44
.gitignore
5+
.github/
56
.yarnrc
67
vsc-extension-quickstart.md
78
**/tsconfig.json
89
**/.eslintrc.json
910
**/*.map
1011
**/*.ts
1112
**/.vscode-test.*
13+
14+
docs/**
15+
CHANGELOG.md
16+
LICENSE.md
17+
README.md

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ You can read a little bit more about the motivation behind the project [here](ht
2525
- Provides the user with a terminal to manually run west commands
2626
- Saves/loads project structure to workspace in a human readable and editable file
2727
- Works with all platforms zephyr supports
28+
- **Code Quality Tools**: Includes unused code detection to help maintain clean codebases
29+
30+
## Code Quality
31+
32+
This extension includes tools to help maintain code quality:
33+
34+
- **Unused Code Detection**: Static analysis tool to identify potentially unused files and exports
35+
- Available via command palette: "Zephyr IDE: Detect Unused Code"
36+
- Also available via npm script: `npm run detect-unused`
37+
- See [detailed documentation](docs/unused-code-detection.md) for more information
2838

2939

3040
## Getting Started
@@ -97,6 +107,6 @@ See [CHANGELOG](CHANGELOG.md) for release notes
97107

98108
## Development and Debugging
99109

100-
See the [Zephyr IDE for VS Code Developer's Guide](developer-guide.md) for development and debugging instructions.
110+
See the [Zephyr IDE for VS Code Developer's Guide](docs/developer-guide.md) for development and debugging instructions.
101111

102112
---

developer-guide.md renamed to docs/developer-guide.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
# Zephyr IDE for VS Code Developer's Guide
2-
1+
# Zephyr IDE for VS Code Developer's Guide
2+
3+
This guide covers the development setup for the Zephyr IDE VS Code extension.
4+
5+
## Related Documentation
6+
7+
- [User Manual](MANUAL.md) - Complete user guide for the extension
8+
- [Testing Guide](TESTING.md) - Information about running tests and test infrastructure
9+
- [Unused Code Detection](unused-code-detection.md) - Guide for detecting unused code
10+
311
## Prerequisites
412

513
* Git (https://git-scm.com/)

docs/unused-code-detection.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Unused Code Detection
2+
3+
This project includes a static analysis tool to detect potentially unused code and dead files. This helps maintain a clean codebase by identifying exports and files that may no longer be needed.
4+
5+
## Features
6+
7+
The unused code detector analyzes:
8+
- **Unused Files**: TypeScript files that are never imported by other files
9+
- **Unused Exports**: Functions, classes, variables, and types that are exported but never imported
10+
- **VS Code Integration**: Smart detection of VS Code extension patterns like `activate`/`deactivate` functions
11+
12+
## Usage
13+
14+
### Command Line
15+
16+
Run the detection script from the command line:
17+
18+
```bash
19+
npm run detect-unused
20+
```
21+
22+
### VS Code Command
23+
24+
1. Open the Command Palette (`Ctrl+Shift+P` / `Cmd+Shift+P`)
25+
2. Search for "Zephyr IDE: Detect Unused Code"
26+
3. Run the command
27+
4. View results in the Output panel (select "Zephyr IDE" from the dropdown)
28+
29+
## Understanding the Results
30+
31+
### Report Sections
32+
33+
**🗂️ Potentially Unused Files**
34+
- Lists TypeScript files that are never imported
35+
- Excludes test files and the main extension entry point
36+
- These files might be safe to remove, but review carefully
37+
38+
**📤 Potentially Unused Exports**
39+
- Lists exported functions, classes, variables that are never imported
40+
- Shows the file, export name, type, and line number
41+
- Includes smart filtering for VS Code extension patterns
42+
43+
**📈 Summary**
44+
- Total files analyzed
45+
- Count of potentially unused files and exports
46+
47+
### Important Notes
48+
49+
⚠️ **This analysis is static and may show false positives**
50+
51+
The tool cannot detect:
52+
- Dynamic imports using `import()` statements
53+
- Reflection-based usage
54+
- External references from other packages
55+
- Command handlers registered via strings in package.json
56+
- Functions called via VS Code's command system
57+
58+
### Best Practices
59+
60+
1. **Review before removing**: Always manually verify that flagged code is truly unused
61+
2. **Check git history**: Look at recent usage patterns before removing old code
62+
3. **Consider API boundaries**: Some exports might be intended for external use
63+
4. **Test thoroughly**: After removing code, run all tests and verify functionality
64+
65+
## Technical Details
66+
67+
The detection script:
68+
1. Scans all `.ts` files in the `src` directory
69+
2. Parses import/export statements using regex patterns
70+
3. Builds a dependency graph
71+
4. Identifies unused files and exports
72+
5. Applies VS Code extension-specific filtering rules
73+
74+
### Limitations
75+
76+
- Does not use TypeScript compiler API for performance reasons
77+
- Regex-based parsing may miss complex import/export patterns
78+
- Cannot detect runtime-only dependencies
79+
- May not catch all dynamic usage patterns
80+
81+
## Example Output
82+
83+
```
84+
📊 UNUSED CODE DETECTION REPORT
85+
==================================================
86+
87+
🗂️ POTENTIALLY UNUSED FILES:
88+
✅ No unused files detected!
89+
90+
📤 POTENTIALLY UNUSED EXPORTS:
91+
92+
📁 utilities/utils.ts:
93+
🔸 unusedHelper (declaration, line 42)
94+
🔸 oldFunction (declaration, line 156)
95+
96+
📈 SUMMARY:
97+
📁 Total files analyzed: 36
98+
🗂️ Potentially unused files: 0
99+
📤 Potentially unused exports: 2
100+
```
101+
102+
This report suggests reviewing `unusedHelper` and `oldFunction` in the utils file to determine if they can be safely removed.

media/logo_small.jpg

1.19 KB
Loading

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "zephyr-ide",
33
"displayName": "Zephyr IDE",
44
"description": "A VS Code extension that streamlines setup, build, flashing, and debugging of Zephyr Projects",
5-
"version": "2.0.0",
5+
"version": "2.0.2",
66
"license": "Apache-2.0",
77
"publisher": "mylonics",
88
"icon": "media/logo.png",
@@ -63,6 +63,13 @@
6363
],
6464
"default": false,
6565
"description": "Display gui config instead of menu config in Project Tree View"
66+
},
67+
"zephyr-ide.westNarrowUpdate": {
68+
"type": [
69+
"boolean"
70+
],
71+
"default": false,
72+
"description": "If true, uses 'west update --narrow'. If false, uses 'west update' without --narrow."
6673
}
6774
}
6875
},
@@ -615,7 +622,8 @@
615622
"watch": "tsc -watch -p ./",
616623
"pretest": "npm run compile && npm run esbuild && npm run lint",
617624
"lint": "eslint src --ext ts",
618-
"test": "vscode-test"
625+
"test": "vscode-test",
626+
"detect-unused": "node scripts/detect-unused-code.js"
619627
},
620628
"devDependencies": {
621629
"@types/fs-extra": "^11.0.4",

0 commit comments

Comments
 (0)