Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Cyclomatic complexity
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Correlation to number of defects=== Multiple studies have investigated the correlation between McCabe's cyclomatic complexity number with the frequency of defects occurring in a function or method.<ref name="fenton">{{cite journal |journal=IEEE Transactions on Software Engineering|author1=Norman E Fenton |author2=Martin Neil | url=http://www.eecs.qmul.ac.uk/~norman/papers/defects_prediction_preprint105579.pdf| title=A Critique of Software Defect Prediction Models| year=1999|volume=25|issue=3|pages=675β689|doi=10.1109/32.815326|citeseerx=10.1.1.548.2998 }}</ref> Some studies<ref name="schroeder99">{{cite journal| title=A Practical guide to object-oriented metrics|author=Schroeder, Mark|s2cid=14945518|year=1999|volume=1|issue=6|pages=30β36|journal=IT Professional |doi=10.1109/6294.806902}}</ref> find a positive correlation between cyclomatic complexity and defects; functions and methods that have the highest complexity tend to also contain the most defects. However, the correlation between cyclomatic complexity and program size (typically measured in [[lines of code]]) has been demonstrated many times. [[Les Hatton]] has claimed<ref name="taic"> {{cite web |url=http://www.leshatton.org/TAIC2008-29-08-2008.html |title=The role of empiricism in improving the reliability of future software |author=Les Hatton |year=2008 |at=version 1.1}}</ref> that complexity has the same predictive ability as lines of code. Studies that controlled for program size (i.e., comparing modules that have different complexities but similar size) are generally less conclusive, with many finding no significant correlation, while others do find correlation. Some researchers question the validity of the methods used by the studies finding no correlation.<ref name="kan"> {{cite book |title=Metrics and Models in Software Quality Engineering |author=Kan |pages=316β317 |publisher=Addison-Wesley |year=2003 |isbn=978-0-201-72915-3}}</ref> Although this relation likely exists, it is not easily used in practice.<ref name=cherf>{{cite journal| journal=Journal of Software Quality| author=G.S. Cherf| title=An Investigation of the Maintenance and Support Characteristics of Commercial Software| year=1992|volume=1|issue=3|pages=147β158| issn=1573-1367|doi=10.1007/bf01720922| s2cid=37274091}}</ref> Since program size is not a controllable feature of commercial software, the usefulness of McCabe's number has been questioned.<ref name="fenton" /> The essence of this observation is that larger programs tend to be more complex and to have more defects. Reducing the cyclomatic complexity of code is [[correlation does not imply causation|not proven]] to reduce the number of errors or bugs in that code. International safety standards like [[ISO 26262]], however, mandate coding guidelines that enforce low code complexity.<ref name="ISO26262Part3">{{cite book | title =ISO 26262-3:2011(en) Road vehicles β Functional safety β Part 3: Concept phase| publisher =International Standardization Organization | url =https://www.iso.org/obp/ui/#iso:std:iso:26262:-3:ed-1:v1:en}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)