pytorch / translate
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 860 units with 13,186 lines of code in units (62.7% of code).
    • 9 very long units (1,575 lines of code)
    • 47 long units (3,318 lines of code)
    • 108 medium size units (3,506 lines of code)
    • 142 small units (2,031 lines of code)
    • 554 very small units (2,756 lines of code)
11% | 25% | 26% | 15% | 20%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py11% | 25% | 26% | 15% | 20%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
pytorch_translate18% | 27% | 22% | 12% | 19%
pytorch_translate/dual_learning0% | 50% | 24% | 13% | 11%
pytorch_translate/research0% | 15% | 48% | 18% | 16%
pytorch_translate/tasks0% | 33% | 23% | 21% | 20%
pytorch_translate/rescoring0% | 30% | 30% | 23% | 14%
pytorch_translate/data0% | 0% | 23% | 26% | 49%
pytorch_translate/word_prediction0% | 0% | 50% | 19% | 30%
pytorch_translate/attention0% | 0% | 18% | 32% | 48%
ROOT0% | 0% | 0% | 0% | 100%
pytorch_translate/models0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def add_args()
in pytorch_translate/rnn.py
351 2 1
def add_preprocessing_args()
in pytorch_translate/options.py
308 1 1
def add_args()
in pytorch_translate/transformer.py
160 2 1
def _generate_score()
in pytorch_translate/generate.py
157 42 5
def add_args()
in pytorch_translate/transformer_aan.py
136 1 1
def expand_generation_args()
in pytorch_translate/options.py
121 2 2
def get_parser_with_args()
in pytorch_translate/generate.py
120 1 0
def add_args()
in pytorch_translate/hybrid_transformer_rnn.py
116 2 1
def forward()
in pytorch_translate/ensemble_export.py
106 16 5
def forward()
in pytorch_translate/research/rescore/rescoring_criterion.py
100 13 4
def load_dataset()
in pytorch_translate/dual_learning/dual_learning_task.py
97 4 3
def build_model()
in pytorch_translate/semi_supervised.py
97 25 3
def build_model()
in pytorch_translate/dual_learning/dual_learning_models.py
95 4 3
def generate()
in pytorch_translate/ensemble_export.py
95 9 5
def add_args()
in pytorch_translate/dual_learning/dual_learning_task.py
94 1 1
def build_model()
in pytorch_translate/multilingual_model.py
94 19 3
def build_model()
in pytorch_translate/char_source_model.py
89 6 3
def add_args()
in pytorch_translate/char_encoder.py
87 1 1
def add_dataset_args()
in pytorch_translate/options.py
85 3 3
def expand_optimization_args()
in pytorch_translate/options.py
81 1 1