priv-kweihmann / multimetric

Calculate code metrics in various languages
zlib License
36 stars 13 forks source link

pylint and coverage #17

Closed ruimaranhao closed 3 years ago

ruimaranhao commented 3 years ago

Hello!

Thanks for this tool: wonderful work!

I do have a question about how pylint and coverage works. Do you have a more exhaustive example?

Thanks, Rui

priv-kweihmann commented 3 years ago

This tool just imitates the same formula used by pylint 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) to calculate a score. The classifications from above forluma are done here https://github.com/priv-kweihmann/multimetric/blob/c3a7cb472d995ecfe4f1ee8f2b08cd8f26af7bde/multimetric/cls/calc/pylint.py#L21

There is no real usage of pylint in the background. Does that answer your question?

ruimaranhao commented 3 years ago

So, one would have to pass the Pylint's report to multimetric, is it?

priv-kweihmann commented 3 years ago

no no, I just found one usage of the coverage information -> https://github.com/priv-kweihmann/multimetric/blob/c3a7cb472d995ecfe4f1ee8f2b08cd8f26af7bde/multimetric/cls/calc/tiobe.py#L42

basically you need to pass a file containing information about the given coverage from any tool you like to this tool. As the README states this can be either a csv or a json

csv: CSV file of following line format
     <file>,<content>,<severity>

json: JSON file
     <file>: {
         "content": <content>,
         "severity": <severity>
     }

which makes it for the case of coverage information something like

file1.c,45.9
file2.h,80.9

or as a json

[
 "file1.c": { "content": 45.9 },
  "file2.h": { "content": 80.9 }
]

where those values are coming from is up to you.

In case you'd like to import from another tool in a different format, I'd happy about PRs :-)

ruimaranhao commented 3 years ago

This is great! Thanks.

Regarding pylint, just checking my understanding: you need to run pylint and map the results to a csv/json in order for it to be used by multimetrics. Is my understanding correct?

priv-kweihmann commented 3 years ago

Correct