Automatic Contract Insertion with CCBot
Open Access
- 4 November 2016
- journal article
- research article
- Published by Institute of Electrical and Electronics Engineers (IEEE) in IEEE Transactions on Software Engineering
- Vol. 43 (8) , 701-714
Abstract
Existing static analysis tools require significant programmer effort. On large code bases, static analysis tools produce thousands of warnings. It is unrealistic to expect users to review such a massive list and to manually make changes for each warning. To address this issue we propose CCBot (short for CodeContracts Bot), a new tool that applies the results of static analysis to existing code through automatic code transformation. Specifically, CCBot instruments the code with method preconditions, postconditions, and object invariants which detect faults at runtime or statically using a static contract checker. The only configuration the programmer needs to perform is to give CCBot the file paths to code she wants instrumented. This allows the programmer to adopt contract-based static analysis with little effort. CCBot's instrumented version of the code is guaranteed to compile if the original code did. This guarantee means the programmer can deploy or test the instrumented code immediately without additional manual effort. The inserted contracts can detect common errors such as null pointer dereferences and out-of-bounds array accesses. CCBot is a robust large-scale tool with an open-source C# implementation. We have tested it on real world projects with tens of thousands of lines of code. We discuss several projects as case studies, highlighting undiscovered bugs found by CCBot, including 22 new contracts that were accepted by the project authors.Keywords
Funding Information
- NSF (CNS-1464155)
This publication has 40 references indexed in Scilit:
- Contracts in PracticeLecture Notes in Computer Science, 2014
- Automatic Inference of Necessary Preconditions2013
- Automatic Verification of Advanced Object-Oriented Features: The AutoProof Approach2012
- Inference of Necessary Field Conditions with Abstract InterpretationLecture Notes in Computer Science, 2012
- Static Contract Checking with Abstract InterpretationLecture Notes in Computer Science, 2011
- Invariant Generation in VampireLecture Notes in Computer Science, 2011
- Are Practitioners Writing Contracts?2006
- The Spec# Programming System: An Overview2005
- An overview of JML tools and applicationsInternational Journal on Software Tools for Technology Transfer, 2004
- Houdini, an Annotation Assistant for ESC/Java2001