awslabs / aws-well-architected-labs
Unit Size

The distribution of size of units (measured in lines of code).

Intro
  • Unit size measurements show the distribution of size of units of code (methods, functions...).
  • Units are classified in four categories based on their size (lines of code): 1-20 (small units), 20-50 (medium size units), 51-100 (long units), 101+ (very long units).
  • You should aim at keeping units small (< 20 lines). Long units may become "bloaters", code that have increased to such gargantuan proportions that they are hard to work with.
Learn more...
Unit Size Overall
  • There are 318 units with 6,669 lines of code in units (15.9% of code).
    • 7 very long units (1,137 lines of code)
    • 18 long units (1,186 lines of code)
    • 84 medium size units (2,358 lines of code)
    • 85 small units (1,243 lines of code)
    • 124 very small units (745 lines of code)
17% | 17% | 35% | 18% | 11%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py14% | 18% | 36% | 19% | 10%
ts97% | 0% | 0% | 0% | 2%
java0% | 47% | 26% | 16% | 9%
cs0% | 24% | 55% | 9% | 10%
js0% | 0% | 36% | 28% | 34%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
static/Reliability12% | 22% | 40% | 11% | 12%
static/Sustainability97% | 0% | 0% | 0% | 2%
static/watool14% | 22% | 35% | 24% | 2%
static/Security86% | 0% | 0% | 9% | 3%
static/Cost0% | 7% | 43% | 26% | 22%
static/Operations0% | 0% | 72% | 27% | 0%
static/Common0% | 0% | 8% | 31% | 59%
static/wapartners0% | 0% | 0% | 70% | 29%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
constructor()
in static/Sustainability/300_cur_reports_as_efficiency_reports/lab3/code/aws-usage-queries.ts
344 1 3
def lensTabCreation()
in static/watool/utilities/Code/exportAnswersToXLSX.py
206 28 8
def lambda_handler()
in static/Reliability/200_Testing_Backup_and_Restore_of_Data/Code/lambda_function.py
137 26 2
def lambda_handler()
in static/watool/200_Manage_Workload_Risks_with_OpsCenter/Code/risk_tracking.py
122 25 2
def lambda_handler()
in static/Security/200_Automated_IAM_User_Cleanup/Code/lambda-iam-user-cleanup.py
117 21 2
def deploy_dms()
in static/Reliability/300_Testing_for_Resiliency_of_EC2_RDS_and_S3/Code/Python/DMSLambda/deploy_dms_lambda.py
109 22 1
def generate_one_record()
in static/Reliability/200_Backup_Restore_Failback_Analytics/Code/src/tweetmaker.py
102 1 1
def deploy_web_servers()
in static/Reliability/300_Testing_for_Resiliency_of_EC2_RDS_and_S3/Code/Python/WebAppLambda/deploy_web_lambda.py
96 13 1
def deploy_read_replica()
in static/Reliability/300_Testing_for_Resiliency_of_EC2_RDS_and_S3/Code/Python/ReadReplicaLambda/deploy_read_replica_lambda.py
84 13 1
def main()
in static/watool/200_Using_AWSCLI_To_Manage_WA_Reviews/Code/LabExample.py
83 4 0
def main()
in static/watool/utilities/Code/exportImportWAFR.py
80 22 0
public void failover()
in static/Reliability/300_Testing_for_Resiliency_of_EC2_RDS_and_S3/Code/FailureSimulations/java/appresiliency/src/main/java/com/app/resiliency/AZFailover.java
79 18 0
def lambda_handler()
in static/watool/200_Manage_Workload_Risks_with_OpsCenter/Code/update_workload.py
72 17 2
def lambda_handler()
in static/Cost/300_Optimization_Data_Collection/Code/source/ecs/ecs.py
68 10 2
def deploy_rds()
in static/Reliability/300_Testing_for_Resiliency_of_EC2_RDS_and_S3/Code/Python/RDSLambda/deploy_rds_lambda.py
66 10 1
def main()
in static/watool/utilities/Code/duplicateWAFR.py
61 19 0
def do_GET()
in static/Reliability/300_Health_Checks_and_Dependencies/Code/Python/server_healthcheck.py
61 12 1
def do_GET()
in static/Reliability/100_Deploy_CloudFormation/Code/Python/server_healthcheck.py
61 12 1
public virtual async Task Failover()
in static/Reliability/300_Testing_for_Resiliency_of_EC2_RDS_and_S3/Code/FailureSimulations/c#/AppResiliency/AppResiliency/AZFailover.cs
60 8 0
def main()
in static/watool/utilities/Code/exportAnswersToXLSX.py
58 20 0