1. 36
  1.  

  2. 22

    This immediately suggests another metric:

    DRYness = ULOC / SLOC

    Or if you prefer,

    WETness = 1 - DRYness

    (‘Violations of DRY are typically referred to as WET solutions, which is commonly taken to stand for either “write everything twice”, “we enjoy typing” or “waste everyone’s time”. ’)

    1. 2

      I was thinking the same. Immediately had a look at my main codebase at my day job. DRYness: 0.44. Subjectively I’d say it’s somewhat WET.

    2. 3

      if you want to see them with counts, and no whitespace at the front or end, then there’s this terrible one-liner:

      sort **/*.hs | sed 's/^[ \t]*//;s/[ \t]*$//' | sort | uniq -c | sort -k 1,1 -g
      
      1. 3

        For me they both give the same metrics

        $ sort -u $(git ls-files) | wc -l
        3350
        $ cloc --vcs=git
              21 text files.
              20 unique files.                              
               4 files ignored.
        
        github.com/AlDanial/cloc v 1.80  T=0.05 s (356.2 files/s, 94271.2 lines/s)
        -------------------------------------------------------------------------------
        Language                     files          blank        comment           code
        -------------------------------------------------------------------------------
        C                                9            451            439           2777
        C/C++ Header                     4             85            152            518
        make                             3             13              4             43
        Markdown                         1              5              0             12
        -------------------------------------------------------------------------------
        SUM:                            17            554            595           3350
        -------------------------------------------------------------------------------
        $ cat $(git ls-files) | wc -l
        5470
        

        edit: just a bizarre coincidence

        1. 1

          How about conceptual duplication? Besides, not all code contributes to project complexity. For instance no one would argue if I said the same project could be considered less complex if we kept the non-comment code exactly the same and added new useful comments on top of it. I’d argue that the same is true for type annotations. Value-level code describes what the program does. Type-level code describes what the program can’t do, so it’s a net reduction in project complexity.