'use strict';
import { ESLintUtils } from '@typescript-eslint/utils';
import { createNodeVisitor, nodeTypes, isMethodFunction, countFunctionLines } from '@flint/infra/analysis';
import { ruleTypes, url, ruleMessageIds } from '@flint/infra/constants/rules-meta';
import { firstOrUndefined } from '../../../fd-toolbox/server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0x5176ec,_0x44fd7a)=>__defProp(_0x5176ec,'name',{'value':_0x44fd7a,'configurable':!![]});const ruleName='max-lines-per-function';const constants={'defaultMaxLines':0x3c,'meta':{'type':ruleTypes['suggestion'],'docs':{'description':'Sets\x20the\x20maximum\x20number\x20of\x20lines\x20that\x20a\x20single\x20function\x20can\x20contain,\x20excluding\x20lines\x20with\x20parameters,\x20the\x20return\x20statement,\x20comments,\x20and\x20empty\x20lines'},'messages':{'tooManyLines':ruleName+'\x0aFunction\x20has\x20too\x20many\x20lines\x20({{lineCount}}).\x20Maximum\x20allowed\x20is\x20{{maxLines}}.\x0a\x0a###\x20**Must**\x20limit\x20the\x20number\x20of\x20lines\x20in\x20a\x20function\x20body.\x0a\x0a####\x20Wrong\x0a\x0afunction\x20Fun()\x20{\x0a\x20\x20\x20\x20const\x20a\x20=\x201;\x0a\x20\x20\x20\x20const\x20b\x20=\x202;\x0a\x20\x20\x20\x20//\x20...\x0a\x20\x20\x20\x20//\x20(More\x20than\x20{{maxLines}}\x20lines\x20in\x20function)\x0a\x20\x20\x20\x20return\x20a;\x0a}\x0a\x0a####\x20Correct\x0a\x0afunction\x20Fun()\x20{\x0a\x20\x20\x20\x20return\x201;\x0a}\x0a\x0a####\x20Why\x0a\x0aLimiting\x20function\x20length\x20improves\x20code\x20readability\x20and\x20maintainability.\x20It\x20encourages\x20developers\x20to\x20break\x20complex\x20logic\x20into\x20smaller,\x20reusable\x20functions.'},'schema':[{'type':'object','properties':{'maxLines':{'type':'number','minimum':0x0}},'additionalProperties':![]}]}},createRule=ESLintUtils['RuleCreator'](_0x1a01fd=>''+url+_0x1a01fd),maxLinesPerFunction=createRule({'name':ruleName,'meta':constants['meta'],'create'(_0x1cf37e){const _0x5d0261=_0x1cf37e['sourceCode'],_0x46b9f8=firstOrUndefined(_0x1cf37e['options'])??{'maxLines':constants['defaultMaxLines']},_0x5702b4=_0x46b9f8['maxLines'];return {...createNodeVisitor(_0x5d7412=>checkFunction(_0x5d7412,_0x1cf37e,_0x5d0261,_0x5702b4),[nodeTypes['functionDeclaration'],nodeTypes['functionExpression'],nodeTypes['arrowFunctionExpression'],nodeTypes['methodDefinition']])};},'defaultOptions':[{'maxLines':constants['defaultMaxLines']}]});function checkFunction(_0x56b9f8,_0xf7bff8,_0x4782dc,_0x267b37){if((_0x56b9f8['type']===nodeTypes['functionExpression']||_0x56b9f8['type']===nodeTypes['arrowFunctionExpression'])&&isMethodFunction(_0x56b9f8))return;const _0x267140=countFunctionLines(_0x56b9f8,_0x4782dc);_0x267140>_0x267b37&&_0xf7bff8['report']({'node':_0x56b9f8,'messageId':ruleMessageIds['tooManyLines'],'data':{'lineCount':_0x267140['toString'](),'maxLines':_0x267b37['toString']()}});}__name(checkFunction,'checkFunction');

export { maxLinesPerFunction as default, ruleName };
