CodeGPT icon indicating copy to clipboard operation
CodeGPT copied to clipboard

New option to scan the code in the main window after every 25 new lines are added

Open nimi73 opened this issue 2 years ago • 1 comments
trafficstars

Describe the need of your request

I am using codegpt for security vulnerability scanning. I have to manually select the code after every few lines and then send it for scanning by selecting my custom prompt from the dropdown menu (the one which opens after right-clicking the selected code).

Proposed solution

instead of manually selecting the code and then sending it to codegpt, i want codegpt to scan it in the background and on the go, after i write 25 or 50 lines of code. it will scan the entire code after every time 25 lines are added. if any vulnerabilities are found it will popup in the window.

Additional context

please help me make this possible

nimi73 avatar Sep 02 '23 17:09 nimi73

In theory, it should be possible to listen for change events and trigger certain actions based on those events:

public class CodeChangeListener implements BulkFileListener {

  private final ChangeListManager changeListManager;

  public CodeChangeListener(Project project) {
    this.changeListManager = ChangeListManager.getInstance(project);
  }

  @Override
  public void after(@NotNull List<? extends VFileEvent> events) {
    for (VFileEvent event : events) {
      Optional.ofNullable(event.getFile())
          .map(changeListManager::getChange)
          .ifPresent(change -> {
            switch (change.getFileStatus().getId()) {
              case "ADDED":
                // process new file
              case "MODIFIED":
                // process modified file
              case "DELETED":
                // process deleted file
              default:
                break;
            }
          });
    }
  }
}

However, I'm not sure how this would actually work in practice, nor how to prompt the model or process the response. Having a one-shot example prompt would be useful for prototyping

carlrobertoh avatar Nov 26 '23 23:11 carlrobertoh

This is a really cool idea! I have been longing for an assistant that is more of an actual copilot (double-checking me and offering improvements) and less of a backseat driver (constantly telling me what I should probably do next).

UX-wise it would be important that any remarks it has should not interrupt my coding flow but can be dealt with asynchronously when I want to revisit and review my written code.

ralfstrobel avatar Oct 11 '24 14:10 ralfstrobel