anapaulagomes / looong

Discovery of Long Parameter List
Other
16 stars 1 forks source link

Find correlated parameters and suggest possible objects #1

Open anapaulagomes opened 7 years ago

anapaulagomes commented 7 years ago

After finding the top 10 methods with long parameter list smell, we should suggest which objects could be created according to the parameters who appear together. For instance:

Output from Django project with:

method_name [path] [parameters] number_of_parameters
render [tests/repos/django-master/django/shortcuts.py] ['request', 'template_name', 'context', 'content_type', 'status', 'using'] 6
create [tests/repos/django-master/django/contrib/admin/filters.py] ['field', 'request', 'params', 'model', 'model_admin', 'field_path'] 6
kml [tests/repos/django-master/django/contrib/gis/sitemaps/views.py] ['request', 'label', 'model', 'field_name', 'compress', 'using'] 6
run [tests/repos/django-master/django/core/servers/basehttp.py] ['addr', 'port', 'wsgi_handler', 'ipv6', 'threading', 'server_cls'] 6
data [tests/repos/django-master/django/contrib/gis/gdal/raster/band.py] ['data', 'offset', 'size', 'shape', 'as_memoryview'] 5
kmz [tests/repos/django-master/django/contrib/gis/sitemaps/views.py] ['request', 'label', 'model', 'field_name', 'using'] 5
dumps [tests/repos/django-master/django/core/signing.py] ['obj', 'key', 'salt', 'serializer', 'compress'] 5
loads [tests/repos/django-master/django/core/signing.py] ['s', 'key', 'salt', 'serializer', 'max_age'] 5
migrate [tests/repos/django-master/django/db/migrations/executor.py] ['targets', 'plan', 'state', 'fake', 'fake_initial'] 5
connect [tests/repos/django-master/django/db/models/signals.py] ['receiver', 'sender', 'weak', 'dispatch_uid', 'apps'] 5

Goal

Correlated parameters and possible objects:

(request, model)
(field_name, model)
(key, salt, serializer)
ayharano commented 7 years ago

Just trying to understand before digging into code...

anapaulagomes commented 7 years ago

Answering the questions:

anapaulagomes commented 7 years ago

By the way, I'll write more about it on README. Thanks!

ayharano commented 7 years ago
  • I'm not sure if this problem is recurrent in Python but in languages like Java (the language that I was programming at the time I began this little project) methods with long parameter list pointing to a problem with OO principles. One of the approach to solve is creating objects with the parameters that appear more together. Makes sense?

From the README, it wasn't clear that this library should be used as a tool to other languages, not just Python. Having this in mind, I think there are other conditions I should be considering. I still don't know to proceed considering that newly presented context.

I'll just reply about the other bullet points later.

anapaulagomes commented 7 years ago

The idea is making this configurable. But this is an MVP, so we should just think about Python. But I don't see any trouble because in the end the analysis will be made on top of a list of words.