Skip to content

Commit

Permalink
Fix linters + Disable deadcode and golint.
Browse files Browse the repository at this point in the history
A buncher of linter were not actually linting (yay)
Had to disable deadcode and golint because their fixes would take
too long.
  • Loading branch information
hpidcock committed Apr 23, 2020
1 parent 5d2b5a8 commit 3e2c2e6
Show file tree
Hide file tree
Showing 29 changed files with 74 additions and 93 deletions.
2 changes: 1 addition & 1 deletion api/caasfirewaller/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (c *Client) Life(appName string) (life.Value, error) {
if err := results.Results[0].Error; err != nil {
return "", maybeNotFound(err)
}
return life.Value(results.Results[0].Life), nil
return results.Results[0].Life, nil
}

// ApplicationConfig returns the config for the specified application.
Expand Down
2 changes: 1 addition & 1 deletion api/caasoperator/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func (c *Client) Life(entityName string) (life.Value, error) {
if err := results.Results[0].Error; err != nil {
return "", maybeNotFound(err)
}
return life.Value(results.Results[0].Life), nil
return results.Results[0].Life, nil
}

// maybeNotFound returns an error satisfying errors.IsNotFound
Expand Down
2 changes: 1 addition & 1 deletion api/caasoperatorprovisioner/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (c *Client) Life(appName string) (life.Value, error) {
if err := results.Results[0].Error; err != nil {
return "", maybeNotFound(err)
}
return life.Value(results.Results[0].Life), nil
return results.Results[0].Life, nil
}

// OperatorProvisioningInfo holds the info needed to provision an operator.
Expand Down
2 changes: 1 addition & 1 deletion api/caasunitprovisioner/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func (c *Client) Life(entityName string) (life.Value, error) {
if err := results.Results[0].Error; err != nil {
return "", maybeNotFound(err)
}
return life.Value(results.Results[0].Life), nil
return results.Results[0].Life, nil
}

// maybeNotFound returns an error satisfying errors.IsNotFound
Expand Down
2 changes: 1 addition & 1 deletion api/lifeflag/facade.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (facade *Facade) Life(entity names.Tag) (life.Value, error) {
}
return "", errors.Trace(result.Error)
}
life := life.Value(result.Life)
life := result.Life
if err := life.Validate(); err != nil {
return "", errors.Trace(err)
}
Expand Down
3 changes: 1 addition & 2 deletions api/watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

"github.com/juju/juju/api/base"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/life"
"github.com/juju/juju/core/migration"
"github.com/juju/juju/core/status"
"github.com/juju/juju/core/watcher"
Expand Down Expand Up @@ -584,7 +583,7 @@ func (w *relationStatusWatcher) loop(initialChanges []params.RelationLifeSuspend
for i, ch := range changes {
result[i] = watcher.RelationStatusChange{
Key: ch.Key,
Life: life.Value(ch.Life),
Life: ch.Life,
Suspended: ch.Suspended,
SuspendedReason: ch.SuspendedReason,
}
Expand Down
15 changes: 0 additions & 15 deletions apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,21 +457,6 @@ func (srv *Server) getAgentToken() error {
return nil
}

// loggoWrapper is an io.Writer() that forwards the messages to a loggo.Logger.
// Unfortunately http takes a concrete stdlib log.Logger struct, and not an
// interface, so we can't just proxy all of the log levels without inspecting
// the string content. For now, we just want to get the messages into the log
// file.
type loggoWrapper struct {
logger loggo.Logger
level loggo.Level
}

func (w *loggoWrapper) Write(content []byte) (int, error) {
w.logger.Logf(w.level, "%s", string(content))
return len(content), nil
}

// logsinkMetricsCollectorWrapper defines a wrapper for exposing the essentials
// for the logsink api handler to interact with the metrics collector.
type logsinkMetricsCollectorWrapper struct {
Expand Down
8 changes: 4 additions & 4 deletions apiserver/common/networkingcommon/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func NetworkInterfacesToStateArgs(ifaces []corenetwork.InterfaceInfo) (
args := state.LinkLayerDeviceArgs{
Name: iface.InterfaceName,
MTU: mtu,
ProviderID: corenetwork.Id(iface.ProviderId),
ProviderID: iface.ProviderId,
Type: corenetwork.LinkLayerDeviceType(iface.InterfaceType),
MACAddress: iface.MACAddress,
IsAutoStart: !iface.NoAutoStart,
Expand Down Expand Up @@ -220,9 +220,9 @@ func NetworkInterfacesToStateArgs(ifaces []corenetwork.InterfaceInfo) (

addr := state.LinkLayerDeviceAddress{
DeviceName: iface.InterfaceName,
ProviderID: corenetwork.Id(iface.ProviderAddressId),
ProviderNetworkID: corenetwork.Id(iface.ProviderNetworkId),
ProviderSubnetID: corenetwork.Id(iface.ProviderSubnetId),
ProviderID: iface.ProviderAddressId,
ProviderNetworkID: iface.ProviderNetworkId,
ProviderSubnetID: iface.ProviderSubnetId,
ConfigMethod: derivedConfigMethod,
CIDRAddress: cidrAddress,
DNSServers: iface.DNSServers.ToIPAddresses(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (a *API) IssueOperatorCertificate(args params.Entities) (params.IssueOperat
}

res.Results[i] = params.IssueOperatorCertificateResult{
CACert: string(caCert),
CACert: caCert,
Cert: string(cert),
PrivateKey: string(privateKey),
}
Expand Down
2 changes: 1 addition & 1 deletion apiserver/params/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ type RemoveSpaceResults struct {
// RemoveSpaceResult contains entries if removing a space is not possible.
// Constraints are a slice of entities which has constraints on the space.
// Bindings are a slice of entities which has bindings on that space.
// Error is filled if an error has occured which is unexpected.
// Error is filled if an error has occurred which is unexpected.
type RemoveSpaceResult struct {
Constraints []Entity `json:"constraints,omitempty"`
Bindings []Entity `json:"bindings,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion apiserver/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ func (w *SrvModelSummaryWatcher) translate(summaries []cache.ModelSummary) []par
Units: summary.UnitCount,
Relations: summary.RelationCount,
},
Status: string(summary.Status),
Status: summary.Status,
Messages: w.translateMessages(summary.Messages),
Annotations: summary.Annotations,
}
Expand Down
2 changes: 1 addition & 1 deletion caas/kubernetes/provider/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ func (k *kubernetesClient) ensureService(
return errors.Annotate(err, "creating or updating DaemonSet")
}
default:
// This should never happend because we have validated both in this method and in `charm.v6`.
// This should never happened because we have validated both in this method and in `charm.v6`.
return errors.NotSupportedf("deployment type %q", params.Deployment.DeploymentType)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/commands/debugcode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (s *DebugCodeSuite) TestArgFormatting(c *gc.C) {
debugArgsRegex := regexp.MustCompile(`echo "([A-Z-a-z0-9+/]+=*)" \| base64.*-debug-hooks`)
debugArgsCommand := debugArgsRegex.FindString(string(scriptContent))
debugArgsB64 := debugArgsCommand[len(`echo "`):strings.Index(debugArgsCommand, `" | base64`)]
yamlContent, err := base64.StdEncoding.DecodeString(string(debugArgsB64))
yamlContent, err := base64.StdEncoding.DecodeString(debugArgsB64)
var args map[string]interface{}
err = goyaml.Unmarshal(yamlContent, &args)
c.Assert(err, jc.ErrorIsNil)
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/commands/debughooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (s *DebugHooksSuite) TestDebugHooksArgFormatting(c *gc.C) {
debugArgsRegex := regexp.MustCompile(`echo "([A-Z-a-z0-9+/]+=*)" \| base64.*-debug-hooks`)
debugArgsCommand := debugArgsRegex.FindString(string(scriptContent))
debugArgsB64 := debugArgsCommand[len(`echo "`):strings.Index(debugArgsCommand, `" | base64`)]
yamlContent, err := base64.StdEncoding.DecodeString(string(debugArgsB64))
yamlContent, err := base64.StdEncoding.DecodeString(debugArgsB64)
var args map[string]interface{}
err = goyaml.Unmarshal(yamlContent, &args)
c.Assert(err, jc.ErrorIsNil)
Expand Down
2 changes: 1 addition & 1 deletion core/quota/multichecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type MultiChecker struct {
checkers []Checker
}

// NewMultiChecker retuns a Checker that composes the Check/Outcome logic for
// NewMultiChecker returns a Checker that composes the Check/Outcome logic for
// the specified list of Checkers.
func NewMultiChecker(checkers ...Checker) *MultiChecker {
return &MultiChecker{
Expand Down
2 changes: 1 addition & 1 deletion pki/authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Authority interface {

// LeafGroupFromPemCertKey loads an already existing certificate key pair as
// a new leaf at the given group. Returns error if a leaf for the given
// group already exists or an error occured loading the pem data.
// group already exists or an error occurred loading the pem data.
LeafGroupFromPemCertKey(group string, certPem, key []byte) (Leaf, error)

// LeafRequestForGroup starts a new leaf request for the given group. If a
Expand Down
2 changes: 1 addition & 1 deletion pki/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type DefaultRequestSigner struct {
}

const (
// DefaultValidtyYears is the max age a certificate is signed for useing the
// DefaultValidityYears is the max age a certificate is signed for using the
// DefaultRequestSigner
DefaultValidityYears = 10
)
Expand Down
2 changes: 1 addition & 1 deletion provider/azure/internal/errorutils/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func CheckForGraphError(r autorest.Responder) autorest.Responder {
})
}

// GraphError is a go error that wraps the graphrbac.GraphError reponse
// GraphError is a go error that wraps the graphrbac.GraphError response
// type, which doesn't implement the error interface.
type GraphError struct {
graphrbac.GraphError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ func locationToRegion(loc string) (string, bool) {
"US West (N. California)": "us-west-1",
"US West (Oregon)": "us-west-2",
// LA is a local zone, we currently don't support them.
// It is a AZ in us-west-2, but for pricing it is a seperate region.
// It is a AZ in us-west-2, but for pricing it is a separate region.
"US West (Los Angeles)": ignoreRegion,
"Canada (Central)": "ca-central-1",
"EU (Frankfurt)": "eu-central-1",
Expand Down
2 changes: 1 addition & 1 deletion provider/vsphere/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (step modelFoldersUpgradeStep) Run(ctx context.ProviderCallContext) error {
// We must create the folder even if there are no VMs in the model.
modelFolderPath := path.Join(env.getVMFolder(), controllerFolderName(step.controllerUUID), env.modelFolderName())

// EnsureVMFolder needs credential attributes to be defined separatedly
// EnsureVMFolder needs credential attributes to be defined separately
// from the folders it is supposed to create
if _, err := env.client.EnsureVMFolder(
env.ctx,
Expand Down
2 changes: 1 addition & 1 deletion state/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type actionNotificationDoc struct {
// represents.
ActionID string `bson:"actionid"`

// Changed represents the time when the corrosponding Action had a change
// Changed represents the time when the corresponding Action had a change
// worthy of notifying on.
// NOTE: changed should not be set on pending actions, see actionNotificationWatcher.
Changed time.Time `bson:"changed,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion state/allwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func (m *backingMachine) updated(ctx *allWatcherContext) error {
return errors.Annotatef(err, "retrieving space for ID %q", spaceID)
}
mAddr.SpaceName = network.SpaceName(space.Name())
mAddr.ProviderSpaceID = network.Id(space.ProviderId())
mAddr.ProviderSpaceID = space.ProviderId()
}

info.Addresses = append(info.Addresses, mAddr)
Expand Down
16 changes: 8 additions & 8 deletions state/allwatcher_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1278,8 +1278,8 @@ func testChangePermissions(c *gc.C, runChangeTests func(*gc.C, []changeTestFunc)
about: "model update keeps permissions",
initialContents: []multiwatcher.EntityInfo{&multiwatcher.ModelInfo{
ModelUUID: st.ModelUUID(),
// Existance doesn't care about the other values, and they are
// not entirely relevent to this test.
// Existence doesn't care about the other values, and they are
// not entirely relevant to this test.
UserPermissions: map[string]permission.Access{
"bob": permission.ReadAccess,
"mary": permission.AdminAccess,
Expand Down Expand Up @@ -1324,8 +1324,8 @@ func testChangePermissions(c *gc.C, runChangeTests func(*gc.C, []changeTestFunc)
initialContents: []multiwatcher.EntityInfo{&multiwatcher.ModelInfo{
ModelUUID: st.ModelUUID(),
Name: model.Name(),
// Existance doesn't care about the other values, and they are
// not entirely relevent to this test.
// Existence doesn't care about the other values, and they are
// not entirely relevant to this test.
UserPermissions: map[string]permission.Access{
"bob": permission.ReadAccess,
"mary": permission.AdminAccess,
Expand Down Expand Up @@ -1356,8 +1356,8 @@ func testChangePermissions(c *gc.C, runChangeTests func(*gc.C, []changeTestFunc)
initialContents: []multiwatcher.EntityInfo{&multiwatcher.ModelInfo{
ModelUUID: st.ModelUUID(),
Name: model.Name(),
// Existance doesn't care about the other values, and they are
// not entirely relevent to this test.
// Existence doesn't care about the other values, and they are
// not entirely relevant to this test.
UserPermissions: map[string]permission.Access{
"bob": permission.ReadAccess,
"mary": permission.AdminAccess,
Expand Down Expand Up @@ -1403,8 +1403,8 @@ func testChangePermissions(c *gc.C, runChangeTests func(*gc.C, []changeTestFunc)
initialContents: []multiwatcher.EntityInfo{&multiwatcher.ModelInfo{
ModelUUID: st.ModelUUID(),
Name: model.Name(),
// Existance doesn't care about the other values, and they are
// not entirely relevent to this test.
// Existence doesn't care about the other values, and they are
// not entirely relevant to this test.
UserPermissions: map[string]permission.Access{
"bob": permission.ReadAccess,
"mary": permission.AdminAccess,
Expand Down
2 changes: 1 addition & 1 deletion state/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ func (a *Application) SetCharm(cfg SetCharmConfig) (err error) {
quotaErr := a.preUpgradeRelationLimitCheck(cfg.Charm)

// If the operator specified --force, we still allow
// the ugprade to continue with a warning.
// the upgrade to continue with a warning.
if errors.IsQuotaLimitExceeded(quotaErr) && cfg.Force {
logger.Warningf("%v; allowing upgrade to proceed as the operator specified --force", quotaErr)
} else if quotaErr != nil {
Expand Down
4 changes: 2 additions & 2 deletions state/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -3240,13 +3240,13 @@ type actionNotificationWatcher struct {
sink chan []string
filter func(interface{}) bool
// notifyPending when true will notify all pending and running actions as
// initial events, but therafter only notify on pending actions.
// initial events, but thereafter only notify on pending actions.
notifyPending bool
}

// newActionNotificationWatcher starts and returns a new StringsWatcher configured
// with the given collection and filter function. notifyPending when true will notify all pending and running actions as
// initial events, but therafter only notify on pending actions.
// initial events, but thereafter only notify on pending actions.
func newActionNotificationWatcher(backend modelBackend, notifyPending bool, receivers ...ActionReceiver) StringsWatcher {
w := &actionNotificationWatcher{
commonWatcher: newCommonWatcher(backend),
Expand Down
Loading

0 comments on commit 3e2c2e6

Please sign in to comment.