Skip to content

Update linter #4671

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

Merged
merged 13 commits into from
Jul 1, 2025
Merged

Update linter #4671

merged 13 commits into from
Jul 1, 2025

Conversation

stefanhaller
Copy link
Collaborator

  • Update the golangci-lint configuration to use the latest version (2.2.1)
  • Enable a few more linter checks
  • Improve the VS Code configuration so that we don't get spurious linter warnings that wouldn't also show up on CI
  • Provide a way to run the exact same golangci-lint version locally that we use on CI. This is useful in case the globally installed version is a newer one which emits more warnings.

@stefanhaller stefanhaller added the maintenance For refactorings, CI changes, tests, version bumping, etc label Jun 30, 2025
Copy link

codacy-production bot commented Jun 30, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 44395311 88.26%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (4439531) Report Missing Report Missing Report Missing
Head commit (ca05a2c) 56675 49222 86.85%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4671) 264 233 88.26%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@stefanhaller stefanhaller marked this pull request as draft June 30, 2025 13:54
@stefanhaller
Copy link
Collaborator Author

I will hold off merging this until the next version of the go extension for VS Code has been released (which is supposed to be soon). The current version of the extension doesn't support golangci-lint v2 yet, so users would have to switch to the prerelease version of the extension.

… to use it

The script expects a golangci-lint binary in .bin; this makes it possible to
install the exact same version that also runs on CI.
…eiver name

Most methods use gui as a receiver name (120 of them), so switch the few that
use self over to that too.
It doesn't use the receiver at all, so doesn't have to be a method.

This fixes ST1016: methods on the same type should have the same receiver name.
The config file was migrated using `golangci-lint migrate`, and then edited by
hand to disable a few checks that we don't want.
We configure it to call the same binary that the new lint script also uses (see
beginning of the branch).
... and configure it to run the same checks as golangci-lint.

It may seem redundant to have two linter checks enabled; however, there are
reasons to have both. golangci-lint is what we are running on CI, and it has a
lot more linters than gopls, so we want to run it locally too to get the same
coverage. The linter that is built into gopls is only staticcheck, so that's
redundant; but it has the advantage that the warnings appear a bit faster
(golangci-lint runs only on save, and with a bit of delay), and in particular it
provides quick fixes for some of the checks, which is quite convenient.
I took the set of enabled checks from revive's recommended configuration [1],
and removed some that I didn't like. There might be other useful checks in
revive that we might want to enable, but this is a nice improvement already.

The bulk of the changes here are removing unnecessary else statements after
returns, but there are a few others too.

[1] https://github.com/mgechev/revive?tab=readme-ov-file#recommended-configuration
@stefanhaller
Copy link
Collaborator Author

Version 0.48.0 of the go extension has been released, which supports golangci-lint v2, so merging now.

@stefanhaller stefanhaller marked this pull request as ready for review July 1, 2025 09:08
@stefanhaller stefanhaller merged commit 36388e5 into master Jul 1, 2025
14 checks passed
@stefanhaller stefanhaller deleted the update-linter branch July 1, 2025 09:08
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jul 6, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [jesseduffield/lazygit](https://github.com/jesseduffield/lazygit) | minor | `v0.52.0` -> `v0.53.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>jesseduffield/lazygit (jesseduffield/lazygit)</summary>

### [`v0.53.0`](https://github.com/jesseduffield/lazygit/releases/tag/v0.53.0)

[Compare Source](jesseduffield/lazygit@v0.52.0...v0.53.0)

<!-- Release notes generated using configuration in .github/release.yml at v0.53.0 -->

This is the first lazygit release after Jesse [passed the maintainership to me](jesseduffield/lazygit#4655) ([@&#8203;stefanhaller](https://github.com/stefanhaller)), and I'm excited (and a little bit nervous 😄) about it.

No big new features this time, but lots of smaller quality-of-life improvements. The one that makes the biggest difference for me is an improved hunk selection mode in the staging view (in case you didn't know, you can switch from the normal line selection mode to hunk mode by pressing `a`). This now works a bit more fine-grained, by selecting groups of added or deleted lines rather than entire hunks, which often consist of several such groups. With this change I find that I prefer hunk mode over line mode in most cases, so I added a user config to switch to hunk automatically upon entering the staging view; it is off by default, but I encourage you to enable it (`gui.useHunkModeInStagingView`) to see if you like it as much as I do. Feedback about this is welcome; please comment on [the MR](jesseduffield/lazygit#4684) if you have any.

The detailed list of all changes follows:

#### What's Changed

##### Enhancements 🔥

- Add option to disable warning when amending last commit by [@&#8203;johnhamlin](https://github.com/johnhamlin) in jesseduffield/lazygit#4640
- Add bold style for border by [@&#8203;aidancz](https://github.com/aidancz) in jesseduffield/lazygit#4644
- Add credential prompts for PKCS11-based SSH keys by [@&#8203;Jadeiin](https://github.com/Jadeiin) in jesseduffield/lazygit#4646
- Show annotation information for selected tag by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4663
- Show stash name for selected stash by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4673
- Auto-stash modified files when cherry-picking or reverting commits by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4683
- Move to next stageable line when adding a line to a custom patch by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4675
- Improve hunk selection mode in staging view by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4684
- Add user config to use hunk mode by default when entering staging view by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4685

##### Fixes 🔧

- Fix stash operations when branch named 'stash' exists by [@&#8203;ChrisMcD1](https://github.com/ChrisMcD1) in jesseduffield/lazygit#4641
- Fix moving a custom patch from the very first commit of the history to a later commit by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4631
- Fix DEFAULT\_REMOTE\_ICON character code by [@&#8203;bedlamzd](https://github.com/bedlamzd) in jesseduffield/lazygit#4653
- Show GPG error before entering commit editor when rewording non-latest commits by [@&#8203;m04f](https://github.com/m04f) in jesseduffield/lazygit#4660
- Fix branch head icon appearing at head commit when a remote or tag exists with the same name as the current branch by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4669
- Fix applying custom patches to a dirty working tree by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4674
- Collapse selection after deleting a range of branches or stashes by [@&#8203;nileric](https://github.com/nileric) in jesseduffield/lazygit#4661

##### Maintenance ⚙️

- Instantiate mutexes by value by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4632
- Bump github.com/cloudflare/circl from 1.6.0 to 1.6.1 by [@&#8203;dependabot](https://github.com/dependabot) in jesseduffield/lazygit#4633
- Update linter by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4671
- Some code cleanups to the "discard file changes from commit" feature by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4679
- Change Refresh to not return an error by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4680

##### Docs 📖

- Fix formatting of a keyboard shortcut in the README.md by [@&#8203;DanOpcode](https://github.com/DanOpcode) in jesseduffield/lazygit#4678

##### I18n 🌎

- Update translations from Crowdin by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4686

#### New Contributors

- [@&#8203;johnhamlin](https://github.com/johnhamlin) made their first contribution in jesseduffield/lazygit#4640
- [@&#8203;aidancz](https://github.com/aidancz) made their first contribution in jesseduffield/lazygit#4644
- [@&#8203;bedlamzd](https://github.com/bedlamzd) made their first contribution in jesseduffield/lazygit#4653
- [@&#8203;Jadeiin](https://github.com/Jadeiin) made their first contribution in jesseduffield/lazygit#4646
- [@&#8203;m04f](https://github.com/m04f) made their first contribution in jesseduffield/lazygit#4660
- [@&#8203;DanOpcode](https://github.com/DanOpcode) made their first contribution in jesseduffield/lazygit#4678
- [@&#8203;nileric](https://github.com/nileric) made their first contribution in jesseduffield/lazygit#4661

**Full Changelog**: jesseduffield/lazygit@v0.52.0...v0.53.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC42Mi4xIiwidXBkYXRlZEluVmVyIjoiNDAuNjIuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance For refactorings, CI changes, tests, version bumping, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant