From 73e5479639c2006d859bc5d4a43034b047333bb2 Mon Sep 17 00:00:00 2001 From: kt Date: Sun, 20 Jan 2019 23:30:47 -0800 Subject: [PATCH] update to work with new static check --- .gometalinter.json | 3 +-- azurerm/helpers/suppress/string.go | 2 +- azurerm/resource_arm_container_registry.go | 4 ++-- azurerm/resource_arm_container_registry_migrate.go | 2 +- azurerm/resource_arm_container_registry_test.go | 2 +- azurerm/resource_arm_servicebus_namespace.go | 2 +- staticcheck.conf | 10 ++++++++++ 7 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 staticcheck.conf diff --git a/.gometalinter.json b/.gometalinter.json index fc7116727057..961b91cb9da7 100644 --- a/.gometalinter.json +++ b/.gometalinter.json @@ -7,13 +7,12 @@ "gotype", "ineffassign", "interfacer", - "megacheck", "nakedret", "misspell", + "staticcheck", "structcheck", "unparam", "unconvert", - "unused", "varcheck", "vet", "vetshadow" diff --git a/azurerm/helpers/suppress/string.go b/azurerm/helpers/suppress/string.go index 9c9615102c49..2db9554de5ce 100644 --- a/azurerm/helpers/suppress/string.go +++ b/azurerm/helpers/suppress/string.go @@ -7,5 +7,5 @@ import ( ) func CaseDifference(_, old, new string, _ *schema.ResourceData) bool { - return strings.ToLower(old) == strings.ToLower(new) + return strings.EqualFold(old, new) } diff --git a/azurerm/resource_arm_container_registry.go b/azurerm/resource_arm_container_registry.go index 14b1da036bb4..1312f960cba8 100644 --- a/azurerm/resource_arm_container_registry.go +++ b/azurerm/resource_arm_container_registry.go @@ -168,7 +168,7 @@ func resourceArmContainerRegistryCreate(d *schema.ResourceData, meta interface{} } if v, ok := d.GetOk("storage_account_id"); ok { - if strings.ToLower(sku) != strings.ToLower(string(containerregistry.Classic)) { + if !strings.EqualFold(sku, string(containerregistry.Classic)) { return fmt.Errorf("`storage_account_id` can only be specified for a Classic (unmanaged) Sku.") } @@ -176,7 +176,7 @@ func resourceArmContainerRegistryCreate(d *schema.ResourceData, meta interface{} ID: utils.String(v.(string)), } } else { - if strings.ToLower(sku) == strings.ToLower(string(containerregistry.Classic)) { + if strings.EqualFold(sku, string(containerregistry.Classic)) { return fmt.Errorf("`storage_account_id` must be specified for a Classic (unmanaged) Sku.") } } diff --git a/azurerm/resource_arm_container_registry_migrate.go b/azurerm/resource_arm_container_registry_migrate.go index c6982467325f..392588a247eb 100644 --- a/azurerm/resource_arm_container_registry_migrate.go +++ b/azurerm/resource_arm_container_registry_migrate.go @@ -99,7 +99,7 @@ func findAzureStorageAccountIdFromName(name string, meta interface{}) (string, e } for _, account := range *accounts.Value { - if strings.ToLower(*account.Name) == strings.ToLower(name) { + if strings.EqualFold(*account.Name, name) { return *account.ID, nil } } diff --git a/azurerm/resource_arm_container_registry_test.go b/azurerm/resource_arm_container_registry_test.go index a1f22557e66b..efbc0668db28 100644 --- a/azurerm/resource_arm_container_registry_test.go +++ b/azurerm/resource_arm_container_registry_test.go @@ -444,7 +444,7 @@ func testCheckAzureRMContainerRegistryGeoreplications(resourceName string, sku s expectedLocationsCount := len(expectedLocations) + 1 // the main location is returned by the API as a geolocation for replication. // if Sku is not premium, listing the geo-replications locations returns an empty list - if strings.ToLower(sku) != strings.ToLower(string(containerregistry.Premium)) { + if !strings.EqualFold(sku, string(containerregistry.Premium)) { expectedLocationsCount = 0 } diff --git a/azurerm/resource_arm_servicebus_namespace.go b/azurerm/resource_arm_servicebus_namespace.go index b145faa09926..82929dd9cbc4 100644 --- a/azurerm/resource_arm_servicebus_namespace.go +++ b/azurerm/resource_arm_servicebus_namespace.go @@ -98,7 +98,7 @@ func resourceArmServiceBusNamespace() *schema.Resource { //so lets only allow it to be set if the SKU is premium if _, ok := d.GetOk("capacity"); ok { sku := d.Get("sku").(string) - if strings.ToLower(sku) != strings.ToLower(string(servicebus.Premium)) { + if strings.EqualFold(sku, string(servicebus.Premium)) { return fmt.Errorf("`capacity` can only be set for a Premium SKU") } } diff --git a/staticcheck.conf b/staticcheck.conf new file mode 100644 index 000000000000..ff0d7186ffc7 --- /dev/null +++ b/staticcheck.conf @@ -0,0 +1,10 @@ +checks = ["all", "-ST1000", "-ST1003", "-ST1005", "-ST1016"] +initialisms = ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", + "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", + "IP", "JSON", "QPS", "RAM", "RPC", "SLA", + "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", + "UDP", "UI", "GID", "UID", "UUID", "URI", + "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", + "XSS"] +dot_import_whitelist = [] +http_status_code_whitelist = ["200", "400", "404", "500"] \ No newline at end of file