Skip to main content

Simple Bash program to list function by its length

Sometime it is useful to list function order by its length for example when refactoring.

Write a simple program count this.
It may be depend on Languages.
Currently the manual way is to list function and its line number then calculate.

$ grep -rn "public" MainGameScreen.java  |grep "("
9:  public Random rnd = new Random();
108:  public MainGameHelper gameHelper = new MainGameHelper(); // new MainGameHelper(this.readMedia)
110:  public void init_game(GameConfig paramGameCnf, int paramInt)
320:  public int turn_calc(int paramInt1, int paramInt2)
332:  public void graphic_helper(Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
358:  public void left_right(boolean paramBoolean)
365:  public void init_game2()
404:  public int shift_byte_6(int paramInt1, int paramInt2, int paramInt3)
409:  public void init_600()

grep "(" added to avoid properties declare: public int a; for example.

Comments