Skip to main content

ADR 008: Removing duplicated code and unmaintained libraries

Status: accepted

Context​

In the inherited Open ENT NG code base, a significant amount of code is duplicated across several projects. Cryptography code in particular is repeated in different modules. Some external dependencies, such as the jp.eisbahn.oauth2 library, are no longer maintained.

Problem​

  1. Duplicated code increases maintenance and the risk of inconsistencies and defects when updating.
  2. Unmaintained dependencies expose the platform to unpatched vulnerabilities and to incompatibilities with future versions of tools and frameworks.
  3. Maintenance load slows down new features and can affect overall stability.

Decision​

  1. Centralize and reuse. Identify duplicated code, starting with cryptography, and move it into one internal library, or adopt an existing, well-maintained one.
  2. Replace obsolete dependencies. Replace jp.eisbahn.oauth2 and any other unmaintained dependency with an actively maintained alternative, such as Nimbus JOSE + JWT or the Quarkus OAuth2 client, depending on compatibility and needs.
  3. Automate updates. Use continuous integration and a tool such as Dependabot or Renovate to watch for new versions of libraries and update them regularly.
  4. Audit regularly. Scan dependencies with a tool such as OWASP Dependency-Check or Snyk to detect and fix vulnerabilities in third-party libraries quickly.

Consequences​

  • Less maintenance, with fewer inconsistencies and less update work.
  • Better security, by replacing unmaintained libraries.
  • Easier updates, since dependency updates are automated.
  • Risk of regression when replacing dependencies and centralizing code, which calls for thorough testing.

Next steps​

  1. Audit the code base for every instance of duplicated code.
  2. Compare the maintained alternatives and choose those that fit the current stack.
  3. Refactor to remove duplicated code and obsolete dependencies.
  4. Test the changes thoroughly.
  5. Roll the changes out incrementally.