build(clint): remove "function size is too large" warning

This warning is essentially only triggered for ported vim functions.
It's unlikely that we'll refactor vim functions solely based on their
size since it'd mean we'd greatly deviate from vim, which is a high cost
when it comes to importing the vim patches. Thus, this warning only
serves as an annoyance and should be removed.
This commit is contained in:
Dundar Goc 2022-05-06 17:40:52 +02:00
parent d9ec57e16a
commit d0897243f6
10 changed files with 9 additions and 38 deletions

View File

@ -44,7 +44,6 @@ same line, but it is far from perfect (in either direction).
import codecs
import copy
import getopt
import math # for log
import os
import re
import sre_compile
@ -183,7 +182,6 @@ _ERROR_CATEGORIES = [
'readability/alt_tokens',
'readability/bool',
'readability/braces',
'readability/fn_size',
'readability/multiline_comment',
'readability/multiline_string',
'readability/nul',
@ -642,32 +640,6 @@ class _FunctionState:
if self.in_a_function:
self.lines_in_function += 1
def Check(self, error, filename, linenum):
"""Report if too many lines in function body.
Args:
error: The function to call with any errors found.
filename: The name of the current file.
linenum: The number of the line to check.
"""
if Match(r'T(EST|est)', self.current_function):
base_trigger = self._TEST_TRIGGER
else:
base_trigger = self._NORMAL_TRIGGER
trigger = base_trigger * 2**_VerboseLevel()
if self.lines_in_function > trigger:
error_level = int(
math.log(self.lines_in_function / base_trigger, 2))
# 50 => 0, 100 => 1, 200 => 2, 400 => 3, 800 => 4, 1600 => 5, ...
if error_level > 5:
error_level = 5
error(filename, linenum, 'readability/fn_size', error_level,
'Small and focused functions are preferred:'
' %s has %d non-comment lines'
' (error triggered by exceeding %d lines).' % (
self.current_function, self.lines_in_function, trigger))
def End(self):
"""Stop analyzing function body."""
self.in_a_function = False
@ -1887,7 +1859,6 @@ def CheckForFunctionLengths(filename, clean_lines, linenum,
error(filename, linenum, 'readability/fn_size', 5,
'Lint failed to find start of function body.')
elif Match(r'^\}\s*$', line): # function end
function_state.Check(error, filename, linenum)
function_state.End()
elif not Match(r'^\s*$', line):
function_state.Count() # Count non-blank/non-comment lines.

View File

@ -4544,7 +4544,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
}
return width;
} // NOLINT(readability/fn_size)
}
/// Get relative cursor position in window into "buf[buflen]", in the form 99%,
/// using "Top", "Bot" or "All" when appropriate.

View File

@ -1802,7 +1802,7 @@ theend:
xfree(next_line);
xfree(allocated);
return retval;
} // NOLINT(readability/fn_size)
}
/// Delete from cursor to end of line.
/// Caller must have prepared for undo.

View File

@ -2586,7 +2586,7 @@ ret_free:
if (show_block) {
ui_ext_cmdline_block_leave();
}
} // NOLINT(readability/fn_size)
}
/// @return 5 if "p" starts with "<SID>" or "<SNR>" (ignoring case).
/// 2 if "p" starts with "s:".

View File

@ -4467,7 +4467,7 @@ skip:
return preview_buf;
#undef ADJUST_SUB_FIRSTLNUM
#undef PUSH_PREVIEW_LINES
} // NOLINT(readability/fn_size)
}
/// Give message for number of substitutions.
/// Can also be used after a ":global" command.

View File

@ -2219,7 +2219,7 @@ doend:
--ex_nesting_level;
return ea.nextcmd;
} // NOLINT(readability/fn_size)
}
static char ex_error_buf[MSG_BUF_LEN];

View File

@ -3761,7 +3761,7 @@ end:
// If the cursor is past the end of the line put it at the end.
adjust_cursor_eol();
} // NOLINT(readability/fn_size)
}
/*
* When the cursor is on the NUL past the end of the line and it should not be

View File

@ -3382,7 +3382,7 @@ ambw_end:
check_redraw(options[opt_idx].flags);
return errmsg;
} // NOLINT(readability/fn_size)
}
/// Simple int comparison function for use with qsort()
static int int_cmp(const void *a, const void *b)

View File

@ -1748,7 +1748,7 @@ static void win_update(win_T *wp, DecorProviders *providers)
if (!got_int) {
got_int = save_got_int;
}
} // NOLINT(readability/fn_size)
}
/// Returns width of the signcolumn that should be used for the whole window
///

View File

@ -3067,7 +3067,7 @@ viml_pexpr_parse_end:
}
kvi_destroy(ast_stack);
return ast;
} // NOLINT(readability/fn_size)
}
#undef NEW_NODE
#undef HL