-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bear to validate functions #2354
Comments
That sounds awesome, but also pretty hard :D Maybe we can somehow detect such code parts with code-complexity analysis? |
I am glad you liked the idea @Makman2 I will do some research on its implementation and get back to you. :) |
|
@Makman2 @jayvdb Here are some parameter based on which we could judge the complexity of any function:
By considering these factors and maybe assigning different weights/measure of severity to each one of these, we can identify complex functions and suggest splitting. |
which languages are you considering targeting with this bear? C/C++/etc should be done based on the Clang bears. Python, IMO, should wait until the Python AST project is completed. If you are intending to make it very generic, supporting any language, then the extraction of function metadata in a generic manner is going to be the very hard part, and that should be a project over in the coala core projects' language definitions area. |
@kriti21 How do you plan to judge if a function is solving a specific task? also, how do you plan to know what actual task function is supposed to do? Can you explain broadly (I'm assuming you plan to solve it generically)? because it seems somewhat infeasible to me without AST or some other complexity. |
I was targeting on C++ and Python for now. But in the long run, I would like to be very generic. @jayvdb |
I don't think this is possible unless using some really complex methods or tools. Based on #2354 (comment) these parameters though, we could only judge the complexity to some extent. How many tasks a particular function does is really dependent on the code and language used. @aptrishu |
Yeah, That is why I thought, it would not be possible as a generic bear. because judging what specific tasks a function is doing is pretty complex. |
Frankly, Python is too hard. Even C++ is very hard, but thanks to CLangBear you can take advantage of a very good ast on which to build a bear, and it can be generic across a large group of languages. |
@kriti21 first of all cool idea 👍 secondly rather than a bear (which seems impractical as this idea is too big and complex to be implemented as a generic bear) maybe you should focus on building an API for it something like a |
Yeah let's start with a specific language and then try to develop more generic techniques. As we have Clang stuff like @jayvdb mentioned, we might start there, so we can focus on the actual logic 👍 |
A generic bear that would check if the functions in a program file are of some reasonable length and solve one specific purpose. It would suggest if a long function can be split into two or more smaller ones.
Tags: bear-proposal, generic-bears
The text was updated successfully, but these errors were encountered: