github.com/wata727/tflint@v0.12.2-0.20191013070026-96dd0d36f385/rules/terraformrules/terraform_documented_variables.go (about)

     1  package terraformrules
     2  
     3  import (
     4  	"fmt"
     5  	"log"
     6  
     7  	"github.com/wata727/tflint/tflint"
     8  )
     9  
    10  // TerraformDocumentedVariablesRule checks whether variables have descriptions
    11  type TerraformDocumentedVariablesRule struct{}
    12  
    13  // NewTerraformDocumentedVariablesRule returns a new rule
    14  func NewTerraformDocumentedVariablesRule() *TerraformDocumentedVariablesRule {
    15  	return &TerraformDocumentedVariablesRule{}
    16  }
    17  
    18  // Name returns the rule name
    19  func (r *TerraformDocumentedVariablesRule) Name() string {
    20  	return "terraform_documented_variables"
    21  }
    22  
    23  // Enabled returns whether the rule is enabled by default
    24  func (r *TerraformDocumentedVariablesRule) Enabled() bool {
    25  	return false
    26  }
    27  
    28  // Severity returns the rule severity
    29  func (r *TerraformDocumentedVariablesRule) Severity() string {
    30  	return tflint.NOTICE
    31  }
    32  
    33  // Link returns the rule reference link
    34  func (r *TerraformDocumentedVariablesRule) Link() string {
    35  	return tflint.ReferenceLink(r.Name())
    36  }
    37  
    38  // Check checks whether variables have descriptions
    39  func (r *TerraformDocumentedVariablesRule) Check(runner *tflint.Runner) error {
    40  	log.Printf("[TRACE] Check `%s` rule for `%s` runner", r.Name(), runner.TFConfigPath())
    41  
    42  	for _, variable := range runner.TFConfig.Module.Variables {
    43  		if variable.Description == "" {
    44  			runner.EmitIssue(
    45  				r,
    46  				fmt.Sprintf("`%s` variable has no description", variable.Name),
    47  				variable.DeclRange,
    48  			)
    49  		}
    50  	}
    51  
    52  	return nil
    53  }