DevOps.com

Where the world meets DevOps

  • Latest
    • Articles
    • Features
    • Most Read
    • News
    • News Releases
  • Topics
    • AI
    • Continuous Delivery
    • Continuous Testing
    • Cloud
    • Culture
    • DevSecOps
    • Enterprise DevOps
    • Leadership Suite
    • DevOps Practice
    • ROELBOB
    • DevOps Toolbox
    • IT as Code
  • DevOps Chats
  • Webinars
    • Upcoming
    • On-Demand Webinars
  • Library
  • Events
    • Virtual Summits
    • Conferences
  • Sponsored Communities
    • CloudBees
    • IT as Code
  • Related Sites
    • MediaOps
    • Container Journal
    • Security Boulevard
    • SweetCode.io
    • Digital Anarchist
    • DevOps TV on YouTube
    • DevOps Chat on SoundCloud
    • DevOps Connect
    • DevOps Dozen
  • Media Kit
  • Follow Us
    • Twitter
    • Google News
    • LinkedIn
    • Facebook
    • DevOps TV on YouTube
    • Email
MENUMENU
  • AI
    • OpsRamp Adds Synthetic Monitoring to AIOps Platform

      OpsRamp Adds Synthetic Monitoring to AIOps Platform

      Micro Focus AI

      Micro Focus Extends AI Testing Tools Reach

      Blue Medora

      VMware’s Blue Medora Buy Advances AIOps

      Eggplant testing

      Eggplant Injects AI Into Application Testing

      Eggplant testing

      Appian Infuses Low-Code Platform With AI

  • Cloud
    • cloud COVID-19

      Cloud Is Red Hot in the COVID-19 Era

      AWS machine learning

      AWS Brings Machine Learning to Code Optimization

      Oracle on-premises

      Cloud Foundry Foundation Updates CLI to Extend DevOps Processes

      ServiceNow Sweagle

      ServiceNow Acquires Sweagle to Advance DevOps Agenda

      HashiCorp Unfurls Cloud Platform for Managed Services

      HashiCorp Unfurls Cloud Platform for Managed Services

  • Continuous Delivery
    • microservices

      How to Use Microservices To Evolve DevOps Pipelines

      JFrog platform

      JFrog Extends Reach and Scope of CI/CD Platform

      CD Foundation

      CD Foundation Touts Spinnaker CD Progress

      Atlassian DevOps

      Atlassian Unfurls Bevy of DevOps Updates

      CircleCI

      CircleCI Extends Core CI/CD Platform

  • Continuous Testing
    • Shift-Right Testing - TestOps

      Shift-Right Testing: The Emergence of TestOps

      What Developers Should Take Away from the Iowa Caucus App Debacle

      What Developers Should Take Away from the Iowa Caucus App Debacle

      survey testing

      Survey Sees Little Progress in Drive to Shift Testing Left

      DevOps Software Testing

      DevOps Places Software Testing in the Crosshairs

      testing

      DevOps Chats: Enterprise Continuous Testing With a Shift-Right Mindset

  • DevSecOps
    • RunSafe

      RunSafe Allies With JFrog to Secure Applications

      distributed tracing

      Traceable Secures Apps Using Distributed Tracing

      vulnerability

      How to Source Vulnerability Data for True DevSecOps

      IaC

      How IaC Bridges the Divide Between DevOps, Security

      ShiftLeft

      ShiftLeft Brings Security Workflows to DevOps Processes

  • Leadership Suite
    • teams scale

      Designing Engineering Teams for Scale

      DevOps

      Has the Pandemic Made DevOps Tougher or Easier?

      project management

      Product vs. Project: Balancing Management Roles for Success

      data people

      Data and Tools Don’t Solve Problems, People Do

      SREs

      SREs Tasked With More To Improve Digital Experiences

  • Practices
    • DevOps

      Solving the DevOps Dilemma in the COVID Era 

      DevOps

      Has the Pandemic Made DevOps Tougher or Easier?

      apps

      Features or Quality? App Survey Shows Surprising Results

      learning DevOps

      Learning DevOps: All You Need Is a Browser

      Keysight Eggplant

      Keysight Technologies Jumps into App Testing by Acquiring Eggplant

  • ROELBOB
    • stars-n-status

      Stars and Status

      email-marketing

      Email Marketing Recipients in the Real World

      abundance-and-scarcity

      Abundance and Scarcity

      defining-value

      Defining Value

      wfh-no-more

      WFH No More

  • Toolbox
    • DevOps

      Solving the DevOps Dilemma in the COVID Era 

      Puppet Relay

      Puppet Launches Relay to Simplify Automating DevOps Workflows

      Pinpoint

      Pinpoint Dives Deeper into Software Delivery Analytics

      Checkmarx, survey, DevOps, AppSec

      Participate in the Checkmarx 2020 Survey

      debugging

      Rookout Extends Reach of Debugging Platform to On-Prem

  • IT as Code
  • More Topics
    • Application Performance Management/Monitoring
    • Culture
    • Enterprise DevOps

Home » Blogs » DevOps Practice » Code Quality Doesn’t Have to Be Like the Weather

Code quality, Clean as You Code

Code Quality Doesn’t Have to Be Like the Weather

By G. Ann Campbell on June 24, 2020 Leave a Comment

Sometimes code quality feels like the weather: everyone talks about it, but no one ever does anything. Of course, that’s not from a lack of good will; most folks would love to have a week or two set aside to just clean things up. Unfortunately, that’s not how the world works. The best course of action is to sneak in a little clean up here, and a little there as part of normal work. Fortunately, that’s actually the best way to go about it. At SonarSource, we call it the Clean as You Code methodology, and we’ve found that this behavioral approach to code quality is as important as the tools developers use to track it. 

Related Posts
  • Code Quality Doesn’t Have to Be Like the Weather
  • The Use of Feature Flags in Code: Too Many Flags?
  • Why 2019 Will Be the Year for Shift-Left Mainframe Testing
    Related Categories
  • Blogs
  • DevOps Practice
  • Doin' DevOps
    Related Topics
  • Clean as You Code
  • code quality
  • developers
  • New Code
  • sub-standard code
  • test coverage
Show more
Show less

The idea behind Clean as You Code is to ignore the quality of old code and focus exclusively on the quality of new changes. This may sound radical, but bear with me. Why focus exclusively on today’s changes? Because dredging up legacy code for the sole purpose of addressing code quality likely requires layers of approvals and perhaps business testing that may be difficult to get. But developers have absolute control over the quality of the code they’re writing now, and they’ll take pride in setting and enforcing high standards for that code. Focusing exclusively on the quality of new code works in both legacy and greenfield projects, and for all quality axes. 

Let’s take test coverage as an example. Many developers are on projects that have lower test coverage than they would like. But stealing an hour here and there to add tests for random methods is generally a frustrating and ultimately futile endeavor. Instead, start with today’s changes. Make sure they’re fully covered and don’t release until they are. That’s it, that’s all that’s required. Covering those one or two methods — or even one or two lines — may feel like a drop in the bucket, but over time it will have a real impact. In fact, that’s been exactly our experience.

Since the early days of my company’s flagship product, we’ve had an internal standard of 80% unit test coverage. And yet in those early days, we routinely released with coverage in the ’60s. There was always the intent to write unit tests, but inevitably it was left to just before release. And then it became a scramble to find the biggest uncovered files and slog through their unfamiliar code to write tests. Among the problems with this approach was the fact that the developer who wrote the code often wasn’t the one who wrote its tests, and thus could never be quite sure of testing the right behavior. And of course, no one likes cleaning up after someone else.

In the end, it was a painful and ultimately ineffective routine; coverage didn’t break 80% until July 2014 — approximately seven years after the project started, and about a year and a half after we first formulated and adopted Clean as You code. You can see the October 2012 inflection point in this graph of project coverage (yes, the first few years of data are missing; victim of an early structural refactoring):

On November 9, 2011 test coverage was at 66.9%. After rising to 70.3% on July 23, 2012 it fell to 69.3% by that October. From that October 2012 inflection point, it climbed steadily for more than three years, crossing the 80% threshold in July 2014. Coverage today is at 86.2%, comfortably above the 80% goal.

Today, we’re at 86% coverage and rising. The formula for getting there was simple: