You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue shall list some suggestions for inspections we might want to implement. New suggestions might be added over time. You can of course add your own suggestions in the comments.
Legacy | Expressions not supported in this version
Reports expressions which are not supported in the specified version. This inspection should have an option to specify the version.
Legacy | Usage of unquoted `or`
In certain situations, the Nix Expression Language allows using or as identifier or unquoted attribute. This seems to be permitted for backward compatibility. However, the behavior is not always as expected. See the following expression:
let f = x: x; or = 0; in [ "before" f or "after" ] #-> [ "before" 0 "after" ]
If you replace or with another identifier, the result would be different:
let f = x: x; id = 0; in [ "before" f id "after" ] #-> [ "before" <LAMBDA> 0 "after" ]
Also note that we would get another result if we replace f with a longer attribute path:
let f._ = x: x; or = 0; in [ "before" f._ or "after" ] #-> [ "before" <LAMBDA> ]
Due to this unexpected differences, we should warn at least about the usage in such scenarios. We might optionally also warn the user when the keyword is used as an attribute, although it doesn't have such consequences.
Legacy | Usage of unquoted URL
Reports usages of the URL syntax, which allows using unquoted URLs in the Nix Expression Language. This syntax was deprecated by RFC 45 in Nix 2.4.
Probable bugs | Indented strings inhibitor
Reports tabs and carriage returns (i.e. CR and CRLF). Leading whitespace is usually removed from indented strings (strings in double single quotes). However, tabs and carriage returns prevent this feature from working. (#3759)
Probable bugs | Infinite recursion
Reports attributes in recursive sets which cannot be resolved due to infinite recursion.
rec {
x = y;
y = x;
}
Probable bugs | Invalid antiquotation value
Reports expressions in antiquotations which evaluate to something that cannot be coerced into a string. Expressions evaluating to null are ignored in attribute declarations.
Probable bugs | Merging options in modules with `//`
If you merge multiple sets of options with // instead of mkMerge, one of both sets might be ignored.
Probable bugs | Option defined outside `config` attribute
Warns about options which are defined outside the config attribute in a module if there is a config or options attribute. In such case, the option would be ignored. Option definitions outside the config attribute are only respected if the module does not contain any attribute called config or options.
Probable bugs | Path does not exist
Reports path literals which point to non-existent files. This inspection should have an option to ignore absolute pathes.
Probable bugs | Quoted path
Reports string literals when path literals should be used. When a string literals is used as relative path, the path might be resolved differently depending on how the file is loaded. This can be avoided by using path literals which are always resolved relative to the containing file.
Redundancy | Unused attribute or variable
Reports variables and attributes which are never used.
let var = "unused"; in true
or
let
var = { attr1 = "used"; attr2 = "unused"; };
in
var.attr1
Verbose or redundant code constructs | Redundant antiquotation
Reports unnecessary antiquotations in strings and attribute paths.
"a ${"b"} c" // → "a b c"
var.${"attr"} // → var."attr"
Verbose or redundant code constructs | Redundant inherit
Reports redundant usage of the inherit keyword. Specifically, this inspection reports the inheritance of a local variable within a let expression.
let x = 42; in
let inherit x; in
x
Verbose or redundant code constructs | Redundant parenthesis
Reports redundant parenthesis.
(1 + 2) + 3
This inspection should have an option to allow clarifying parenthesis which doesn't change the meaning but clarify the precedence.
(1 * 2) + 3
Verbose or redundant code constructs | Redundant quotes in attribute path
This issue shall list some suggestions for inspections we might want to implement. New suggestions might be added over time. You can of course add your own suggestions in the comments.
Legacy | Expressions not supported in this version
Reports expressions which are not supported in the specified version. This inspection should have an option to specify the version.
Legacy | Usage of unquoted `or`
In certain situations, the Nix Expression Language allows using
or
as identifier or unquoted attribute. This seems to be permitted for backward compatibility. However, the behavior is not always as expected. See the following expression:If you replace
or
with another identifier, the result would be different:Also note that we would get another result if we replace
f
with a longer attribute path:Due to this unexpected differences, we should warn at least about the usage in such scenarios. We might optionally also warn the user when the keyword is used as an attribute, although it doesn't have such consequences.
Legacy | Usage of unquoted URL
Reports usages of the URL syntax, which allows using unquoted URLs in the Nix Expression Language. This syntax was deprecated by RFC 45 in Nix 2.4.
Probable bugs | Indented strings inhibitor
Reports tabs and carriage returns (i.e. CR and CRLF). Leading whitespace is usually removed from indented strings (strings in double single quotes). However, tabs and carriage returns prevent this feature from working. (#3759)
Probable bugs | Infinite recursion
Reports attributes in recursive sets which cannot be resolved due to infinite recursion.
Probable bugs | Invalid antiquotation value
Reports expressions in antiquotations which evaluate to something that cannot be coerced into a string. Expressions evaluating to
null
are ignored in attribute declarations.Probable bugs | Merging options in modules with `//`
If you merge multiple sets of options with
//
instead ofmkMerge
, one of both sets might be ignored.Probable bugs | Option defined outside `config` attribute
Warns about options which are defined outside the
config
attribute in a module if there is aconfig
oroptions
attribute. In such case, the option would be ignored. Option definitions outside theconfig
attribute are only respected if the module does not contain any attribute calledconfig
oroptions
.Probable bugs | Path does not exist
Reports path literals which point to non-existent files. This inspection should have an option to ignore absolute pathes.
Probable bugs | Quoted path
Reports string literals when path literals should be used. When a string literals is used as relative path, the path might be resolved differently depending on how the file is loaded. This can be avoided by using path literals which are always resolved relative to the containing file.
Redundancy | Unused attribute or variable
Reports variables and attributes which are never used.
or
Verbose or redundant code constructs | Redundant antiquotation
Reports unnecessary antiquotations in strings and attribute paths.
Verbose or redundant code constructs | Redundant inherit
Reports redundant usage of the
inherit
keyword. Specifically, this inspection reports the inheritance of a local variable within alet
expression.Verbose or redundant code constructs | Redundant parenthesis
Reports redundant parenthesis.
This inspection should have an option to allow clarifying parenthesis which doesn't change the meaning but clarify the precedence.
Verbose or redundant code constructs | Redundant quotes in attribute path
Reports unnecessary quotes in an attribute path.
Verbose or redundant code constructs | Successive let expressions can be merged
Reports let expressions which have another let expression as its direct parent. For example
can be simplified into
Verbose or redundant code constructs | Unnecessarily escaped character
Reports unnecessarily escaped characters in strings.
Visibility | Variable hides built-in
Reports variable declarations which hide built-in variables like
true
,false
,null
andimport
.Visibility | Variable hides other variable
Reports variable declarations which hide other variables.
This inspection should have an option to include or exclude
with
expressions.This Wiki page might also contain some inspirations: https://nixos.wiki/wiki/Nix_Language_Quirks
The text was updated successfully, but these errors were encountered: