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

Additional version bound checks #10554

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

philderbeast
Copy link
Collaborator

@philderbeast philderbeast commented Nov 18, 2024

Fixes #9806. Checks that lower bounds are inclusive, upper bounds are exclusive and don't have trailing zeros.

Copy link
Collaborator

@ulysses4ever ulysses4ever left a comment

Choose a reason for hiding this comment

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

Cool!

@philderbeast philderbeast marked this pull request as draft November 18, 2024 18:11
Comment on lines +152 to +158
-- | Is the version range without an upper bound?
withoutUpperBound :: Dependency -> Bool
withoutUpperBound (Dependency _ ver _) = not . hasUpperBound $ ver

-- | Is the upper bound version range LEQ (less or equal, <=)?
leqUpperBound :: Dependency -> Bool
leqUpperBound (Dependency _ ver _)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you considered moving this to Distribution.Types.Dependency?

Not a request, just want to know what your thoughts about it are.

Comment on lines +726 to +734
isTrailingZeroUpperBound :: C.PackageCheck -> Bool
isTrailingZeroUpperBound pc = case C.explanation pc of
C.TrailingZeroUpperBounds{} -> True
_ -> False
isLeqUpperBound :: C.PackageCheck -> Bool
isLeqUpperBound pc = case C.explanation pc of
C.LEQUpperBounds{} -> True
_ -> False
isgtLowerBound :: C.PackageCheck -> Bool
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason to hav multiple functions instead of one? (isBoundCheck or similar)

Please avoid trailing zeros for upper bounds. There is more information at https://pvp.haskell.org/
Warning: [greater-than-lower-bounds] On library, these packages have greater than (>) lower bounds:
- base
Please use greater than or equals (>=) for lower bounds. There is more information at https://pvp.haskell.org/
Copy link
Collaborator

Choose a reason for hiding this comment

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

The message is very good, but does PVP actually explains clearly why we would need such and such bounds? Maybe it is/was/will be in the FVP FAQ?

@@ -1,3 +1,5 @@
{-# LANGUAGE ViewPatterns #-}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where is this needed? How verbose would this PR become without it?

@@ -116,34 +122,58 @@ partitionDeps ads ns ds = do
-- for important dependencies like base).
checkPVP
:: Monad m
=> (String -> PackageCheck) -- Warn message dependend on name
=> (Dependency -> Bool)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we passing a new function?

@ffaf1
Copy link
Collaborator

ffaf1 commented Nov 18, 2024

And of course, if something is not clear in the checks scaffold, ask!

@philderbeast
Copy link
Collaborator Author

philderbeast commented Nov 18, 2024

Converted to draft as I think there's more work to do:

$ cabal init "version-checks" --non-interactive
Warning: this is a debug build of cabal-install with assertions enabled.
[Info] Guessing dependencies...
[Info] Using cabal specification: 3.0
[Warn] unknown license type, you must put a copy in LICENSE yourself.
[Info] Creating fresh file CHANGELOG.md...
[Info] Creating fresh directory ./app...
[Info] Creating fresh file app/Main.hs...
[Info] Creating fresh file version-checks.cabal...
[Warn] No synopsis given. You should edit the .cabal file and add one.
[Info] You may want to edit the .cabal file and add a Description field.

$ cd version-checks/

$ grep -R -E 'base' *.cabal
    build-depends:    base ^>=4.20.0.0

$ cabal check
Warning: this is a debug build of cabal-install with assertions enabled.
These warnings will likely cause trouble when distributing the package:
Warning: [no-category] No 'category' field.
These warnings may cause trouble when distributing the package:
Warning: [less-than-equals-upper-bounds] On executable 'version-checks', these
packages have less than or equals (<=) upper bounds:
- base
Please use less than (<) for upper bounds. There is more information at
https://pvp.haskell.org/
Warning: [trailing-zero-upper-bounds] On executable 'version-checks', these
packages have upper bounds with trailing zeros:
- base
Please avoid trailing zeros for upper bounds. There is more information at
https://pvp.haskell.org/
Warning: [greater-than-lower-bounds] On executable 'version-checks', these
packages have greater than (>) lower bounds:
- base
Please use greater than or equals (>=) for lower bounds. There is more
information at https://pvp.haskell.org/
The following errors will cause portability problems on other environments:
Error: [no-syn-desc] No 'synopsis' or 'description' field.
Error: [license-none] The 'license' field is missing or is NONE.
Error: Hackage would reject this package.

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.

cabal check: Warn about "bad" bounds
3 participants