Since I acquired entry to the Open AI Codex(by my startup) it has been an excuse to strive some stuff of the facet, and this one positively deserves an article!
Lately I up to date the pipeline with SonarQube to see if could be helpful in the long term. Clearly, when operating it for the primary time you’re going to get a few dozen bugs (if the code base is large enough). In my case was one thing like this:
All of the bugs right here had been trivial to appropriate. Then I acquired the concept “Codex have to have the ability to do that proper? No less than with the fitting tweaking ”. So let’s examine some use circumstances!
Firstly, works higher simply including the minimal needed context, or in different phrases, do not go the complete file, simply the portion of code the place the bug occurs, like a operate. Then, you want the fitting Open Codex setup, in any other case, you’ll not get something helpful. Go to the translate programming languages, and alter to the textual content under:
This is sufficient to give it some context.
That is essentially the most primary of all of them and the picture converse for itself:
This was a replica/previous in fact. by no means noticed such a factor being accomplished!
Now let’s take a look at how Codex solves this:
Seems to be good! It saved the context and the state variable was named in the fitting approach.
This one is extra advanced and requires some tweaking. The issue is easy:
The issue is that the state variable
password begins at undefined (
useState()). So I gave it a run with the complete Hook and acquired this:
No correction! After a few tries, I got here to the answer of giving some apparent clues for the Codex to create a greater context.
So, simply including (password to empty string) does the trick:
As we are able to see, each variables with the “password” within the identify get the empty string.
Now now we have a state of affairs that assures me that I ought to have accomplished this “SonarQube factor” earlier. This generally is a lapse bug, or almost definitely a junior developer making an attempt to close up the compiler.
After a few tries, I used to be in a position to make it work by including the textual content of the bug as a remark in the identical line:
It really works so effectively that it may appropriate the bug and take away the remark!!!
Right here we wish to take away the feedback (code scent), in addition to the bug. This can be a use case that catches a number of the limitations of the Codex. Personally, I used to be not in a position to remedy the code smells. It could possibly be accomplished with time, however most likely in a separate batch, earlier than the bug.
To resolve the bug, including (take away if/else) did the trick.
I began this brainstorm with the query “a easy auto-correct button could possibly be launched utilizing Open AI Codex in SonarQube?”, and my response is a powerful YES. It’s not a trivial characteristic, since a cautious request message must be constructed, however these use circumstances are proof of some potential. Even when some folks would disagree, GTP-4 is on the way in which, with 500x extra parameters.