mirror of
https://github.com/github/codeql.git
synced 2025-12-28 06:36:33 +01:00
66 lines
1.7 KiB
XML
66 lines
1.7 KiB
XML
<!DOCTYPE qhelp PUBLIC
|
|
"-//Semmle//qhelp//EN"
|
|
"qhelp.dtd">
|
|
<qhelp>
|
|
<overview>
|
|
<p>
|
|
This metric measures the number of statements that occur in a module.
|
|
</p>
|
|
|
|
<p>
|
|
If there are too many statements in a module, it is generally
|
|
for one of two reasons:
|
|
</p>
|
|
|
|
<ul>
|
|
<li>
|
|
One or more individual classes or functions of the module contain too many statements,
|
|
making them hard to understand, difficult to check and a common source of defects
|
|
(particularly towards the end of the class or function, since few people ever read that
|
|
far). These entities typically lack cohesion because they are trying to do too many things.
|
|
</li>
|
|
|
|
<li>
|
|
The module contains too many functions or classes, which generally indicates that it is
|
|
trying to do too much, either at the interface or implementation level or
|
|
both. It can be difficult for readers to understand because there is a
|
|
confusing list of operations.
|
|
</li>
|
|
</ul>
|
|
|
|
</overview>
|
|
<recommendation>
|
|
|
|
<p>
|
|
As described above, modules reported as violations by this rule contain one
|
|
or more classes or functions with too many statements, or the module itself contains
|
|
too many classes or functions. </p>
|
|
|
|
<ul>
|
|
<li>
|
|
Individual classes or functions of the module that contain too many statements
|
|
should be refactored into multiple, smaller parts. As a rough
|
|
guide, functions should be able to fit on a single screen or side of A4. Anything
|
|
longer than that increases the risk of introducing new defects during routine code changes.
|
|
</li>
|
|
|
|
<li>
|
|
Modules that contain too many functions or classes often lack cohesion and are
|
|
prime candidates for refactoring.
|
|
</li>
|
|
</ul>
|
|
|
|
|
|
</recommendation>
|
|
<references>
|
|
|
|
|
|
<li>
|
|
M. Fowler. <em>Refactoring</em>. Addison-Wesley, 1999.
|
|
</li>
|
|
|
|
|
|
|
|
</references>
|
|
</qhelp>
|