Revisiting technical debt with simple expiry annotations

Managing technical debt is important for the health of all software projects. One way to manage certain types of technical debt is to revisit code and decide if it’s still relevant to the project and to potentially remove it. Doing so can reducing complexity and the amount of code developers are required to maintain.

by
Sam Becker
/ 16 January 2020

To address this we’ve been experimenting with adding simple annotations to code, which indicate an “expiry”. A nudge to developers to go and reevaluate if some bit of code will still be needed at some point in the future. This can be integrated into CI pipelines to fail builds which have outstanding expiry annotations.
Some scenarios where this has proved to be helpful have been:
Removing workarounds in CSS to address bugs in web browsers which have since been fixed.
Removing uninstalled modules, which were required only for hook_uninstall.
Removing code that exists for features which are gradually being superseded, like an organisation gradually migrating content from nodes into a new custom entity.
Here is an real snippet of code we were able to recently delete from a project, based on a bug which was fixed upstream in Firefox. I don’t believe without an explicit prompt to revisit the code, which was introduced many months earlier, we would have been able to confidently clean this up.

// @expire Jan 2020
// Fix a bug in firefox which causes all form elements to match the exact size
// specified in the “size” or “cols” attribute. Firefox probably will have
// fixed this bug by now. Test it by removing the following code and visiting
// the contact form at a small screen size. If the elements dont overflow the
// viewport, the bug is fixed.
.form-text__manual-size {
width: 529px;
@media (max-width: 598px) {
width: 100%;
}
}The code we’ve integrated into our CI pipeline to check these expiry annotations simply greps the code base for strings matching the expiry pattern for the last n months worth of time:

#!/bin/bash

SEARCH_FORMAT=”@expire %s”
DATE_FORMAT=”+%b %Y”
DIRS=”./app/modules/custom/ ./app/themes/”
SEARCH_LAST_N_MONTHS=4

# Cross-platform date formatting with a month offset.
case `uname` in
Darwin)
function date_offset_month() {
date -v $1m “$DATE_FORMAT”;
}
;;
Linux)
function date_offset_month() {
date –d=”$1 month” “$DATE_FORMAT”
}
;;
*)
esac

for i in $(seq 0 $SEARCH_LAST_N_MONTHS); do
FORMATTED_DATE=$(date_offset_month -$i)
SEARCH_STRING=$(printf “$SEARCH_FORMAT” “$FORMATTED_DATE”)
echo “Searching codebase for “$SEARCH_STRING”.”
grep -rni “$SEARCH_STRING” $DIRS && exit 1
done

exit 0


Source: New feed

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Revisiting technical debt with simple expiry annotations

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.