BREAKING CHANGES
- passes/R008: Due to removing terraform-plugin-sdk v1 support, this check will no longer return reports.
- passes/S034: Due to removing terraform-plugin-sdk v1 support, this check will no longer return reports.
- passes/V002: Due to removing terraform-plugin-sdk v1 support, this check will no longer return reports.
- passes/V003: Due to removing terraform-plugin-sdk v1 support, this check will no longer return reports.
- passes/V004: Due to removing terraform-plugin-sdk v1 support, this check will no longer return reports.
- passes/V005: Due to removing terraform-plugin-sdk v1 support, this check will no longer return reports.
- passes/V006: Due to removing terraform-plugin-sdk v1 support, this check will no longer return reports.
- passes/V007: Due to removing terraform-plugin-sdk v1 support, this check will no longer return reports.
- passes/V008: Due to removing terraform-plugin-sdk v1 support, this check will no longer return reports.
NOTES
- all: This Go module and the associated Docker image has been updated to Go 1.21 per the Go support policy. Any consumers building on earlier Go versions or dependent on earlier Go version functionality may experience errors. (#299 / #308)
- all: Support for terraform-plugin-sdk v1 has been removed as it has been end-of-life for many years. Any checks that were only for that dependency have been converted to skip all logic and return no reports. (#305)
- all: For Go module consumers, provider SDK dependencies such as github.com/hashicorp/terraform-plugin-sdk at a specific version are no reflected in the main Go module. This should prevent dependency conflict errors and potentially reduce indirect dependency security notices. (#307)
NOTES
- all: This Go module and the associated Docker image has been updated to Go 1.19 per the Go support policy. Any consumers building on earlier Go versions or dependent on earlier Go version functionality may experience errors. (#269)
FEATURES
- all: Released binaries now include
darwin/arm64
,linux/arm64
, andwindows/arm64
(#258)
BUG FIXES
- all: Prevented Go 1.18 and later
internal error: package XXX without types was imported
errors (#270)
BUG FIXES
- passes/commentignore: Prevent regression from v0.28.0 in which leading spaces before the lintignore directive would not trigger the directive (#252)
ENHANCEMENTS
- passes/commentignore: Support multiple line comments (#249)
BUG FIXES
- xpasses/XS001: Prevent false positives with non string literal descriptions (#242)
- xpasses/XR005: Prevent false positives with non string literal descriptions (#242)
ENHANCEMENTS
- passes/R006: Add
package-aliases
flag
FEATURES
- New Check:
XR007
: check foros/exec.Command
usage - New Check:
XR008
: check foros/exec.CommandContext
usage
ENHANCEMENTS
- helper/terraformtype/helper/schema: Add constants for new
Resource
typeCreateWithoutTimeout
,DeleteWithoutTimeout
,ReadWithoutTimeout
, andDeleteWithoutTimeout
fields - xpasses/XR006: Support
CreateWithoutTimeout
,DeleteWithoutTimeout
,ReadWithoutTimeout
, andDeleteWithoutTimeout
FEATURES
- New Check:
AT010
: check forTestCase
includingIDRefreshName
implementation - New Check:
AT011
: check forTestCase
includingIDRefreshIgnore
implementation withoutIDRefreshName
- New Check:
AT012
: check for files containing multiple acceptance test function name prefixes - New Check:
V011
: check for customSchemaValidateFunc
that implementvalidation.StringLenBetween()
- New Check:
V012
: check for customSchemaValidateFunc
that implementvalidation.IntAtLeast()
,validation.IntAtMost()
, orvalidation.IntBetween()
- New Check:
V013
: check for customSchemaValidateFunc
that implementvalidation.StringInSlice()
orvalidation.StringNotInSlice()
- New Check:
V014
: check for customSchemaValidateFunc
that implementvalidation.IntInSlice()
orvalidation.IntNotInSlice()
FEATURES
- New Extra Check:
XAT001
: check forTestCase
missingErrorCheck
implementation
FEATURES
- New Check:
XR006
: check forResource
that implementsTimeouts
for missingCreate
,Delete
,Read
, orUpdate
implementation (#222)
ENHANCEMENTS
- passes/helper/schema/crudfuncinfo: Support
CreateContextFunc
,DeleteContextFunc
,ReadContextFunc
, andUpdateContextFunc
matches (#221) - passes/R014: Support
CreateContextFunc
,DeleteContextFunc
,ReadContextFunc
, andUpdateContextFunc
reports (#221)
BUG FIXES
- helper/terraformtype/helper/schema: Prevent panics with function or variable
Elem
field values
FEATURES
- New Check:
R019
: check for(*schema.ResourceData).HasChanges()
receiver method usage with many arguments - New Check:
V009
: check forvalidation.StringMatch()
calls with empty message argument - New Check:
V010
: check forvalidation.StringDoesNotMatch()
calls with empty message argument
BUG FIXES
- passes/AT009: Correct constant detection for
acctest.RandStringFromCharSet()
calls that can beacctest.RandString
(#215)
FEATURES
- New Check:
AT009
: check foracctest.RandStringFromCharSet()
calls that can beacctest.RandString
ENHANCEMENTS
- passes/helper/acctest: Pass for collecting
acctest.RandStringFromCharSet()
calls - passes/АТ001: Add optional
-ignored-filename-suffixes
and-ignored-filename-prefixes
flags (#210)
FEATURES
- New Check:
R018
: check fortime.Sleep()
function usage
ENHANCEMENTS
- passes/commentignore: Support multiple comma separated keys and extra
//
comments (#208) - passes/stdlib: Pass for collecting
time.Sleep()
calls
BUG FIXES
- helper/astutils: Prevent
(*types.Info).ObjectOf()
type assertion panics (#207)
ENHANCEMENTS
- passes/helper/validation: Pass for collecting
validation.StringInSlice()
calls - passes/stdlib: Pass for collecting
fmt.Errorf()
calls
FEATURES
- New Check:
R015
: check for(*schema.ResourceData).SetId()
receiver method usage with unstableresource.UniqueId()
value - New Check:
R016
: check for(*schema.ResourceData).SetId()
receiver method usage with unstableresource.PrefixedUniqueId()
value - New Check:
R017
: check for(*schema.ResourceData).SetId()
receiver method usage with unstabletime.Now()
value
ENHANCEMENTS
- helper/analysisutils: Add
StdlibFunctionCallExprAnalyzer
with associated runner - helper/astutils: Support standard library handling equivalents (no vendoring) for package functions
- passes/helper/schema: Pass for collecting
(*schema.ResourceData).SetId()
calls - passes/stdlib: Pass for collecting
fmt.Sprintf()
calls
BREAKING CHANGES
- helper/terraformtype/helper/resource: Real SDK v1 types inside
RetryErrorInfo
,TestCaseInfo
, andTestStepInfo
have been replaced with internal representations to prevent importing SDK versions. - helper/terraformtype/helper/schema: Real SDK v1 types inside
SchemaInfo
andResourceInfo
have been replaced with internal representations to prevent importing SDK versions.
FEATURES
- New Extra Check:
XS002
: check formap[string]*Schema
that keys are in alphabetical order (#177)
BREAKING CHANGES
- helper/analysisfixtest: Removed package since testing for
SuggestedFixes
is now available withgolang.org/x/tools/go/analysis/analysistest.RunWithSuggestedFixes
FEATURES
- New Extra Check:
XR005
: check forResource
thatDescription
is configured
ENHANCEMENTS
- helper/terraformtype/helper/schema: Support basic linking of
ResourceInfo
andSchemaInfo
(#129) - passes: Initial support for Terraform Plugin SDK v2
- passes/terraform: Pass for collecting
terraform.ResourceProviderFactory
selectors - xpasses: Initial support for Terraform Plugin SDK v2
ENHANCEMENTS
- helper/analysisutils: Add
DeprecatedWithReplacementPointerSelectorExprAnalyzer
,TypeAssertExprRemovalAnalyzer
andTypeAssertExprAnalyzer
with associated runners - helper/astutils: Support
*ast.StarExpr
inIsPackageFunc
- helper/terraformtype/helper/schema: Constants and functions for working with
Provider
type - helper/terraformtype/terraform: Constants and functions for working with
ResourceProviderFactory
type - passes/helper/schema: Pass for collecting
*schema.Provider
type assertions - passes/terraform: Pass for collecting
terraform.ResourceProvider
selectors
BREAKING CHANGES
- helper/analysisutils:
DeprecatedReceiverMethodSelectorExprAnalyzer
andDeprecatedReceiverMethodSelectorExprRunner
now expect an*ast.CallExpr
analyzer and package path (e.g.github.com/hashicorp/terraform-plugin-sdk/helper/validation
) instead of just package name (e.g.validation
) - helper/analysisutils:
DeprecatedWithReplacementSelectorExprAnalyzer
andDeprecatedWithReplacementSelectorExprRunner
now expect package paths (e.g.github.com/hashicorp/terraform-plugin-sdk/helper/validation
) instead of just package names (e.g.validation
)
ENHANCEMENTS
- helper/analysisutils:
DeprecatedReceiverMethodSelectorExprRunner
now implementsSuggestedFixes
- helper/analysisutils:
DeprecatedWithReplacementSelectorExprRunner
now implementsSuggestedFixes
- helper/astutils: Add
HasFieldListLength
,IsExprTypeBool
,IsExprTypeMapStringInterface
functions - helper/terraformtype/helper/customdiff: Constants and functions for working with entire package
- helper/terraformtype/helper/schema: Constants and functions for working with
CustomizeDiffFunc
type - helper/terraformtype/helper/schema: Constants and functions for working with
StateUpgradeFunc
type - helper/terraformtype/terraform: Constants and functions for working with
ResourceProvider
type - passes/helper/customdiff: Passes for collecting
customdiff
function information for further analysis - passes/helper/schema: Pass for collecting
CustomizeDiffFunc
function information for further analysis - passes/helper/schema: Pass for collecting
StateUpgradeFunc
function information for further analysis - passes/R007: Support suggested fix
- passes/R008: Support suggested fix
- passes/V002: Support suggested fix
- passes/V003: Support suggested fix
- passes/V004: Support suggested fix
- passes/V005: Support suggested fix
- passes/V006: Support suggested fix
- passes/V007: Support suggested fix
- passes/V008: Support suggested fix
BREAKING CHANGES
- helper/astutils: The
IsFunctionParameterType*
functions have been renamedIsExprType*
to better denote their purpose.
FEATURES
- New Check:
S035
: check forSchema
with invalidAtLeastOneOf
attribute references - New Check:
S036
: check forSchema
with invalidConflictsWith
attribute references - New Check:
S037
: check forSchema
with invalidExactlyOneOf
attribute references
ENHANCEMENTS
- passes/AT004: Support ignore comments
- passes/AT005: Support ignore comments
- passes/AT006: Support ignore comments
- passes/AT007: Support ignore comments
BREAKING CHANGES
- helper/terraformtype/helper/schema:
NewSchemaValidateFuncInfo
now accepts a singleast.Node
instead of separate*ast.FuncDecl
and*ast.FuncLit
FEATURES
- New Check:
AT008
: check for acceptance test function declaration*testing.T
parameter naming - New Check:
R007
: check for deprecated(schema.ResourceData).Partial
receiver method usage - New Check:
R008
: check for deprecated(schema.ResourceData).SetPartial
receiver method usage - New Check:
R009
: check for Go panic usage - New Check:
R010
: check for(schema.ResourceData).GetChange
assignment which should use(schema.ResourceData).Get
- New Check:
R011
: check forResource
that configureMigrateState
- New Check:
R012
: check for data sourceResource
that configureCustomizeDiff
- New Check:
R013
: check formap[string]*Resource
that resource names contain at least one underscore - New Check:
R014
: check forCreateFunc
,DeleteFunc
,ReadFunc
, andUpdateFunc
parameter naming - New Check:
S034
: check forSchema
that configurePromoteSingle
BREAKING CHANGES
- helper/terraformtype: Refactored into helper/resource and helper/schema subpackages
- passes/schemamap:
GetSchemaAttributes
has been replaced withhelper/terraformtype/helper/schema.GetSchemaMapSchemas
- passes/schemamap:
GetSchemaAttributeNames
has been replaced withhelper/terraformtype/helper/schema.GetSchemaMapAttributeNames
FEATURES
- New Check:
S024
: check forSchema
that should omitForceNew
in data source schema attributes - New Check:
S025
: check forSchema
of onlyComputed
enabled withAtLeastOneOf
configured - New Check:
S026
: check forSchema
of onlyComputed
enabled withConflictsWith
configured - New Check:
S027
: check forSchema
of onlyComputed
enabled withDefault
configured - New Check:
S028
: check forSchema
of onlyComputed
enabled withDefaultFunc
configured - New Check:
S029
: check forSchema
of onlyComputed
enabled withExactlyOneOf
configured - New Check:
S030
: check forSchema
of onlyComputed
enabled withInputDefault
configured - New Check:
S031
: check forSchema
of onlyComputed
enabled withMaxItems
configured - New Check:
S032
: check forSchema
of onlyComputed
enabled withMinItems
configured - New Check:
S033
: check forSchema
of onlyComputed
enabled withStateFunc
configured - New Check:
V002
: check for deprecatedCIDRNetwork
validation function usage - New Check:
V003
: check for deprecatedIPRange
validation function usage - New Check:
V004
: check for deprecatedSingleIP
validation function usage - New Check:
V005
: check for deprecatedValidateJsonString
validation function usage - New Check:
V006
: check for deprecatedValidateListUniqueStrings
validation function usage - New Check:
V007
: check for deprecatedValidateRegexp
validation function usage - New Check:
V008
: check for deprecatedValidateRFC3339TimeString
validation function usage
ENHANCEMENTS:
- helper/analysisutils:
DeprecatedWithReplacementSelectorExprAnalyzer
,FunctionCallExprAnalyzer
,ReceiverMethodCallExprAnalyzer
, andSelectorExprAnalyzer
Analyzer generators - helper/astutils:
ExprBoolValue
,ExprIntValue
, andExprStringValue
functions - helper/terraformtype/helper/schema:
GetSchemaMapAttributeNames
,GetSchemaMapSchemas
, andIsMapStringHelperSchemaTypeSchema
functions - helper/terraformtype/helper/schema:
ResourceInfo
typeIsDataSource
andIsResource
receiver methods
FEATURES
- New Analyzer:
resourcedataget
: returnsResourceData.Get()
calls for later passes - New Analyzer:
resourcedatagetchange
: returnsResourceData.GetChange()
calls for later passes - New Analyzer:
resourcedatagetok
: returnsResourceData.GetOk()
calls for later passes - New Analyzer:
resourcedatagetokexists
: returnsResourceData.GetOkExists()
calls for later passes - New Command:
tfproviderlintx
: Runs all standard and extra checks - New Extra Check:
XS001
: check formap[string]*Schema
thatDescription
is configured - New Extra Check:
XR001
: check for usage ofResourceData.GetOkExists()
calls - New Extra Check:
XR002
: check forResource
that should implementImporter
- New Extra Check:
XR003
: check forResource
that should implementTimeouts
- New Extra Check:
XR004
: check forResourceData.Set()
calls that should implement error checking with complex values
FEATURES
- New Analyzer:
retryfunc
: returnsRetryFunc
declarations - New Analyzer:
schemavalidatefunc
: returnsSchemaValidateFunc
declarations - New Check:
R005
: check forResourceData.HasChange()
calls that can be combined into oneHasChanges()
call - New Check:
R006
: check forRetryFunc
that omit retryable errors - New Check:
S021
: check forSchema
that should omitComputedWhen
- New Check:
S022
: check forSchema
ofTypeMap
with invalidElem
of*schema.Resource
- New Check:
S023
: check forSchema
that should omitElem
with incompatibleType
- New Check:
V001
: check for customSchemaValidateFunc
that implementvalidation.StringMatch()
orvalidation.StringDoesNotMatch()
ENHANCEMENTS
- cmd/tfproviderlint: Add
-V
and-version
flags for version information (#40) - helper/astutils: Functions for determining package functions, package receiver methods, package types, and some function parameter types
- helper/terraformtype: Support pointers with
IsHelperResourceTypeTestCase()
,IsHelperResourceTypeTestStep()
,IsHelperSchemaTypeResource()
,IsHelperSchemaTypeResourceData()
,IsHelperSchemaTypeSchema()
, andIsHelperSchemaTypeSet()
functions - helper/terraformtype: Add constants for helper/resource
NonRetryableError
andRetryableError
function names - helper/terraformtype: Add constants and helper functions for helper/resource
RetryError
type - passes: Add
AllChecks
variable which can be used to bootstrap custom downstream linters
BREAKING CHANGES
- The
acctestcase
,schemaresource
, andschemaschema
passes now return results withhelper/terraformtype
types ([]*terraformtype.TestCaseInfo
,[]*terraformtype.HelperSchemaResourceInfo
, and[]*terraformtype.HelperSchemaSchemaInfo
respectively) instead of[]*ast.CompositeLit
. The*ast.CompositeLit
can be accessed via theAstCompositeLit
field of each of the new types.
NOTES
- Tests are now Go 1.13 compatible
- Updates github.com/hashicorp/terraform-plugin-sdk dependency to v1.4.1 which cleans up some transitive dependencies
FEATURES
- New Analyzer:
accteststep
: returnsresource.TestStep
literals for later passes - New Analyzer:
testcheckresourceattr
: returnsresource.TestCheckResourceAttr()
calls for later passes - New Analyzer:
testcheckresourceattrset
: returnsresource.TestCheckResourceAttrSet()
calls for later passes - New Analyzer:
testmatchresourceattr
: returnsresource.TestMatchResourceAttr()
calls for later passes - New Check:
AT005
: check for acceptance test names missingTestAcc
prefix - New Check:
AT006
: check for acceptance tests containing multipleresource.Test()
invocations - New Check:
AT007
: check for acceptance tests containing multipleresource.ParallelTest()
invocations - New Check:
S020
: check forSchema
of onlyComputed
enabled withForceNew
enabled
ENHANCEMENTS
- helper/terraformtype: Create enhanced AST types and field name constants for helper/schema.Resource, helper/schema.Schema, helper/resource.TestCase, and helper/resource.TestStep types
NOTES
- Updates github.com/hashicorp/terraform-plugin-sdk dependency to allow repositories using this project as a dependency to switch from github.com/hashicorp/hcl2 to github.com/hashicorp/hcl/v2
BREAKING CHANGES
- The import path checking used for the linters and underlying Terraform codebase dependency has been migrated from
github.com/hashicorp/terraform
togithub.com/hashicorp/terraform-plugin-sdk
. For more information see the Terraform Plugin SDK page in the Extending Terraform documentation.
FEATURES
- New Check:
S007
: check forSchema
with bothRequired
andConflictsWith
configured - New Check:
S008
: check forSchema
ofTypeList
orTypeSet
withDefault
configured - New Check:
S009
: check forSchema
ofTypeList
orTypeSet
withValidateFunc
configured - New Check:
S010
: check forSchema
of onlyComputed
enabled withValidateFunc
configured - New Check:
S011
: check forSchema
of onlyComputed
enabled withDiffSuppressFunc
configured - New Check:
S012
: check forSchema
thatType
is configured - New Check:
S013
: check formap[string]*Schema
that one ofComputed
,Optional
, orRequired
is configured - New Check:
S014
: check forSchema
withinElem
thatComputed
,Optional
, orRequired
are not configured - New Check:
S015
: check formap[string]*Schema
that attribute names are valid - New Check:
S016
: check forSchema
thatSet
is only configured forTypeSet
- New Check:
S017
: check forSchema
thatMaxItems
andMinItems
are only configured forTypeList
,TypeMap
, orTypeSet
- New Check:
S018
: check forSchema
that should preferTypeList
withMaxItems: 1
- New Check:
S019
: check forSchema
that should omitComputed
,Optional
, orRequired
set tofalse
BUG FIXES
- passes/AT001: Ignore file names beginning with
data_source_
[GH-25]
ENHANCEMENTS
- Support
map[string]*schema.Schema
in schema checks [GH-24]
FEATURES:
- New Check
R004
[GH-21]
- Initial release with checks:
AT001
,AT002
,AT003
,AT004
R001
,R002
,R003
S001
,S002
,S003
,S004
,S005
,S006