  Context: Free and Open Source Software (FOSS) communities' ability to stay
viable and productive over time is pivotal for society as they maintain the
building blocks that digital infrastructure, products, and services depend on.
Sustainability may, however, be characterized from multiple aspects, and less
is known how these aspects interplay and impact community outputs, and software
quality specifically.
  Objective: This study, therefore, aims to empirically explore how the
different aspects of FOSS sustainability impact software quality.
  Method: 16 sustainability metrics across four categories were sampled and
applied to a set of 217 OSS projects sourced from the Apache Software
Foundation Incubator program. The impact of a decline in the sustainability
metrics was analyzed against eight software quality metrics using Bayesian data
analysis, which incorporates probability distributions to represent the
regression coefficients and intercepts.
  Results: Findings suggest that selected sustainability metrics do not
significantly affect defect density or code coverage. However, a positive
impact of community age was observed on specific code quality metrics, such as
risk complexity, number of very large files, and code duplication percentage.
Interestingly, findings show that even when communities are experiencing
sustainability, certain code quality metrics are negatively impacted.
  Conclusion: Findings imply that code quality practices are not consistently
linked to sustainability, and defect management and prevention may be
prioritized over the former. Results suggest that growth, resulting in a more
complex and large codebase, combined with a probable lack of understanding of
code quality standards, may explain the degradation in certain aspects of code
quality.
