Placate SonarQube
This should remove the 2 critical issues and enough of the major issues that sonarqube finds to get the sonarqube job to pass.
Sonar will probably complain about this MR about the cognitive complexity of create_association_matrix, but fixing that is beyond the scope of this MR. (The CC of that class should actually be lower than it was though.)