Code compliance

What is code compliance?

Code Compliance is the phrase used to determine how much the code written within the BHoM framework is in line with the rules/regulations/guidelines of BHoM development. The compliance rules have evolved following the initial ethos of BHoM and been carefully refined as BHoM has developed.

The core of the rules however remains the same - that the code should be architected in such a way to facilitate, and promote, adoption and collaboration by any engineer using the BHoM. The components they see on the UI, should reflect what they can see in the code, the code should be easy to navigate by those wishing to find information, and the style from toolkit to toolkit should be consistent. All of this allows new members of BHoM to quickly get to grips with the basics, and the ability for multiple people to work on multiple toolkits is enhanced as a result.

The rules, regulations, and guidelines set out in this section of the wiki are there to give us reference for writing sustainable, maintainable, and compliant code within the framework of BHoM. They are our standards by which we should all follow.

The compliance laid out in the following pages does undergo periodic review by the DevOps team, as styles develop, and the guidance evolves, so if you feel something isn't quite right or is unclear, please feel free to open a discussion.

Types of compliance

Compliance can be broken into the following categories.

• Code Compliance - this is the compliance of code which is written within the BHoM framework
• Documentation Compliance - this is the compliance of the documentation that aids users and wraps around code
• Project Compliance - this is the compliance of the repository, its associated project files, and planning operations

Compliance results

Compliance results can form one of three outcomes.

• Pass - everything is good, compliant, and meets the guidance available
• Warning - a piece of code is not compliant, but it is deemed not to be so severe as to prevent a PR being merged, but it should be addressed as quick as possible
• Fail - a piece of code is not compliant, and it is critical to resolve it before the PR is merged

Toolkit and Discipline Leads are responsible for deciding whether warning results are acceptable on their toolkit on a case-by-case basis.

Current compliance checks

Correct at time of writing.

Check Severity Compliance Type
Assembly Information Fail Project
AttributeHasEndingPunctuation Warning Documentation
EngineClassMatchesFilePath Fail Code
HasConstructor Fail Code
HasDescriptionAttribute Warning Documentation
HasOneConstructor Fail Code
HasOutputAttribute Warning Documentation
HasPublicGet Fail Code
HasSingleClass Fail Code
HasSingleNamespace Fail Code
HasUniqueOutputAttribute Fail Documentation
HasUniqueMultiOutputAttributes Fail Documentation
HasValidConstructor Fail Code
HasValidOutputAttribute Fail Documentation
HasValidMultiOutputAttributes Fail Documentation
HasValidPreviousVersionAttribute Fail Documentation
InputAttributeHasMatchingParameter Fail Documentation
InputAttributeIsUnique Fail Documentation
InputParameterStartsLower Fail Code
IsDocumentationURLValid Fail Documentation
IsExtensionMethod Fail Code
IsInputAttributePresent Warning Documentation
IsPublicClass Fail Code
IsPublicProperty Fail Code
IsStaticClass Fail Code
IsUsingCustomData Warning Code
IsValidCreateMethod Fail Code
IsValidConvertMethodName Fail Code
IsValidCreateMethodName Fail Code
IsValidDataset Fail Dataset
IsValidEngineClassName Fail Code
IsValidIImmutableObject Fail Code
IsVirtualProperty Fail Code
MethodNameContainsFileName Fail Code
MethodNameStartsUpper Fail Code
ModifyReturnsDifferentType Fail Code
ObjectNameMatchesFileName Fail Code
PreviousInputNamesAttributeHasMatchingParameter Fail Documentation
PreviousInputNamesAttributeIsUnique Fail Documentation
Project References and Build Paths Fail Project
PropertyAccessorsHaveNoBody Fail Code

Last update: March 17, 2023