pytorch / test-infra
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 237 units with 4,009 lines of code in units (56.0% of code).
    • 1 very long units (172 lines of code)
    • 13 long units (816 lines of code)
    • 54 medium size units (1,666 lines of code)
    • 52 small units (745 lines of code)
    • 117 very small units (610 lines of code)
4% | 20% | 41% | 18% | 15%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
ts11% | 21% | 40% | 14% | 12%
tsx0% | 36% | 39% | 17% | 6%
py0% | 4% | 45% | 23% | 26%
js0% | 0% | 0% | 60% | 40%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
torchci/pages17% | 32% | 33% | 11% | 5%
torchci/lib0% | 26% | 41% | 18% | 13%
torchci/components0% | 21% | 48% | 20% | 10%
aws/lambda0% | 7% | 39% | 27% | 24%
torchci/log_classifier0% | 0% | 54% | 17% | 28%
tools/self-hosted-runner-utils0% | 0% | 100% | 0% | 0%
tools/scripts0% | 0% | 30% | 28% | 40%
aws/websites0% | 0% | 0% | 30% | 69%
torchci0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
export default async function handler()
in torchci/pages/api/classifier/rules.ts
172 3 2
97 7 1
function CommitSummaryLine()
in torchci/pages/minihud.tsx
74 5 5
function FailedJob()
in torchci/pages/minihud.tsx
72 5 1
function FailureInfo()
in torchci/pages/failure/[capture].tsx
69 3 4
def lambda_handler()
in aws/lambda/github-status-webhook-handler/lambda_function.py
60 4 2
export default async function fetchCommit()
in torchci/lib/fetchCommit.ts
59 4 1
export function formValidationComment()
in torchci/lib/bot/verifyDisableTestIssueBot.ts
59 7 3
function FilterableHudTable()
in torchci/pages/hud/[repoOwner]/[repoName]/[branch]/[page].tsx
58 7 4
function CommitSummary()
in torchci/pages/minihud.tsx
57 7 1
async function runBotForLabels()
in torchci/lib/bot/autoCcBot.ts
54 11 2
function registerLogLanguage()
in torchci/components/LogViewer.tsx
53 1 1
function genCircleParametersForPush()
in torchci/lib/bot/triggerCircleCIWorkflows.ts
53 10 2
function DisableIssue()
in torchci/components/JobLinks.tsx
51 9 1
def classify()
in torchci/log_classifier/classify_log.py
48 11 2
function filterLog()
in torchci/components/LogViewer.tsx
47 5 1
export default async function handler()
in torchci/pages/api/original_pr_hud/[repoOwner]/[repoName]/[branch]/[page].ts
46 4 2
export default function JobConclusion()
in torchci/components/JobConclusion.tsx
45 9 1
def extract_github_objects()
in aws/lambda/github-webhook-rds-sync/utils.py
45 18 3
function mergeBot()
in torchci/lib/bot/mergeBot.ts
43 3 1