AI commented the entire Spring Boot codebase
github.com
github.com
Comments should be about why the code is doing what it's doing. By definition, this won't be in the code, so the AI cannot divine it to existence.
Readable code is about what the code is doing, which should be apparent from reading the code. This AI tool can be used as a helper for a junior dev or to follow the call stack or code flow.
Maybe AI can do a good job one day when it has the full context of code, i.e requirements docs, transcripts of meetings, emails, JIRA tickets etc.
I don't think that's true.
You're essentially saying that no one other than the original author can possibly add useful comments, and that is manifestly untrue.
It's well within the reach of AI to add comments about how a function is used, and even infer things like "detects errors that might cause an exception to be thrown later".
private void makeAllWarningsFatal(Project project) {
/**
* Makes all warnings fatal for the given project.
*
* @param project the project for which to make warnings fatal
*/
What does this achieve? The code already has readable function names. It just creates clutter and makes things worse by forcing people to scroll more by making less code fit in a window.What would be useful is commenting why a setting to make all warnings fatal is a use case. For example, a comment stating that this is used to improve code quality and reduce risk by forcing the developer to fix all warnings which could be hiding errors. This AI is utterly useless at coming up with that.
Otherwise I agree with you.
State-of-the-art digital solutions to liberate humanity from the tyranny of work.
Maybe this is what will save humans against the robots — the ability to verify and study topics in their context efficiently.
/\**
\* Checks if a library is excluded.
\*
\* @param library the library to check
\* @return true if the library is excluded, false otherwise
\*/
protected boolean isLibraryExcluded(Library library) {
return library.getName().equals("Spring Boot");
}
The comment adds nothing - I'm still confused what this one line function is meant to do or what the word "excluded" means in this context.The thought definitely occurs that whatever comment value can be generated automatically could also (and perhaps should instead) be done locally for the viewer, rather than actually being stored in the codebase. Then it doesn't clutter up the codebase, and also can't get out of sync.
Or since these comments are really JSDoc style comments, they could be applied just before documentation is generated.
a lot of generative AI is like this. Oh, it made a beautiful picture, but why bother saving it, you can just generate a fresh one every time
Also, you can't easily search against those code comments using standard tools.
This is interesting, but a waste .
Skimming through some of the code comments, this tool actually does a pretty good (though not perfect) job of interpreting each function. It would likely need to be limited to only larger functions though, since many of the smaller or boilerplate functions are self-explanatory. And seeing as this is Java, there are a lot of those!
/**
* Returns the type of the artifact release.
* @return the type of the artifact release
*/
public String getType() {
return this.type;
}
But then you also have the following which looks reasonably promising and does contain useful information that you would only get from the code or the docs. /**
* Constructs a new instance of AutoConfigurationMetadata.
*
* This method retrieves the inputs and sets the file path for the
* AutoConfiguration.imports file located in the
* META-INF/spring/org.springframework.boot.autoconfigure directory. The path
* sensitivity is set to RELATIVE and the property name is set to
* "org.springframework.boot.autoconfigure.AutoConfiguration".
*
* The method also sets a dependency on the processResources task name of the source
* set.
*
* Additionally, it creates a configuration named
* "AutoConfigurationPlugin.AUTO_CONFIGURATION_METADATA_CONFIGURATION_NAME" if it does
* not already exist in the project's configurations.
*/
public AutoConfigurationMetadata() {
getInputs()
.file((Callable<File>) () -> new File(this.sourceSet.getOutput().getResourcesDir(),
@@ -68,19 +84,35 @@ public AutoConfigurationMetadata() {
.maybeCreate(AutoConfigurationPlugin.AUTO_CONFIGURATION_METADATA_CONFIGURATION_NAME);
}*Especially for Java which has always tended to be a verbose language that emphasises highly descriptive class and method names.
The idea is interesting but better done as an IDE plugin where I can hover over a method and have it show an auto-generated help popup. I suspect IntelliJ is already working on something like that.
At a glance - and I'm not a java developer - a handful of the comments seem to add some specific context that's not obvious from the code alone: https://github.com/spring-projects/spring-boot/pull/39754/co...
Whether you want every function in the codebase to have a comment is a rather deliberate style, not something you'd just merge in from an unsolicited PR.
But if the tool is automated and easy to use, seems like something useful for local development or a way to shop for good comments that are missing from the code.
Look at this trash:
...
/* * Makes all warnings fatal for the given project. * @param project the project for which to make warnings fatal / private void makeAllWarningsFatal(Project project) { project.getExtensions().getByType(AsciidoctorJExtension.class).fatalWarnings("."); } ...
Quite possibly the most useless javadoc I have seen. Code itself is self documenting. It's like when the developer gets paid per line of code, this is what is generated.
Tell me where it's called from, how often it's called, if the caller can ever send null args, expected execution time, who wrote it, and when, and what else changed when it was first created, whether it is executed under a unit test or functional test.
But please do not tell me what it is doing... That's the one piece of information I don't need since I'm already looking at the code.