Codium-ai / cover-agent

QodoAI Cover-Agent: An AI-Powered Tool for Automated Test Generation and Code Coverage Enhancement! ๐Ÿ’ป๐Ÿค–๐Ÿงช๐Ÿž
https://qodo.ai/
GNU Affero General Public License v3.0
4.37k stars 327 forks source link

Incorrect Java class name identification #189

Open kevintweber-crandkgroup opened 1 month ago

kevintweber-crandkgroup commented 1 month ago

In the file CoverageProcessor.py and method def extract_package_and_class_java(self), the line of code that identifies the class name is incorrect.

class_pattern = re.compile(r"^\s*public\s+class\s+(\w+).*")

This only handles classes with a single pattern: public class NameOfClass ... Other class declarations are not handled:

Additionally, interfaces can also be tested.

I would recommend modifying the class_pattern to be:

class_pattern = re.compile(r"\s*(class|interface)\s+(\w+).*")

and then match the second group instead of the first.

Additionally, you should get only the first class declaration, which will not pull in inner classes.

Good luck!

-- Kevin

P.S. Great project! Well done.

EmbeddedDevops1 commented 4 weeks ago

@kevintweber-crandkgroup Thank you very much for filing the issue. We'll add this to the queue. If you happen to get to it before us please do open up a Pull Request and add a sample project under templated_tests/.