* Update information of the code path segment when a code path was * looped. * @param {CodePathSegment} fromSegment The code path segment of the * end of a loop. * @param {CodePathSegment} toSegment A code path segment of the head * of a loop. * @returns {void}
(fromSegment, toSegment)
| 332 | * @returns {void} |
| 333 | */ |
| 334 | onCodePathSegmentLoop(fromSegment, toSegment) { |
| 335 | if (!(funcInfo.isConstructor && funcInfo.hasExtends)) { |
| 336 | return; |
| 337 | } |
| 338 | |
| 339 | funcInfo.codePath.traverseSegments( |
| 340 | { first: toSegment, last: fromSegment }, |
| 341 | (segment, controller) => { |
| 342 | const info = segInfoMap[segment.id]; |
| 343 | |
| 344 | // skip segments after the loop |
| 345 | if (!info) { |
| 346 | controller.skip(); |
| 347 | return; |
| 348 | } |
| 349 | |
| 350 | const seenPrevSegments = |
| 351 | segment.prevSegments.filter(hasSegmentBeenSeen); |
| 352 | const calledInSomePreviousPaths = |
| 353 | seenPrevSegments.some(isCalledInSomePath); |
| 354 | const calledInEveryPreviousPaths = |
| 355 | seenPrevSegments.every(isCalledInEveryPath); |
| 356 | |
| 357 | info.calledInSomePaths ||= calledInSomePreviousPaths; |
| 358 | info.calledInEveryPaths ||= calledInEveryPreviousPaths; |
| 359 | |
| 360 | // If flags become true anew, reports the valid nodes. |
| 361 | if (calledInSomePreviousPaths) { |
| 362 | const nodes = info.validNodes; |
| 363 | |
| 364 | info.validNodes = []; |
| 365 | |
| 366 | for (let i = 0; i < nodes.length; ++i) { |
| 367 | const node = nodes[i]; |
| 368 | |
| 369 | context.report({ |
| 370 | messageId: "duplicate", |
| 371 | node, |
| 372 | }); |
| 373 | } |
| 374 | } |
| 375 | }, |
| 376 | ); |
| 377 | }, |
| 378 | |
| 379 | /** |
| 380 | * Checks for a call of `super()`. |
nothing calls this directly
no test coverage detected
searching dependent graphs…