awsdocs / aws-lambda-developer-guide
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 66 units with 702 lines of code in units (22.4% of code).
    • 0 very long units (0 lines of code)
    • 1 long units (65 lines of code)
    • 7 medium size units (181 lines of code)
    • 16 small units (221 lines of code)
    • 42 very small units (235 lines of code)
0% | 9% | 25% | 31% | 33%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
java0% | 16% | 17% | 23% | 41%
js0% | 0% | 42% | 41% | 16%
cs0% | 0% | 41% | 30% | 28%
go0% | 0% | 0% | 65% | 34%
rb0% | 0% | 0% | 100% | 0%
py0% | 0% | 0% | 0% | 100%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
sample-apps/s3-java0% | 100% | 0% | 0% | 0%
sample-apps/error-processor0% | 0% | 72% | 27% | 0%
sample-apps/ec2-spot0% | 0% | 56% | 21% | 21%
sample-apps/java-basic0% | 0% | 25% | 12% | 62%
sample-apps/java-events0% | 0% | 14% | 35% | 49%
sample-apps/blank-java0% | 0% | 72% | 0% | 27%
sample-apps/nodejs-apig0% | 0% | 0% | 81% | 18%
sample-apps/java-events-v1sdk0% | 0% | 0% | 60% | 40%
sample-apps/blank-go0% | 0% | 0% | 65% | 34%
sample-apps/blank-csharp0% | 0% | 0% | 54% | 45%
sample-apps/blank-ruby0% | 0% | 0% | 100% | 0%
sample-apps/list-manager0% | 0% | 0% | 48% | 52%
sample-apps/blank-python0% | 0% | 0% | 0% | 100%
sample-apps/blank-nodejs0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
public String handleRequest()
in sample-apps/s3-java/src/main/java/example/Handler.java
65 8 2
var getTrace = function()
in sample-apps/error-processor/processor/index.js
44 7 1
public void handleRequest()
in sample-apps/java-basic/src/main/java/example/HandlerStream.java
26 3 3
public async Task FunctionHandler()
in sample-apps/ec2-spot/src/ec2spot/Function.cs
26 3 2
public String handleRequest()
in sample-apps/java-events/src/main/java/example/HandlerCWLogs.java
22 2 2
exports.handler = function()
in sample-apps/error-processor/processor/index.js
21 3 2
public async Task TerminateSpotInstance()
in sample-apps/ec2-spot/src/ec2spot/Function.cs
21 3 1
public String handleRequest()
in sample-apps/blank-java/src/main/java/example/Handler.java
21 3 2
func handleRequest()
in sample-apps/blank-go/function/main.go
19 3 2
public async Task RequestSpotInstance()
in sample-apps/ec2-spot/src/ec2spot/Function.cs
18 1 5
public async Task FunctionHandler()
in sample-apps/blank-csharp/src/blank-csharp/Function.cs
17 2 2
public APIGatewayV2ProxyResponseEvent handleRequest()
in sample-apps/java-events/src/main/java/example/Handler.java
15 1 2
var formatResponse = function()
in sample-apps/nodejs-apig/function/index.js
14 1 1
var getLogStream = function()
in sample-apps/error-processor/processor/index.js
14 2 3
public APIGatewayProxyResponseEvent handleRequest()
in sample-apps/java-events/src/main/java/example/HandlerApiGateway.java
14 1 2
lambda_handler
in sample-apps/blank-ruby/function/lambda_function.rb
14 1 2
public Integer handleRequest()
in sample-apps/java-basic/src/main/java/example/HandlerDivide.java
13 2 2
var formatError = function()
in sample-apps/nodejs-apig/function/index.js
12 1 1
public String handleRequest()
in sample-apps/java-events/src/main/java/example/HandlerDynamoDB.java
12 2 2
public String handleRequest()
in sample-apps/java-events/src/main/java/example/HandlerS3.java
12 1 2