Skip to content

Commit

Permalink
Add linters and fix some new linting errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
dopey committed Sep 20, 2019
1 parent 662cb15 commit 8bf124f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 16 deletions.
6 changes: 4 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,21 @@ linters:
- misspell
- ineffassign
- deadcode
- staticcheck
- unused

run:
skip-dirs:
- pkg

issues:
exclude:
- can't lint
- declaration of "err" shadows declaration at line
- should have a package comment, unless it's in another file for this package
- func `CLICommand.
# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration
service:
golangci-lint-version: 1.17.x # use the fixed version to not introduce new linters unexpectedly
golangci-lint-version: 1.18.x # use the fixed version to not introduce new linters unexpectedly
prepare:
- echo "here I can run custom commands, but no preparation needed for this repo"
2 changes: 1 addition & 1 deletion command/crypto/jwe/decrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func decryptAction(ctx *cli.Context) error {
return errors.Wrap(err, "error decrypting data")
}

fmt.Printf(string(decrypted))
fmt.Print(string(decrypted))

return nil
}
2 changes: 0 additions & 2 deletions crypto/x509util/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ func ToStepX509CertificateRequest(csr *x509.CertificateRequest) *stepx509.Certif
PublicKeyAlgorithm: stepx509.PublicKeyAlgorithm(csr.PublicKeyAlgorithm),
PublicKey: csr.PublicKey,
Subject: csr.Subject,
Attributes: csr.Attributes,
Extensions: csr.Extensions,
ExtraExtensions: csr.ExtraExtensions,
DNSNames: csr.DNSNames,
Expand All @@ -194,7 +193,6 @@ func ToX509CertificateRequest(csr *stepx509.CertificateRequest) *x509.Certificat
PublicKeyAlgorithm: x509.PublicKeyAlgorithm(csr.PublicKeyAlgorithm),
PublicKey: csr.PublicKey,
Subject: csr.Subject,
Attributes: csr.Attributes,
Extensions: csr.Extensions,
ExtraExtensions: csr.ExtraExtensions,
DNSNames: csr.DNSNames,
Expand Down
5 changes: 4 additions & 1 deletion make/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,13 @@ integration: bin/$(BINNAME)
# Linting
#########################################

fmt:
$Q gofmt -l -w $(SRC)

lint:
$Q LOG_LEVEL=error golangci-lint run

.PHONY: lint
.PHONY: fmt lint

#########################################
# Install
Expand Down
4 changes: 2 additions & 2 deletions pkg/x509/name_constraints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,7 @@ func makeConstraintsCACert(constraints constraintsSpec, name string, key *ecdsa.
NotAfter: time.Unix(2000, 0),
KeyUsage: KeyUsageCertSign,
BasicConstraintsValid: true,
IsCA: true,
IsCA: true,
}

if err := addConstraintsToTemplate(constraints, template); err != nil {
Expand Down Expand Up @@ -1633,7 +1633,7 @@ func makeConstraintsLeafCert(leaf leafSpec, key *ecdsa.PrivateKey, parent *Certi
NotAfter: time.Unix(2000, 0),
KeyUsage: KeyUsageDigitalSignature,
BasicConstraintsValid: true,
IsCA: false,
IsCA: false,
}

for _, name := range leaf.sans {
Expand Down
8 changes: 4 additions & 4 deletions pkg/x509/x509_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ func TestCreateSelfSignedCertificate(t *testing.T) {
UnknownExtKeyUsage: testUnknownExtKeyUsage,

BasicConstraintsValid: true,
IsCA: true,
IsCA: true,

OCSPServer: []string{"http://ocsp.example.com"},
IssuingCertificateURL: []string{"http://crt.example.com/ca1.crt"},
Expand Down Expand Up @@ -1474,7 +1474,7 @@ func TestMaxPathLen(t *testing.T) {
NotAfter: time.Unix(100000, 0),

BasicConstraintsValid: true,
IsCA: true,
IsCA: true,
}

cert1 := serialiseAndParse(t, template)
Expand Down Expand Up @@ -1515,8 +1515,8 @@ func TestNoAuthorityKeyIdInSelfSignedCert(t *testing.T) {
NotAfter: time.Unix(100000, 0),

BasicConstraintsValid: true,
IsCA: true,
SubjectKeyId: []byte{1, 2, 3, 4},
IsCA: true,
SubjectKeyId: []byte{1, 2, 3, 4},
}

if cert := serialiseAndParse(t, template); len(cert.AuthorityKeyId) != 0 {
Expand Down
12 changes: 8 additions & 4 deletions usage/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type list struct {
parent *list
}

/* TODO: commented because unused
func (l *list) isUnordered() bool {
return !l.isOrdered() && !l.isDefinition()
}
Expand All @@ -46,15 +47,16 @@ func (l *list) isOrdered() bool {
return l.flags&md.ListTypeOrdered != 0
}
func (l *list) isDefinition() bool {
return l.flags&md.ListTypeDefinition != 0
}

func (l *list) containsBlock() bool {
// TODO: Not sure if we have to check every item or if it gets
// automatically set on the list?
return l.flags&md.ListItemContainsBlock != 0
}
*/

func (l *list) isDefinition() bool {
return l.flags&md.ListTypeDefinition != 0
}

type bufqueue struct {
w io.Writer
Expand Down Expand Up @@ -105,9 +107,11 @@ func (r *Renderer) inParagraph() bool {
return r.inpara
}

/* TODO: commented because unused
func (r *Renderer) inList() bool {
return r.list != nil
}
*/

func (r *Renderer) renderParagraphKeepBreaks(buf *bytes.Buffer) {
scanner := bufio.NewScanner(buf)
Expand Down

0 comments on commit 8bf124f

Please sign in to comment.