Skip to content
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

lint: add W74 to detect 'pin-depends' packages that are not present in 'depends' nor in 'depopts' #6317

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rjbou
Copy link
Collaborator

@rjbou rjbou commented Nov 28, 2024

fix #5795
This lint doesn't detect when the versions mismatch.

@rjbou rjbou added this to the 2.4.0~alpha1 milestone Nov 28, 2024
kit-ty-kate
kit-ty-kate previously approved these changes Nov 28, 2024
master_changes.md Outdated Show resolved Hide resolved
Copy link
Member

@kit-ty-kate kit-ty-kate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code can be improved by eliminating 3 out of the 6 datatypes traverses.
The gain is small in this particular case but out of principle it feels weird to not do better if the code is as short and maybe even more understandable

Comment on lines +1103 to +1105
List.map fst t.pin_depends
|> OpamPackage.Set.of_list
|> OpamPackage.names_of_packages
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
List.map fst t.pin_depends
|> OpamPackage.Set.of_list
|> OpamPackage.names_of_packages
List.fold_left
(fun (pkg, _) set -> OpamPackage.Name.Set.add (OpamPackage.name pkg) set)
t.pin_depends OpamPackage.Name.Set.empty

Comment on lines +1107 to +1109
OpamPackage.Name.Set.diff pkgs all_depends
|> OpamPackage.Name.Set.elements
|> List.map OpamPackage.Name.to_string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
OpamPackage.Name.Set.diff pkgs all_depends
|> OpamPackage.Name.Set.elements
|> List.map OpamPackage.Name.to_string
OpamPackage.Name.Set.fold
(fun pkgname acc -> OpamPackage.Name.to_string pkgname :: acc)
(OpamPackage.Name.Set.diff pkgs all_depends) []

@rjbou
Copy link
Collaborator Author

rjbou commented Dec 3, 2024

I find the set transformation by pipe more human understandable (you just follow the function name, not read the code of the function given to fold). But agree on the optim part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

should pin-depends imply depends ?
2 participants