Skip to content

Commit

Permalink
Enable govet nilness check and fix infractions (#2729)
Browse files Browse the repository at this point in the history
Seems like a reasonable check; removes some unnecessary extra code.

Some of these codepaths don't exist in `bufmod`, but happy to port over
this check and fixes there as well.
  • Loading branch information
stefanvanburen authored Jan 24, 2024
1 parent 758b89d commit 2e1d627
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ linters-settings:
- '^log\.'
- '^print$'
- '^println$'
govet:
enable:
- nilness
importas:
alias:
- pkg: github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/image/v1
Expand Down
3 changes: 0 additions & 3 deletions private/buf/bufsync/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,9 +641,6 @@ func (s *syncer) protectSyncedModuleBranch(
if err != nil {
return fmt.Errorf("resolve sync point for module %s: %w", moduleIdentity.IdentityString(), err)
}
if err != nil {
return err
}
if syncPoint == nil {
// Branch has never been synced, there is nothing to protected against.
return nil
Expand Down
3 changes: 0 additions & 3 deletions private/buf/cmd/buf/command/beta/graph/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ func run(
bufcli.NewFetchReader(container.Logger(), storageosProvider, runner, moduleResolver, moduleReader),
bufmodulebuild.NewModuleBucketBuilder(),
)
if err != nil {
return err
}
graphBuilder := bufgraph.NewBuilder(
container.Logger(),
moduleResolver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func javaMultipleFilesForFile(
// The option is already set to the same value, don't do anything.
return nil
}
case options == nil && descriptorpb.Default_FileOptions_JavaMultipleFiles == value:
case descriptorpb.Default_FileOptions_JavaMultipleFiles == value:
// The option is not set, but the value we want to set is the
// same as the default, don't do anything.
return nil
Expand Down
3 changes: 0 additions & 3 deletions private/pkg/protosource/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -638,9 +638,6 @@ func (f *file) populateMessage(
getMessageExtensionPackedPath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),
getMessageExtensionExtendeePath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),
)
if err != nil {
return nil, err
}
message.addExtension(field)
if oneof != nil {
oneof.addField(field)
Expand Down

0 comments on commit 2e1d627

Please sign in to comment.