priv-kweihmann/multimetric

ZeroDivisionError: float division by zero

Closed this issue Β· 4 comments

Hi, I have this problem when I try to test JS code, for example:

$ multimetric test.js
source code

`//π•‚π•–π•§π•šπ•Ÿ π”Έπ•π•–π•›π•’π•Ÿπ••π•£π•  𝕍𝕖𝕝𝕖𝕫 π”Έπ•˜π•¦π••π•–π•π• - π•œπ•–π•§π•šπ•Ÿ.π•’π•π•–π•›π•’π•Ÿπ••π•£π• .𝕧𝕖𝕝𝕖𝕫@π•”π• π•£π•£π•–π• π•¦π•Ÿπ•šπ•§π•’π•π•π•–.𝕖𝕕𝕦.𝕔𝕠- πŸšπŸ˜πŸšπŸ™πŸšπŸ›πŸšπŸ πŸ™ - πŸ›πŸŸπŸœπŸ›

    /*
    Proposito: Esta funcion nos mostrara en consola la union de dos listas, a este proceso se le llama concataciΓ³n
    Contrato: list -> list
    Prototipo: concat(listaa, listab)
    ejemplos:  concat([],[]) -> []
               concat([],[1, 2]) -> [1,2]
               concat([3,5], []) -> [3,5]

    */
    const {cons, first, rest, isEmpty, isList, length} = require('functional-light');

    function concat(listaa,listab){
      if(isEmpty(listaa)){
        return listab;
      }else if(isEmpty(listab)){
        return listaa;
      }else if(isEmpty(listaa) && isEmpty(listab)){
        return [];
      }else{
        return cons(first(listaa),concat(rest(listaa),listab));
      }
    }
    console.log(concat([],[]));
    console.log(concat([],[1, 2]));
    console.log(concat([3,5], []));
    console.log(concat([1,2,true], ['FDP',3,8,2,7]));`

output:

Traceback (most recent call last):
File "/home/lstiven/Documents/multimetric/venv/bin/multimetric", line 8, in
sys.exit(main())
File "/home/lstiven/Documents/multimetric/venv/lib/python3.8/site-packages/multimetric/main.py", line 146, in main
_result["overall"].update(y.get_results_global([x[4] for x in results]))
File "/home/lstiven/Documents/multimetric/venv/lib/python3.8/site-packages/multimetric/cls/metric/comments.py", line 54, in get_results_global
MetricBaseComments.METRIC_COMMENT_RATIO: __comments * 100.0 / float(__overall)
ZeroDivisionError: float division by zero

What is the problem?
thanks for your time (sorry for my English)

The problem is that __overall is zero in this case πŸ˜„ - so much for the obvious... it's a bug and needs to be fixed. Will spin up a fix later that week

The problem is that __overall is zero in this case πŸ˜„ - so much for the obvious... it's a bug and needs to be fixed. Will spin up a fix later that week

thanks for answering.
I noticed something and it may be relevant (I hope so), when the source code has special characteres like in the example code:
//π•‚π•–π•§π•šπ•Ÿ π”Έπ•π•–π•›π•’π•Ÿπ••π•£π•  𝕍𝕖𝕝𝕖𝕫 π”Έπ•˜π•¦π••π•–π•π• - π•œπ•–π•§π•šπ•Ÿ.π•’π•π•–π•›π•’π•Ÿπ••π•£π• .𝕧𝕖𝕝𝕖𝕫@π•”π• π•£π•£π•–π• π•¦π•Ÿπ•šπ•§π•’π•π•π•–.𝕖𝕕𝕦.𝕔𝕠- πŸšπŸ˜πŸšπŸ™πŸšπŸ›πŸšπŸ πŸ™ - πŸ›πŸŸπŸœπŸ›
or emojis, etc in the comments the error ocurrs. When source code is "clean"(in comments) no errors appear.

hmmm, so it might be an issue of character encoding... currently the lib does use chardet for that, so likely all the character encoding shouldn't be the problem... anyway the issue should be fixed now

Again, thanks for answering and for your time, I am currently using your tool in a section of my degree work.