Skip to content

Commit

Permalink
golangci-lint update and fixes (#782)
Browse files Browse the repository at this point in the history
* Code Linter Update

* linter suggestions

* fixing code lints
  • Loading branch information
christopher-henderson committed Dec 16, 2023
1 parent f90a51e commit c1aacb0
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
go-version: ^1.20
- name: Install golangci-lint
run: |
wget https://github.com/golangci/golangci-lint/releases/download/v1.51.2/golangci-lint-1.51.2-linux-amd64.deb
sudo apt install -y ./golangci-lint-1.51.2-linux-amd64.deb\
wget https://github.com/golangci/golangci-lint/releases/download/v1.55.2/golangci-lint-1.55.2-linux-amd64.deb
sudo apt install -y ./golangci-lint-1.55.2-linux-amd64.deb
- name: Run golangci-lint
run: |
cd v3
Expand Down
4 changes: 2 additions & 2 deletions v3/formattedoutput/formattedOutput.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func OutputSummary(zlintResult *zlint.ResultSet, longSummary bool) {
" Details ",
}
lines := [][]string{}
lsl := ""
rescount := ""
var lsl string
var rescount string

hlengths := printTableHeadings(headings)
// Construct the table lines, but don't repeat
Expand Down
2 changes: 1 addition & 1 deletion v3/integration/lints/lint/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ type File struct {
//
// The word "remember" begins at position 81 within this text, therefor LineOf(81) should return line 3.
func (f *File) LineOf(pos token.Pos) int {
start := 0
var start int
end := 0
for lineno, line := range f.Lines {
start = end
Expand Down
3 changes: 2 additions & 1 deletion v3/integration/lints/lints/not_committing_genTestCerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package lints

import (
"crypto/sha256"
"encoding/hex"
"fmt"
"go/ast"
"os"
Expand All @@ -42,7 +43,7 @@ func (i *NotCommittingGenTestCerts) Lint(tree *ast.File, file *lint.File) *lint.
if err != nil {
return lint.NewResult(fmt.Sprintf("failed to hash the contents of %s", file.Name))
}
got := fmt.Sprintf("%x", hasher.Sum([]byte{}))
got := hex.EncodeToString(hasher.Sum([]byte{}))
if got == want {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion v3/lint/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ func TestStripGlobalsFromStructWithPrivates(t *testing.T) {
A string
B Global
C int
//nolint:unused
//nolint:unused,structcheck
d int
}
test := Test{}
Expand Down
4 changes: 2 additions & 2 deletions v3/lints/rfc/lint_serial_number_longer_than_20_octets.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ func (l *serialNumberTooLong) Execute(c *x509.Certificate) *lint.LintResult {
// DER encoded lengths are without having to guess.
encoding, err := asn1.Marshal(c.SerialNumber)
if err != nil {
return &lint.LintResult{Status: lint.Fatal, Details: fmt.Sprint(err)}
return &lint.LintResult{Status: lint.Fatal, Details: err.Error()}
}
serial := new(asn1.RawValue)
_, err = asn1.Unmarshal(encoding, serial)
if err != nil {
return &lint.LintResult{Status: lint.Fatal, Details: fmt.Sprint(err)}
return &lint.LintResult{Status: lint.Fatal, Details: err.Error()}
}
length := len(serial.Bytes)
if length > 20 {
Expand Down
2 changes: 1 addition & 1 deletion v3/test/configuration_test_framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ type LintEmbedsAConfiguration struct {
}

type embeddedConfiguration struct {
IsWebPKI bool `toml:"is_web_pki" comment:"Indicates that the certificate is intended for the Web PKI."`
IsWebPKI bool `comment:"Indicates that the certificate is intended for the Web PKI." toml:"is_web_pki"`
}

func init() {
Expand Down

0 comments on commit c1aacb0

Please sign in to comment.