Skip to content

Add HLint configuraton. - #9041

Merged
ulysses4ever merged 1 commit into
haskell:masterfrom
cabalism:hlint-configuraton
Jul 10, 2023
Merged

ulysses4ever merged 1 commit into
haskell:masterfrom
cabalism:hlint-configuraton

Conversation

@philderbeast

Copy link
Copy Markdown
Collaborator

HLS often alerts me to one HLint suggestion or another in this project. This adds a default configuration that silences these and shows how many of each suggestion we have so that when we want to tackle these we can.

@ulysses4ever

Copy link
Copy Markdown
Collaborator

After @Kleidukos added the auto-formatting (via Fourmolu) I was thinking that HLint should be the next step. But simply adding the file with exceptions doesn't seem very useful. Imagine someone adds a patch that regresses some of these metrics (so the numbers will loose any meaning over time) or adds code that would need another HLint flag to silence it (so, you're back to square one seeing warnings locally).

The way to go I think is to add a CI job alongside the HLint config.

@ffaf1

ffaf1 commented Jun 18, 2023

Copy link
Copy Markdown
Collaborator

The way to go I think is to add a CI job alongside the HLint config.

Some Hlint suggestions canbe really annoying (e.g. all those redundant $, I bet half of those are in tests which follow a specific template — yes you can remove the $ but the day someone copies your code they will maybe get an annoying compilation error).

Sorting which ones are useful (always) and which not could be a good first step.

I wonder what other large codebases do.

@ulysses4ever

Copy link
Copy Markdown
Collaborator

I don't suggest to sort anything out. Just add a CI job along with the config file. Hopefully, the job could check that we don't regress beyond the current values in the file.

@philderbeast

Copy link
Copy Markdown
Collaborator Author

The approach we took with liquid-fixpoint##552 was to tackle one hint at a time, each with its own pull request. For those hints we didn't want to adopt, we kept the ignores. The counts are useful for gauging which of the hints to tackle next.

# The following are kept for usability and style sake
- ignore: {name: "Avoid lambda"} # 4 hints
- ignore: {name: "Eta reduce"} # 30 hints
- ignore: {name: "Use $>"} # 7 hints
- ignore: {name: "Use <$"} # 1 hint
- ignore: {name: "Use infix"} # 4 hints

@philderbeast

Copy link
Copy Markdown
Collaborator Author

The way to go I think is to add a CI job alongside the HLint config.

I actually started doing this as well but then saw that the gh-action wasn't running in my fork (after altering the on condition too) but I would be happy to add this too (in another pull request preferably).

@ulysses4ever

Copy link
Copy Markdown
Collaborator

@philderbeast did you allow actions on the fork? By default they are disabled, see the screenshot
Screenshot_20230618-134339

My opinion is that the action should go in the same PR as the config file for the reasons described above. But others may feel differently.

@ulysses4ever ulysses4ever left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Oh, you should have pinged me. Thanks a lot for doing this! Let's hope someone else adds the second approval.

@geekosaur geekosaur left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@ulysses4ever

Copy link
Copy Markdown
Collaborator

Now, after 2 approvals, feel free to apply one of the merge labels. I'd expect squashing (via label or manually).

@andreabedini

Copy link
Copy Markdown
Collaborator

Yes please!

@philderbeast philderbeast added squash+merge me Tell Mergify Bot to squash-merge and removed attention: needs-review labels Jul 5, 2023
@mergify mergify Bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label Jul 7, 2023
@ulysses4ever

Copy link
Copy Markdown
Collaborator

@mergify rebase

@mergify

mergify Bot commented Jul 8, 2023

Copy link
Copy Markdown
Contributor

rebase

❌ Pull request can't be updated with latest base branch changes

Details

Mergify needs the author permission to update the base branch of the pull request.
@cabalism needs to authorize modification on its head branch.
err-code: 5A5C8

@ulysses4ever

Copy link
Copy Markdown
Collaborator

@philderbeast could you please allow maintainers' updates of your patch? Otherwise it's very tricky to make our merge bot happy.

@ulysses4ever

Copy link
Copy Markdown
Collaborator

@philderbeast same here: our merge policy (rebased) requires permissions to update your branch

@philderbeast

Copy link
Copy Markdown
Collaborator Author

@philderbeast same here: our merge policy (rebased) requires permissions to update your branch

I haven't been able to find where to do that for an organisation-owned fork. The advice for this setting is for user-owned forks.

On user-owned forks, if you want to allow anyone with push access to the upstream repository to make changes to your pull request, select Allow edits from maintainers.
Allowing changes to a pull request branch created from a fork
Creating a pull request from a fork

@philderbeast

Copy link
Copy Markdown
Collaborator Author

@ulysses4ever I did the squashing myself.

@ulysses4ever ulysses4ever added merge me Tell Mergify Bot to merge and removed squash+merge me Tell Mergify Bot to squash-merge labels Jul 9, 2023
* hlint --default -j . > .hlint.yaml

* Ignore modules that #include "MachDeps.h"

  Warning: Can't find file "MachDeps.h" in directories
	./cabal-testsuite/PackageTests/CmmSources/src
	.
  Asked for by: ./cabal-testsuite/PackageTests/CmmSources/src/Demo.hs  at line 8 col 1

  Warning: Can't find file "MachDeps.h" in directories
	./cabal-testsuite/PackageTests/CmmSourcesDyn/src
	.
  Asked for by: ./cabal-testsuite/PackageTests/CmmSourcesDyn/src/Demo.hs  at line 8 col 1

* Ignore the manually generated Lexer.hs

	templates/Lexer.x:10:1-20: Warning: Use fewer LANGUAGE pragmas
	Found:
	  {-# LANGUAGE CPP #-}
	  {-# LANGUAGE CPP #-}

	Perhaps:
	  {-# LANGUAGE CPP #-}

	1 hint

* Ignore templates/Paths_pkg.template.hs for its parse error

* Ignore templates/SPDX*.hs for their parse errors

* Add a linting workflow and rename the formatting one

* Redo default configuration with hlint-3.5

	I had mistakenly used a development build before:

	$ hlint --version
	HLint v3.6.20230213, (C) Neil Mitchell 2006-2022

* Shorten github workflow
@ulysses4ever

Copy link
Copy Markdown
Collaborator

@philderbeast thank you and sorry for the inconvenience. It's not only squashing it's also rebasing that bites us. I have a to-do to look into supporting people who can't / won't allow updating their branches: this does come up once in a while. We could have a separate, merge-based workflow besides the current rebase-based one.

So far let's hope that by the time CI finishes master won't update.

@philderbeast

Copy link
Copy Markdown
Collaborator Author

@ulysses4ever I rebased at the same time as squashing, if that helps.

@ulysses4ever

Copy link
Copy Markdown
Collaborator

@philderbeast yes, thank you, this helps a bit. The issue is that every update starts CI which will take time to pass, and during that time master can get updates. Currently, any master update, even non-conflicting one, will make the whole thing fail because the merge bot is set up to rebase in such case, and it can't rebase without the permission. We need to create a bot setting that would simply merge instead of rebase for cases when the bot is not allowed to rebase.

@philderbeast philderbeast mentioned this pull request Jul 10, 2023
1 task done
@ulysses4ever
ulysses4ever merged commit 31ae312 into haskell:master Jul 10, 2023
@ulysses4ever

Copy link
Copy Markdown
Collaborator

@philderbeast thanks and sorry it took so long! I noticed you have a couple older PRs open. Do you want to do anything about them?

@philderbeast

Copy link
Copy Markdown
Collaborator Author

@philderbeast thanks and sorry it took so long! I noticed you have a couple older PRs open. Do you want to do anything about them?

I think I'll need to go back to them myself first to see if they're worth reviving. Thanks for asking.

This was referenced Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked: action-required continuous-integration merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days merge me Tell Mergify Bot to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants