Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
b1b83f4
temporary data type fix for multi files
Sevhena Jan 25, 2025
2241185
updated readme with instructions for now
Ayushi1972 Jan 29, 2025
bf49447
fixed issue off highlighting entire line
Sevhena Jan 28, 2025
9b10f82
Updated smell detection functionality
Sevhena Jan 29, 2025
d59509c
Merge branch 'plugin-multi-file' of https://github.com/tbrar06/capsto…
Sevhena Jan 29, 2025
e71d6bf
Made updates to README.md
Sevhena Jan 29, 2025
019d57e
Update README.md
nivethakuruparan Jan 30, 2025
658bf96
bug fixes
Sevhena Jan 30, 2025
0572040
fixed bugs in type definitions
Sevhena Jan 30, 2025
7d6f5e7
Stage 1 adding difference UI
Jan 30, 2025
f3b6251
Merge branch 'plugin-multi-file' of https://github.com/ssm-lab/capsto…
Jan 30, 2025
3afbb70
Fixed smell data mismatch that caused refactorings to fail
Sevhena Jan 30, 2025
f95cd75
started working custom hover message
Ayushi1972 Jan 30, 2025
c3e1cde
changed refactorSmell.ts to refactor selected smell from hover Window
Ayushi1972 Jan 30, 2025
509480e
Fixed smells showing up multiple times in the same hover window
Ayushi1972 Jan 30, 2025
c9a942d
fixed extension.ts for refactorSmell() call
Ayushi1972 Jan 30, 2025
27e9146
refactor all smells of type button works
Ayushi1972 Jan 30, 2025
a02ede4
Merge branch 'plugin-multi-file' of https://github.com/ssm-lab/capsto…
Jan 30, 2025
0c4788b
Moved hashing to utils and added wipe cache cmd
Sevhena Jan 30, 2025
634b4bb
removed silly parameter
Ayushi1972 Jan 30, 2025
cc25823
Merge branch 'plugin-multi-file' of https://github.com/ssm-lab/capsto…
Jan 30, 2025
a6a5702
removed unnecessary parameter
Sevhena Jan 30, 2025
4c2859e
added back fixes that were lost
Sevhena Jan 30, 2025
1159bb7
fixed bug added multiple arrow decorations to multi smell line
Sevhena Jan 31, 2025
7292898
Merge branch 'plugin-multi-file' of https://github.com/ssm-lab/capsto…
Jan 31, 2025
dc0a6c9
Added Refactoring comparison functionality closes #353 in ecooptimize…
Jan 31, 2025
61a39e7
Updated refactoring diff view (ssm-lab/capstone--sco-vs-code-plugin#353)
Sevhena Feb 3, 2025
5cdba76
fixed issue where sidebar reloads on file navigation (ssm-lab/capston…
Sevhena Feb 3, 2025
8304af5
Updated refactor functionality to work with refactoring all smells
Sevhena Feb 3, 2025
123e04f
fixed bug where refactorings were deleted before they could be applied
Sevhena Feb 3, 2025
18226f0
Added functionality to highlight smells in different colours based on…
Sevhena Feb 4, 2025
45430bd
Fixed up refactorSmell not refactoring the selected smell line #345
Ayushi1972 Feb 6, 2025
bc8a385
fixed bug causing sidebar to throw and error after wiping cache
Sevhena Feb 6, 2025
1b80ed1
changed payload to send the actual workspace folder
Sevhena Feb 6, 2025
8650061
fixed refactorings not being applied to original files
Sevhena Feb 6, 2025
dbe1cb9
ssm-lab/capstone--source-code-optimizer#346 added contributes for so…
Feb 8, 2025
9df0642
ssm-lab/capstone--source-code-optimizer#346 added dialog on activate…
Feb 8, 2025
ddffa99
Added functionality for filtering and showing logs
nivethakuruparan Feb 9, 2025
6a0c860
ssm-lab/capstone--source-code-optimizer#346 added warning dialog for…
Feb 9, 2025
e4e618d
ssm-lab/capstone--source-code-optimizer#346 added reminder for missi…
Feb 9, 2025
8e012ce
Edited some setting configs ssm-lab/capstone--source-code-optimizer#346
Sevhena Feb 9, 2025
2d48954
Merge pull request #1 from ssm-lab/nivetha/logging_and_filtering
nivethakuruparan Feb 9, 2025
65e2e34
Merge branch 'plugin-config' into plugin-multi-file
Feb 9, 2025
569e72b
Fixed refactor error msgs and made logging automatic
Sevhena Feb 10, 2025
94f1d7d
ssm-lab/capstone--source-code-optimizer#346 removed unit test path, …
Feb 10, 2025
479f92b
Updated logging to use websockets and store in vscode built-in log dir
Sevhena Feb 17, 2025
59d718c
minor fixes and adjustments
Sevhena Feb 18, 2025
93f2788
fixed server url env variable + added settings popup feature
Sevhena Feb 18, 2025
c37e682
fix: explicitly close websockets on extension disconnect
Sevhena Feb 18, 2025
23fcbea
fixed async file handling
Sevhena Feb 18, 2025
aa0697b
Implement automatic reconnection to backend server
Sevhena Feb 19, 2025
9eb07cd
add eslint config
Sevhena Feb 22, 2025
89546f2
added lint + format pre-commit
Sevhena Feb 22, 2025
8f59f58
updated linting configuration
Sevhena Feb 22, 2025
bd4a09a
fixed issues raised by linter
Sevhena Feb 22, 2025
0c3d60f
linter ignores type def files + stop checking line ending type
Sevhena Feb 22, 2025
0617d35
minor bug fixes
Sevhena Feb 24, 2025
bf4839a
ssm-lab/capstone--source-code-optimizer#385 Added test libraries, set…
Feb 24, 2025
0fb9fc5
setup: configured project for jest testing
Sevhena Mar 1, 2025
00db119
adjusted global type paths
Sevhena Mar 1, 2025
461f6fd
added tests for smellDetection module
Sevhena Mar 1, 2025
42ed14d
ssm-lab/capstone--source-code-optimizer#385 Add unit tests for wipeWo…
Mar 1, 2025
1238f98
Centralized env config mocking
Mar 1, 2025
c53bc6c
Have 2/3 test cases working for hoverManager (#396)
Ayushi1972 Mar 1, 2025
3c48042
Finished hoverManager test cases (#396)
Ayushi1972 Mar 2, 2025
5040c26
Merge branch 'plugin-multi-file' into ayushi/vnvp-hover
Ayushi1972 Mar 2, 2025
f180c01
Merge pull request #2 from ssm-lab/ayushi/vnvp-hover
Ayushi1972 Mar 2, 2025
d234135
Added 4/6 passing test cases for line selection manager (#413)
Ayushi1972 Mar 2, 2025
3400ebb
Finished adding test cases for line selection manager (#413)
Ayushi1972 Mar 2, 2025
4703119
Merge branch 'ayushi/vnvp-lineselection' into plugin-multi-file
Ayushi1972 Mar 2, 2025
cf78358
Added unit tests for fileHighlighter module
Sevhena Mar 3, 2025
eba4711
Added coverage reporting to jest config
Sevhena Mar 3, 2025
a5e18be
Merge branch 'plugin-multi-file' of https://github.com/tbrar06/capsto…
Sevhena Mar 3, 2025
366fe71
Added unit tests for hashing module
Sevhena Mar 3, 2025
808cc93
Changed mention of "Energy Saved" to "Carbon Saved"
Sevhena Mar 5, 2025
b9c34f6
fixed bug that caused race condition when trying to apply a refactori…
Sevhena Mar 7, 2025
2cd44b1
ssm-lab/capstone--source-code-optimizer#445 Added unit tests for api …
Mar 10, 2025
0565e40
Added test for smells filter in settings (https://github.com/ssm-lab/…
nivethakuruparan Mar 10, 2025
8df531d
ssm-lab/capstone--source-code-optimizer#399 Added unit tests for refa…
Mar 10, 2025
5b8b5e0
update webpack config
Sevhena Mar 15, 2025
11297fa
Added jest testing workflow
Sevhena Mar 15, 2025
af9b361
Added test cases for backend
Sevhena Mar 15, 2025
c684c16
Added test cases for refactorSmell command module
Sevhena Mar 15, 2025
b42eb10
updated file coverage config
Sevhena Mar 16, 2025
b39ac41
temporarily omitting sidebar files from coverage
Sevhena Mar 17, 2025
fd8582c
Merge pull request #6 from ssm-lab/plugin-multi-file
Sevhena Mar 17, 2025
d399883
Moved changes to new-toggle-button branch
Mar 17, 2025
87c1f72
Closes ssm-lab/capstone--source-code-optimizer#405
Mar 17, 2025
26655e4
Merge branch 'dev' into new-toggle-button
Mar 17, 2025
cdb98b2
Add file path to avoid tests
Mar 17, 2025
f113976
fixed failing tests + added test for new detection toggle module
Sevhena Mar 18, 2025
277b10c
Merge pull request #7 from ssm-lab/new-toggle-button
mmyaaaaa Mar 18, 2025
55fb8ff
[DEV] Add Smell Customization (#8)
Sevhena Mar 18, 2025
82cda06
Updated log message processing (#9)
Sevhena Mar 18, 2025
e1ca557
[DEV] All Plugin Changes (#12)
Sevhena Apr 3, 2025
3454d50
Merge branch 'main' into dev
Sevhena Apr 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SERVER_URL='127.0.0.1'
HASH_PATH_MAP_KEY='hashPathMap'
SMELL_CACHE_KEY='smellCache'
WORKSPACE_METRICS_DATA='metricsData'
WORKSPACE_CONFIGURED_PATH='workspaceConfiguredPath'
UNFINISHED_REFACTORING='unfinishedRefactoring'
33 changes: 33 additions & 0 deletions .github/workflows/jest-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Jest Tests and Coverage Check

on:
pull_request:
types: [opened, reopened, synchronize]
branches: [dev]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Clean install
run: |
npm ci

- name: Run Jest tests
run: npm test -- --coverage

- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/
71 changes: 52 additions & 19 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,59 @@
name: Publish Extension

on:
push:
branches:
- main
release:
types:
- created
branches: [main]

jobs:
build:
publish:
runs-on: ubuntu-latest
permissions:
contents: write # Needed for tag/release creation
id-token: write # For OIDC auth

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install
- run: npm install @vscode/vsce --save-dev
- name: Publish
if: startsWith(github.ref, 'refs/tags/')
run: npm run deploy
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history needed for tagging

- name: Get version
id: version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "tag_name=v$VERSION" >> $GITHUB_OUTPUT

- name: Create and push tag
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git tag ${{ steps.version.outputs.tag_name }}
git push origin ${{ steps.version.outputs.tag_name }}

- name: Install dependencies
run: |
npm install
npm install -g @vscode/vsce

- name: Package Extension
run: |
mkdir -p dist
vsce package --out ./dist/extension-${{ steps.version.outputs.tag_name }}.vsix

- name: Create Draft Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.tag_name }}
name: ${{ steps.version.outputs.tag_name }}
body: 'Release notes'
files: |
dist/extension-${{ steps.version.outputs.tag_name }}.vsix
draft: true
prerelease: false

- name: Publish to Marketplace
run: |
vsce publish -p $VSCE_PAT
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}

59 changes: 59 additions & 0 deletions .github/workflows/version-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: PR Version Check

on:
pull_request:
branches: [main]

jobs:
validate_version:
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0 # Required for branch comparison

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- run: npm install compare-versions

- name: Get PR version
id: pr_version
run: |
PR_VERSION=$(node -p "require('./package.json').version")
echo "pr_version=$PR_VERSION" >> $GITHUB_OUTPUT

- name: Fetch main branch
run: git fetch origin main

- name: Get main's version
id: main_version
run: |
MAIN_VERSION=$(git show origin/main:package.json | node -p "JSON.parse(require('fs').readFileSync(0)).version")
echo "main_version=$MAIN_VERSION" >> $GITHUB_OUTPUT

- name: Validate version bump
run: |
# Write a temporary Node.js script for version comparison
cat > compare-versions.mjs << 'EOF'
import { compareVersions } from 'compare-versions';

const mainVersion = process.argv[2];
const prVersion = process.argv[3];

console.log("Main version:", mainVersion)
console.log("PR version:", prVersion)

if (compareVersions(prVersion, mainVersion) < 1) {
console.error(`::error::Version ${prVersion} must be greater than ${mainVersion}`);
process.exit(1);
}
EOF

node compare-versions.mjs "${{ steps.main_version.outputs.main_version }}" "${{ steps.pr_version.outputs.pr_version }}"

echo "✓ Version validated"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ dist
node_modules
.vscode-test/
*.vsix
coverage/
.venv/
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
10 changes: 10 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
dist
.vscode
.husky
media
.env
**/*.config.js
**/*.mjs'
**/*d.ts
coverage/
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"bracketSpacing": true,
"printWidth": 85,
"semi": true,
"singleQuote": true,
"endOfLine": "auto",
"tabWidth": 2,
"trailingComma": "all",
"plugins": ["prettier-plugin-tailwindcss"]
}
15 changes: 14 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,18 @@
"dist": true
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
"typescript.tsc.autoDetect": "off",
"cSpell.words": [
"ecooptimizer",
"occurences"
],
"eslint.enable": true,
"eslint.lintTask.enable": true,
"eslint.validate": [
"javascript",
"typescript",
"javascriptreact",
"typescriptreact"
],
"files.eol": "\n",
}
26 changes: 15 additions & 11 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
.vscode/**
.vscode-test/**
out/**
node_modules/**
src/**
.gitignore
.yarnrc
.vscode
node_modules
package-lock.json
tsconfig.json
webpack.config.js
vsc-extension-quickstart.md
**/tsconfig.json
**/eslint.config.mjs
eslint.config.mjs
.prettier*
.gitignore
run/**
.venv/**
test/**
.github/**
.husky/**
coverage/**
**/*.map
**/*.ts
**/.vscode-test.*
.vscode-test.mjs
.env
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Change Log

All notable changes to the "ecooptimizer-vs-code-plugin" extension will be documented in this file.
All notable changes to the "ecooptimizer" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

Expand Down
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Copyright (c) 2024-2025 Ayushi Amin, Mya Hussain, Nivetha Kuruparan, Sevhena Walker, Tanveer Brar

Permission is hereby granted, on a case-by-case basis, to specific individuals or organizations ("Licensee") to use and access the software and associated documentation files (the "Software") strictly for evaluation or development purposes. This permission is non-transferable, non-exclusive, and does not grant the Licensee any rights to modify, merge, publish, distribute, sublicense, sell, or otherwise exploit the Software in any manner without explicit prior written consent from the copyright holder.

Any unauthorized use, modification, distribution, or sale of the Software is strictly prohibited and may result in legal action.

The Software is provided "AS IS," without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, or non-infringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the Software or the use or other dealings in the Software.

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,55 @@
VS Code Plugin for Source Code Optimizer
# EcoOptimizers - Sustainable Python Code Refactoring

EcoOptimizers is a VS Code extension that detects and refactors inefficient Python code, reducing unnecessary computations and lowering CO₂ emissions. By identifying common code smells and providing automated refactoring suggestions, EcoOptimizers helps you write cleaner, more efficient, and environmentally friendly code.

## Features

- **Detect Code Smells** – Automatically analyze your Python code to find inefficiencies.
- **Refactor Code Smells** – Get instant suggestions and apply refactorings with ease.
- **Reduce CO₂ Emissions** – Improve computational efficiency and contribute to a greener future.
- **Seamless VS Code Integration** – Analyze and optimize your code directly within the editor.

## Supported Code Smells

EcoOptimizers detects and refactors the following common code smells:

- **Cache Repeated Calls** – Identifies functions that repeatedly compute the same result and suggests caching techniques.
- **Long Lambda Functions** – Flags excessively long lambda expressions and converts them into named functions for readability and maintainability.
- **Use A Generator** – Suggests using generators instead of list comprehensions for memory efficiency.
- **Long Element Chain** – Detects deeply nested attribute accesses and recommends breaking them into intermediate variables for clarity.
- **Member Ignoring Method** – Identifies methods that do not use their class members and suggests converting them into static methods or external functions.
- **Long Message Chains** – Finds excessive method chaining and refactors them for better readability.
- **String Concatenation in Loop** – Detects inefficient string concatenation inside loops and suggests using lists or other optimized methods.
- **Long Parameter List** – Flags functions with too many parameters and suggests refactoring strategies such as grouping related parameters into objects.

## How It Works

1. **Detect Smells** – Run the EcoOptimizers analysis tool to scan your code for inefficiencies.
2. **Refactor Suggestions** – View recommended changes and apply them with a click.
3. **Optimize Your Code** – Enjoy cleaner, more efficient Python code with reduced computational overhead.

## Demo Videos

Watch EcoOptimizers in action:

- [Detecting Code Smells](https://drive.google.com/file/d/1Uyz0fpqjWVZVe_WXuJLB0bTtzOvjhefu/view?usp=sharing) 🔍
- [Refactoring Code Smells](https://drive.google.com/file/d/1LQFdnKhuZ7nQGFEXZl3HQtF3TFgMJr6F/view?usp=sharing) 🔧

## Installation

1. Open VS Code.
2. Go to the Extensions Marketplace.
3. Search for **EcoOptimizers**.
4. Click **Install**.
5. Intall the `ecooptimizer` python package.
- run: `pip install ecooptimizer`
- run: `eco-ext`
6. Start optimizing your Python code!

## Contribute

EcoOptimizers is open-source! Help improve the extension by contributing to our GitHub repository: [GitHub Repository](https://github.com/ssm-lab/capstone--source-code-optimizer)

---

🚀 Start writing cleaner, more efficient Python code today with EcoOptimizers!
Binary file added assets/black_leaf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/darkgreen_leaf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/eco-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/eco_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/green_leaf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/white_leaf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading