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

golangci-lint #1319

Merged
merged 18 commits into from
Aug 21, 2024
31 changes: 31 additions & 0 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: golangci-lint
on:
pull_request:

permissions:
contents: read
checks: write # Optional: allow write access to checks to allow the action to annotate code in the PR.

jobs:
golangci:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: stable
cache: false
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose we can try turn this on in a follow-up PR and see what effect it has?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah definitely!


- name: Touch approle
run: touch ./local/vault/approle.json

- name: Run Golangci-lint
uses: golangci/golangci-lint-action@v6
with:
args: --timeout 30m --verbose
version: v1.60

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Security Check
name: Vulnerability Check

on:
schedule:
Expand All @@ -16,5 +16,5 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Security checks
- name: Security scan
uses: canonical/comsys-build-tools/.github/actions/security-scan@main
8 changes: 4 additions & 4 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ run:
tests: true
allow-parallel-runners: false
allow-serial-runners: false
# go: "1.17" # Do not set a go limit
# go: "1.23"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this comment stick around?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't think it does any harm really


issues:
exclude-use-default: true
Expand Down Expand Up @@ -53,8 +53,8 @@ linters:

# Style based linters
- promlinter
- gocritic
- gocognit # To be fixed
- gocritic
- gocognit
- goheader
- importas
- gci
Expand Down Expand Up @@ -87,4 +87,4 @@ linters-settings:
sections:
- standard
- default
- localmodule
- localmodule
2 changes: 1 addition & 1 deletion doc/golangci-lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ In the .vscode folder of this repository you will find it is defined as the lint
To install, please install the golangci-lint binary or install it via "go install".

The version this was tested with is:
```go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1```
```go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1```
1 change: 1 addition & 0 deletions internal/jimm/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ func (w *Watcher) handleDelta(ctx context.Context, modelIDf func(string) *modelS
var cores int64
machine := d.Entity.(*jujuparams.MachineInfo)
if machine.HardwareCharacteristics != nil && machine.HardwareCharacteristics.CpuCores != nil {
//nolint:gosec // We expect cpu cores to fit into int64.
cores = int64(*machine.HardwareCharacteristics.CpuCores)
}
sCores, ok := state.machines[eid.Id]
Expand Down
1 change: 1 addition & 0 deletions internal/jimmtest/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ func (m *Model) DBObject(c *qt.C, db db.Database) dbmodel.Model {
m.env.Controller(m.Controller)
migrationControllerID := sql.NullInt32{}
if m.MigrationController != "" {
//nolint:gosec // Database IDs for tests will fit into int32.
migrationControllerID.Int32 = int32(m.env.Controller(m.MigrationController).dbo.ID)
migrationControllerID.Valid = true
}
Expand Down
1 change: 1 addition & 0 deletions internal/openfga/openfga.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ func (o *OFGAClient) removeTuples(ctx context.Context, tuple Tuple) (err error)
for {
// Since we're deleting the returned tuples, it's best to avoid pagination,
// and fresh query for the relations.
//nolint:gosec // The page size will not exceed int32.
tuples, ct, err := o.ReadRelatedObjects(ctx, tuple, int32(pageSize), "")
if err != nil {
return err
Expand Down
Loading