Closed mr072318 closed 2 years ago
I made a few test and check you regular expression with https://regex101.com/ .
I have the following comments :
/for\s*(.*;.*\(.*\).*;.*).*/g
match the followings expression but shall not : /* for you information; use the new (and not the old); */
for(i=0;i<10;i++) { my_function();}
for (let i= startingindex();i<1000;i++)
(no problem with calling this method startingindex as it will be called once)
if(result.match(/for\s*(.*;.*\(.*\).*;.*).*/g) || result.match(/for\s*(.*\(.*\).*;.*.*;).*/g))
{
++count;
}
Too much false-positives , the followings expressions match but shall not :
for(let in =0; in < 10;in++)
for (let i=2;i<10;i++) if ( in === 2 ) return true;
for (let i=1;i<10;i++) {check_value(i)} // check if value exist in my_function()
/* You have to look for ( in the documentation) */
....
The following method return either 0 either 1 even if there us more than one duplicates. So the message "xxx.css has 1 similar CSS " can be shown even if we have 10 similar css ..
for(let j=0;j<CSSlen;j++)
{
re = new RegExp(CSSPattern[j], 'g');
repeatedCSS = result.match(re);
if(repeatedCSS && repeatedCSS.length>1)
{
count++;
break;
}
}
return count;
{margin-left:10; margin-right:10}
is not detected -> tabs should be considered too
{margin-left:10; /* a css comment about margin */}
match but shall not
Based on the comments made on our previous pull request for the 4 accepted rules https://github.com/cnumr/GreenIT-Analysis/pull/24
We have made the requested changes by you which are:-