@regele/devtools
Version:
A collection of developer utilities for code processing and text analysis
32 lines (31 loc) • 1.1 kB
TypeScript
import * as parser from '@babel/parser';
import * as t from '@babel/types';
import { Rule } from '../rule';
import { CategoryType, CodeFinding, SeverityLevel } from '../../types';
/**
* Rule to detect nested loops that could be optimized
*/
export declare class NestedLoopsRule extends Rule {
readonly id = "perf-nested-loops";
readonly name = "Nested Loops";
readonly description = "Detects nested loops that could be optimized for better performance";
readonly category = CategoryType.Performance;
readonly defaultSeverity = SeverityLevel.Warning;
readonly requiresAST = true;
/**
* Apply the rule to the given code
*
* @param code - Source code
* @param ast - Parsed AST
* @param filePath - Path to the file
* @returns Array of findings
*/
apply(code: string, ast: parser.ParseResult<t.File>, filePath: string): CodeFinding[];
/**
* Generate a suggestion for optimizing nested loops
*
* @param code - Original code
* @returns Suggested code
*/
protected generateSuggestion(_code: string): string;
}