UNPKG

@regele/devtools

Version:

A collection of developer utilities for code processing and text analysis

33 lines (32 loc) 1.13 kB
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 deeply nested code */ export declare class DeepNestingRule extends Rule { readonly id = "maint-deep-nesting"; readonly name = "Deep Nesting"; readonly description = "Detects deeply nested code blocks that reduce readability"; readonly category = CategoryType.Maintainability; 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 reducing nesting * * @param code - Original code * @param depth - Nesting depth * @returns Suggested code */ protected generateSuggestion(_code: string, _depth?: number): string; }