Skip to content

Commit

Permalink
Enable dead code elimination linter
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonRichardson committed Feb 8, 2021
1 parent 7455a0b commit f76391a
Show file tree
Hide file tree
Showing 176 changed files with 154 additions and 1,266 deletions.
1 change: 1 addition & 0 deletions .github/golangci-lint.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ linters:
- ineffassign
- misspell
- unconvert
- deadcode
run:
timeout: 20m
skip-dirs:
Expand Down
2 changes: 0 additions & 2 deletions api/applicationoffers/access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ type accessSuite struct {
testing.BaseSuite
}

type accessFunc func(string, string, ...string) error

var _ = gc.Suite(&accessSuite{})

const (
Expand Down
3 changes: 0 additions & 3 deletions api/backups/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ var (
// TODO(perrito666) This is a workaround for lp:1399722 .
type ClientConnection func() (*Client, error)

// closerfunc is a function that allows you to close a client connection.
type closerFunc func() error

func prepareAttempt(client *Client) (error, error) {
var remoteError error
defer client.Close()
Expand Down
4 changes: 0 additions & 4 deletions api/bundle/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@

// Package bundle provides access to the bundle api facade.
// This facade contains api calls that are specific to bundles.

package bundle

import (
"github.com/juju/errors"
"github.com/juju/loggo"

"github.com/juju/juju/api/base"
"github.com/juju/juju/apiserver/params"
)

var logger = loggo.GetLogger("juju.api.bundle")

// Client allows access to the bundle API end point.
type Client struct {
base.ClientFacade
Expand Down
7 changes: 0 additions & 7 deletions api/caasoperator/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,6 @@ func (c *Client) SetStatus(
return result.OneError()
}

func convertNotFound(err error) error {
if params.IsCodeNotFound(err) {
return errors.NewNotFound(err, "")
}
return err
}

// CharmInfo holds info about the charm for an application.
type CharmInfo struct {
// URL holds the URL of the charm assigned to the
Expand Down
3 changes: 0 additions & 3 deletions api/credentialmanager/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ package credentialmanager

import (
"github.com/juju/errors"
"github.com/juju/loggo"

"github.com/juju/juju/api/base"
"github.com/juju/juju/apiserver/params"
)

var logger = loggo.GetLogger("juju.api.credentialmanager")

// Client allows access to the credential management API end point.
type Client struct {
base.ClientFacade
Expand Down
3 changes: 0 additions & 3 deletions api/credentialvalidator/credentialvalidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package credentialvalidator

import (
"github.com/juju/errors"
"github.com/juju/loggo"
"github.com/juju/names/v4"

"github.com/juju/juju/api/base"
Expand All @@ -14,8 +13,6 @@ import (
"github.com/juju/juju/core/watcher"
)

var logger = loggo.GetLogger("juju.api.credentialvalidator")

// Facade provides methods that the Juju client command uses to interact
// with the Juju backend.
type Facade struct {
Expand Down
3 changes: 0 additions & 3 deletions api/crosscontroller/crosscontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ package crosscontroller

import (
"github.com/juju/errors"
"github.com/juju/loggo"

"github.com/juju/juju/api/base"
apiwatcher "github.com/juju/juju/api/watcher"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/watcher"
)

var logger = loggo.GetLogger("juju.api.crosscontroller")

// Client provides access to the CrossController API facade.
type Client struct {
base.ClientFacade
Expand Down
3 changes: 0 additions & 3 deletions api/highavailability/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ package highavailability

import (
"github.com/juju/errors"
"github.com/juju/loggo"

"github.com/juju/juju/api/base"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/constraints"
)

var logger = loggo.GetLogger("juju.api.highavailability")

// Client provides access to the high availability service, used to manage controllers.
type Client struct {
base.ClientFacade
Expand Down
4 changes: 0 additions & 4 deletions api/highavailability/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ type KillerForTesting interface {
KillForTesting() error
}

func assertKill(c *gc.C, killer KillerForTesting) {
c.Assert(killer.KillForTesting(), gc.IsNil)
}

func assertEnableHA(c *gc.C, s *jujutesting.JujuConnSuite) {
m, err := s.State.AddMachine("quantal", state.JobManageModel)
c.Assert(err, jc.ErrorIsNil)
Expand Down
2 changes: 0 additions & 2 deletions api/modelmanager/access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ type accessSuite struct {
testing.BaseSuite
}

type accessFunc func(string, string, ...string) error

var _ = gc.Suite(&accessSuite{})

const (
Expand Down
3 changes: 0 additions & 3 deletions api/modelupgrader/modelupgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package modelupgrader

import (
"github.com/juju/errors"
"github.com/juju/loggo"
"github.com/juju/names/v4"

"github.com/juju/juju/api/base"
Expand All @@ -15,8 +14,6 @@ import (
"github.com/juju/juju/core/watcher"
)

var logger = loggo.GetLogger("juju.api.modelupgrader")

// Client provides methods that the Juju client command uses to interact
// with models stored in the Juju Server.
type Client struct {
Expand Down
6 changes: 0 additions & 6 deletions api/modelupgrader/modelupgrader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ type ModelUpgraderSuite struct {
coretesting.BaseSuite
}

var nullAPICaller = testing.APICallerFunc(
func(objType string, version int, id, request string, arg, result interface{}) error {
return nil
},
)

func (s *ModelUpgraderSuite) TestModelEnvironVersion(c *gc.C) {
apiCaller := testing.APICallerFunc(func(objType string, version int, id, request string, arg, result interface{}) error {
c.Check(objType, gc.Equals, "ModelUpgrader")
Expand Down
2 changes: 0 additions & 2 deletions api/remoterelations/remoterelations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,6 @@ func (s *remoteRelationsSuite) TestSetRemoteApplicationStatus(c *gc.C) {
c.Check(callCount, gc.Equals, 1)
}

type facadeCallFunc = func(objType string, version int, id, request string, arg, result interface{}) error

func (s *remoteRelationsSuite) TestUpdateControllerForModelResultCount(c *gc.C) {
apiCaller := testing.APICallerFunc(
func(objType string, version int, id, request string, arg, result interface{}) error {
Expand Down
4 changes: 0 additions & 4 deletions api/uniter/podspec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ type podSpecSuite struct {

var _ = gc.Suite(&podSpecSuite{})

func strPtr(s string) *string {
return &s
}

func (s *podSpecSuite) TestGetPodSpec(c *gc.C) {
expected := params.Entities{
Entities: []params.Entity{{
Expand Down
4 changes: 2 additions & 2 deletions apiserver/common/firewall/firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
package firewall

import (
"net"

"github.com/juju/errors"
"github.com/juju/loggo"
"github.com/juju/names/v4"
Expand Down Expand Up @@ -121,6 +119,7 @@ func localApplication(st State, relationTag names.RelationTag) (*localEndpointIn
}

// TODO(wallyworld) - this is unused until we query subnets again
/*
func includeAsEgressSubnet(cidr string) (bool, error) {
ip, _, err := net.ParseCIDR(cidr)
if err != nil {
Expand All @@ -135,3 +134,4 @@ func includeAsEgressSubnet(cidr string) (bool, error) {
}
return true, nil
}
*/
6 changes: 0 additions & 6 deletions apiserver/common/firewall/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"gopkg.in/macaroon.v2"
"gopkg.in/tomb.v2"

"github.com/juju/juju/apiserver/common/cloudspec"
"github.com/juju/juju/apiserver/common/firewall"
"github.com/juju/juju/controller"
"github.com/juju/juju/core/crossmodel"
Expand All @@ -23,11 +22,6 @@ import (
coretesting "github.com/juju/juju/testing"
)

type mockCloudSpecAPI struct {
// TODO - implement when remaining firewaller tests become unit tests
cloudspec.CloudSpecAPI
}

type mockState struct {
// TODO - implement when remaining firewaller tests become unit tests
state.ModelMachinesWatcher
Expand Down
3 changes: 0 additions & 3 deletions apiserver/facades/agent/machine/machiner.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package machine

import (
"github.com/juju/errors"
"github.com/juju/loggo"
"github.com/juju/names/v4"

"github.com/juju/juju/apiserver/common"
Expand All @@ -19,8 +18,6 @@ import (
"github.com/juju/juju/state"
)

var logger = loggo.GetLogger("juju.apiserver.machine")

// TODO (manadart 2020-10-21): Remove the ModelUUID method
// from the next version of this facade.

Expand Down
25 changes: 0 additions & 25 deletions apiserver/facades/client/applicationoffers/conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,6 @@ func paramsFromProviderSpaceInfo(info *environs.ProviderSpaceInfo) params.Remote
return result
}

// providerSpaceInfoFromParams converts a params.RemoteSpace to the
// equivalent ProviderSpaceInfo.
func providerSpaceInfoFromParams(space params.RemoteSpace) *environs.ProviderSpaceInfo {
result := &environs.ProviderSpaceInfo{
CloudType: space.CloudType,
ProviderAttributes: space.ProviderAttributes,
SpaceInfo: network.SpaceInfo{
Name: network.SpaceName(space.Name),
ProviderId: network.Id(space.ProviderId),
},
}
for _, subnet := range space.Subnets {
resultSubnet := network.SubnetInfo{
CIDR: subnet.CIDR,
ProviderId: network.Id(subnet.ProviderId),
ProviderNetworkId: network.Id(subnet.ProviderNetworkId),
ProviderSpaceId: network.Id(subnet.ProviderSpaceId),
VLANTag: subnet.VLANTag,
AvailabilityZones: subnet.Zones,
}
result.Subnets = append(result.Subnets, resultSubnet)
}
return result
}

// spaceInfoFromState converts a state.Space into the equivalent
// network.SpaceInfo.
func spaceInfoFromState(space Space) (*network.SpaceInfo, error) {
Expand Down
2 changes: 0 additions & 2 deletions apiserver/facades/client/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ import (
"github.com/juju/juju/storage"
)

var logger = loggo.GetLogger("juju.apiserver.bundle")

// APIv1 provides the Bundle API facade for version 1.
type APIv1 struct {
*APIv2
Expand Down
12 changes: 0 additions & 12 deletions apiserver/facades/client/charms/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@ type storeCharmShim struct {
*charm.CharmArchive
}

func newStoreCharmShim(archive *charm.CharmArchive) *storeCharmShim {
return &storeCharmShim{
CharmArchive: archive,
}
}

// LXDProfile implements core.lxdprofile.LXDProfiler
func (p *storeCharmShim) LXDProfile() *charm.LXDProfile {
if p.CharmArchive == nil {
Expand All @@ -106,12 +100,6 @@ type storeCharmLXDProfiler struct {
StoreCharm
}

func makeStoreCharmLXDProfiler(shim StoreCharm) storeCharmLXDProfiler {
return storeCharmLXDProfiler{
StoreCharm: shim,
}
}

// LXDProfile implements core.lxdprofile.LXDProfiler
func (p storeCharmLXDProfiler) LXDProfile() lxdprofile.LXDProfile {
if p.StoreCharm == nil {
Expand Down
17 changes: 0 additions & 17 deletions apiserver/facades/client/charms/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package charms

import (
"bytes"
"strings"

"github.com/juju/charm/v8"
Expand Down Expand Up @@ -73,22 +72,6 @@ type Metadata interface {
ComputedSeries() []string
}

func unmarshalCharmMetadata(metadataYAML string) (Metadata, error) {
meta, err := charm.ReadMeta(bytes.NewBufferString(metadataYAML))
if err != nil {
return nil, errors.Trace(err)
}
return meta, nil
}

func unmarshalBundleMetadata(bundleYAML string) (Metadata, error) {
meta, err := charm.ReadBundleData(bytes.NewBufferString(bundleYAML))
if err != nil {
return nil, errors.Trace(err)
}
return bundleMetadata{BundleData: meta}, nil
}

type bundleMetadata struct {
*charm.BundleData
}
Expand Down
Loading

0 comments on commit f76391a

Please sign in to comment.