Skip to content

Identify empty function blocks as code generation tasks - MVC

We want to identify freshly started functions which are empty and route such requests to our code generation model

e.g:

const validateCountryCode = (countryCode) => {}

becomes then (real model response)

const validateCountryCode = (countryCode) => {
  // Check if the country code is a valid ISO 3166-1 alpha-2 code
  if (!/^[A-Z]{2}$/.test(countryCode)) {
    return false;
  }

  // Check if the country code is a valid country
  if (!Object.keys(countries).includes(countryCode)) {
    return false;
  }

  return true;
};

Proposal

In the initial solution, let's use regex to identify function signatures in the following languages (in rough order of importance):

Stretch Goals

This list is from our current usage (see this comment) and the top languages at GitLab (see this dashboard)

Edited by Tim Zallmann