Professional Documents
Culture Documents
Blocks Pre-Certification Checks Glossary
Blocks Pre-Certification Checks Glossary
The purpose of this document is to provide the reader guidance, and examples, on how to
resolve the errors which are flagged by the Pre-Certification Checklists Analysis tool, that is
automatically run on all Merge Requests raised in a client project for building block development.
This document is owned and maintained by the BX Team.
⚠️ - please DO NOT delete the source branch which the pre-cert tool is triggered on
Frontend Blocks
Builder Guidelines All business logic must be in 1. View files should only contain render
controller files functions that return JSX. Any functions
that contain setState, useState or react
lifecycle methods should be in the
corresponding controller files.
Type of Check Criteria How to resolve
Builder Guidelines All network requests must be 1. There should not no use fetch, axios and
made using runEngine all network requests should be made
through runEngine
Builder Guidelines All css files must be removed 1. There must be no css, sass, scss or less
files under the src folder
Builder Guidelines All index.tsx files must be 1. There must be no index.tsx files under the
removed src folder
Builder Guidelines All navigation must be in 1. There should be no navigation logic inside
controller files the view
Builder Guidelines The config.json for the block must 1. Add all npm dependencies that the block
be correct requires to assembler-dependencies (in the
correct format - see other blocks for
examples)
Type of Check Criteria How to resolve
Builder Guidelines Unit tests must be of a good 1. Each ‘then’ block in the unit test should
quality have an expect inside it
2. Tests should be single responsibility (only
one expect statement inside each test)
3. Tests should not directly call functions on
the component e.g. instance.setState or
instance.doSomething()
Builder Guidelines There should be no hard coded 1. Remove all references to hard coded
backend urls backend domains and just use the API
endpoint when sending requests through
RunEngine. RunEngine automatically uses
the backend domain from the environment
variables if no ‘http’ is included in the
network request
Type of Check Criteria How to resolve
Builder Guidelines There should be no .native.ts(x) 1. Use .web.tsx or .web.ts extensions when
extensions defining the platform for the file
Code Quality Code must not interfere with 1. Remove all eslint_disable and ts-ignores
Typescript compilation or ES Lint
Type of Check Criteria How to resolve
Code Quality Promise chaining must not be 1. Remove all uses of .then() and .catch() in
used your code and switch to using async await
and try {} catch (error) {}
Code Quality Types must be specified 1. All code must be strongly typed with
Typescript. No uses of the word ‘any’ are
allowed
File Structure Both Web and Mobile 1. Check if both .web.tsx and .tsx (mobile)
implementation should be files are present for a building block - in
developed for a Building Block some cases, the feature may not be
compatible to build for both Web and
Mobile hence why this check will only be
flagged as a warning to start with
Pre-cert Execution Error Block’s metadata must be 1. The config.json of the block must exist and
configured correctly (or npm be configured correctly
cache issues) a. All data must be in the correct
format (see other certified blocks for
examples) e.g.
assemblerDependencies,
assemblerDevDependencies,
catalogDependencies etc.
2. Check the logs of the pipeline to see if
there are any npm cache related errors - if
so retrigger the pipeline
Structural All new code must be in the src 1. Ensure that only the allowed files and
folder folders are in the root and that only new
code is in the src folder
Structural There must be only one view per 1. E.g. iCalendarSupportController.tsx can
controller have either or both of iCalendarSupport.tsx
and iCalendarSupport.web.tsx. In
functional components, this equates to
iCalendarSupport.tsx (controller) to either
or both of iCalendarSupportView.tsx and
iCalendarSupportView.web.tsx
Backend Blocks
Report - Not Generated:
- Build failed for branch `BRANCH_NAME`. If the bundle install fails, the message will be sent instead of the table as MR
comment.
Invalid branch Make sure branch name follows the ● Verify building block name in branch
name pattern and includes Building Block name name
Good examples
● view
● index
Bx/Association Make sure parent block does not have Bad and good examples
BlockDependen model association dependent on child
cy block
Bx/MigrationFil Make sure migration filenames end with Rename migration filename to include block suffix
ename a block name suffix
Bad examples
● 20221005143904_create_catalogu
e_variant_sizes.rb
● 20221005143904_bx_block_catalo
gue_create_catalogue_variant_s
izes.rb
Good examples
● 20221005143904_create_catalogu
e_variant_sizes.bx_block_catal
ogue.rb
● 20221005143858_create_accounts
.account_block.rb
● 20221005143855_create_active_s
torage_tables.active_storage.r
b
Bx/MigrationSin Make sure migration modifies only tables Bad and good examples
gleBlock of Building Block specified in file name
Bx/ModelTable Make sure table names start with a block Go to a model and fix self.table_name
Name name using snake convention definition.
File Structure Bx/Namespace Make sure controllers have all their Bad and good examples
dRoute endpoints under the same namespace
File Structure Bx/PathAndMo Make sure classes (models, controllers, Bad and good code examples
duleName services, helpers, and serializers) are
located in correct folders and have
correct module names.
Rules
● If a class has a Building Block in
its path, then it must have a
module with the name of the
Building Block.
● If a class has a module with a
Building Block, then it must have
the Building Block name in its
path.
File Structure Bx/SpecPresen Make sure classes (models, controllers, Bad and good examples
ce and services) are covered with tests.
Rules
● Model must have a spec
spec/models/<BX_BLOCK>/<
MODEL_NAME>_spec.rb
● Service must have a spec
spec/services/<BX_BLOCK>
/<SERVICE_NAME>_spec.rb
● Controller must have a spec
spec/api/<BX_BLOCK>/<MOD
EL_NAME>s_spec.rb
spec/swagger_helper.rb:
● info configuration has title,
version and description.
● openapi version is set to 3.0.1
swagger/v1/swagger.json:
SonarQube Smells Make sure there are NO code smells Bad and good examples
reported by SonarQube in any files of the
client application's template app in
subdirectories named for the block in
question
SonarQube Bugs Make sure there are NO code bugs Bad and good examples
reported by SonarQube in any files of the
client application's template app in
subdirectories named for the block in
question
SonarQube Test Coverage Make sure test coverage of a Building Required minimum is 90%
Block meets minimal required level
Bx/AssociationBlockDependency
Bad example Good example
Rails.application.reloader.to_prepare do
AccountBlock::Account.include(BxBlockExpenses:
:PatchAccountExpensesAssociations)
end
Bx/MigrationSingleBlock
Bad example Good example
# #
20230615055425_change_table_columns.bx_block_w 20230615055425_change_table_columns.bx_block_w
iki.rb iki.rb
class ChangeTableColumns < class ChangeTableColumns <
ActiveRecord::Migration[6.0] ActiveRecord::Migration[6.0]
def change def change
add_column :bx_block_catalogue_review, add_column :bx_block_wiki_pages, :version,
:version, :integer :integer
end end
end end
Bx/NamespacedRoute
Bad example Good example
# config/routes.rb # config/routes.rb
resources :referral_codes, only: :create namespace :bx_block_referrals do
resources :referral_codes, only: :create
# end
controllers/bx_block_referrals/referral_codes_
controller.rb #
module BxBlockReferrals controllers/bx_block_referrals/referral_codes_
class ReferralCodesController < controller.rb
ApplicationController module BxBlockReferrals
def create; end class ReferralCodesController <
end ApplicationController
end def create; end
end
end
# config/routes.rb
namespace :bx_block_wrong do
resources :referral_codes, only: :create
end
#
controllers/bx_block_referrals/referral_codes_
controller.rb
module BxBlockReferrals
class ReferralCodesController <
ApplicationController
def create; end
end
end
# config/routes.rb # config/routes.rb
namespace :bx_block_referrals do namespace :bx_block_referrals do
patch :approve, to: 'referral_codes#approve' resources :referral_codes do
end member do
patch :approve
# end
controllers/bx_block_referrals/referral_codes_ end
controller.rb end
module BxBlockReferrals
class ReferralCodesController < #
ApplicationController controllers/bx_block_referrals/referral_codes_
def approve; end controller.rb
end module BxBlockReferrals
end class ReferralCodesController <
ApplicationController
def approve; end
end
end
Bx/PathAndModuleName
Bad example Good example
# app/models/bx_block_favourites/favourite.rb # app/models/bx_block_favourites/favourite.rb
class Favourite < ApplicationRecord; end module BxBlockFavourites
class Favourite < ApplicationRecord; end
end
# app/models/bx_block_favourites/favourite.rb # app/services/bx_block_sms/send_message.rb
module BxBlockExpenses module BxBlockSms
class Favourite < ApplicationRecord; end class SendMessage; end
end end
# app/services/providers/katrix.rb #
module BxBlockSms app/services/bx_block_sms/providers/katrix.rb
module Providers module BxBlockSms
class Karix; end module Providers
end class Karix; end
end end
end
#
app/services/bx_block_sms/providers/katrix.rb
module Providers
class Karix; end
end
Bx/SpecPresence
Bad example Good example
app/models/bx_block_favourites/favourite.rb app/models/bx_block_favourites/favourite.rb
tested by tested by
spec/models/favourite_spec.rb spec/models/bx_block_favourites/favourite_spec
.rb
app/controllers/bx_block_favourites/favourites app/controllers/bx_block_favourites/favourites
_controller.rb _controller.rb
tested by tested by
spec/controllers/bx_block_favourites/favourite spec/api/bx_block_favourites/favourites_spec.r
s_controller_spec.rb b
app/controllers/bx_block_favourites/favourites app/services/bx_block_sms/provider_service.rb
_controller.rb tested by
tested by spec/services/bx_block_sms/provider_service_sp
spec/api/bx_block_favourites/favourites_contro ec.rb
ller_spec.rb
app/services/bx_block_sms/providers/katrix.rb
tested by
spec/services/bx_block_sms/providers/katrix_sp
ec.rb
Bx/Swagger
Bad example Good example
# #
controllers/bx_block_comments/comments_control controllers/bx_block_comments/comments_control
ler.rb ler.rb
module BxBlockComments module BxBlockComments
class CommentsController < class CommentsController <
ApplicationController ApplicationController
# method with no content would be a code # method with no content would be a code
smell smell
def archive;end def archive
end # adding even a comment should remove
end the ‘smell’
end
end
end
# #
controllers/bx_block_comments/comments_control controllers/bx_block_comments/comments_control
ler.rb ler.rb
module BxBlockComments module BxBlockComments
class CommentsController < class CommentsController <
ApplicationController ApplicationController
# method with no content would be a code # method with no content would be a code
smell smell
def archive def archive
return false if "this can never get reached" == true
if "this can never get reached" == true return false
# do some stuff else
end return false
end end
end end
end end
end