Nixpkgs: Adjust all non-conforming package descriptions

Created on 10 Sep 2020  路  8Comments  路  Source: NixOS/nixpkgs

There's a section in CONTRIBUTING.md that gives some rules on package descriptions, e.g. do not start with package name, do not end with period. However, a quick grep reveals that a lot of packages have periods at the end, and some even start with the package name. Can we fix this, perhaps with some automation as well?

Most helpful comment

Though I do believe the above code can be a nix check inside ofborg.

All 8 comments

@siraben Yep, this actually should be very easy to add a check for this.

Here's a script I wrote to report this automatically;
Save it as ./maintainers/scripts/description-check.nix and run
nix-instantiate --strict --eval ./maintainers/scripts/description-check.nix --attr periodDesc to list the packages whose descriptions end with a period.

nix-instantiate --strict --eval ./maintainers/scripts/description-check.nix --attr prefixDescCaseInsen to list the packages whose descriptions start with the package name (case insensitive)

nix-instantiate --strict --eval ./maintainers/scripts/description-check.nix --attr prefixDescCaseSen to list the packages whose descriptions start with the package name (case sensitive)

Note that there are some false positives with the prefix lists.

let
  pkgs = import ./../../default.nix {};

  safeEval = e: let result = builtins.tryEval e;
                in
                  if result.success
                  then result.value
                  else [ ];

  packagesWith = cond:
    pkgs.lib.concatLists (pkgs.lib.mapAttrsToList
      (name: pkg: safeEval
        (if pkgs.lib.isDerivation pkg && cond name pkg
         then [ name ]
         else [ ]))
      pkgs);

  hasDesc = pkg: builtins.hasAttr "description" pkg.meta;
  lastChar = x: builtins.substring (builtins.stringLength x - 1) (-1) x;
  report = desc: l:
    builtins.trace
      (pkgs.lib.concatStrings
        [ "There are "
          (builtins.toString (builtins.length l))
          " packages that "
          desc
          ".\n"
          (builtins.toString l)
        ])
      "";
in
{
  periodDesc =
    report "have a period at the end of their description"
      (packagesWith
        (name: pkg:
          if hasDesc pkg && builtins.stringLength pkg.meta.description != 0
          then lastChar pkg.meta.description == "."
          else false));
  prefixDescCaseInsen =
    report "start with the package name in the description (case insensitive)"
      (packagesWith
        (name: pkg:
          hasDesc pkg && pkgs.lib.hasPrefix (pkgs.lib.toLower name) (pkgs.lib.toLower pkg.meta.description)));
  prefixDescCaseSen =
    report "start with the package name in the description (case sensitive)"
      (packagesWith
        (name: pkg:
          hasDesc pkg && pkgs.lib.hasPrefix name pkg.meta.description));
}

The stats are:
308 descriptions ending with a period
231 descriptions starting with package name (case insensitive)
31 descriptions starting with package name (case sensitive)

I think we're trying to use github actions now? cc @Mic92 @grahamc ?

Though I do believe the above code can be a nix check inside ofborg.

Any update on this? Should I extend ofborg?

Any update on this? Should I extend ofborg?

I would go for github actions, as it can be reviewed by more people. Reviews in ofborg are kind of bottle-necked right now, since graham has less time these days for it.

#97835 has been merged. However the package descriptions that start with the package name should be adjusted.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ob7 picture ob7  路  3Comments

grahamc picture grahamc  路  3Comments

domenkozar picture domenkozar  路  3Comments

langston-barrett picture langston-barrett  路  3Comments

teto picture teto  路  3Comments