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 1,179 units with 10,291 lines of code in units (55.9% of code).
public void onItemClicked() in LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/MainFragment.java
93
16
4
public void onDownloadingCompleted() in LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/room/controller/overview/LiveDataFragment.java
67
7
1
private void setupUi() in LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/details/DetailViewExampleWithVideoBackgroundFragment.java
67
5
0
private void setupUi() in LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/details/DetailViewExampleFragment.java
66
5
0
override fun onCreate() in ReferenceAppKotlin/app/src/main/java/com/android/tv/reference/browse/BrowseFragment.kt
65
4
1
public void setItems() in LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/room/adapter/ListAdapter.java
private void subscribeToModel() in LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/room/controller/detail/LiveDataDetailViewWithVideoBackgroundFragment.java
50
6
1
protected void onHandleIntent() in Leanback/app/src/main/java/com/example/android/tvleanback/recommendation/UpdateRecommendationsService.java
47
7
1
private void fetchVideosInfo() in LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/grid/VideoGridExampleFragment.java