@@ -209,9 +209,7 @@ def visit_functiondef(self, node: nodes.FunctionDef) -> None:
209209 return
210210
211211 # skip functions smaller than 'docstring-min-length'
212- lines = checker_utils .get_node_last_lineno (node ) - node .lineno
213- max_lines = self .linter .config .docstring_min_length
214- if max_lines > - 1 and lines < max_lines :
212+ if self ._is_shorter_than_min_length (node ):
215213 return
216214
217215 self .check_functiondef_params (node , node_doc )
@@ -281,6 +279,10 @@ def visit_raise(self, node: nodes.Raise) -> None:
281279 if not isinstance (func_node , astroid .FunctionDef ):
282280 return
283281
282+ # skip functions smaller than 'docstring-min-length'
283+ if self ._is_shorter_than_min_length (node ):
284+ return
285+
284286 # skip functions that match the 'no-docstring-rgx' config option
285287 no_docstring_rgx = self .linter .config .no_docstring_rgx
286288 if no_docstring_rgx and re .match (no_docstring_rgx , func_node .name ):
@@ -364,6 +366,10 @@ def visit_yield(self, node: nodes.Yield | nodes.YieldFrom) -> None:
364366 if self .linter .config .accept_no_yields_doc :
365367 return
366368
369+ # skip functions smaller than 'docstring-min-length'
370+ if self ._is_shorter_than_min_length (node ):
371+ return
372+
367373 func_node : astroid .FunctionDef = node .frame ()
368374
369375 # skip functions that match the 'no-docstring-rgx' config option
@@ -671,6 +677,22 @@ def _add_raise_message(
671677 confidence = HIGH ,
672678 )
673679
680+ def _is_shorter_than_min_length (self , node : nodes .FunctionDef ) -> bool :
681+ """Returns true on functions smaller than 'docstring-min-length'.
682+
683+ :param node: Node for a function or method definition in the AST
684+ :type node: :class:`astroid.scoped_nodes.Function`
685+
686+ :rtype: bool
687+ """
688+ node_line_count = checker_utils .get_node_last_lineno (node ) - node .lineno
689+ min_lines = self .linter .config .docstring_min_length
690+ result = - 1 < node_line_count < min_lines
691+ assert isinstance (
692+ result , bool
693+ ), "Result of int comparison should have been a boolean"
694+ return result
695+
674696
675697def register (linter : PyLinter ) -> None :
676698 linter .register_checker (DocstringParameterChecker (linter ))
0 commit comments