-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add problem: ByNamePackagePrefixedWithNumber #122
base: main
Are you sure you want to change the base?
Conversation
@philiptaron I think I have the bulk of the idea here.
...I'm just not sure about this: https://github.com/NixOS/nixpkgs-vet/actions/runs/11570703378/job/32207036558?pr=122#step:4:907 (I see that I should probably be going by the invalid-shard-name test. That resolves the local test failure) ...and feedback on what the error message should actually be (I'm pretty sure the suggestion is wrong) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contributions!
src/problem/npv_170.rs
Outdated
} = self; | ||
write!( | ||
f, | ||
r#"- {relative_package_dir}: Attribute `{package_name}` should not be number-prefixed. It is suggestet to `"`-wrap this name"# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestet
typo
"
-wrap this name
I had to read that a couple of times before realizing what was meant. I think I'd prefer if it said something like "Wrap the name in quotes." However, it wasn't too clear to me when reading NixOS/nixpkgs#333281 if wrapping in quotes is preferred over underscore prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what the recommendation should be. This was a best guess. I'd happily take direction on what the warning should explicitly be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh looking at this again, realized they're not talking about the pname
but the directory name for the package (which is what this checks 😂). Can you instead only recommend the _
prefix?
$ pwd
/home/will/code/external/nixpkgs/pkgs/by-name
$ find . -type d -name '_*'
./_1
./_1/_1oom
./_1/_1fps
./_2
./_2/_2ship2harkinian
./_4
./_4/_4ti2
./_4/_4th
./_4/_4d-minesweeper
./_6
./_6/_64gram
./_9
./_9/_9base
./_9/_9menu
./mi/micro/tests/_001-hello-expect
./_0
./_0/_0xpropo
./_0/_0ver
$ rg "pname = \"1"
_1/_1fps/package.nix
8: pname = "1fps";
_1/_1oom/package.nix
19: pname = "1oom";
$ rg "pname = \"_"
@philiptaron @infinisil forgot how where landed on how clean commit history should be for feature branches since we merge commit them into main? For example, should requested fix changes on a PR be rebased? |
use relative_path::RelativePathBuf; | ||
|
||
#[derive(Clone, new)] | ||
pub struct ByNamePackegPrefixedWithNumber { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed this typo Packeg
@@ -69,6 +69,7 @@ The following checks are performed when calling the binary: | |||
- `pkgs/by-name` must only contain subdirectories of the form `${shard}/${name}`, called _package directories_. | |||
- The `name`'s of package directories must be unique when lowercased. | |||
- `name` is a string only consisting of the ASCII characters `a-z`, `A-Z`, `0-9`, `-` or `_`. | |||
- `name` only starts with an ASCII character `a-z`, `A-Z`, `-` or `_`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `name` only starts with an ASCII character `a-z`, `A-Z`, `-` or `_`. | |
- `name` only starts with an ASCII character `a-z`, `A-Z` or `_`. |
It cannot start with -
. -
will be parsed to a negation operator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be done in this same PR, since it's technically a separate problem, but yeah this would be good too :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be done in this same PR, since it's technically a separate problem, but yeah this would be good too :)
It's not allowed in the regex already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Left some comments :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something to think about is how users are likely to run into a problem. Since users will know that the first two chars of the shard need to match the attribute name, _1/10foo
is rather unlikely, so instead it's better to make sure it triggers on 10/10foo
.
@@ -69,6 +69,7 @@ The following checks are performed when calling the binary: | |||
- `pkgs/by-name` must only contain subdirectories of the form `${shard}/${name}`, called _package directories_. | |||
- The `name`'s of package directories must be unique when lowercased. | |||
- `name` is a string only consisting of the ASCII characters `a-z`, `A-Z`, `0-9`, `-` or `_`. | |||
- `name` only starts with an ASCII character `a-z`, `A-Z`, `-` or `_`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be done in this same PR, since it's technically a separate problem, but yeah this would be good too :)
static ref SHARD_NAME_REGEX: Regex = Regex::new(r"^((_[0-9])|([a-z][a-z0-9_-]?))$").unwrap(); | ||
static ref PACKAGE_NAME_REGEX: Regex = | ||
Regex::new(r"^((_[0-9])|[a-zA-Z])[a-zA-Z0-9_-]*$").unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static ref SHARD_NAME_REGEX: Regex = Regex::new(r"^((_[0-9])|([a-z][a-z0-9_-]?))$").unwrap(); | |
static ref PACKAGE_NAME_REGEX: Regex = | |
Regex::new(r"^((_[0-9])|[a-zA-Z])[a-zA-Z0-9_-]*$").unwrap(); | |
static ref SHARD_NAME_REGEX: Regex = Regex::new(r"^[a-z_-][a-z0-9_-]?$").unwrap(); | |
static ref PACKAGE_NAME_REGEX: Regex = Regex::new(r"^[a-zA-Z_-][a-zA-Z0-9_-]*$").unwrap(); |
I think this is a bit simpler to understand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually don't even need a new error type for this, because we can just update the message for when these regexes don't match here:
nixpkgs-vet/src/problem/npv_110.rs
Line 19 in 02db8e4
"- {relative_shard_path}: Invalid directory name \"{shard_name}\", must be at most 2 ASCII characters consisting of a-z, 0-9, \"-\" or \"_\".", |
nixpkgs-vet/src/problem/npv_141.rs
Line 22 in 02db8e4
"- {relative_package_dir}: Invalid package directory name \"{package_name}\", must be ASCII characters consisting of a-z, A-Z, 0-9, \"-\" or \"_\".", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static ref PACKAGE_NAME_REGEX: Regex = Regex::new(r"^[a-zA-Z_-][a-zA-Z0-9_-]*$").unwrap();
This allows _abc
and even ___
as package name.
Hi, do you still want to work on this? |
Yeah. Thanks for prompting this, had some other commitments that pulled me away from it, but ready to come back to it before the end of the week. |
Reference issue: #107
This is first time putting together something of substance for this repo.