github.com/serversong/goreporter@v0.0.0-20200325104552-3cfaf44fd178/linters/flen/README.md (about)

     1  ##Get info on length of functions in a Go package.
     2  
     3  Given package is searched in  directories provided by envs in following order: GOPATH, GOROOT. AST is generated only for Go source files present in package path, ie, `flen crypto` shall only parse `crypto.go`. For parsing `crypto/sha1`, full package path needs to be provided, ie `flen crypto/sha1`. For externally implemented functions, line number will be 0, as their is no enough information available to get their line numbers.
     4  
     5  ###Install
     6  `go get github.com/lafolle/flen/cmd/flen`
     7  
     8  ###Usage
     9  ```
    10  Usage: flen [options] <pkg>
    11    -bs int
    12          bucket size (natural number) (default 5)
    13    -l int
    14          min length (inclusive)
    15    -t    include tests files
    16    -u int
    17          max length (exclusive) (default 1000000)	
    18  ```
    19  ###Examples
    20  Simple usage  
    21  ```
    22  $ flen strings
    23  Full path of pkg:  /usr/local/go/src/strings
    24  Externally implemented funcs
    25  +-------+-----------+-------------------------------------------+---------+------+
    26  | INDEX |   NAME    |                 FILEPATH                  | LINE NO | SIZE |
    27  +-------+-----------+-------------------------------------------+---------+------+
    28  |     0 | IndexByte | /usr/local/go/src/strings/strings_decl.go |       0 |    0 |
    29  +-------+-----------+-------------------------------------------+---------+------+
    30  
    31  [1-6)   -       ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
    32  [6-11)  -       ∎∎∎∎∎∎∎∎∎∎
    33  [11-16) -       ∎∎∎∎∎∎∎∎∎∎∎∎
    34  [16-21) -       ∎∎∎∎∎
    35  [21-26) -       ∎∎∎
    36  [26-31) -       ∎∎∎∎
    37  [31-36) -       ∎∎∎∎
    38  [36-41) -       ∎∎∎
    39  [41-46) -       ∎∎
    40  [46-51) -       ∎
    41  [51-56) -
    42  [56-61) -       ∎
    43  [61-66) -
    44  $
    45  ```  
    46  
    47  ###Range of lengths
    48  To get all function/methods whose lengths fall in given range:   
    49  ```
    50  flen -l 16 -u 41 strings
    51  Full path of pkg:  /usr/local/go/src/strings
    52  Functions with length in range [16, 41)
    53  +-------+---------------------+--------------------------------------+---------+------+
    54  | INDEX |        NAME         |               FILEPATH               | LINE NO | SIZE |
    55  +-------+---------------------+--------------------------------------+---------+------+
    56  |     0 | Replace             | /usr/local/go/src/strings/replace.go |     365 |   17 |
    57  |     1 | Seek                | /usr/local/go/src/strings/reader.go  |     109 |   17 |
    58  |     2 | Join                | /usr/local/go/src/strings/strings.go |     388 |   18 |
    59  |     3 | WriteString         | /usr/local/go/src/strings/replace.go |     432 |   20 |
    60  |     4 | isSeparator         | /usr/local/go/src/strings/strings.go |     502 |   20 |
    61  |     5 | WriteString         | /usr/local/go/src/strings/replace.go |     385 |   22 |
    62  |     6 | genSplit            | /usr/local/go/src/strings/strings.go |     281 |   23 |
    63  |     7 | explode             | /usr/local/go/src/strings/strings.go |      17 |   25 |
    64  |     8 | Replace             | /usr/local/go/src/strings/replace.go |     461 |   26 |
    65  |     9 | WriteString         | /usr/local/go/src/strings/replace.go |     490 |   27 |
    66  |    10 | makeGenericReplacer | /usr/local/go/src/strings/replace.go |     240 |   29 |
    67  |    11 | FieldsFunc          | /usr/local/go/src/strings/strings.go |     353 |   30 |
    68  |    12 | Replace             | /usr/local/go/src/strings/strings.go |     681 |   31 |
    69  |    13 | Index               | /usr/local/go/src/strings/strings.go |     147 |   33 |
    70  |    14 | LastIndex           | /usr/local/go/src/strings/strings.go |     184 |   33 |
    71  |    15 | lookup              | /usr/local/go/src/strings/replace.go |     193 |   33 |
    72  |    16 | Map                 | /usr/local/go/src/strings/strings.go |     422 |   37 |
    73  |    17 | WriteString         | /usr/local/go/src/strings/replace.go |     312 |   38 |
    74  |    18 | makeStringFinder    | /usr/local/go/src/strings/search.go  |      48 |   40 |
    75  +-------+---------------------+--------------------------------------+---------+------+
    76  
    77  [1-6)   -       ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
    78  [6-11)  -       ∎∎∎∎∎∎∎∎∎∎
    79  [11-16) -       ∎∎∎∎∎∎∎∎∎∎∎∎
    80  [16-21) -       ∎∎∎∎∎
    81  [21-26) -       ∎∎∎
    82  [26-31) -       ∎∎∎∎
    83  [31-36) -       ∎∎∎∎
    84  [36-41) -       ∎∎∎
    85  [41-46) -       ∎∎
    86  [46-51) -       ∎
    87  [51-56) -
    88  [56-61) -       ∎
    89  [61-66) -
    90  ```
    91  
    92  ###Including test files
    93  By default, test files are ignored. Enable parsing test files by `-t` flag
    94  ```
    95  $ flen -t strings
    96  Full path of pkg:  /usr/local/go/src/strings
    97  
    98  Externally implemented funcs
    99  +-------+-----------+-------------------------------------------+---------+------+
   100  | INDEX |   NAME    |                 FILEPATH                  | LINE NO | SIZE |
   101  +-------+-----------+-------------------------------------------+---------+------+
   102  |     0 | IndexByte | /usr/local/go/src/strings/strings_decl.go |       0 |    0 |
   103  +-------+-----------+-------------------------------------------+---------+------+
   104  
   105  [1-6)		-	∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
   106  [6-11)		-	∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
   107  [11-16)		-	∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
   108  [16-21)		-	∎∎∎∎∎∎∎∎∎∎∎∎
   109  [21-26)		-	∎∎∎∎∎
   110  [26-31)		-	∎∎∎∎∎∎
   111  [31-36)		-	∎∎∎∎
   112  [36-41)		-	∎∎∎∎
   113  [41-46)		-	∎∎∎∎∎∎∎
   114  [46-51)		-	∎
   115  [51-56)		-	∎
   116  [56-61)		-	∎
   117  [61-66)		-	
   118  [66-71)		-	∎
   119  [71-76)		-	
   120  [76-81)		-	
   121  [81-86)		-	
   122  [86-91)		-	
   123  [91-96)		-	
   124  [96-101)	-	
   125  [101-106)	-	
   126  [106-111)	-	
   127  [111-116)	-	
   128  [116-121)	-	
   129  [121-126)	-	
   130  [126-131)	-	
   131  [131-136)	-	
   132  [136-141)	-	
   133  [141-146)	-	
   134  [146-151)	-	
   135  [151-156)	-	
   136  [156-161)	-	
   137  [161-166)	-	
   138  [166-171)	-	
   139  [171-176)	-	
   140  [176-181)	-	
   141  [181-186)	-	
   142  [186-191)	-	
   143  [191-196)	-	
   144  [196-201)	-	
   145  [201-206)	-	
   146  [206-211)	-	
   147  [211-216)	-	
   148  [216-221)	-	
   149  [221-226)	-	
   150  [226-231)	-	
   151  [231-236)	-	
   152  [236-241)	-	
   153  [241-246)	-	
   154  [246-251)	-	
   155  [251-256)	-	
   156  [256-261)	-	
   157  [261-266)	-	∎
   158  [266-271)	-	
   159  ```