Skip to content

[Discussion] Should "unused code" that are "useful" in a file be removed (or commented out)? #331085

@Aleksanaa

Description

@Aleksanaa

Case 1. unused with in maintainer list

Removing with lib.maintainers; [ ] because nixf-tidy complaints about with being unused. #330664

Opposed view: #330664 (comment) A package should have maintainers. A package that does not have a maintainer is a special case. Keeping this with can help reduce diff.

Supporting view: #330232 (comment) An exception should not be made here, it would make the rule unnecessarily complex.

Case 2. Unused helper functions in files for enumeration

In an enumerated file, a function that may be used needs to be removed or commented out because there is no use case for the time being, in order to pass nixf-tidy's check. https://github.com/NixOS/nixpkgs/pull/331017/files

Opposed view: Not being used is temporary, being used is normal, and the placed function has a documentation functionality.

Case 3. Unused argument in commonly used builder function

Arguments such as pname, version, src are not used directly, but are passed in as { ... }@args and args is further passed to underlying builder function. nixf-tidy suggests these arguments should be deleted. #330589

Opposed view: They can capture missing arguments as early as possible, and have certain documentation functionality, because this information can be obtained using functionArgs.

Supporting view: #330589 (comment) They can cause problems, such as making arguments with a default value to be actually undefined (example: in doInstallCheck = attrs.doCheck or true;, doInstallCheck is true if doCheck is not passed as an argument, even if doCheck defaults to false); there are better ways to write them; functionArgs is not good documentation and should be replaced by doc-comments in the future.

CC @inclyc @SuperSandro2000 @AndersonTorres @piegamesde @Mic92 @mweinelt @jian-lin

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: architectureRelating to code and API architecture of Nixpkgs6.topic: policy discussionDiscuss policies to work in and around Nixpkgs9.needs: maintainer feedbackWaiting for the package maintainer to respond.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions