microsoft / graph-based-code-modelling
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 698 units with 7,928 lines of code in units (83.8% of code).
    • 3 very long units (470 lines of code)
    • 14 long units (908 lines of code)
    • 82 medium size units (2,501 lines of code)
    • 115 small units (1,689 lines of code)
    • 484 very small units (2,360 lines of code)
5% | 11% | 31% | 21% | 29%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py14% | 13% | 36% | 18% | 17%
cs0% | 10% | 27% | 23% | 38%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
Models/exprsynth15% | 14% | 34% | 18% | 17%
DataExtraction/SourceGraphExtractionUtils0% | 14% | 23% | 8% | 54%
DataExtraction/SourceGraphExtractionUtils/Utils0% | 8% | 26% | 34% | 30%
DataExtraction/ExpressionDataExtractor0% | 0% | 63% | 17% | 19%
Models/utils0% | 0% | 64% | 25% | 10%
DataExtraction/TestProject0% | 0% | 52% | 31% | 15%
Models/exprsynth/metadata0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def generate_suggestions_for_one_sample()
in Models/exprsynth/nagdecoder.py
226 60 9
135 6 15
def __make_train_model()
in Models/exprsynth/nagdecoder.py
109 7 1
public static Dictionary CreateNodeToTokenMap()
in DataExtraction/SourceGraphExtractionUtils/Utils/RoslynUtils.cs
89 21 3
def __make_train_placeholders()
in Models/exprsynth/nagdecoder.py
76 12 1
public void ExtractAllSamplesFromSemanticModel()
in DataExtraction/SourceGraphExtractionUtils/GraphDataExtractor.cs
75 17 2
def __load_contextgraph_data_from_sample()
in Models/exprsynth/contextgraphmodel.py
75 20 9
private static IDictionary ComputeNodeCompressionMap()
in DataExtraction/SourceGraphExtractionUtils/GraphDataExtractor.cs
65 20 1
def __make_test_model()
in Models/exprsynth/nagdecoder.py
65 2 1
public void WriteJson()
in DataExtraction/SourceGraphExtractionUtils/Utils/DirectedGraph.cs
62 10 5
62 14 5
public static void AddDataFlowEdges()
in DataExtraction/SourceGraphExtractionUtils/Utils/VariableUseGraph.cs
61 17 4
def test()
in Models/exprsynth/model.py
60 9 10
def __make_train_model()
in Models/exprsynth/seqdecoder.py
56 3 1
public void Add()
in DataExtraction/SourceGraphExtractionUtils/TypeHierarchy.cs
55 15 1
def generate_suggestions_for_one_sample()
in Models/exprsynth/seqdecoder.py
55 10 6
private static void CopySubgraphAroundHole()
in DataExtraction/SourceGraphExtractionUtils/GraphDataExtractor.cs
52 16 5
def _load_data_from_sample()
in Models/exprsynth/seq2graphmodel.py
47 4 9
private static void GetReachableNodes()
in DataExtraction/SourceGraphExtractionUtils/GraphDataExtractor.cs
46 12 7
public void WriteElement()
in DataExtraction/SourceGraphExtractionUtils/Utils/ChunkedJsonWriter.cs
45 6 1