mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C++: Improve the JSF 3.02 rule 1 message, and add a test
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
import cpp
|
||||
|
||||
from Function f
|
||||
where f.getMetrics().getNumberOfLinesOfCode() > 200
|
||||
select f, "AV Rule 1: any one function (or method) will contain no more than 200 logical source lines of code."
|
||||
from Function f, int n
|
||||
where n = f.getMetrics().getNumberOfLinesOfCode()
|
||||
and n > 200
|
||||
select f, "AV Rule 1: any one function (or method) will contain no more than 200 logical source lines of code. Function '" + f.toString() + "' contains " + n.toString() + " lines of code."
|
||||
|
||||
@@ -0,0 +1,611 @@
|
||||
int good1() {
|
||||
good1();
|
||||
}
|
||||
|
||||
int good2() {
|
||||
good2();
|
||||
// 199 bottles of beer on the wall
|
||||
// 198 bottles of beer on the wall
|
||||
// 197 bottles of beer on the wall
|
||||
// 196 bottles of beer on the wall
|
||||
// 195 bottles of beer on the wall
|
||||
// 194 bottles of beer on the wall
|
||||
// 193 bottles of beer on the wall
|
||||
// 192 bottles of beer on the wall
|
||||
// 191 bottles of beer on the wall
|
||||
// 190 bottles of beer on the wall
|
||||
// 189 bottles of beer on the wall
|
||||
// 188 bottles of beer on the wall
|
||||
// 187 bottles of beer on the wall
|
||||
// 186 bottles of beer on the wall
|
||||
// 185 bottles of beer on the wall
|
||||
// 184 bottles of beer on the wall
|
||||
// 183 bottles of beer on the wall
|
||||
// 182 bottles of beer on the wall
|
||||
// 181 bottles of beer on the wall
|
||||
// 180 bottles of beer on the wall
|
||||
// 179 bottles of beer on the wall
|
||||
// 178 bottles of beer on the wall
|
||||
// 177 bottles of beer on the wall
|
||||
// 176 bottles of beer on the wall
|
||||
// 175 bottles of beer on the wall
|
||||
// 174 bottles of beer on the wall
|
||||
// 173 bottles of beer on the wall
|
||||
// 172 bottles of beer on the wall
|
||||
// 171 bottles of beer on the wall
|
||||
// 170 bottles of beer on the wall
|
||||
// 169 bottles of beer on the wall
|
||||
// 168 bottles of beer on the wall
|
||||
// 167 bottles of beer on the wall
|
||||
// 166 bottles of beer on the wall
|
||||
// 165 bottles of beer on the wall
|
||||
// 164 bottles of beer on the wall
|
||||
// 163 bottles of beer on the wall
|
||||
// 162 bottles of beer on the wall
|
||||
// 161 bottles of beer on the wall
|
||||
// 160 bottles of beer on the wall
|
||||
// 159 bottles of beer on the wall
|
||||
// 158 bottles of beer on the wall
|
||||
// 157 bottles of beer on the wall
|
||||
// 156 bottles of beer on the wall
|
||||
// 155 bottles of beer on the wall
|
||||
// 154 bottles of beer on the wall
|
||||
// 153 bottles of beer on the wall
|
||||
// 152 bottles of beer on the wall
|
||||
// 151 bottles of beer on the wall
|
||||
// 150 bottles of beer on the wall
|
||||
// 149 bottles of beer on the wall
|
||||
// 148 bottles of beer on the wall
|
||||
// 147 bottles of beer on the wall
|
||||
// 146 bottles of beer on the wall
|
||||
// 145 bottles of beer on the wall
|
||||
// 144 bottles of beer on the wall
|
||||
// 143 bottles of beer on the wall
|
||||
// 142 bottles of beer on the wall
|
||||
// 141 bottles of beer on the wall
|
||||
// 140 bottles of beer on the wall
|
||||
// 139 bottles of beer on the wall
|
||||
// 138 bottles of beer on the wall
|
||||
// 137 bottles of beer on the wall
|
||||
// 136 bottles of beer on the wall
|
||||
// 135 bottles of beer on the wall
|
||||
// 134 bottles of beer on the wall
|
||||
// 133 bottles of beer on the wall
|
||||
// 132 bottles of beer on the wall
|
||||
// 131 bottles of beer on the wall
|
||||
// 130 bottles of beer on the wall
|
||||
// 129 bottles of beer on the wall
|
||||
// 128 bottles of beer on the wall
|
||||
// 127 bottles of beer on the wall
|
||||
// 126 bottles of beer on the wall
|
||||
// 125 bottles of beer on the wall
|
||||
// 124 bottles of beer on the wall
|
||||
// 123 bottles of beer on the wall
|
||||
// 122 bottles of beer on the wall
|
||||
// 121 bottles of beer on the wall
|
||||
// 120 bottles of beer on the wall
|
||||
// 119 bottles of beer on the wall
|
||||
// 118 bottles of beer on the wall
|
||||
// 117 bottles of beer on the wall
|
||||
// 116 bottles of beer on the wall
|
||||
// 115 bottles of beer on the wall
|
||||
// 114 bottles of beer on the wall
|
||||
// 113 bottles of beer on the wall
|
||||
// 112 bottles of beer on the wall
|
||||
// 111 bottles of beer on the wall
|
||||
// 110 bottles of beer on the wall
|
||||
// 109 bottles of beer on the wall
|
||||
// 108 bottles of beer on the wall
|
||||
// 107 bottles of beer on the wall
|
||||
// 106 bottles of beer on the wall
|
||||
// 105 bottles of beer on the wall
|
||||
// 104 bottles of beer on the wall
|
||||
// 103 bottles of beer on the wall
|
||||
// 102 bottles of beer on the wall
|
||||
// 101 bottles of beer on the wall
|
||||
// 100 bottles of beer on the wall
|
||||
// 99 bottles of beer on the wall
|
||||
// 98 bottles of beer on the wall
|
||||
// 97 bottles of beer on the wall
|
||||
// 96 bottles of beer on the wall
|
||||
// 95 bottles of beer on the wall
|
||||
// 94 bottles of beer on the wall
|
||||
// 93 bottles of beer on the wall
|
||||
// 92 bottles of beer on the wall
|
||||
// 91 bottles of beer on the wall
|
||||
// 90 bottles of beer on the wall
|
||||
// 89 bottles of beer on the wall
|
||||
// 88 bottles of beer on the wall
|
||||
// 87 bottles of beer on the wall
|
||||
// 86 bottles of beer on the wall
|
||||
// 85 bottles of beer on the wall
|
||||
// 84 bottles of beer on the wall
|
||||
// 83 bottles of beer on the wall
|
||||
// 82 bottles of beer on the wall
|
||||
// 81 bottles of beer on the wall
|
||||
// 80 bottles of beer on the wall
|
||||
// 79 bottles of beer on the wall
|
||||
// 78 bottles of beer on the wall
|
||||
// 77 bottles of beer on the wall
|
||||
// 76 bottles of beer on the wall
|
||||
// 75 bottles of beer on the wall
|
||||
// 74 bottles of beer on the wall
|
||||
// 73 bottles of beer on the wall
|
||||
// 72 bottles of beer on the wall
|
||||
// 71 bottles of beer on the wall
|
||||
// 70 bottles of beer on the wall
|
||||
// 69 bottles of beer on the wall
|
||||
// 68 bottles of beer on the wall
|
||||
// 67 bottles of beer on the wall
|
||||
// 66 bottles of beer on the wall
|
||||
// 65 bottles of beer on the wall
|
||||
// 64 bottles of beer on the wall
|
||||
// 63 bottles of beer on the wall
|
||||
// 62 bottles of beer on the wall
|
||||
// 61 bottles of beer on the wall
|
||||
// 60 bottles of beer on the wall
|
||||
// 59 bottles of beer on the wall
|
||||
// 58 bottles of beer on the wall
|
||||
// 57 bottles of beer on the wall
|
||||
// 56 bottles of beer on the wall
|
||||
// 55 bottles of beer on the wall
|
||||
// 54 bottles of beer on the wall
|
||||
// 53 bottles of beer on the wall
|
||||
// 52 bottles of beer on the wall
|
||||
// 51 bottles of beer on the wall
|
||||
// 50 bottles of beer on the wall
|
||||
// 49 bottles of beer on the wall
|
||||
// 48 bottles of beer on the wall
|
||||
// 47 bottles of beer on the wall
|
||||
// 46 bottles of beer on the wall
|
||||
// 45 bottles of beer on the wall
|
||||
// 44 bottles of beer on the wall
|
||||
// 43 bottles of beer on the wall
|
||||
// 42 bottles of beer on the wall
|
||||
// 41 bottles of beer on the wall
|
||||
// 40 bottles of beer on the wall
|
||||
// 39 bottles of beer on the wall
|
||||
// 38 bottles of beer on the wall
|
||||
// 37 bottles of beer on the wall
|
||||
// 36 bottles of beer on the wall
|
||||
// 35 bottles of beer on the wall
|
||||
// 34 bottles of beer on the wall
|
||||
// 33 bottles of beer on the wall
|
||||
// 32 bottles of beer on the wall
|
||||
// 31 bottles of beer on the wall
|
||||
// 30 bottles of beer on the wall
|
||||
// 29 bottles of beer on the wall
|
||||
// 28 bottles of beer on the wall
|
||||
// 27 bottles of beer on the wall
|
||||
// 26 bottles of beer on the wall
|
||||
// 25 bottles of beer on the wall
|
||||
// 24 bottles of beer on the wall
|
||||
// 23 bottles of beer on the wall
|
||||
// 22 bottles of beer on the wall
|
||||
// 21 bottles of beer on the wall
|
||||
// 20 bottles of beer on the wall
|
||||
// 19 bottles of beer on the wall
|
||||
// 18 bottles of beer on the wall
|
||||
// 17 bottles of beer on the wall
|
||||
// 16 bottles of beer on the wall
|
||||
// 15 bottles of beer on the wall
|
||||
// 14 bottles of beer on the wall
|
||||
// 13 bottles of beer on the wall
|
||||
// 12 bottles of beer on the wall
|
||||
// 11 bottles of beer on the wall
|
||||
// 10 bottles of beer on the wall
|
||||
// 9 bottles of beer on the wall
|
||||
// 8 bottles of beer on the wall
|
||||
// 7 bottles of beer on the wall
|
||||
// 6 bottles of beer on the wall
|
||||
// 5 bottles of beer on the wall
|
||||
// 4 bottles of beer on the wall
|
||||
// 3 bottles of beer on the wall
|
||||
// 2 bottles of beer on the wall
|
||||
// 1 bottles of beer on the wall
|
||||
good2();
|
||||
good2();
|
||||
}
|
||||
|
||||
void justStillGood(int x) {
|
||||
justStillGood(2);
|
||||
justStillGood(3);
|
||||
justStillGood(4);
|
||||
justStillGood(5);
|
||||
justStillGood(6);
|
||||
justStillGood(7);
|
||||
justStillGood(8);
|
||||
justStillGood(9);
|
||||
justStillGood(10);
|
||||
justStillGood(11);
|
||||
justStillGood(12);
|
||||
justStillGood(13);
|
||||
justStillGood(14);
|
||||
justStillGood(15);
|
||||
justStillGood(16);
|
||||
justStillGood(17);
|
||||
justStillGood(18);
|
||||
justStillGood(19);
|
||||
justStillGood(20);
|
||||
justStillGood(21);
|
||||
justStillGood(22);
|
||||
justStillGood(23);
|
||||
justStillGood(24);
|
||||
justStillGood(25);
|
||||
justStillGood(26);
|
||||
justStillGood(27);
|
||||
justStillGood(28);
|
||||
justStillGood(29);
|
||||
justStillGood(30);
|
||||
justStillGood(31);
|
||||
justStillGood(32);
|
||||
justStillGood(33);
|
||||
justStillGood(34);
|
||||
justStillGood(35);
|
||||
justStillGood(36);
|
||||
justStillGood(37);
|
||||
justStillGood(38);
|
||||
justStillGood(39);
|
||||
justStillGood(40);
|
||||
justStillGood(41);
|
||||
justStillGood(42);
|
||||
justStillGood(43);
|
||||
justStillGood(44);
|
||||
justStillGood(45);
|
||||
justStillGood(46);
|
||||
justStillGood(47);
|
||||
justStillGood(48);
|
||||
justStillGood(49);
|
||||
justStillGood(50);
|
||||
justStillGood(51);
|
||||
justStillGood(52);
|
||||
justStillGood(53);
|
||||
justStillGood(54);
|
||||
justStillGood(55);
|
||||
justStillGood(56);
|
||||
justStillGood(57);
|
||||
justStillGood(58);
|
||||
justStillGood(59);
|
||||
justStillGood(60);
|
||||
justStillGood(61);
|
||||
justStillGood(62);
|
||||
justStillGood(63);
|
||||
justStillGood(64);
|
||||
justStillGood(65);
|
||||
justStillGood(66);
|
||||
justStillGood(67);
|
||||
justStillGood(68);
|
||||
justStillGood(69);
|
||||
justStillGood(70);
|
||||
justStillGood(71);
|
||||
justStillGood(72);
|
||||
justStillGood(73);
|
||||
justStillGood(74);
|
||||
justStillGood(75);
|
||||
justStillGood(76);
|
||||
justStillGood(77);
|
||||
justStillGood(78);
|
||||
justStillGood(79);
|
||||
justStillGood(80);
|
||||
justStillGood(81);
|
||||
justStillGood(82);
|
||||
justStillGood(83);
|
||||
justStillGood(84);
|
||||
justStillGood(85);
|
||||
justStillGood(86);
|
||||
justStillGood(87);
|
||||
justStillGood(88);
|
||||
justStillGood(89);
|
||||
justStillGood(90);
|
||||
justStillGood(91);
|
||||
justStillGood(92);
|
||||
justStillGood(93);
|
||||
justStillGood(94);
|
||||
justStillGood(95);
|
||||
justStillGood(96);
|
||||
justStillGood(97);
|
||||
justStillGood(98);
|
||||
justStillGood(99);
|
||||
justStillGood(100);
|
||||
justStillGood(101);
|
||||
justStillGood(102);
|
||||
justStillGood(103);
|
||||
justStillGood(104);
|
||||
justStillGood(105);
|
||||
justStillGood(106);
|
||||
justStillGood(107);
|
||||
justStillGood(108);
|
||||
justStillGood(109);
|
||||
justStillGood(110);
|
||||
justStillGood(111);
|
||||
justStillGood(112);
|
||||
justStillGood(113);
|
||||
justStillGood(114);
|
||||
justStillGood(115);
|
||||
justStillGood(116);
|
||||
justStillGood(117);
|
||||
justStillGood(118);
|
||||
justStillGood(119);
|
||||
justStillGood(120);
|
||||
justStillGood(121);
|
||||
justStillGood(122);
|
||||
justStillGood(123);
|
||||
justStillGood(124);
|
||||
justStillGood(125);
|
||||
justStillGood(126);
|
||||
justStillGood(127);
|
||||
justStillGood(128);
|
||||
justStillGood(129);
|
||||
justStillGood(130);
|
||||
justStillGood(131);
|
||||
justStillGood(132);
|
||||
justStillGood(133);
|
||||
justStillGood(134);
|
||||
justStillGood(135);
|
||||
justStillGood(136);
|
||||
justStillGood(137);
|
||||
justStillGood(138);
|
||||
justStillGood(139);
|
||||
justStillGood(140);
|
||||
justStillGood(141);
|
||||
justStillGood(142);
|
||||
justStillGood(143);
|
||||
justStillGood(144);
|
||||
justStillGood(145);
|
||||
justStillGood(146);
|
||||
justStillGood(147);
|
||||
justStillGood(148);
|
||||
justStillGood(149);
|
||||
justStillGood(150);
|
||||
justStillGood(151);
|
||||
justStillGood(152);
|
||||
justStillGood(153);
|
||||
justStillGood(154);
|
||||
justStillGood(155);
|
||||
justStillGood(156);
|
||||
justStillGood(157);
|
||||
justStillGood(158);
|
||||
justStillGood(159);
|
||||
justStillGood(160);
|
||||
justStillGood(161);
|
||||
justStillGood(162);
|
||||
justStillGood(163);
|
||||
justStillGood(164);
|
||||
justStillGood(165);
|
||||
justStillGood(166);
|
||||
justStillGood(167);
|
||||
justStillGood(168);
|
||||
justStillGood(169);
|
||||
justStillGood(170);
|
||||
justStillGood(171);
|
||||
justStillGood(172);
|
||||
justStillGood(173);
|
||||
justStillGood(174);
|
||||
justStillGood(175);
|
||||
justStillGood(176);
|
||||
justStillGood(177);
|
||||
justStillGood(178);
|
||||
justStillGood(179);
|
||||
justStillGood(180);
|
||||
justStillGood(181);
|
||||
justStillGood(182);
|
||||
justStillGood(183);
|
||||
justStillGood(184);
|
||||
justStillGood(185);
|
||||
justStillGood(186);
|
||||
justStillGood(187);
|
||||
justStillGood(188);
|
||||
justStillGood(189);
|
||||
justStillGood(190);
|
||||
justStillGood(191);
|
||||
justStillGood(192);
|
||||
justStillGood(193);
|
||||
justStillGood(194);
|
||||
justStillGood(195);
|
||||
justStillGood(196);
|
||||
justStillGood(197);
|
||||
justStillGood(198);
|
||||
justStillGood(199);
|
||||
}
|
||||
|
||||
void bad(int x) {
|
||||
bad(2);
|
||||
bad(3);
|
||||
bad(4);
|
||||
bad(5);
|
||||
bad(6);
|
||||
bad(7);
|
||||
bad(8);
|
||||
bad(9);
|
||||
bad(10);
|
||||
bad(11);
|
||||
bad(12);
|
||||
bad(13);
|
||||
bad(14);
|
||||
bad(15);
|
||||
bad(16);
|
||||
bad(17);
|
||||
bad(18);
|
||||
bad(19);
|
||||
bad(20);
|
||||
bad(21);
|
||||
bad(22);
|
||||
bad(23);
|
||||
bad(24);
|
||||
bad(25);
|
||||
bad(26);
|
||||
bad(27);
|
||||
bad(28);
|
||||
bad(29);
|
||||
bad(30);
|
||||
bad(31);
|
||||
bad(32);
|
||||
bad(33);
|
||||
bad(34);
|
||||
bad(35);
|
||||
bad(36);
|
||||
bad(37);
|
||||
bad(38);
|
||||
bad(39);
|
||||
bad(40);
|
||||
bad(41);
|
||||
bad(42);
|
||||
bad(43);
|
||||
bad(44);
|
||||
bad(45);
|
||||
bad(46);
|
||||
bad(47);
|
||||
bad(48);
|
||||
bad(49);
|
||||
bad(50);
|
||||
bad(51);
|
||||
bad(52);
|
||||
bad(53);
|
||||
bad(54);
|
||||
bad(55);
|
||||
bad(56);
|
||||
bad(57);
|
||||
bad(58);
|
||||
bad(59);
|
||||
bad(60);
|
||||
bad(61);
|
||||
bad(62);
|
||||
bad(63);
|
||||
bad(64);
|
||||
bad(65);
|
||||
bad(66);
|
||||
bad(67);
|
||||
bad(68);
|
||||
bad(69);
|
||||
bad(70);
|
||||
bad(71);
|
||||
bad(72);
|
||||
bad(73);
|
||||
bad(74);
|
||||
bad(75);
|
||||
bad(76);
|
||||
bad(77);
|
||||
bad(78);
|
||||
bad(79);
|
||||
bad(80);
|
||||
bad(81);
|
||||
bad(82);
|
||||
bad(83);
|
||||
bad(84);
|
||||
bad(85);
|
||||
bad(86);
|
||||
bad(87);
|
||||
bad(88);
|
||||
bad(89);
|
||||
bad(90);
|
||||
bad(91);
|
||||
bad(92);
|
||||
bad(93);
|
||||
bad(94);
|
||||
bad(95);
|
||||
bad(96);
|
||||
bad(97);
|
||||
bad(98);
|
||||
bad(99);
|
||||
bad(100);
|
||||
bad(101);
|
||||
bad(102);
|
||||
bad(103);
|
||||
bad(104);
|
||||
bad(105);
|
||||
bad(106);
|
||||
bad(107);
|
||||
bad(108);
|
||||
bad(109);
|
||||
bad(110);
|
||||
bad(111);
|
||||
bad(112);
|
||||
bad(113);
|
||||
bad(114);
|
||||
bad(115);
|
||||
bad(116);
|
||||
bad(117);
|
||||
bad(118);
|
||||
bad(119);
|
||||
bad(120);
|
||||
bad(121);
|
||||
bad(122);
|
||||
bad(123);
|
||||
bad(124);
|
||||
bad(125);
|
||||
bad(126);
|
||||
bad(127);
|
||||
bad(128);
|
||||
bad(129);
|
||||
bad(130);
|
||||
bad(131);
|
||||
bad(132);
|
||||
bad(133);
|
||||
bad(134);
|
||||
bad(135);
|
||||
bad(136);
|
||||
bad(137);
|
||||
bad(138);
|
||||
bad(139);
|
||||
bad(140);
|
||||
bad(141);
|
||||
bad(142);
|
||||
bad(143);
|
||||
bad(144);
|
||||
bad(145);
|
||||
bad(146);
|
||||
bad(147);
|
||||
bad(148);
|
||||
bad(149);
|
||||
bad(150);
|
||||
bad(151);
|
||||
bad(152);
|
||||
bad(153);
|
||||
bad(154);
|
||||
bad(155);
|
||||
bad(156);
|
||||
bad(157);
|
||||
bad(158);
|
||||
bad(159);
|
||||
bad(160);
|
||||
bad(161);
|
||||
bad(162);
|
||||
bad(163);
|
||||
bad(164);
|
||||
bad(165);
|
||||
bad(166);
|
||||
bad(167);
|
||||
bad(168);
|
||||
bad(169);
|
||||
bad(170);
|
||||
bad(171);
|
||||
bad(172);
|
||||
bad(173);
|
||||
bad(174);
|
||||
bad(175);
|
||||
bad(176);
|
||||
bad(177);
|
||||
bad(178);
|
||||
bad(179);
|
||||
bad(180);
|
||||
bad(181);
|
||||
bad(182);
|
||||
bad(183);
|
||||
bad(184);
|
||||
bad(185);
|
||||
bad(186);
|
||||
bad(187);
|
||||
bad(188);
|
||||
bad(189);
|
||||
bad(190);
|
||||
bad(191);
|
||||
bad(192);
|
||||
bad(193);
|
||||
bad(194);
|
||||
bad(195);
|
||||
bad(196);
|
||||
bad(197);
|
||||
bad(198);
|
||||
bad(199);
|
||||
bad(200);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
| AV Rule 1.c:411:6:411:8 | bad | AV Rule 1: any one function (or method) will contain no more than 200 logical source lines of code. Function 'bad' contains 201 lines of code. |
|
||||
@@ -0,0 +1 @@
|
||||
jsf/3.02 Code Size and Complexity/AV Rule 1.ql
|
||||
Reference in New Issue
Block a user