-
Notifications
You must be signed in to change notification settings - Fork 39
Description
Currently MvnFreeNPathMetric computes a total NPath for all methods in a class.
However, in order to make it usable for real applications, it is necessary to make it format output in a more structured way.
Consider these options below.
Pure text format
- filename
- Class1
- method1 - 1
- method2 - 5
- method3 - 2
- Class2
- method1 - 2
- method2 - 3
- method3 - 1
Nested dictionary
>>> pprint(npath_metric.value())
{
'Class1': {
'method1': 1,
'method2': 5,
'method3': 2,
},
'Class2': {
'method1': 2,
'method2': 3,
'method3': 1,
},
}
Benefits of the nested dictionary format is that:
- it can be used to compute total NPath for a class, highest Npath for a class from a file, etc
- it can be easily re-formatted to a plain text later on, when necessary
However, we need to consider this intention to unify interfaces of Metric and Pattern #813. There it was suggested that the interfaces should produce int as an output, which contradicts this approach of splitting NPath for each method.
@yegor256 please have a look.
Does a nested dictionary format sound like a good idea?
What do you think of the expected output? If it is enforced to be an int, then do we need to produce a total NPath for a whole file? In my opinion, it does not make a clear picture of the metric - it can give high value for a class with many simple methods, which is not reflective of a bad code.
@kodsurfer there is quite some stuff to do.
From the top of my head, currentlyMvnFreeNPathMetricworks fine when it comes to finding a total NPath for all methods in a class (https://github.com/cqfn/aibolit/blob/master/aibolit/metrics/npath/main.py#L93). So, when it comes to computing NPath, it works OK, but the resulting output is probably not what we ultimately expect.It seems reasonable to provide the report on NPath metric for a given file in the following format, maybe:
- filename - Class1 - method1 - 1 - method2 - 5 - method3 - 2 - Class2 - method1 - 2 - method2 - 3 - method3 - 1@yegor256 what's your take on the output format?