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.
"If you have to spend effort into looking at a fragment of code to figure out what it's doing, then you should extract it into a function and name the function after that 'what'."
"Use common sense, stick to small function sizes in most instances but don't be dogmatic about it if you have a genuinely good reason to make an unusually big function."
"All other things being equal, a shorter method is easier to read, easier to understand, and easier to troubleshoot. Refactor long methods into smaller methods if you can."
"The first rule of functions is that they should be small. The second rule of functions is that they should be smaller than that. Functions should not be 100 lines long. Functions should hardly ever be 20 lines long."
Unit Size Overall
There are 10,278 units with 134,889 lines of code in units (71.4% of code).
def main() in reinforcement_learning/rl_deepracer_robomaker_coach_gazebo/src/markov/rollout_worker.py
309
25
0
def main() in reinforcement_learning/rl_deepracer_robomaker_coach_gazebo/src/markov/evaluation_worker.py
288
25
0
def main() in sagemaker-training-compiler/huggingface/pytorch_multiple_gpu_multiple_node/scripts/run_mlm.py
274
74
0
def main() in sagemaker-training-compiler/huggingface/pytorch_multiple_gpu_single_node/scripts/run_mlm.py
272
74
0
def main() in sagemaker-training-compiler/huggingface/pytorch_multiple_gpu_multiple_node/scripts/run_clm.py
266
70
0
def main() in sagemaker-training-compiler/huggingface/pytorch_multiple_gpu_single_node/scripts/run_clm.py
258
70
0
def main() in training/distributed_training/pytorch/model_parallel/bert/bert_example/sagemaker_smp_pretrain.py
256
54
0
def main() in training/distributed_training/pytorch/model_parallel/gpt2/train_gpt_simple.py
219
56
0
def main() in reinforcement_learning/rl_deepracer_robomaker_coach_gazebo/src/markov/training_worker.py
212
17
0
def parse_args() in training/distributed_training/pytorch/model_parallel/gpt2/train_gpt_simple.py
199
1
0
def builder() in reinforcement_learning/rl_network_compression_ray_custom/src/tensorflow_resnet/compressor/resnet.py
186
40
4
def train() in sagemaker_neo_compilation_jobs/gluoncv_yolo/train_yolo.py
182
30
6
def train() in sagemaker-python-sdk/mxnet_horovod_maskrcnn/source/train_mask_rcnn.py
169
48
8
def parse_arguments() in training/distributed_training/pytorch/model_parallel/bert/bert_example/sagemaker_smp_pretrain.py
166
4
0
def parse_args() in sagemaker-python-sdk/mxnet_horovod_maskrcnn/source/train_mask_rcnn.py
164
19
0
def parse_args() in sagemaker-python-sdk/mxnet_horovod_fasterrcnn/source/train_faster_rcnn.py
164
19
0
def annotation_consolidation_config() in ground_truth_labeling_jobs/multi_modal_parallel_sagemaker_labeling_workflows_with_step_functions/src/lambda_src/shared/label_arn.py
147
1
2
def pre_human_task_lambda_arn() in ground_truth_labeling_jobs/multi_modal_parallel_sagemaker_labeling_workflows_with_step_functions/src/lambda_src/shared/label_arn.py
144
1
2
def train() in sagemaker-python-sdk/mxnet_horovod_fasterrcnn/source/train_faster_rcnn.py
141
43
8
def train() in sagemaker-python-sdk/dgl_gcmc/train.py