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

Open
wants to merge 24 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!

@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.

@philderbeast philderbeast force-pushed the fix/check-version-bounds branch 3 times, most recently from 8ca45cf to b2e539b Compare November 19, 2024 23:14
@philderbeast philderbeast marked this pull request as ready for review November 20, 2024 19:43
@philderbeast philderbeast force-pushed the fix/check-version-bounds branch from edf1712 to 50313b1 Compare November 21, 2024 15:01
@philderbeast philderbeast requested a review from ffaf1 November 21, 2024 15:07
@ffaf1
Copy link
Collaborator

ffaf1 commented Nov 21, 2024

Thanks, most likely I will review this this weekend.

@philderbeast philderbeast force-pushed the fix/check-version-bounds branch from 50313b1 to d40acfd Compare November 23, 2024 14:32
Copy link
Collaborator

@ffaf1 ffaf1 left a comment

Choose a reason for hiding this comment

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

Excellent work.
I have some things I don't agree with and I was overt in my thoughts (apologies if I missed some of your earlier notes).

I am sure we can work together to make this in master speedily~

Cabal/src/Distribution/PackageDescription/Check/Warning.hs Outdated Show resolved Hide resolved
Cabal/src/Distribution/PackageDescription/Check/Warning.hs Outdated Show resolved Hide resolved
Cabal/src/Distribution/PackageDescription/Check/Warning.hs Outdated Show resolved Hide resolved
changelog.d/pr-10554 Show resolved Hide resolved
changelog.d/pr-10554 Outdated Show resolved Hide resolved
Cabal-syntax/src/Distribution/Version.hs Outdated Show resolved Hide resolved
Cabal/src/Distribution/PackageDescription/Check.hs Outdated Show resolved Hide resolved
These warnings may cause trouble when distributing the package:
Warning: [trailing.zero(*.0)-upper-bounds] On library, these packages have upper bounds with trailing zeros:
- pkg
Please avoid trailing zeros for upper bounds. There is more information at https://pvp.haskell.org/
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That this Please avoid line is not indented below the Warning: line breaks the itemization of each warning for me.

Cabal/src/Distribution/PackageDescription/Check/Warning.hs Outdated Show resolved Hide resolved
Cabal/src/Distribution/PackageDescription/Check/Warning.hs Outdated Show resolved Hide resolved
changelog.d/pr-10554 Show resolved Hide resolved
Cabal-syntax/src/Distribution/Version.hs Outdated Show resolved Hide resolved
Cabal/src/Distribution/PackageDescription/Check/Warning.hs Outdated Show resolved Hide resolved
@philderbeast philderbeast force-pushed the fix/check-version-bounds branch 4 times, most recently from 7be19e7 to 5bef5e7 Compare November 25, 2024 21:37
@ffaf1
Copy link
Collaborator

ffaf1 commented Nov 29, 2024

@philderbeast is this ready for a re-review?

(no fret if it is not)

@philderbeast philderbeast force-pushed the fix/check-version-bounds branch from 5bef5e7 to 7e74f9c Compare November 29, 2024 20:33
@philderbeast
Copy link
Collaborator Author

@ffaf1 I've rebased and this is ready for review.

@philderbeast philderbeast requested a review from ffaf1 November 29, 2024 20:33
@philderbeast philderbeast force-pushed the fix/check-version-bounds branch 3 times, most recently from d39851e to 498ca97 Compare December 7, 2024 01:15
Comment on lines +720 to +721
-- NOTE: Satisfy the Parsimonious test, a test that checks that these messages
-- don't have too many dashes:
-- $ cabal run Cabal-tests:unit-tests -- --pattern=Parsimonious
Copy link
Collaborator

Choose a reason for hiding this comment

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

Erase this, not needed anymore.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is actually a helpful note. Other than failing the test there's no indication of this restriction other than recognizing a pattern that the other CheckExplanationIDString have no more than two dashes. I'll move the note near the type signature, alongside the other note there.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Add it where it belong then, near the test code Cabal-tests/tests/UnitTests/Distribution/PackageDescription/Check.hs
(and jus a reference from …/Check/Warning.hs.

@ffaf1
Copy link
Collaborator

ffaf1 commented Dec 10, 2024

I have added a few more comments @philderbeast.

If you need help or are ready for another review, just ping me and I will chime in!

@philderbeast philderbeast force-pushed the fix/check-version-bounds branch from a7ba282 to 322328c Compare December 13, 2024 01:07
- Check for LEQ upper bounds
- Check for GT lower bounds
- Check for trailing zero upper bounds
- Add missing gtLowerBound to checks
- Handle ^>= versions with its IntersectVersionRangesF
- Set baseline for cabal init generated bounds
- Use recursive functions for checking bounds
- Handle union version ranges
- Used named chunk for predicate examples
- Add predicate subsections for types of bounds
- avoid name clash with has*Bound (VersionRange -> Bool) predicates
- use TZ not TrailingZero, a two-letter prefix like the other two
@philderbeast philderbeast force-pushed the fix/check-version-bounds branch from d767d43 to 0d787e3 Compare December 14, 2024 18:48
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
4 participants