OrgCheck icon indicating copy to clipboard operation
OrgCheck copied to clipboard

Check for commented code in apex as well in OrgCheck

Open VinceFINET opened this issue 1 year ago • 2 comments

image

Can you do this? Check for commented code????

VinceFINET avatar May 17 '23 20:05 VinceFINET

the minimum I could do is to calculate the percentage of code versus comment. that could be a good start.

VinceFINET avatar May 17 '23 20:05 VinceFINET

SOQL like:

SELECT Id, LengthWithoutComments, body 
FROM ApexClass

Then code like this:

query.forEach(c => { 
    const v = c.LengthWithoutComments !== -1 ? ((c.Body.length-c.LengthWithoutComments)/c.Body.length * 100) : (-1); 
    console.log(c.Id, c.Body.length, c.LengthWithoutComments, v); 
});

That would output something like:

01p3V00000044ywQAA 168 169 -0.5952380952380952
01p3V000001I3zWQAS 503 502 0.19880715705765406
01p3V00000044QzQAI 167 168 -0.5988023952095809
01p3V000000SBZqQAO 219 220 -0.45662100456621
01p3V000000SBZlQAO 468 464 0.8547008547008548
01p3V000000BalqQAC 2036 1779 12.622789783889981
01p3V000000BalrQAC 607 513 15.485996705107082
01p3V000000BaWvQAK 229 194 15.283842794759824
01p3V000000BaX0QAK 104 24 76.92307692307693
01p3V000000BaQnQAK 86 81 5.813953488372093
01p3V000000MErGQAW 817 310 62.0563035495716
...

Needs improvement for sure but that's a start !

I am not answering the question at all. because i can't parse the comments looking for a specific piece of code.... it can be anything so... might be complex to check if comments are actually old code...

VinceFINET avatar May 17 '23 20:05 VinceFINET